RE: [Zope-dev] ZPatterns Design Issue
I generally follow this approach for long lists and reports, but the tree tag is a bit more tricky because you only have a simple "data" object without the context that a real object provides. A real object makes it a lot simpler if you recursively draw a hierarchy - doing it with simple "data" objects requires some thinking but thanks for pointing me in the right direction. Roché > Just return the result directly. If the data is all from SQL, that's all > you need to do. The catch is that you may have to structure your ZClass > differently to allow it to be returned from an SQL method. > > The simplest thing, though, is to define your application API's so that > methods which must return multiple objects in this fashion are returning > sequences of simple "data" objects which do not provide the full > semantics > of the real objects. In essence, define the API as returning "reporting > data" rather than objects. This is similar to the ZCatalog > approach which > returns dumb record objects, but can optionally retrieve the real > object if > needed. It is generally the best approach for report-like > situations (such > as use of the tree tag). > ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
RE: [Zope-dev] ZPatterns Design Issue
At 05:26 PM 4/24/01 +0200, Roch'e Compaan wrote: >How do you bind a SQL Result with multiple records with multiple instances >of the class? Can you do this in Skinscript? Or do you mean I should return >the sql result directly? Just return the result directly. If the data is all from SQL, that's all you need to do. The catch is that you may have to structure your ZClass differently to allow it to be returned from an SQL method. The simplest thing, though, is to define your application API's so that methods which must return multiple objects in this fashion are returning sequences of simple "data" objects which do not provide the full semantics of the real objects. In essence, define the API as returning "reporting data" rather than objects. This is similar to the ZCatalog approach which returns dumb record objects, but can optionally retrieve the real object if needed. It is generally the best approach for report-like situations (such as use of the tree tag). ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
RE: [Zope-dev] ZPatterns Design Issue
How do you bind a SQL Result with multiple records with multiple instances of the class? Can you do this in Skinscript? Or do you mean I should return the sql result directly? Roché > Why don't you just have the rack's getChildrenFor() method return > instances > of the correct class, with all the data filled in from the SQL > method? There should be no need to re-retrieve the same items with > getItem(). Note, by the way, that this does not violate encapsulation, > since the specialist and racks are specifically the place to put > implementation-specific versions of multi-object methods like this. > > (Btw, if anybody's compiling a ZPatterns FAQ, this should probably get in > there.) > ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZPatterns Design Issue
At 03:01 PM 4/24/01 +0200, Roch'e Compaan wrote: >Building the tree leads to a whole bunch of queries to the database that >really slows thing down ie. besides the queries that retrieve children, >select queries to retrieve individual instances is called by getItem through >SkinScript for each item in the tree. Why don't you just have the rack's getChildrenFor() method return instances of the correct class, with all the data filled in from the SQL method? There should be no need to re-retrieve the same items with getItem(). Note, by the way, that this does not violate encapsulation, since the specialist and racks are specifically the place to put implementation-specific versions of multi-object methods like this. (Btw, if anybody's compiling a ZPatterns FAQ, this should probably get in there.) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )