[Zope] Re: How to get REST friendly urls from sql database
Tres Seaver
tseaver at palladion.com
Wed Feb 21 10:02:56 EST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Gaute Amundsen wrote:
> On Tuesday 20 February 2007 17:39, Paul Winkler wrote:
> <snip>
>> Another option is that the object at /articles could be an instance
>> of a class that looks something like:
>>
>> class MyArticleContainer():
>>
>> def __before_publishing_traverse__(self, unused, request):
>> # Save the rest of the path as 'traverse_subpath'.
>> request.set('traverse_subpath',
>> reversed(request['TraversalRequestNameStack']))
>> # Tell the publisher to stop traversing now.
>> request['TraversalRequestNameStack'][:] = []
>>
>> def __call__(self, *args, **kw):
>> subpath = self.REQUEST['traverse_subpath']
>> data = get_data_however_you_like(subpath)
>> return data
>>
>>
>> For background, read the stuff about traversal hooks at
>> http://wiki.zope.org/zope2/ZPublisher
Or you can give 'MyArticleContainer' a '__getitem__' method which
returns a non-persistent instance fabricated from the key passed to it
(assuming you need only that one bit of information).
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF3F8g+gerLs4ltQ4RAkkgAJ9pTuCKKAOrPSFOUVvrVI9FYhhxOQCg0Cwz
JAg6TDKquR2kKhvJoFoIUUE=
=OGlZ
-----END PGP SIGNATURE-----
More information about the Zope
mailing list