[Zope-dev] pluggable brains - namespace blues
Philipp Auersperg
zope@philosoft.at
Fri, 03 Nov 2000 12:30:09 +0100
--=====_97325100915724=_
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a problem with pluggable brains:
1. Given is a ZClass named 'Merchant' that maps to a SQL table 'Merchant'=
with the columns 'ID' and 'name'.
2. I the ZClass I defined a Python method 'getName' with the body:
return self.name
3. I have a SQL Method with "select * from merchant" that I bind to the=
brain class 'Merchant'
4. I define a Python method with the following body:
--------------------------------
rs=3Dself.Merchants()
return rs[0].name
--------------------------------
And now the problems:
That works fine, but when I want to access the Merchant's name through the=
its member function getName() with the following code:
--------------------------------
rs=3Dself.Merchants()
return rs[0].getName()
--------------------------------
then I get an AttributeError mentioning that 'name' cannot be found.
when I change the getName() Python method to:
return 42
it works!
It seems that the namespace is somehow shreddered, I have to dig into that=
but if anybody can help it would spare much time!
So finally my desperate question:
How can I solve/workaround that problem to call methods in pluggable brains=
that access database-based members from a python method?
thanks in advance
phil
--=====_97325100915724=_
Content-Type: text/html; charset="us-ascii"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff style="FONT-FAMILY: Arial; FONT-SIZE: x-small"
text=#000000>
<DIV>I have a problem with pluggable brains:</DIV>
<DIV> </DIV>
<DIV>1. Given is a ZClass named 'Merchant' that maps to a SQL table 'Merchant'
with the columns 'ID' and 'name'.</DIV>
<DIV> </DIV>
<DIV>2. I the ZClass I defined a Python method 'getName' with the body:</DIV>
<DIV> return self.name</DIV>
<DIV> </DIV>
<DIV>3. I have a SQL Method with "select * from merchant" that I bind to the
brain class 'Merchant'</DIV>
<DIV> </DIV>
<DIV>4. I define a Python method with the following body:</DIV>
<DIV>--------------------------------</DIV>
<DIV>rs=self.Merchants()<BR>return rs[0].name</DIV>
<DIV>--------------------------------</DIV>
<DIV> </DIV>
<DIV>And now the problems:</DIV>
<DIV> </DIV>
<DIV>That works fine, but when I want to access the Merchant's name through the
its member function getName() with the following code:</DIV>
<DIV> </DIV>
<DIV>--------------------------------</DIV>
<DIV>rs=self.Merchants()<BR>return rs[0].getName()</DIV>
<DIV>--------------------------------</DIV>
<DIV> </DIV>
<DIV>then I get an AttributeError mentioning that 'name' cannot be found.</DIV>
<DIV>when I change the getName() Python method to:</DIV>
<DIV>return 42</DIV>
<DIV>it works!</DIV>
<DIV> </DIV>
<DIV>It seems that the namespace is somehow shreddered, I have to dig into that
but if anybody can help it would spare much time!</DIV>
<DIV> </DIV>
<DIV>So finally my desperate question:</DIV>
<DIV>How can I solve/workaround that problem to call methods in pluggable brains
that access database-based members from a python method?</DIV>
<DIV> </DIV>
<DIV>thanks in advance</DIV>
<DIV>phil</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>
--=====_97325100915724=_--