[Zope] different namespaces in a python script by calling
it by<dtml-var xxx> and <dtml-var "xxx()">?
Grégoire Weber
gregoire.weber@switzerland.org
Thu, 19 Jul 2001 18:28:04 +0200
Thanks Chris,
your answer helped me!
But I am not really satisfied in general about the solution.
I know it's not your fault!
> > <dtml-var xxx> --> foo
>
> This is the equivalent of:
> <dtml-var "xxx(_.None,_)">
I have additional parameters so I replaced the '_.None'
by the parameters like this (as I suppose, the _.None
is only used if there are no parameters at all):
<dtml-var "xxx(anypar='foo_par',_=_)">
without '_=_' it does not work as expected.
> This is confusing, isn't it?
You're damn right! :-(
Questions which turn up (just for interest):
1) Why isn't this done automagically by setting the 'Namespace'
thing in the bindings tab to '_'? So that the caller does not
have to grant access to '_' to the calles Python Script
explicitly?
2) Isn't there really any possibility for the Script to access
the '_' namespace of it's own? It seems that I have access
to the '_' namespace version which is set up at the
beginning of the request.
3) Why do DTML know about the actual namespace of the calling
methods and Python Scripts not?
It seems to me that Python Scripts do not at all have the same
behaviour as DTML methods have. :-(
Greg
P.S.: Is there a documentation about thsi anywhere?
-------------------------------------------------- xxx script
## Script (Python) "xxx"
##bind container=container
##bind context=context
##bind namespace=_
##bind script=script
##bind subpath=traverse_subpath
##parameters=anypar='foo_default'
##title=
##
if _.has_key('sort_order'): return (_['sort_order'],anypar)
else: return ('sort_order not defined',anypar)
------------------------------- xxxcaller dtml method snippet
<dtml-let sort_order="'foo_sort_order'">
<dtml-var xxx><br>
<dtml-var "xxx(anypar='foo_par',_=_)">
</dtml-let>
_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org