[Zope] Pluggable brains
Fri, 15 Sep 2000 08:37:15 -0700
I would like to understand how to do this in Zope also. I've done similar
things in Delphi and C++. But am having a little trouble seeing how to do it
Below is a snippet from a document that was suggested however It's not clear
how the data is "Wrapped" by the class. Can someone explain this. I would be
will to document it if I can figure this out.
----------------- snippet -----------------------------------------
Brains allow you to associate a Python or ZClass with a Record object.
Consider the example class:
""" return the full name in the form 'John Doe' """
return self.first_name + ' ' + self.last_name
""" calculate the employees yearlyIncome """
return (self.weekly_hours * self.hourly_wage * 52)
This class is then mixed in the with Record class which defines the behavior
for Record objects. When a Record object with Brains is instanciated as the
result of a SQL query, those objects will have Employee as a base class,
giving the resultant Record objects behavior, as well as data:
<dd><p><dtml-var fullName> makes an estimated
<dtml-var yearlyIncome fmt=dollars> per year.</p>
From: firstname.lastname@example.org [mailto:email@example.com]On Behalf Of
Sent: Thursday, September 14, 2000 1:40 PM
Subject: Re: [Zope] Pluggable brains
> Is there a place where pluggable brains mechanism is described ?
I forgot where I saw a description.
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?
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -