[Zope] Pluggable brains sample using Script (Python)
Julian Sanchez
julian.sanchez@ieee.org
Sun, 13 Apr 2003 16:23:08 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_000E_01C301D8.F87E0D00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hi,
I was wondering if somebody has a handy example on how to use pluggable
brains inside python scripts. For the most part I've only seen the sample in
which you have a class:
class MyDataClass:
def getSomething(self):
return self.field1 + self.field2
and then you have a DTML method that goes something like
<dtml-in myquery>
<dtml-var getSomething>
</dtml-in>
How would I access the MyDataClass if I were to write a python script rather
than a DTML method?
Thanks for your help,
Julian
------=_NextPart_000_000E_01C301D8.F87E0D00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial size=3D2>I was =
wondering if=20
somebody has a handy example on how to use pluggable brains inside =
python=20
scripts. For the most part I've only seen the sample in which you have a =
class:</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New" =
size=3D2>class=20
MyDataClass:</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New"=20
size=3D2> def getSomething(self):</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT=20
face=3D"Courier New"> <FONT=20
size=3D2>return self.field1 + self.field2</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New"=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial size=3D2>and =
then you have a=20
DTML method that goes something like</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New" =
size=3D2><dtml-in=20
myquery></FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New" =
size=3D2> =20
<dtml-var getSomething></FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3D"Courier New"=20
size=3D2></dtml-in></FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial size=3D2>How =
would I access=20
the MyDataClass if I were to write a python script rather than a DTML=20
method?</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial size=3D2>Thanks =
for your=20
help,</FONT></SPAN></DIV>
<DIV><SPAN class=3D235491921-13042003><FONT face=3DArial=20
size=3D2>Julian</FONT></SPAN></DIV></BODY></HTML>
------=_NextPart_000_000E_01C301D8.F87E0D00--