Obtaining URL of Object w/Non-Var Name
Alright, what's the trick to be able to retrieve the URL of a Zope object via DTML whose id has blanks or punctuation in it? For example, in a normally-named object called 'site_css', I'd do: Ex. 1 <LINK REL=stylesheet HREF=<dtml-var "site_css.absolute_url()"> TYPE="text/css"> But if the object is named 'site.css', I can use it w/o another layer/call or escape code. I tried the following (and a lot of others) and the _[] expression is returning a string, which then fails when it lacks a 'absolute_url' attribute: Ex. 2 <LINK REL=stylesheet HREF=<dtml-var "_['site.css'].absolute_url()"> TYPE="text/css"> Any solution must work with acquisition, as example one does, so I can keep the stylesheet in the site root folder. -Jeff Rush
On Fri, 29 Oct 1999, Jeff Rush wrote:
<LINK REL=stylesheet HREF=<dtml-var "_['site.css'].absolute_url()"> TYPE="text/css">
<untested> <LINK REL=stylesheet HREF=<dtml-var "_.getattr(_.getattr(_, 'site.css'), absolute_url)()"> TYPE="text/css"> </untested> Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd@phd.russ.ru Programmers don't die, they just GOSUB without RETURN.
At 19:19 29-10-99 , Jeff Rush wrote:
Alright, what's the trick to be able to retrieve the URL of a Zope object via DTML whose id has blanks or punctuation in it? For example, in a normally-named object called 'site_css', I'd do:
Ex. 1 <LINK REL=stylesheet HREF=<dtml-var "site_css.absolute_url()"> TYPE="text/css">
But if the object is named 'site.css', I can use it w/o another layer/call or escape code. I tried the following (and a lot of others) and the _[] expression is returning a string, which then fails when it lacks a 'absolute_url' attribute:
Ex. 2 <LINK REL=stylesheet HREF=<dtml-var "_['site.css'].absolute_url()"> TYPE="text/css">
<LINK REL=stylesheet HREF="<dtml-var "_.getitem('site.css', 0).absolute_url()">" TYPE="text/css"> This retrieves the object from the namespace without calling it. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
On Fri, 29 Oct 1999, Martijn Pieters wrote:
<LINK REL=stylesheet HREF="<dtml-var "_.getitem('site.css', 0).absolute_url()">" TYPE="text/css">
This retrieves the object from the namespace without calling it.
So add a parameter to getitem - getitem(object, 1). This should call the object. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd@phd.russ.ru Programmers don't die, they just GOSUB without RETURN.
participants (3)
-
Jeff Rush -
Martijn Pieters -
Oleg Broytmann