[Zope] Problem Accessing a Z SQL Method
Chris Kratz
chris.kratz at vistashare.com
Fri Apr 2 09:27:17 EST 2004
Hello Asad,
It looks like you are losing your name space. If you call the second dtml
explicitly, then you have to pass the name space.
fist dtml call
<dtml-call some_dtml_method>
and
<dtml-call "some_dtml_method(None, _)">
are roughly similiar. If you require the explicit call, use the second form,
otherwise use the first form and save yourself some headache.
In most cases they will behave the same. It's almost always easiest to let
zope handle name spaces with dtml. IE don't call explicitely. It get's even
more fun if you try to render snippets by calling dtml methods from a python
script. Don't even try calling a python statement directly from the web
which has several layers of dtml underneath it. You will get strange
namespace errors. In our experience it has always been best to front scripts
with a zpt or dtml even if it does nothing but call a python script.
I believe dieter has some documentation on name spaces, try the url below and
read the calling DTML objects (4.4) and Name lookup (3.0) sections.
http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
HTH
-Chris
On Friday 02 April 2004 8:43 am, Asad Habib wrote:
> Hello. I am still having a problem with this. What I don't understand is
> why I am getting an error when both DTML methods involved and the Z SQL
> method being called are in the same folder. In this case(by default), Zope
> should be looking in this folder for the Z SQL method when the second DTML
> method calls it. If the DTML method and Z SQL method were in different
> folders, then it is possible to lose the context. Help from anyone would be
> greatly appreciated. Thanks.
>
> On Tue, 30 Mar 2004, David Hassalevris wrote:
> > Hey Asad,
> > Didnt know if someone helped you ... just a quick tip: if you call zSql
> > from a second script you may be losing your context ...
> > you can try something like
> > <dtml-with directory in zSql aquisition path>
> > <dtml-call yourSql>
> > hth,
> > David
> > ----- Original Message -----
> > From: "Asad Habib" <ahabib at engin.umich.edu>
> > To: <zope at zope.org>
> > Sent: Monday, March 29, 2004 11:56 AM
> > Subject: [Zope] Problem Accessing a Z SQL Method
> >
> > > I have a DTML document that calls a DTML method which in turn calls
> > > another DTML method. This second DTML method is called using the
> > > following syntax:
> > >
> > > <dtml-call "some_dtml_method">
> > >
> > > Wihin this second DTML method I try to access a Z SQL method using the
> > > following syntax:
> > >
> > > <dtml-call "update_something_sql">
> > >
> > > This causes Zope to flag me with an error which states the following:
> > >
> > > Error Type: NameError
> > > Error Value: global name 'update_something_sql' is not defined
> > >
> > > I am fairly certain this is a namespace issue but I don't know how to
> > > correct it. When I try accessing this same Z SQL method from the first
> > > DTML method, everything works fine.
> > >
> > > Also, for your information, the DTML document, the two DTML methods,
> > > and the Z SQL method are all defined on the same level.
> > >
> > > Any help would be greatly appreciated. Thanks.
> > >
> > > - Asad
> > >
> > > _______________________________________________
> > > Zope maillist - Zope at 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 )
>
> _______________________________________________
> Zope maillist - Zope at 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 )
--
Chris Kratz
Systems Analyst/Programmer
VistaShare LLC
www.vistashare.com
More information about the Zope
mailing list