Re: [Zope] calling (SQL) methods dynamically from External methods

2000-08-21 Thread Philipp Auersperg

Thanks for the answer, it helped me, 
but you missed what I really wanted.

I don't want to call SQL queries by query string, what I want is to
use Z SQL Methods, but I need to identify them by their name as string, because 
in this project we have many complicated queries with parameters.

But finally I am happy because that works:

m1=getattr(self,'dbTest')   #dbTest is a ZSQL method
rs=m1(self)   

for r in rs:
...

Thanks

Philipp Auersperg(zwork)

*** REPLY SEPARATOR  ***

On 21.08.2000 at 13:32 Andrew Kenneth Milton wrote:

+---[ Philipp Auersperg ]--
| 
| What I want to do is calling a SQL method given its
| name as string, so I first have to get the method out of
| the self.__dict__ and then call it. I need that for calling
| the SQL methods dynamically for example out of an URL
| string.

realConnection=getattr(self,connectionId)
realConnection().query(query_in_a_string)

-- 
Totally Holistic Enterprises Internet|  P:+61 7 3870 0066   | Andrew Milton
The Internet (Aust) Pty Ltd  |  F:+61 7 3870 4477   | 
ACN: 082 081 472 ABN: 83 082 081 472 |  M:+61 416 022 411   | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068|[EMAIL PROTECTED]|




___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] calling (SQL) methods dynamically from External methods

2000-08-21 Thread R. David Murray

On Mon, 21 Aug 2000, Philipp Auersperg wrote:
 Interesting fact:
 When retrieving the method object with "m=self.dbTest" and then with 
"m1=self.__dict__['dbTest']" 
 "print m,m1" show the same string but "m==m1" results to false!
 
 What am I doing wrong? There seems something mixed up with namespaces, but I am too 
solly to solve it :(

I *think* what you are running into here is the difference between
an context-wrapped object and the unwrapped object.  I think __dict__
gets you the latter, but self.dbTest calls __getattr__ and the Zope
hook for that returns a wrapped object.  The wrapped object can
use acquisition to find the db connection, the unwrapped object can't.

As you found, getattr is the way to do what you want.

--RDM


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] calling (SQL) methods dynamically from External methods

2000-08-21 Thread Andrew Kenneth Milton

+---[ Philipp Auersperg ]--
| Thanks for the answer, it helped me, 
| but you missed what I really wanted.

Sorry. d8)

-- 
Totally Holistic Enterprises Internet|  P:+61 7 3870 0066   | Andrew Milton
The Internet (Aust) Pty Ltd  |  F:+61 7 3870 4477   | 
ACN: 082 081 472 ABN: 83 082 081 472 |  M:+61 416 022 411   | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068|[EMAIL PROTECTED]| 

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] calling (SQL) methods dynamically from External methods

2000-08-20 Thread Andrew Kenneth Milton

+---[ Philipp Auersperg ]--
| 
| What I want to do is calling a SQL method given its
| name as string, so I first have to get the method out of
| the self.__dict__ and then call it. I need that for calling
| the SQL methods dynamically for example out of an URL
| string.

realConnection=getattr(self,connectionId)
realConnection().query(query_in_a_string)

-- 
Totally Holistic Enterprises Internet|  P:+61 7 3870 0066   | Andrew Milton
The Internet (Aust) Pty Ltd  |  F:+61 7 3870 4477   | 
ACN: 082 081 472 ABN: 83 082 081 472 |  M:+61 416 022 411   | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068|[EMAIL PROTECTED]| 

___
Zope maillist  -  [EMAIL PROTECTED]
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 )