[Zope] Zope and Paths
Peter Bengtsson
mail at peterbe.com
Sun Nov 16 16:42:04 EST 2003
If you're a python product developer, you write a method called::
def __before_publishing_traverse__(self, object, request):
In self.REQUEST you'll find REQUEST['TraversalRequestNameStack'] which
is a list of the bits of the URL. I.e. something like ['Articles',
'32042'] depending on your situation.
This list you can modify on the fly to suit your needs.
For example, what I do is this:
Someone enters http://www.peterbe.com/oc-Zope
I get a list like ['oc-Zope']
If I in this list finds something that starts with 'oc-' I pop it from
REQUEST['TraversalRequestNameStack'] and deal with it separately kind of
like this:
REQUEST.set('onlycategory', 'Zope')
Then in some other part of the site I look for the REQUEST key
'onlycategory'.
For the creation of these URLs, I suggest that you wrap all URL
references through some function.
For example, what was:
<a href="ViewArticle?id=32042">
you now do:
<a href="<dtml-var "myURLFixer('ViewArticle' articleid=32042)">">
Another example (warning! extremely slow server), is
http://home.peterbe.com/issuetrackers/newT/ListIssues/start-10/sortorder-urgency/reverse-1
which I think looks better than
http://home.peterbe.com/issuetrackers/newT/ListIssues?start=10&sortorder=urgency&reverse=1
Use your imagination.
On a side note, look at this URL:
http://store.doverpublications.com/by-subject-science-and-mathematics-mathematics-fourier-analysis.html
(not Zope but a nice use of this possibility)
Faro wrote:
> Hi guys,
>
> I'd like to know if I can solve a simple problem:
>
> I'd like to manage path like that:
>
> www.site.com/Articles/32042
>
> as
>
> www.site.com/Articles/ViewArticle?id=32042
>
> How can I do it?? My method "ViewArticle" is inside the Article folder.
> There is an easy way to do it?? My articles are loaded form a Database, so I
> can't create, for every article, a new Document (called with his ID) for
> displaing it.
>
> tnx a lot, bye
>
>
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
> .
>
--
Peter Bengtsson, http://www.peterbe.com
More information about the Zope
mailing list