[Zope] subpath in dtml?

Dylan Reinhardt zope@dylanreinhardt.com
Fri, 22 Nov 2002 16:11:48 -0800


I don't think there's a "keep-it-simple" answer that will let you use 
http://something.com/reg/b6ac3fe9  the way you want to..

In Zope, the URL  somesite/foo/bar  means "use bar in the context of foo," 
_not_ "pass bar to foo"

In typical usage, bar is a _method_ of foo or is _contained by_ foo.

Since what you want to do is to pass an arbitrary value to a specific 
object, the very most straightforward ways would be to roll them up in the 
URL, use POST, or put the value in a cookie.

Thus, you can try:

<form action=reg method=post>
<input type=hidden name=my_id value=<dtml-var some_value>>
<input type=submit value="Finish Registration">
</form>

Or:

<dtml-call "RESPONSE.setCookie('my_id', some_value)">

Either one will allow you can catch my_id in reg thus:

<dtml-var my_id>

and your URL will be the ultra-nice  http://something.com/reg

That's about it for uncomplicated solutions.  You *could* write a 
registration product that trapped unbound methods and used them as passed 
values... but not only did you say you didn't want to write a product, I'm 
not sure it would be such a great idea to do something like that anyway.  :-)

HTH,

Dylan


At 03:37 PM 11/22/2002, jonatan wrote:
>hi!
>
>i would like to make nice looking url's .. what you said would help me,
>but i'd like to have an url like http://something.com/reg/b6ac3fe9
>
>
>jonatan
>
>On Fri, 2002-11-22 at 23:46, Dylan Reinhardt wrote:
> > I think what you want is to generate a URL like so:
> >
> > http://some.site.com/reg?my_id=b6ac3fe9
> >
> > And then within reg you can do:
> >
> > <dtml-if my_id>
> >    <dtml-call "do_something(my_id)">
> > </dtml-if>
> >
> > Does that help?  If not, could you be a little more specific about what
> > you're trying to accomplish?
> >
> > Dylan
> >
> >
> >
> > At 02:01 PM 11/22/2002, jonatan wrote:
> >
> > >hi!
> > >
> > >
> > >i have a very simple problem: i have a dtml method called reg which
> > >should finalize a registration ... so i would like to have such urls:
> > >http://some.site.com/reg/b6ac3fe9
> > >
> > >if reg is a dtml method, then entering this url gives me a not found
> > >error ... ok cool .
> > >
> > >lets do a python script, and traverse_subpath. subpath doesnt exist (but
> > >its binded!!) so lets use traverse_subpath ...
> > >
> > >but now i am in a python script, i dont want to output html from here, i
> > >just want to check a row in the database!
> > >
> > >(outputting html gives me nice &lt; stuff - this is great too!)
> > >
> > >
> > >i searched for traverse_subpath, and didnt find something of use. just a
> > >traversable dtml document product.
> > >
> > >ARGH!
> > >
> > >please! i dont want to install products or make some magic with python
> > >scripts interacting with dtml! i started using zope because of its
> > >simplicity, i dont know why isnt there a simple way of doing this??
> > >
> > >or perhaps there is but i cannot find it?
> > >
> > >i am very desperated :)
> > >
> > >all i need is a <dtml-if> checking against the part after 'reg' ..
> > >(b6ac3fe9 here) ... i dont want python scripts for a single if ... why
> > >do you zope developers think that traverse_subpath should be used in a
> > >pythn script only?
> > >how can i achieve the same in dtml?
> > >
> > >why isnt http://something/reg/foo/bar working as dtml, but is working as
> > >a python script?
> > >
> > >
> > >zope is cool, i love smoking too, but sometimes it can be so hairy ...
> > >damn .. :)
> > >
> > >thanks,
> > >
> > >-jonatan.
> > >
> > >
> > >_______________________________________________
> > >Zope maillist  -  Zope@zope.org
> > >http://lists.zope.org/mailman/listinfo/zope
> > >**   No cross posts or HTML encoding!  **
> > >(Related lists -
> > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
>--
>jonatan <jonatanpelikan@freemail.hu>