[Zope] Change ZSQLMethod connection id

Tino Wildenhain tino at wildenhain.de
Thu Dec 29 08:15:50 EST 2005


Fabio schrieb:
> Hi!
> I solved (partially) my problem: very thanks.
>
> I studied acquisition and then I understood your example.
>
> I've another problem (the last, I hope): I call some ZSQLMethod from
> Python scripts so I need to execute a command dynamically.
> example
>  I need to execute
> 'container.include.sql.%s.getX()' % container.REQUEST.SESSION['dbconn']
>
> but 'exec' is not allowed. Does exist another way or I have to write:
> if container.REQUEST.SESSION['dbconn'] == 'conn1':
>     container.include.sql.conn1.getX()
> elif container.REQUEST.SESSION['dbconn'] == 'conn2':
>     container.include.sql.conn2.getX()
> elif ...
>
> ?
>
> In ZPT pages I use python:path('python:container.%s.getX()' % var) without
> problem but I don't knoe how do the same thing in a script python.
>

Well, thats just python - I'd suggest skimming thru the python
tutorial at python.org at least.

You reach objects by getattr(parent,attributename)
And in Zope also via:

parent[attributename]

This should get you going I think.

Regards
Tino


More information about the Zope mailing list