[Zope] rendered method in dtml document
J. Cameron Cooper
jccooper at jcameroncooper.com
Fri Sep 26 18:22:18 EDT 2003
>I think I maybe didn't explain the problem quite clearly or I don't understand the
>acquisistion reply.
>
>
>Here's the paths :
>
>/dbtitle the method
>/dbtitle_query the sql
>/webmaster/a_test a test document
>
>dbtitle is the method, dbtitle_query is the SQL, a_test is a document. The sample
>document, a_test, has the following contents (which doesn't work).
>
>" a link to <dtml-call dbtitle(74)> which is a proxy or local url"
>
>
>Trying to pass the argument 74 to dbtitle hoping to have the rendered results of dbtitle
>show up in the document a_test. Here are some other permutaitons of a dtml tag I have
>tried in the document a_test without prefered results:
>
>
Based on these examples, I think you probably don't quite get DTML.
That's okay; it's very hard to get.
I'll comment on these and also point you at the previous thread "testing
with dtml-if".
><dtml-var dbtitle(mytitle=74)>
>
>
This asks for the rendering of something named 'dbtitle(mytitle=74)'.
This doesn't exist, and is probably an illegal name. It would work fine,
however, if you said::
<dtml-var "dbtitle(mytitle=74)">
or, in an equivalent but more explicit form,
<dtml-var expr="dbtitle(mytitle=74)">
Putting the quotes in makes it a python expression rather than a name.
Note that you can also use a variable from the DTML namespace like::
<dtml-var "dbtitle(mytitle=someparameter)">
Note also that this is different from a string::
<dtml-var "dbtitle(mytitle='somestring')">
Just like in regular Python.
><dtml-var dbtitle?mytitle=74>
>
>
Somewhat like above, but you conflate URL parameters with Python ones.
URL parameters don't work here.
><dtml-let mytitle=74><dtml-in dbtitle></dtml-let>
>
>
You got close here. This probably would have worked had you used
dtml-var instead of the loop handling dtml-in.
><dtml-var expr="mytitle=74"><dtml-in dbtitle>
>
>
Here you try to use dtml-var to work like dtml-let, and further use
dtml-in instead of dtml-var.
>What I'm thinking is I need a tag that will pass the value of mytitle in the name space to
>the call to dbtitle....
>
You were right here, but the inconsistent syntax of DTML tripped you up
in using its implicit namespace concept.
Both of these problems are why many Zope developers dislike DTML. I for
one will encourage you to look at ZPT and Python Scripts, where it would
have been much more obvious what to do::
<a href="dummyurl" tal:replace="python:context.dbtitle(47)">title</a>
Without the whole implicit namespace thing, it's pretty obvious what you
need to do to pass a parameter: the same thing you do in any other
programming language.
>That part works, what I want to do is to be able to give people that edit web pages on my
>server a single tag with a record number for these hyper links to appear in there web
>pages when some one accesses their page for example my test page, a_test.
>
>
Note that you can do this without any of the above by using a URL
parameter variable. But that's only a suggestion to keep you from having
to create a bunch of a_test lookalikes.
--jcc
--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."
More information about the Zope
mailing list