{ "info": { "author": "Martijn Faassen", "author_email": "faassen@startifact.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries" ], "description": "megrok.traject\n**************\n\n``megrok.traject`` is a library that integrates the traject_ routing\nframework with the Grok_ web framework.\n\n.. _traject: http://pypi.python.org/pypi/traject\n\n.. _grok: http://grok.zope.org\n\nInclude ``megrok.traject`` by adding it in your Grok project's\n``setup.py`` (in ``install_requires``) and re-run buildout.\n\nExternal trajects\n-----------------\n\nExternal trajects are most useful if you do not directly control the\nmodels. This may for instance be the case if the models are defined in\nan external package.\n\nWith ``megrok.traject`` you can declare trajects in Grok like this::\n\n from megrok import traject\n\n class SomeTraject(traject.Traject):\n grok.context(App)\n \n pattern = 'departments/:department_id'\n model = Department\n\n def factory(department_id):\n return get_department(department_id)\n\n def arguments(department):\n return dict(department_id=department.id)\n\nThis registers ``factory`` and the inverse ``arguments`` functions for\nthe pattern ``departments/:department_id``, the root ``App`` and the\nclass ``Department``. This replaces the ``register*`` functions in\ntraject itself.\n\n``App`` is any grok model. This model now automatically allows\ntraversal into the associated patterns; the system registers a custom\ntraverser to do this.\n\nYou can register grok views for ``Department`` as usual.\n\nContext issues\n--------------\n\nIf you *can*, make the models exposed by traject subclass from\n``grokcore.component.Context`` (or its alias ``grok.Context``, or its\nalias ``traject.Context``). By doing so, you avoid the problems\ndescribed below. \n\nSometimes you cannot subclass your models from\n``grokcore.component.Context``, however. Exposing external models was\nsomething that megrok.traject was designed to allow, after all.\n\nWhen you use megrok.traject with external models, you can run into the\nfollowing two issues with your models:\n\n* The ZTK assumes the default view for objects is ``index.html``, not\n ``index``. The ``index`` default view setting is only used when you\n subclass your model from ``grokcore.component.Context``. You can\n still make ``index`` the default view of your model by adding the\n following directive to your project's ``configure.zcml``::\n\n \n\n You can also do this for a common base class that you know all your\n models share, or a common interface that you know is provided by all\n your models.\n\n* Views, adapters and such won't auto-associate with your models in\n the same module. You will need to explicitly use the\n ``grok.context()`` on the module or class level to associate your\n component. For example::\n\n class SomeForeignModel(object):\n ...\n\n class MyView(grok.View):\n grok.context(SomeForeignModel)\n\nTraject models\n--------------\n\nIf you have control over the model definitions yourself, traject\nallows a more compact notation that lets you define traject-based\nmodels directly::\n\n import traject\n\n class Department(traject.Model): \n traject.context(App) \n traject.pattern('departments/:department_id')\n\n def factory(department_id):\n return get_department(department_id)\n \n def arguments(self):\n return dict(department_id=self.id)\n\n``traject.Model`` derives from ``grokcore.component.Context``, so the\nissues mentioned above with external models won't be a problem here.\n\nNote that Traject models are not persistent in the ZODB sense. If you\nneed a persistent Traject models you can mix in ``grok.Model`` or\n``persistent.Persistent``.\n\nTips\n----\n\n* return ``None`` in factory if the model cannot be found. The system\n then falls back to normal traversal to look up the view. Being too\n aggressive in consuming any arguments will break view traversal.\n\n* Use ``megrok.traject.locate`` to locate an object before asking for\n its URL or doing ``checkPermission`` on it. If the object was routed\n to using ``megrok.traject`` already this isn't necessary. This is\n a simple import alias for ``traject.locate``.\n\n* Instead of normal methods (which get interpreted as functions) for\n ``factory`` and ``arguments``, you can also turn them into class\n methods using the ``@classmethod`` decorator. They now take a\n ``cls`` argument as the first argument which is the class they are\n defined on. This can be useful if you want to make the\n implementations of these functions depend on information on its\n class (such as the value of ``model``), and this in turn can be\n useful to implement more declarative traject base classes.\n\nFor more information see the traject_ documentation.\n\n.. _traject: http://pypi.python.org/pypi/traject\n\n\nCHANGES.txt\n***********\n\n1.0 (2010-08-08)\n----------------\n\n- Can now also use @classmethod for ``factory`` and\n ``arguments``. This is useful if these functions depend on\n information on the class they are defined on.\n\n0.10.1 (2010-01-25)\n-------------------\n\n- Added notes to documentation about deriving your models from\n ``grokcore.component.Context``, or what to do what you can't.\n\n- Expose ``traject.Context`` for convenience reasons.\n\n- Fixed ReST documentation.\n\n0.10 (2009-11-30)\n-----------------\n\n- Support ``traject.Model``, a more compact way to define trajects if\n the model is under the control of the developer.\n\n0.9 (2009-11-16)\n----------------\n\n- Initial public release.\n\n\n\nDownload\n********", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "grok megrok url traject traversal routing route", "license": "ZPL", "maintainer": null, "maintainer_email": null, "name": "megrok.traject", "package_url": "https://pypi.org/project/megrok.traject/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/megrok.traject/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/megrok.traject/1.0/", "requires_dist": null, "requires_python": null, "summary": "Traject integration for Grok applications", "version": "1.0" }, "last_serial": 794658, "releases": { "0.10": [ { "comment_text": "", "digests": { "md5": "d6a3ab078b0feb6739f9308ab85f131b", "sha256": "fabb80557f29ebaebba6a3cb6242eff4bf7e6f7d6ae7998a74c09be8a3e0e3f0" }, "downloads": -1, "filename": "megrok.traject-0.10.tar.gz", "has_sig": false, "md5_digest": "d6a3ab078b0feb6739f9308ab85f131b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8634, "upload_time": "2009-11-30T14:19:45", "url": "https://files.pythonhosted.org/packages/eb/ca/0d4fd52bd170c4ee62b85ef62bd9cf91cc5927543f1af6f51e291f22c8db/megrok.traject-0.10.tar.gz" } ], "0.10.1": [ { "comment_text": "", "digests": { "md5": "505fc224b6d274e8ebe1b0c9e5fdacde", "sha256": "117d051b3c1d729d2b9ea72e88b34ea6b3e7910b140e612e8b027affb5d56c8b" }, "downloads": -1, "filename": "megrok.traject-0.10.1.tar.gz", "has_sig": false, "md5_digest": "505fc224b6d274e8ebe1b0c9e5fdacde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9525, "upload_time": "2010-01-25T21:17:34", "url": "https://files.pythonhosted.org/packages/b7/4e/6046370bc89dc5521a76cb805a19f614d3f4e27831eb5d5cb198509dbf31/megrok.traject-0.10.1.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "879ef7839ca0b7ca373354e612c7e9f3", "sha256": "762c3ca1bdbab04915c9647fb3bfba20cf4e08e97d3b18a5cbf57252a36a8acb" }, "downloads": -1, "filename": "megrok.traject-0.9.tar.gz", "has_sig": false, "md5_digest": "879ef7839ca0b7ca373354e612c7e9f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7631, "upload_time": "2009-11-16T13:16:07", "url": "https://files.pythonhosted.org/packages/a3/9b/f472f2ee85250a72affbd98fb1527a3d3e02a80fda0aa648e2d889538cec/megrok.traject-0.9.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "389f813b7778ef54e7f9e68beea14e2c", "sha256": "7a56430642f953902b21382be5241964cccc515982f726c0eef8e022c5067ee1" }, "downloads": -1, "filename": "megrok.traject-1.0.tar.gz", "has_sig": false, "md5_digest": "389f813b7778ef54e7f9e68beea14e2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12729, "upload_time": "2010-08-08T16:53:16", "url": "https://files.pythonhosted.org/packages/b1/bc/ac778f6b8d6ed4f86352658f133317c64e31273b47c010985f2cb421279e/megrok.traject-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "389f813b7778ef54e7f9e68beea14e2c", "sha256": "7a56430642f953902b21382be5241964cccc515982f726c0eef8e022c5067ee1" }, "downloads": -1, "filename": "megrok.traject-1.0.tar.gz", "has_sig": false, "md5_digest": "389f813b7778ef54e7f9e68beea14e2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12729, "upload_time": "2010-08-08T16:53:16", "url": "https://files.pythonhosted.org/packages/b1/bc/ac778f6b8d6ed4f86352658f133317c64e31273b47c010985f2cb421279e/megrok.traject-1.0.tar.gz" } ] }