The challenge is that I have to do this using a string returned from an SQL query. This string must specify a multi-part reference: that is, a directory, and a file... Now, I can work around this by making it more structured; that is, the includes can only be in directory X. But I would really like to be able to put 'uid/studinfo' in the SQL and use that... Do I have to write an External Function to split the directory and perform the equivalent of nested <!--#with-->'s to include this? I had hoped for a simple DTML based solution.
---------- From: Pavlos Christoforou[SMTP:pavlos@gaaros.msrc.sunysb.edu] Sent: Friday, February 19, 1999 9:37 AM To: Shaw, Howard Cc: 'Zope@zope.org' Subject: Re: [Zope] Var includes
On Fri, 19 Feb 1999, Shaw, Howard wrote:
Using 'var' to include acquired documents is easy. How can I use 'var' to include a document in a folder in the hierarchy below me?
I have a folder 'temp_people'. Beneath this is 'uid', and beneath this 'studinfo' I need to include the contents of 'uid/studinfo' in a document in temp_people that is dynamically generated. I tried <!--#var "_[location]"--> where location is from a surrounding 'in sql method' call. I get a traceback saying:
<!-- Error type: Error value: uid/studinfo -->
Is there any reasonable way to put in my SQL table a simple reference that can be reasonably used in DTML to get to a subfolder object? I don't want to have put DTML code in the SQL table and try and get it evaluated...
I am not sure I understand what you need to do but you can call a document from down the hierarchy by simply:
<!--# with uid--> <!--# var studinfo--> <!--# /with-->
This will render the studinfo document and include it in the current document.
Pavlos
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
On Fri, 19 Feb 1999, Shaw, Howard wrote:
The challenge is that I have to do this using a string returned from an SQL query. This string must specify a multi-part reference: that is, a directory, and a file...
Do I have to write an External Function to split the directory and perform the equivalent of nested <!--#with-->'s to include this? I had hoped for a simple DTML based solution.
Ok now I understand the problem. It can be done with or without external methods by using _.string.replace and _.string.split methods. Neverhteless I have a feeling that the whole thing can be done in a more Zopinic way. Now whenever I come to a point that I have to use some ugly expression to get things done, I would reexamine my design to find where I introduced Non-Zopinic elements. For starters couldn't you redirect the client to the appropriate page? Lets suppose your query returns a variable mypath which contains the string: "gid/uid/studinfo" you could do <!--# call "RESPONSE.redirect(path)"-->
Do I have to write an External Function to split the directory and perform the equivalent of nested <!--#with-->'s to include this? I had hoped for a simple DTML based solution.
<!--#in expr="_.string.split(location, '/')"--> <!--#if sequence-start--> <!--#call "REQUEST.set('strFolder', _['sequence-item'])"--> <!--#else--> <!--#call "REQUEST.set('strDocument', _['sequence-item'])"--> <!--#/if--> <!--#/in--> Now we have altered the namespace. Now, these objects, are they _IN_ the current folder (i.e. in folder temp_people the folder uid the object studinfo)? Then you do: <!--#in expr="_.getitem(strFolder).objectItems(['Folder'])"--> <!--#if "_['sequence-key'] == strDocument"--> <!--#with sequence-item--> <!--#var title--> <== now in the namespace of the subobject <!--#/with--> <!--#/if--> <!--#/in--> Took me a minute, but it works. -- M.J. Pieters, Web Developer | ATMM http://www.atmm.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@atmm.nl http://www.atmm.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Ehm.. the following is a bit too much work
<!--#in expr="_.getitem(strFolder).objectItems(['Folder'])"--> <!--#if "_['sequence-key'] == strDocument"--> <!--#with sequence-item--> <!--#var title--> <== now in the namespace of the subobject <!--#/with--> <!--#/if--> <!--#/in-->
because <!--#with expr="_[strFolder]"--> <!--#with expr="_[strDocument]"--> <!--#var title--> <!--#/with--> <!--#/with--> will also do. -- M.J. Pieters, Web Developer | ATMM http://www.atmm.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@atmm.nl http://www.atmm.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (3)
-
Martijn Pieters -
Pavlos Christoforou -
Shaw, Howard