[Zope] Re: Pluggable Brains

Dieter Maurer dieter@handshake.de
Fri, 15 Sep 2000 20:34:39 +0200 (CEST)

gotcha@swing.be writes:
 > Quoting :
 > > 
 > > But it is incredibly simple:
 > > 
 > >   You can wrap an arbitrary class instance around your 
 > database rows.
 > >   This transforms your rows into full featured objects with
 > >   the columns (among others) as attributes and the methods
 > >   defined by the class as potential behaviour.
 > > 
 > > 
 > > What elso do you need to know?
 > > 
 > >
 > How and where you define those pluggable brains ?
You must know Python.

You write a Python class, say "myClass" with all the extra attributes
you like and all methods you may want to use for your
database rows.
You put the class into a source file, say "myExtensionFile"
(or import it there).
You place the file inside the folder "Extensions" (or, to keep
namespaces separate, into an "Extensions" subfolder
of a product).

Then in the "Advanced Tab" of Z SQL methods, you say:
I want to use class "myClass" from source "myExtensionFile"
as custom class.

That's it. Now, the rows retrieved by your query are
"myClass" instances and have all additional attributes
and methods you defined.