[Zope-DB] Re: Example for RDB persistency in zope products?
nicholas.bower at jrc.it
Sat Jun 26 06:07:00 EDT 2004
Thanks, but part of the reason I was wanting to avoid ZSQL is because
(for whatever reason) I've been unable to get any decent performance
using TTW+ZSQL components in a ZEO environment. ZPT benchmarks fine,
but add some ZSQL and you're hosed!
So why would someone want the overhead of DTML parsing in business logic
when I can directly pass SQL statements the the DA? (in my very limited
understanding - correct me if I'm wrong here).
Yes, I did think I would be locking myself to the database adapter being
used, but having a loadable application locked to a single database is
better than having an un-loadable application. (Assuming my reasons for
assuming ditching ZSQL will lead to better performance).
Do these thoughts match with anyone's experiences?
Dieter Maurer wrote:
> Nick Bower wrote at 2004-6-25 20:22 +0200:
>>Does anyone have any examples of how I code relational database
>>persistency into an object (at a Zope product level)?
>>I've an application written to view and manage complex organisational
>>data in Python scripts, ZPTs and ZSQL methods, and would like to move it
>>to the product level and into persistent object land. However, the RDB
>>persistency aspect is what I'm most confused about.
>>I've seen people talk about doing the following:
>>1. Inherit from ZSQL methods for their business objects
>>2. Call ZSQL methods from their business object logic
>>3. Using an existing DA, such as psycopg, directly, bypassing ZSQL
>>methods, and calling the DA connection methods from business logic
>>4. Writing their own DA for integration with business logic
>>3. would have seemed to me like the practical way to go, but I'm just
>>not sure where to start for lack of documentation promoting any way
>>other than using ZSQL.
> I would use Z SQL Methods.
> If necessary, I would use them as class variables:
> from Products.ZSQLMethods.SQL import SQL
> class YourClass(...):
> mySQLMethod1 = SQL('mySQLMethod1', ''
> connection_id, arguments1, template1)
> mySQLMethod2 = SQL('mySQLMethod2', ''
> connection_id, arguments2, template2)
> You can then access them via "YourInstance.mySQLMethod1", ...
More information about the Zope-DB