[Zope] how call a ZSQL method from a product instance+work w the
results SOLVED
hans
hans@beehive.de
Thu, 14 Mar 2002 11:39:56 +0000
Christian Theune wrote:
> Hi.
>
> See zopelabs.com for the article of generically calling objects/functions
> in zope (by casey duncan).
>
> Then simply acquire the query and call it. The resultset is easy handable
> when using
>
> result = .... call the query here ...().dictionaries() which will
> give you a list of dictionaries.
>
> * hans <hans@beehive.de> [020312 17:00]:
> > inside my product i have a method like
> >
> > def manage_draw_PI(self, REQUEST=None):
> > """draw:
> > get the x- and y-coords from database
> > """
> > self.sql_method = \
> > sql_method = self.aq_parent['sql_query'] # aquired from container
> >
> > self.sql_result = sql_method.__call__(query=self.sql_query) # query =
> > 'select * from PI'
> > self._p_changed = 1
> > if REQUEST is not None:
> > management_view='Edit' # tell zope to hilight mgnt tab
> > return self.manage_edit_PraxisIndex_Form(self)
> > else:
> > return
Just for the record (can't repeat it too often), used the excellent
http://www.zope.org/Members/spinwing/ZSQL_Results
i have read also the source files (Shared.DC.ZRDB.Results and related),
but it turns out to be obfuscated python (a *real* programmer
can program assembler in any language) like a class r() w empty body
in the middle of statements and one-lettered identifiers.
Whats the use of open source if its hard to understand?
FACT IS: result objects can't be pickled
which implies can't be made an attribute of a persistent object
and live through several transactions.
The dictionaries() result however can (and thats all i needed).
> > (hey, what is a zbrain and what is it good for?)
> dunno, i never cared for that and it simply doesn't disturb you. :)
Well, part of UNIX understanding is reading M.J.Bach's
The Design of the UNIX Operating System,
and i'd really would appreciate something similar for Zope.
cheers hans
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin (software developer) hans@beehive.de
beehive elektronische medien GmbH http://www.beehive.de
phone: +49 30 847-82 0 fax: +49 30 847-82 299