rendered method in dtml document
Zope Version (Zope 2.6.1 (binary release, python 2.1, linux2-x86), python 2.1.3, linux2) Python Version 2.1.3 (#1, Sep 19 2002, 13:15:46) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] System Platform linux2 I have searched the Zope site, emails, lab, etc and haven't found what I hoped would be a shorter solution rather than write a python script. So, here is what I want to do. I am trying to make available to my web page editors a single tag which would display one URL on the local domain and a different URL to all others. Below I have pasted in my ZSQL and Method which work fine if you supply a record number in a form or in a URL. The Method displays an Online Database Title which is hyperlinked to the online database. If you are in our domain you get the hyperlink which allows access to the database per our IP domain. If you are outside our domain you get a hyper link that allows you to login to our server and use it as a proxy, then the database will allow you access. I've tried as a tag in another page several different permutations of: <dtml-call dbtitle(47)> I've also tried REQUEST.set, dtml-let, and dtml-set . If you put the url http://www.library.appstate.edu/dbtitle?mytitle=74 in the location bar of the browser (or any other number from 1 to 108) the method will disply the hyperlinked title to that databased based on record number. ==================================== DTML METHOD ip_add_flag returns a 1 or 0 depending on if you are in our domain or not ==================================== <dtml-call "REQUEST.set('hostname',ip_add_flag(REMOTE_ADDR))"> <dtml-in db_title_query size=1 start=query_start> <a href="http:// <dtml-if hostname> <dtml-var vdb_local_url null=""> <dtml-else> <dtml-var vdb_proxy_url null=""> </dtml-if> <dtml-var vdb_title null="">"></a> </dtml-in> =================================== Z SQL one argument: mytitle =================================== select vdb_title, vdb_local_url, vdb_proxy_url from vdb_data where vdb_rec=<dtml-var mytitle> Thanks, Thomas PS: Usually I don't need to ask for assistance because the answers are usually already posted here. Thanks to all of those responders that share their insight and knowledge here by answering these requests. ----------------------------------------------------------------- Use The Help Desk at http://linux.library.appstate.edu/help ----------------------------------------------------------------- Rock and Rule Zope Rocks -- http://www.zope.org Python Rules -- http://www.python.org ----------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant III University Library Voice: 828 262 6587 FAX: 828 262 2797 "Windows: A 32-bit GUI on top of a 16-bit wrapper around an 8-bit interpretation of a 4-bit operating system written by a 2-bit company." -David Simmons
On Fri, 2003-09-26 at 08:04, Thomas M G Bennett wrote:
I am trying to make available to my web page editors a single tag which would display one URL on the local domain and a different URL to all others.
The core problem you're having is that the *client* is in charge of forming the URL. That said, it is pretty easy to make a single object available at more than one address. Say you have the following: some_folder/ admin/ some_method Due to the magic of Acquisition, you can call some_method as either: some_folder/some_method - or - some_folder/admin/some_method HTH, Dylan
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: <dtml-var dbtitle(mytitle=74)> <dtml-var dbtitle?mytitle=74> <dtml-let mytitle=74><dtml-in dbtitle></dtml-let> <dtml-var expr="mytitle=74"><dtml-in dbtitle> 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. If you go to http://www.library.appstate.edu/dbtitle?mytitle=74 it will give as its source code in your browser: <a href="http://0-biblioline.nisc.com.wncln.wncln.org/scripts/login.dll? BiblioLine&dbname=QFSD;done=referer">Family & Society Studies Worldwide</a> but in my browser in my domain the source code is : <a href="http://biblioline.nisc.com/scripts/login.dll? BiblioLine&dbname=QFSD;done=referer">Family & Society Studies Worldwide</a> 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. I don't need to access the method or query in a different path, I want the results of the method to appear in a document but I haven't figured out how to make the call to that method and pass it the argument so it can return the correct URL. Thomas 9/26/2003 11:04:47 AM, Thomas M G Bennett <bennettt@pm.appstate.edu> wrote:
Zope Version (Zope 2.6.1 (binary release, python 2.1, linux2-x86), python 2.1.3, linux2)
Python Version 2.1.3 (#1, Sep 19 2002, 13:15:46) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)]
System Platform linux2
I have searched the Zope site, emails, lab, etc and haven't found what I hoped would be a shorter solution rather than write a python script. So, here is what I want to do.
I am trying to make available to my web page editors a single tag which would display one URL on the local domain and a different URL to all others. Below I have pasted in my ZSQL and Method which work fine if you supply a record number in a form or in a URL. The Method displays an Online Database Title which is hyperlinked to the online database.
If you are in our domain you get the hyperlink which allows access to the database per our IP domain. If you are outside our domain you get a hyper link that allows you to login to our server and use it as a proxy, then the database will allow you access. I've tried as a tag in another page several different permutations of:
<dtml-call dbtitle(47)>
I've also tried REQUEST.set, dtml-let, and dtml-set . If you put the url
http://www.library.appstate.edu/dbtitle?mytitle=74
in the location bar of the browser (or any other number from 1 to 108) the method will disply the hyperlinked title to that databased based on record number.
==================================== DTML METHOD ip_add_flag returns a 1 or 0 depending on if you are in our domain or not ==================================== <dtml-call "REQUEST.set('hostname',ip_add_flag(REMOTE_ADDR))">
<dtml-in db_title_query size=1 start=query_start>
<a href="http://
<dtml-if hostname> <dtml-var vdb_local_url null=""> <dtml-else> <dtml-var vdb_proxy_url null=""> </dtml-if>
<dtml-var vdb_title null="">"></a>
</dtml-in>
=================================== Z SQL one argument: mytitle =================================== select vdb_title, vdb_local_url, vdb_proxy_url from vdb_data where vdb_rec=<dtml-var mytitle>
Thanks,
Thomas
PS: Usually I don't need to ask for assistance because the answers are usually already posted here. Thanks to all of those responders that share their insight and knowledge here by answering these requests.
----------------------------------------------------------------- Use The Help Desk at http://linux.library.appstate.edu/help ----------------------------------------------------------------- Rock and Rule Zope Rocks -- http://www.zope.org Python Rules -- http://www.python.org ----------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant III University Library Voice: 828 262 6587 FAX: 828 262 2797
"Windows: A 32-bit GUI on top of a 16-bit wrapper around an 8-bit interpretation of a 4-bit operating system written by a 2-bit company." -David Simmons
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
----------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant III University Library Voice: 828 262 6587 FAX: 828 262 2797 "Windows: A 32-bit GUI on top of a 16-bit wrapper around an 8-bit interpretation of a 4-bit operating system written by a 2-bit company." -David Simmons
On Fri, 2003-09-26 at 12:37, Thomas M G Bennett wrote:
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"
Try this: <dtml-var "dbtitle(74)"> Two things to note: 1. When you use a Python expression, put it in quotes. 2. Both dtml-call and dtml-var will *evaluate* the expression you pass them, but only dtml-var will return a value. HTH, Dylan
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."
participants (3)
-
Dylan Reinhardt -
J. Cameron Cooper -
Thomas M G Bennett