Hi, Do you know the difference between REQUEST['var'] and _[REQUEST['var']] ? And also can you explain me what is this : _ Thanks _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Hi Benoit, AFAIK, the _ is used as a hack. _ actually is the namespace variable, but in this case: REQUEST['var'] and _[REQUEST['var']] is no different. You use the _['something'] construction when a dash is used in the name: <dtml-var sequence-item> works by itself. If you want an expression of that: <dtml-var "sequence-item-5"> does not work because it syubtracts item from sequence and five from item. Instead use: <dtml-var "_['sequence-item']-5"> It is a hack where _['a-b'] forces a-b transalated by zope as a_b so there is not expression problem. Did I miss anything, oh great zopemasters? Cheers, Paz -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Benoit DOMINIAK Sent: Thursday, July 12, 2001 12:57 PM To: zope@zope.org Subject: [Zope] Syntax Hi, Do you know the difference between REQUEST['var'] and _[REQUEST['var']] ? And also can you explain me what is this : _ Thanks _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
At 14:24 12/07/01 +0200, Paul Zwarts wrote: <snip>
<dtml-var "sequence-item-5"> does not work because it syubtracts item from sequence and five from item. Instead use:
<dtml-var "_['sequence-item']-5">
Is this refering to an earlier item in the sequence? Is it the same as _.sequence-item-5 ? Is there a declaration of _ anywhere that I can look at? If I have a name clash (two Z SQL Method's return ID), how to I look up the stack of namespaces? Yours in abject confusion, J. Cone
The best bet is to check the DTML Users Guide. Although it is a long hard stare. Check the Zope book as well for fundamentals.
Is this refering to an earlier item in the sequence?
<dmtl-in list> <dtml-if "_['sequence-index']==5">This is the fifth occurance</dtml-if> </dtml-in> Yes indeed.
Is it the same as _.sequence-item-5 ?
The above is not possible. Remember that _ has a dual function. It A) accesses namespace: _.string.find('stringname, 'findStringText') _ pushes the results of the method into namespace. _.int(string) and so on... _['some-name'] has NOTHING to do with namespace. It only prevents 'some' being subtracted by 'name', when you intend some-name to be only one object.
If I have a name clash (two Z SQL Method's return ID), how to I look up the stack of namespaces?
Dont use ID as good practice, since ID is the document ID. BUT you can return REQUEST['id'] which is the REQUEST variable and not necessarily the Zope object ID. If you have multiple ID used in a nested <dtml-in> the ID resulted is owned by its superior IN. Forinstance, I add an 'a' or 'b'to ID to show: <dtml-in methoda> <-- You will return an ID here--> <dtml-var ID> <dtml-in methodb> <-- You will return an another ID here--> <dtml-var ID> </dtml-in> <dtml-in> Now I a the result <dtml-in methoda> <-- You will return an ID here--> <dtml-var ID(a)> <dtml-in methodb> <-- You will return an another ID here--> <dtml-var ID(b)> </dtml-in> <dtml-in> AFIAK. Possibly not. If you want to look up namespace, simply put <dtml-var REQUEST> in the bottom of your page and you will see all..... Paz -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of J. Cone Sent: Thursday, July 12, 2001 2:30 PM To: Paul Zwarts; benoit.dominiak@makinacorpus.com Cc: Zope Subject: RE: [Zope] Syntax At 14:24 12/07/01 +0200, Paul Zwarts wrote: <snip>
<dtml-var "sequence-item-5"> does not work because it syubtracts item from sequence and five from item. Instead use:
<dtml-var "_['sequence-item']-5">
Is this refering to an earlier item in the sequence? Is it the same as _.sequence-item-5 ? Is there a declaration of _ anywhere that I can look at? If I have a name clash (two Z SQL Method's return ID), how to I look up the stack of namespaces? Yours in abject confusion, J. Cone
Yes, it is a bit confusing, but you'll get used to that :) Look for "DTML Namespace Utility Functions" at the Zope Book http://www.zope.org/Members/michel/ZB/AdvDTML.dtml Ausum "J. Cone" wrote:
At 14:24 12/07/01 +0200, Paul Zwarts wrote: <snip>
<dtml-var "sequence-item-5"> does not work because it syubtracts item from sequence and five from item. Instead use:
<dtml-var "_['sequence-item']-5">
Is this refering to an earlier item in the sequence?
Is it the same as _.sequence-item-5 ?
Is there a declaration of _ anywhere that I can look at?
If I have a name clash (two Z SQL Method's return ID), how to I look up the stack of namespaces?
Yours in abject confusion, J. Cone
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hello there, Paul Zwarts wrote:
Hi Benoit,
AFAIK, the _ is used as a hack.
_ actually is the namespace variable, but in this case:
REQUEST['var'] and _[REQUEST['var']]
is no different. You use the _['something'] construction when a dash is used in the name:
well, I am by no means a great zopemaster, but in my understanding this is _NOT_ the same. _ gives you access to the global namespace, that means to every variable that is defined at the moment you call it. Lets say, you have a form, where var is filled with 'foo', then (after submitting, certainly ;-) REQUEST['var'] gives 'foo'. _['var'] gives the same result, when there is no other variable named 'var' in your global namespace (f.e. a property somewhere, but here I may miss). BUT: _[REQUEST['var']] is the same as _['foo'] and would look for a variable named 'foo'.
Did I miss anything, oh great zopemasters?
Yes, son! :-))
Cheers, Paz
happy zoping, Michael -- Michael Gutmann M.A. gutmann@uni-duesseldorf.de Multimediazentrum Heinrich-Heine-Universitaet Duesseldorf
participants (5)
-
Ausum -
Benoit DOMINIAK -
J. Cone -
Michael Gutmann -
Paul Zwarts