[Zope] Thanks, searching for documentation

chas panda@skinnyhippo.com
Tue, 07 Sep 1999 02:05:49 +0900


At 11:54 AM 9/6/99 -0500, John Goerzen wrote:
>
>Hi,
>
>First, thanks to everyone that gave me help while I've been learning Zope.
>It is much appreciated!
>
>In the QuickStart material, there are three things mentioned for which I
>am interested but have been able to find absolutely zero documentation.
>These are:
>
> * Aqueduct
> * Tabula
> * Pluggable Brains

Sorry, I can't direct you to any info other than the archive.
I'll save you some time on the pluggable-brains one and 
paste what I found to be one of the best posts in the
archive. (basically, pluggable brains are middleware objects
in dire need of a better name). 

Anyway, hope the following helps -

> > People,
> > Can someone point me to some documentation, messages or
> > source code that will give me a handle on what 'pluggable
> > brains' are and what I can do with them?
> >
> > Rob Page has just made a post saying that
> > Zope/ZODB3/pluggable brains can go a long way to integrating
> > with relational databases and I want to make sure I've got a
> > clue about all this! :)
> >
> > thanks
> > tone out,
>
> I was going to refer you the ZSQL Methods User Guide, but I
> just looked and it just barely mentions the concept of
> pluggable brains at the moment :(
>
> Simply put, pluggable brains means that you can associate
> a class that you've written in Python with the result record
> objects for a given SQL query. You can create a .py module in
> your Extensions directory (brain.py, for example) with a class
> definition such as:
>
> class SimpleBrain:
>   """A simple example brain."""
>
>   def fullname(self):
>     return self.first_name + self.last_name
>
> Now you create an SQLMethod, which for the sake of our example
> might look like:
>
>   select first_name, last_name from employees
>
> This query (like all queries) will return a sequence of "record"
> objects, where each record object exposes its data as if the fields
> were object attributes.
>
> Now, if you go to the "advanced" tab for a query, you can enter the
> module and class name of a class that will be added as a "mixin" to
> the normal record object behavior. Just like defining an external
> method, you enter the module name (in Extensions) and the class name
> to be used.
>
> *Now* when you run the query, the record objects will also have your
> custom class mixed in - now they can have not only their data exposed
> as if they were Python attributes, but custom behavior too. In our
> example above, if you made brain.SimpleBrain the "pluggable brain" for
> our SQL method, you can now do:
>
> <!--#in myquery-->
>   <!--#var fullname-->
> <!--#/in-->
>
> ...in DTML, because fullname is provided by the class that is mixed
> into the resulting record objects. The only real rule to keep
> in mind is that your "brain" must be a mixin class (e.g. you can't
> have an __init__ that expects any arguments).
>
> Hope this helps!
>
> Brian Lloyd        brian@digicool.com