{ "info": { "author": "Igor Stroh", "author_email": "igor.stroh@rulim.de", "bugtrack_url": null, "classifiers": [ "Framework :: Pylons", "Intended Audience :: Developers", "License :: Repoze Public License", "Programming Language :: Python" ], "description": "pyramid_extdirect README\n===========================\n\nIntroduction:\n-------------\n\nThis `pyramid`_ plugin provides a router for the `ExtDirect Sencha`_ API\nincluded in `ExtJS`_ .\n\n.. _`pyramid`: http://docs.pylonsproject.org/en/latest/docs/pyramid.html\n.. _`ExtDirect Sencha`: https://docs.sencha.com/extjs/6.0/backend_connectors/direct/specification.html\n.. _`ExtJS`: http://www.sencha.com/products/extjs/\n\n\nExtDirect allows to run server-side callbacks directly through JavaScript without\nthe extra AJAX boilerplate. The typical ExtDirect usage scenario goes like this::\n\n MyApp.SomeClass.fooMethod(foo, bar, function(response) {\n // do cool things with response\n });\n\nor even better, if ExtDirect is used in a GridStore::\n\n var usersStore = new Ext.data.Store({\n fields: ['id', 'name', 'title'],\n proxy: {\n type: 'direct',\n directFn: MyApp.Users.loadAll,\n reader: {\n type: 'json',\n rootProperty: 'items'\n }\n }\n // ...\n });\n\nHere ``MyApp`` is the application namespace, ``SomeClass`` or\n``Grids`` are classes or *actions* and ``fooMethod`` and \n``loadGridData`` are methods.\n\nUsage example:\n--------------\n\nThe minimum requirement for pyramid_extdirect is to create an ExtDirect API and Router::\n\n from pyramid.config import Configurator\n from exampleapp.resources import Root\n\n def main(global_config, **settings):\n \"\"\" This function returns a Pyramid WSGI application.\n \"\"\"\n config = Configurator(root_factory=Root, settings=settings)\n config.add_view('exampleapp.views.my_view',\n context='exampleapp:resources.Root',\n renderer='exampleapp:templates/mytemplate.pt')\n config.add_static_view('static', 'exampleapp:static')\n # let pyramid_extdirect create all the needed views automatically\n config.include('pyramid_extdirect')\n # scan your code once to make sure the @extdirect_method decorators\n # are picked up\n config.scan()\n return config.make_wsgi_app()\n\nAfter this you can decorate arbitrary functions or class methods using @extdirect_method::\n\n @extdirect_method(action='SomeAction')\n def do_stuff(a, b, c):\n return a + b + c\n\nOr, if you'd like to group your methods into classes (actions), you can do so by decoration\nclass methods:\n\nThe ``UsersController`` class could combine all methods for users CRUD operations, the only\nrequirement is that this class accepts ``request`` as its first and only constructor argument,\nthis is needed to make sure your methods have access to ``request`` at any time::\n\n from pyramid_extdirect import extdirect_method\n\n class UsersController(object):\n\n __extdirect_settings__ = { \n 'default_action_name': 'Users',\n 'default_permission': 'view'\n }\n\n def __init__(self, request):\n self.request = request\n\n # we don't need to set ``action`` here, because\n # it's already defined via __extdirect_settings__\n @extdirect_method(permission='view', method_name='loadAll')\n def load_all(self, params):\n # params is a simple dict that will contain the\n # paging and sorting options as well as any other\n # extra parameters (defined using proxy.extraParams\n # your store config)\n users = []\n for user in users_db.fetch_all():\n users.append({\n id: obj.id,\n name: obj.name,\n title: obj.title,\n # ...\n })\n return dict(success=True, items=users)\n\nAs you can see, the ``Users#loadAll`` method doesn't even know it's been called through\na HTTP request, it's just a plain old python method which returns a dict.\nThe ``@extdirect_method(permission='view')`` decoration adds it to\nthe ``Users`` action (also making sure only users with *view* permission are allowed\nto run it). We're returning a ``dict`` here simply because the AJAX response sent to\nthe client has to be JSON serializable. By default python JSON marshallers can only\nencode/decode builtin python primitives. ``pyramid_extdirect`` has a small helper\nthough, that checks if an object has a method called ``json_repr()`` (which should\nreturn a JSON serializable dict/list/string/number/etc.) and if found, this method is\nused to decode an instance to its JSONable version.\nYou can define a ``__extdirect_settings__`` property in a class to define a default\n``action`` and ``permission``, so in the example above we could also just use ``@extdirect_method()``.\n\nSometimes you need to use the upload features of ExtDirect. Since uploads cannot\nbe done using AJAX (through JSON-encoded request body) Ext does a little trick\nby creating a hidden iframe and posting a form within this iframe to the server.\nHowever, ExtDirect needs to know in advance, that your code might receive uploads.\nIn ``pyramid_extdirect`` decorators this is done by adding a ``accepts_files``\nparameter to the ``@extdirect_method`` decorator::\n\n class Users(object):\n ...\n @extdirect_method(accepts_files=True)\n def upload_avatar(self, uploaded_file):\n # uploaded_file is now a FieldStorage instance\n\nIn some situations it is absolutely necessary to access the ``request`` object\nin your functions and you don't want to create an extra class (where the request would be\npassed in to the class constructor) -- this can be achieved by passing ``request_as_last_param`` to the\ndecorator::\n\n from pyramid.security import authenticated_userid\n\n @extdirect_method(action='App', request_as_last_param=True):\n def get_current_user(request):\n return authenticated_userid(request)\n\n-- \nIgor Stroh, \n\n\npyramid_extdirect Changelog\n==============================\n0.6.0\n----------------\n- Added metadata support\n\n0.5.2\n----------------\n- Added error logging and fixed the issue when 'json_encoder'\n wasn't provided in includeme(..) config (thanks Fabian Maier)\n\n0.5.1\n----------------\n- Added optional json_encoder argument to Extdirect constructor\n to allow for providing a custom JSON serializer (e.g.\n pyramid.renderers.JSON)\n\n0.5.0\n----------------\n- We're now python3 compliant (thanks Fabien Coronis)\n\n0.4.0\n----------------\n- Fixed user-defined exfception views handling\n\n0.3.2\n----------------\n- Added permissions check for extdirect_method decorated functions (vs. methods)\n- Added actions filter for extdirect api route \n\n0.3.1\n----------------\nAdded pyramid debug toolbar support (thanks github.com/breath)\n\n0.3\n----------------\nRenamed project to pyramid_extdirect\n\n0.2\n----------------\n- Fixed form quotes quoting\n- Move package structure from repoze.bfg to pyramid\n\n\n0.1.2\n----------------\n- Fixed typo in JsonReprEncoder\n\n\n0.1.1\n----------------\n- Fixed packaging\n- Fixed numargs for methods with request_as_last_param\n\n\n0.1\n----------------\n\n- Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jenner/pyramid_extdirect", "keywords": "web wsgi javascript pyramid extdirect", "license": "BSD-derived (http://www.repoze.org/LICENSE.txt)", "maintainer": null, "maintainer_email": null, "name": "pyramid_extdirect", "package_url": "https://pypi.org/project/pyramid_extdirect/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyramid_extdirect/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/jenner/pyramid_extdirect" }, "release_url": "https://pypi.org/project/pyramid_extdirect/0.6.0/", "requires_dist": null, "requires_python": null, "summary": "ExtDirect Implementation for Pyramid", "version": "0.6.0" }, "last_serial": 2098356, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "bcbaf58298536bb205de31141d2dff48", "sha256": "669bb0ac6b69cd5d6a943e36717868b73d5434a0f1b147dc63ae7a9afdd27b99" }, "downloads": -1, "filename": "pyramid_extdirect-0.3.tar.gz", "has_sig": false, "md5_digest": "bcbaf58298536bb205de31141d2dff48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10575, "upload_time": "2011-08-16T12:48:09", "url": "https://files.pythonhosted.org/packages/90/53/363021429304b9c531c4bb76587953354e39cabb933b171a054f15ea5060/pyramid_extdirect-0.3.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "68320ffbe5842e54a11e1bf246ad877d", "sha256": "7d9d92e15e2e659b346e31c371a5093ba5865e6b2823c222d3ffa06eb6ac2141" }, "downloads": -1, "filename": "pyramid_extdirect-0.3.2.tar.gz", "has_sig": false, "md5_digest": "68320ffbe5842e54a11e1bf246ad877d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14026, "upload_time": "2012-09-06T05:17:30", "url": "https://files.pythonhosted.org/packages/24/b4/af53a952ec8b531da6b45ee2becdb4476ce323ff3d5d92270e6a7c4c3065/pyramid_extdirect-0.3.2.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "adadc230a015c5b6eab2af877fd9b28a", "sha256": "b5caff07e5becc1ee862d37e0484bc33a45ccebfe5620d624f2f3c15250bffb3" }, "downloads": -1, "filename": "pyramid_extdirect-0.4.0.tar.gz", "has_sig": false, "md5_digest": "adadc230a015c5b6eab2af877fd9b28a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11519, "upload_time": "2014-05-19T07:59:21", "url": "https://files.pythonhosted.org/packages/73/f1/407a90d3a7ffb0a0626a460ec3ee8cd4656e2718c4e1b6dc1c1f2f732e14/pyramid_extdirect-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "395d9f2ea6bb9b62b719b32f3b591463", "sha256": "ea02c536933be63e8cc271d3b8ee3a2e743c6f334d12526f2753d209aa8113a5" }, "downloads": -1, "filename": "pyramid_extdirect-0.5.0.tar.gz", "has_sig": false, "md5_digest": "395d9f2ea6bb9b62b719b32f3b591463", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12316, "upload_time": "2014-12-03T08:37:15", "url": "https://files.pythonhosted.org/packages/3e/97/ce3b2e556e3a6930492cf54660bffe59f9dd4d84807b30fdebc2c07ac15d/pyramid_extdirect-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "9426b94e8ddce76cce6b3e202dbb34fa", "sha256": "4cd9a5c010d618a707e976e7c63547f824861aa3d86867423a403cd3a8711ec8" }, "downloads": -1, "filename": "pyramid_extdirect-0.5.1.tar.gz", "has_sig": false, "md5_digest": "9426b94e8ddce76cce6b3e202dbb34fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11482, "upload_time": "2015-09-01T12:12:14", "url": "https://files.pythonhosted.org/packages/8f/1c/319c3d2e8fc487bd0c2bf498357dbe098ec084a760ebfed1de950a53349c/pyramid_extdirect-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "cbe140483416372b618b18db740cb871", "sha256": "eaaf869d1842f2dca14c98155050c70b3c4f17bb07faa2f2d0fc43aec1504e84" }, "downloads": -1, "filename": "pyramid_extdirect-0.5.2.tar.gz", "has_sig": false, "md5_digest": "cbe140483416372b618b18db740cb871", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11615, "upload_time": "2016-02-26T09:54:46", "url": "https://files.pythonhosted.org/packages/a9/53/a3458d426af2221aeea9b24b3a081d86be1d8afcdf48f2978515cb2b1f6d/pyramid_extdirect-0.5.2.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "058237e0763eb173f9acd093964285ac", "sha256": "2ce252fa707768773cd874f755fdcc04f2a45ba626f4ba0ffad6f510a9bc65ce" }, "downloads": -1, "filename": "pyramid_extdirect-0.6.0.tar.gz", "has_sig": false, "md5_digest": "058237e0763eb173f9acd093964285ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11489, "upload_time": "2016-05-04T08:34:42", "url": "https://files.pythonhosted.org/packages/5d/ba/a51bfdc787951615fb3a32ce09796c0fc80b197019b461aab18d28db2f7d/pyramid_extdirect-0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "058237e0763eb173f9acd093964285ac", "sha256": "2ce252fa707768773cd874f755fdcc04f2a45ba626f4ba0ffad6f510a9bc65ce" }, "downloads": -1, "filename": "pyramid_extdirect-0.6.0.tar.gz", "has_sig": false, "md5_digest": "058237e0763eb173f9acd093964285ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11489, "upload_time": "2016-05-04T08:34:42", "url": "https://files.pythonhosted.org/packages/5d/ba/a51bfdc787951615fb3a32ce09796c0fc80b197019b461aab18d28db2f7d/pyramid_extdirect-0.6.0.tar.gz" } ] }