[Zope] ZSQL direct traveral question

John Eikenberry jae@kavi.com
Thu, 18 Mar 1999 15:58:05 -0800 (PST)


On Thu, 18 Mar 1999, Jeff K. Hoffman wrote:

> > I've been messing around with using direct traveral on the ZSQL methods.
> > I'm having a problem getting the traveral to work with anything more than
> > one level of depth, eg:
> > 
> > http://zope.kavi.com/mem/2/comp_admin/contacts/
> > 
> > Where 'mem' is the ZSQL query (that takes one arg), and the arg is '2'.
> > But it does work in this case:
> > 
> > http://zope.kavi.com/comp_admin/contacts/mem/2/
> > 
> > Is this a restriction on the use of ZSQL direct traveral, or am I doing
> > something wrong.
> 
> Without seeing your folder hierarchy, I'm not quite sure what's going on.
> Frankly, my head feels like it's going to explode when I try and figure
> out how your second example even worked. What are comp_admin and contacts?
> Folders? Where do they fit in your folder hierarchy?

Ok, a bit more info...

mem 		ZSQL method (on top level - stands for member company)
+ comp_admin  	folder (company admin)
  + contacts	folder (contact info for that company)

contacts has an index_html which uses information returned from the mem
query (its not how I use it, it won't even display with just #var).

'mem' takes one argument: comp_id (of which 2 is a test case)

> I have an event calendar, in which I use direct traversal of a ZSQL Method
> to display a particular event. My hierarchy is as follows:
> 
> + events [Folder]
>   - event_details_html [DTML Method]
>   - dbFindEventById [ZSQL Method]
> 
> My dbFindEventById method takes on parameter, event_id. To use direct
> traversal on my dbFindEventById query, using the event_details_html file
> to display the details of the event with event_id of 2 requires the
> following URL:
> 
>   http://localhost/events/dbFindEventById/event_id/2/event_details_html
> 
> At first, I tried:
> 
>   http://localhost/events/dbFindEventById/2/event_details_html
>
> which looks very close to your first example, and it did not work. Then I
> realized you are required to specify the name of the parameter in the URL
> as well, so I added event_id before the 2, and I was off to the races. 

Actually, I've found the reverse to be true. When I try:

http://zope.kavi.com/mem/comp_id/2/comp_admin/contacts/

I get this error:

Invalid integer value for comp_id 

Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line 877, in publish_module
  File lib/python/ZPublisher/Publish.py, line 413, in publish
    (Info: /db/m/comp_id/2/comp_admin/contacts/)
  File /usr/local/lib/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 414, in
__getitem__
    (Object: CopySource)
  File /usr/local/lib/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 386, in
__call__
    (Object: CopySource)
  File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__
    (Object: <string>)
  File lib/python/Shared/DC/ZRDB/sqltest.py, line 192, in render
    (Object: comp_id)
ValueError: (see above)

If I use creosote.spew to output the comp_id value before calling the
query (I made spew an external method on the top level, this has come in
very handy), the value resolves to 'comp_id'.

But when I don't use the comp_id arg (like in the original example, and
spew shows the value to be 2), it works fine as long as the method using
it is the next on the URL.
 
> I'm sure I've misunderstood your problem somewhere, and if I did, I
> apologize for spouting off nonsense. But, I figured this just might help,
> since I got tripped up when I first tried to use direct traversal, also.
> Better safe than sorry. :^)

Actually you are close, but in your example you use it as I said it works.
In your code app can you do something like this (fictional change of your
example):

http://localhost/events/dbFindEventById/ 
	event_id/2/modify_event/edit_event_details_html

(should be all one line)

Make more sense now?

BTW, thanks for the help. :) 

---

John Eikenberry
[jae@kavi.com - http://taos.kavi.com/~jae/] 
______________________________________________________________
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
                                         --B. Franklin