{ "info": { "author": "Brandon Craig Rhodes", "author_email": "brandon@rhodesmill.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "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": "============================\nTrails: URL Recipes for Grok\n============================\n\nCave men often hunted by following animal trails through the woods.\nThey could also follow trails to important natural resources; the very\nfirst human migrations may have been along the trails that migratory\nanimal herds created when visiting natural salt deposits.\n\nIn the same tradition, the Trails product, which provides the Python\npackage ``megrok.trails``, allows Grok web site developers to define the\nURLs that web users can travel in order to visit the objects that roam\ntheir site.\n\nIf you need to report bugs or want to request features, please visit the\nproject's Launchpad site at:\n\n https://launchpad.net/megrok.trails\n\nTrails creates both the traversers which make URLs work in the forward\ndirection (so that users can visit them and see the right objects), and\nalso registers the adapters necessary for URLs to be generated (meaning\nthat Grok can ask \"at which URL does this object live?\" and receive\nback an answer).\n\nTrails look something like this when in use::\n\n class MyTrails(megrok.trails.TrailHead):\n grok.context(MyApp)\n trails = [\n Trail('/person/:id', Person),\n Trail('/account/:username', Account),\n ]\n\nThe above example makes a URL like::\n\n http://example.com/app/person/3096\n\ntraverse to the object created by calling ``Person(id=3096)``, while a\nuser visiting the URL::\n\n http://example.com/app/account/dcr\n\nwill find the object created by calling ``Account(username=dcr)``. In\neach case, the colon-prefixed URL elements in the Trail become keyword\narguments passed to the class (or other callable) given as the second\nargument to the ``Trail()``. Each URL element that is not prefixed with\na colon must be matched literally by the corresponding element in the\nsubmitted URL.\n\nA ``TrailHead`` performs traversal for the object which you name as its\n``grok.context()``, so you do not have to define a ``traverse()`` method\nor create a ``grok.Traverser`` for that context yourself. When the\nremaining URL components fail to match any of the ``Trail`` patterns\nthat start from a ``TrailHead``, an error is raised that should return a\n``404 Not Found`` to the user (unless, of course, there is only a single\nURL component left and it names a view). If, instead, one of the URL\npatterns is matched, then the object named in the second argument of the\n``Trail`` is instantiated with the colon-prefixed wildcard URL\ncomponents provided as keyword parameters, as outlined above.\n\nOnce the trail has been matched and resolved to an object, Trails is\ndone processing, and normal Grok traversal then takes over again to\nprocess any remaining URL components, or to look for a default view for\nthe object if the end of the URL has been reached. So, in the above\nexample, the developer would need to have provided normal ``grok.View``\nclasses for the ``Person`` and ``Account`` objects in order for the user\nto see them rendered in a browser. This means that Trails is not\ncomparable to something like `Rails Routes`_ or `Python Routes`_,\nbecause those products impose their own methods for choosing the view\nthat gets placed atop an object. Trails, by contrast, leaves the normal\nGrok rules in place for how a view is selected and placed atop your\nobject; it merely attempts to make object traversal itself cleaner and\neasier to maintain in an application where objects and containers do not\nliterally exist in an object database like the ZODB.\n\n.. _Rails Routes: http://manuals.rubyonrails.com/read/book/9\n.. _Python Routes: http://routes.groovie.org/\n\nNote that Trails stops, satisfied, once any ``Trail`` has been\ncompleted, and returns control to Grok. You cannot, therefore, have two\nworking trails where one is a prefix of the other; the second ``Trail``\nshown here will never be used::\n\n trails = [\n Trail('/person/:id', Person),\n Trail('/person/:id/:acct', BankAccount), # will never be used!\n ]\n\nRemember that Trails also registers adapters that tell Grok where each\nkind of object lives, so that if you, for example, are rendering a page\nfull of ``Person`` objects as part of a search result, then you can call\n``view.url(person)`` on each of them and Trails will construct URLs for\nthem that are built like::\n\n application_url + '/person/%s' % person.id\n\nIf your trail had said something more ambitious, like::\n\n Trail('/town/:name/:state', Town)\n\nthen the URL of any particular town would be formed by computing::\n\n application_url + '/town/%s/%s' % (town.name, town.state)\n\nand might look like ``/town/Springfield/MA``. Note that this means that\nTrails makes two assumptions about every class that you name as the\nsecond argument to a ``Trail``: first, that it can safely be called with\nkeyword arguments that look like the colon-prefixed wildcards that form\nthe URL pattern; and, second, that any live object of that type will\nhave attributes with those same two names which it can look up to form a\nURL for the object.\n\nPlease visit our project page (the link is near the top of this README)\nif you have any suggestions, bug reports, or questions about Trails.\nEnjoy!", "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 trail trails url", "license": "ZPL", "maintainer": null, "maintainer_email": null, "name": "megrok.trails", "package_url": "https://pypi.org/project/megrok.trails/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/megrok.trails/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/megrok.trails/1.0/", "requires_dist": null, "requires_python": null, "summary": "URL patterns for Grok applications", "version": "1.0" }, "last_serial": 794657, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "3349c3e47d51b6d0b2f9a027404d575b", "sha256": "bb6350d8e9896b5ef55dcc7e68f5e3d3ebe168f41db33295cd69858c32767ff3" }, "downloads": -1, "filename": "megrok.trails-1.0.tar.gz", "has_sig": false, "md5_digest": "3349c3e47d51b6d0b2f9a027404d575b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10338, "upload_time": "2008-07-17T00:47:31", "url": "https://files.pythonhosted.org/packages/9f/97/20be7f325413ed696ef1c8babbd12b624d645ba26d4d8adf9908e452d11f/megrok.trails-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3349c3e47d51b6d0b2f9a027404d575b", "sha256": "bb6350d8e9896b5ef55dcc7e68f5e3d3ebe168f41db33295cd69858c32767ff3" }, "downloads": -1, "filename": "megrok.trails-1.0.tar.gz", "has_sig": false, "md5_digest": "3349c3e47d51b6d0b2f9a027404d575b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10338, "upload_time": "2008-07-17T00:47:31", "url": "https://files.pythonhosted.org/packages/9f/97/20be7f325413ed696ef1c8babbd12b624d645ba26d4d8adf9908e452d11f/megrok.trails-1.0.tar.gz" } ] }