{ "info": { "author": "Ian McCracken", "author_email": "ian@zenoss.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "============\nIntroduction\n============\n\nTo use this package, you must either have simplejson installed, or be using\nPython 2.6 (which includes simplejson as the json package).\n\nExtJS 3.0 provides Ext.Direct, an extremely simple way to remote server-side\nmethods to the client side. extdirect provides a Python implementation\nof a server-side Ext.Direct router, which can accept and parse Ext.Direct\nrequest data, route it to the correct method, and create, encode and return the\nproper data structure wrapping the results. extdirect also provides a\nclass that can generate the client-side JavaScript defining an Ext.Direct\nprovider from a router class.\n\nFor a full description of Ext.Direct's features, see:\n\n http://www.extjs.com/products/extjs/direct.php\n\nLet's see how the server side works. First, we'll define a router:\n\n >>> from extdirect.router import DirectRouter\n >>> class TestUtils(DirectRouter):\n ...\n ... def capitalize(self, word):\n ... return word.upper()\n ...\n ... def today(self):\n ... return \"Today is Wednesday.\"\n\nWe've defined two methods we want remoted to the client.\n\nAlthough we don't have a real client in this test runner, here's how one would\ngenerate the code that needs to be given to the client defining the provider.\nIgnoring actual implementation, which would depend on the framework being used,\nlet's say we'll have this class available at URL '/utils', and we want our\nclient-side namespace containing these methods simply to be called 'Remote.'\n\n >>> from extdirect.router import DirectProviderDefinition\n >>> print DirectProviderDefinition(TestUtils, '/utils', 'Remote').render()\n ... #doctest: +NORMALIZE_WHITESPACE\n \n\nNow, assuming that, one way or another, we've provided this code to the client\nand our class is available at that URL, we are now able to access these methods\nfrom the browser:\n \n Remote.TestUtils.capitalize({word:'foo'}, console.log)\n\nThat example would make a call to the 'capitalize' method on our TestUtils\nclass and feed the result to our callback, which in this case merely prints the\nresult to the JS console.\n\nLet's see how that would work from the perspective of the server. That call\nwould make a POST request with a JSON-encoded body, so let's create that\nmanually:\n\n >>> from extdirect.router import json\n >>> data = {\"action\":\"TestUtils\",\"method\":\"capitalize\",\"data\":[{\"word\":\"foo\"}],\"type\":\"rpc\",\"tid\":1}\n >>> body = json.dumps(data)\n\nOur class name is passed in as \"action\", the method name as \"method\", and\nwhatever data we sent as a single-member array containing a hash of our\nparameters. For our purposes, \"type\" will always be \"rpc\". Ext.Direct requests\nalso provide a transaction id (\"tid\") which may be used as you see fit to\nhandle the possibility of stale data.\n\nNow, let's make an instance of our server-side class:\n\n >>> utils = TestUtils()\n\nThis instance is callable and accepts the request body, and returns a\nJSON-encoded object exhibiting the structure expected by Ext.Direct on the\nclient:\n\n >>> utils(body)\n '{\"tid\": 1, \"action\": \"TestUtils\", \"type\": \"rpc\", \"method\": \"capitalize\", \"result\": \"FOO\"}'\n\nNotice the \"result\", which is what we'd expect. The client would decode this\nobject and pass the \"result\" value to the callback. Just for fun, let's check\nout our other defined method:\n\n >>> data = {\"action\":\"TestUtils\",\"method\":\"today\",\"data\":[],\"type\":\"rpc\",\"tid\":1}\n >>> body = json.dumps(data)\n >>> resultob = json.loads(utils(body))\n >>> print resultob['result']\n Today is Wednesday.\n\n\n===========\nZope Router\n===========\n\nUsing extdirect in Zope is extremely simple, due to a custom ZCML\ndirective that registers both a BrowserView for the server-side API and a\nviewlet to deliver the provider definition to the client.\n\n1. Define your class\n \n e.g., in myapi.py:\n\n from extdirect.zope import DirectRouter\n\n class MyApi(DirectRouter):\n\n def a_method(self):\n return 'A Value'\n\n\n2. Register the class as a direct router\n\n \n\n \n\n \n\n \n\n\n3. Provide the extdirect viewletManager in your template. \n (Note: Ext is a prerequisite.)\n\n \n\n\n4. Call methods at will!\n\n \n\n=============\nDjango Router\n=============\n\nSo, you have a Django app, and you want to add Ext.Direct. Here's how:\n\n 1. Add 'extdirect.django' to INSTALLED_APPS in settings.py\n \n 2. In a new file called direct.py, define your router class and register it:\n \n from extdirect.django import DirectRouter, register_router\n\n class MyRouter(DirectRouter):\n def uppercase(self, word):\n return word.upper()\n def lowercase(self, word):\n return word.lower()\n\n register_router(MyRouter, 'Remote')\n \n The arguments to register_router are the router class, the client-side\n namespace, and an optional url under /extdirect at which the router\n should be available (defaults to the name of the class).\n\n\n 3. In the root URLconf, map the extdirect urls by adding:\n\n (r'^extdirect/', include('extdirect.django.urls'))\n\n 4. Also in the root URLconf, add these two lines:\n\n import extdirect.django as extdirect\n extdirect.autodiscover()\n\n 5. In your template, load the provider definitions:\n \n {% load direct_providers %}\n {% direct_providers %}\n\n 6. That's it. You should now have access on that template to the remote\n methods:\n \n Remote.MyRouter.uppercase({word:'a word'}, callback);\n\n \n\n0.4\nRemoved stripped-down direct.js for licensing reasons\n\nRereleased under BSD license\n\nAdded request batching support (thanks to Brian Edwards, bedwards@zenoss.com)\n\nAdded provided timeout option in Zope (thanks to Jon-Pierre Gentil,\njgentil@zenoss.com)\n\n\n0.3\n\nUpdated django subpackage with Avizoa's patch replacing \"import views\" with the\nmuch cleaner \"extdirect.autodiscover()\".\n\n0.2\nAdded django subpackage\n\n0.1\nInitial release, including zope subpackage", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.google.com/p/extdirect", "keywords": "", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "extdirect", "package_url": "https://pypi.org/project/extdirect/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/extdirect/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://code.google.com/p/extdirect" }, "release_url": "https://pypi.org/project/extdirect/0.4/", "requires_dist": null, "requires_python": null, "summary": "Python implementation of an Ext.Direct router", "version": "0.4" }, "last_serial": 744266, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d2ea9c48e131e077464ba1ecd7c93362", "sha256": "e3295aaa0fa6554a128c6bcaf4f7cb30c3fe6657b9bbc16565e17b9a40e0b2a4" }, "downloads": -1, "filename": "extdirect-0.1.tar.gz", "has_sig": false, "md5_digest": "d2ea9c48e131e077464ba1ecd7c93362", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6165, "upload_time": "2009-09-20T19:55:26", "url": "https://files.pythonhosted.org/packages/53/7a/93ff283fd92a4ae6af92b5877db72d76bdc4b9d0a9652115b2ccdebd4243/extdirect-0.1.tar.gz" } ], "0.1dev": [ { "comment_text": "", "digests": { "md5": "315b5fcc1c45beff023bd929268cb1c8", "sha256": "0fb95da83c40ee10b17a9bb6b7359af6ca5d729c6661cef821598379702fc3ea" }, "downloads": -1, "filename": "extdirect-0.1dev.tar.gz", "has_sig": false, "md5_digest": "315b5fcc1c45beff023bd929268cb1c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6175, "upload_time": "2009-09-20T19:55:16", "url": "https://files.pythonhosted.org/packages/bc/80/6716c7f0f43349124b8eecee51ea13a72e2576f8014a45c8aa95ada1319a/extdirect-0.1dev.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "f27c14e18d0947e3d677411fa2a30e61", "sha256": "8335b5e154b76fe44e555cb15f1dd80c2c6d5f431ab1a2d551a75d920683272f" }, "downloads": -1, "filename": "extdirect-0.2.tar.gz", "has_sig": false, "md5_digest": "f27c14e18d0947e3d677411fa2a30e61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71019, "upload_time": "2009-09-21T04:35:25", "url": "https://files.pythonhosted.org/packages/01/02/cdc7460b235cc42c503aa05c2740457af31c0b68624373a42a101deadc98/extdirect-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "58911613dae92dc3da20d56cd157250e", "sha256": "05287631608220ad588dff3be11f6fe95e63f2f9d9636fc21aa6a373f029884e" }, "downloads": -1, "filename": "extdirect-0.3.tar.gz", "has_sig": false, "md5_digest": "58911613dae92dc3da20d56cd157250e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71316, "upload_time": "2009-10-14T20:45:50", "url": "https://files.pythonhosted.org/packages/d0/da/209daad2eec70207fd93809c373cc622864d1682b075b2c0160b480173c3/extdirect-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "ebd07fa4020c484edd206df23d4b8f22", "sha256": "92a2cacf6245d6b57210caf0439e182b8721b6f72b156488316238ea9b998f07" }, "downloads": -1, "filename": "extdirect-0.4-py2.5.egg", "has_sig": false, "md5_digest": "ebd07fa4020c484edd206df23d4b8f22", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 25599, "upload_time": "2010-06-03T15:08:21", "url": "https://files.pythonhosted.org/packages/9e/07/27651bfd6dbf65ce278226bfe3bd6382228e259f0e87b1d3b7afb57ab376/extdirect-0.4-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "14e672a9d29653c4d66e87f9851273a0", "sha256": "28194c74017c0b97f0f6dbd0654e897799bc4f40d89b4cf3547b43bc9e732f3e" }, "downloads": -1, "filename": "extdirect-0.4-py2.6.egg", "has_sig": false, "md5_digest": "14e672a9d29653c4d66e87f9851273a0", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 25613, "upload_time": "2010-06-03T15:08:31", "url": "https://files.pythonhosted.org/packages/3b/df/292c1932d14e77b472881e59b6377d2750b875878edbed829edcb7f1cf71/extdirect-0.4-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "c1d25b94c5f5d04a46f45ebcc642989f", "sha256": "76a3f154a1adc879242121de699077655bb0000add012929a57df17194f19ebc" }, "downloads": -1, "filename": "extdirect-0.4.tar.gz", "has_sig": false, "md5_digest": "c1d25b94c5f5d04a46f45ebcc642989f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9679, "upload_time": "2010-02-06T18:07:24", "url": "https://files.pythonhosted.org/packages/ea/07/8b249ce54ea3c08ec1e16b83f0f68afce1ec0cda28fe53a90ca016308ac0/extdirect-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ebd07fa4020c484edd206df23d4b8f22", "sha256": "92a2cacf6245d6b57210caf0439e182b8721b6f72b156488316238ea9b998f07" }, "downloads": -1, "filename": "extdirect-0.4-py2.5.egg", "has_sig": false, "md5_digest": "ebd07fa4020c484edd206df23d4b8f22", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 25599, "upload_time": "2010-06-03T15:08:21", "url": "https://files.pythonhosted.org/packages/9e/07/27651bfd6dbf65ce278226bfe3bd6382228e259f0e87b1d3b7afb57ab376/extdirect-0.4-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "14e672a9d29653c4d66e87f9851273a0", "sha256": "28194c74017c0b97f0f6dbd0654e897799bc4f40d89b4cf3547b43bc9e732f3e" }, "downloads": -1, "filename": "extdirect-0.4-py2.6.egg", "has_sig": false, "md5_digest": "14e672a9d29653c4d66e87f9851273a0", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 25613, "upload_time": "2010-06-03T15:08:31", "url": "https://files.pythonhosted.org/packages/3b/df/292c1932d14e77b472881e59b6377d2750b875878edbed829edcb7f1cf71/extdirect-0.4-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "c1d25b94c5f5d04a46f45ebcc642989f", "sha256": "76a3f154a1adc879242121de699077655bb0000add012929a57df17194f19ebc" }, "downloads": -1, "filename": "extdirect-0.4.tar.gz", "has_sig": false, "md5_digest": "c1d25b94c5f5d04a46f45ebcc642989f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9679, "upload_time": "2010-02-06T18:07:24", "url": "https://files.pythonhosted.org/packages/ea/07/8b249ce54ea3c08ec1e16b83f0f68afce1ec0cda28fe53a90ca016308ac0/extdirect-0.4.tar.gz" } ] }