Re: [Zope] Pluggable Brains
David H wrote at 2005-8-6 13:12 -0700: >I've been using "pluggable brains" in some zSQL classes. I have some >questions! > >a) It seems if I initialize a variable in the __init__ method that >variable, say self.callCount = 1 is not retained across calls, eg For efficiency reasons, the result row objects of Z SQL methods do not have a dict. Therefore, you cannot create new attributes for them. Your brain classes derive from such objects and therefore, too, lack a dict. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] pluggable brains
What is this ZClass binding for? What\'s its purpose? Quoting Philipp Auersperg <[EMAIL PROTECTED]>: > For ZSQL Methods it is possible to bind a ZClass to the records. > > These can be selected from te combo box labeled \'ZClass\' in the > \'advanced\' tab of the SQLMethod\'s management screen, > but there is always listed just one ZClass. > > My question: > Why is there just one ZClass selectable, even if there are many ZClasses > defined? > Is that a bug or a feature? > > thanks > > phil > > -- Universidad Federico Santa Maria - Campus Guayaquil Enviado por: www.usm.edu.ec ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] pluggable brains
I already found the answer myself: one can only use ZClasses as pluggable brains that are NOT persistent!! phil*** REPLY SEPARATOR ***On 31.10.2000 at 05:05 Philipp Auersperg wrote: For ZSQL Methods it is possible to bind a ZClass to the records. These can be selected from te combo box labeled 'ZClass' in the 'advanced' tab of the SQLMethod's management screen, but there is always listed just one ZClass. My question: Why is there just one ZClass selectable, even if there are many ZClasses defined? Is that a bug or a feature? thanks phil
RE: [Zope] Pluggable brains
Stuart Foster writes: > 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. You wrap via the "Advanced Tab" of a Z SQL method. Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] Pluggable brains
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 in Zope. 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: class Employee: def fullName(self): """ return the full name in the form 'John Doe' """ return self.first_name + ' ' + self.last_name def yearlyIncome(self): """ 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: makes an estimated per year. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Dieter Maurer Sent: Thursday, September 14, 2000 1:40 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [Zope] Pluggable brains [EMAIL PROTECTED] writes: > 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? Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Pluggable brains
[EMAIL PROTECTED] wrote: > Is there a place where pluggable brains mechanism is described ? > > I am beginning a Zope site project. With the few I have read > about pluggable brains, I feel that more info could help me in > deciding which part of data has to stay in ZODB and which should > go inside RDBM. Have a look at http://www.zope.org/Members/michel/ZB/RelationalDatabases.html There is a VERY short description of how it works. -- _ Andreas Heckel[EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Pluggable brains
[EMAIL PROTECTED] writes: > 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? Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Pluggable brains
Alas no, other than what's in the ZSQL guide. :( This is something that badly wants to be documented in the Product Developer's Guide and generalized to include returning brains from the Catalog. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 14, 2000 10:19 AM Subject: [Zope] Pluggable brains Is there a place where pluggable brains mechanism is described ? I am beginning a Zope site project. With the few I have read about pluggable brains, I feel that more info could help me in deciding which part of data has to stay in ZODB and which should go inside RDBM. Thanks. Godefroid Chapelle - BubbleNet sprl rue Victor Horta 30 1348 Louvain-la-Neuve Belgium - This mail sent through SwinG Webmail: http://mail.swing.be ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] (Fwd) Re: [Zope] Pluggable brains aren't seen by first-nnn in - SOLUTION
On 4 Aug 2000, at 22:10, Dieter Maurer wrote: > Brad Clements writes: > > However first-eventday is ALWAYS true, however when I print &dtml- > > eventday; the output value is always the same for each row, so first- > > > > eventday shouldn't be true on any row except the first. > > Almost surely, the "in" tag does not call a callable object > (because it does not expect, they could be callable). > You, therefore, get the method itself. > It is identical for all records. So true, the solution is to define an __init__ class in the brain class, then use that to populate "self". class PackageEvent: """Package Event Pluggable Brain""" def __init__(self): """initialize""" self.__dict__['eday'] = self.eventday() def eventday(self): return DateTime(apply(time.mktime,self.eventtime.tuple()[:3]+(0,0,0,0,0,-1 ))) Now 'first-eday' works. Brad Clements,[EMAIL PROTECTED] (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Pluggable brains aren't seen by first-nnn in ?
Brad Clements writes: > However first-eventday is ALWAYS true, however when I print &dtml- > eventday; the output value is always the same for each row, so first- > eventday shouldn't be true on any row except the first. Almost surely, the "in" tag does not call a callable object (because it does not expect, they could be callable). You, therefore, get the method itself. It is identical for all records. Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )