Re: [Zope] product organization

2005-07-28 Thread Nicholas Wieland

But how do I get the connection id ?
Actually I get it when I instance the product in Zope.
What I think is something like
 
class Foo
 
  def __init__ (self, conn):
    self.conn = conn
 
  myquery = SQL ('doMyQuery', '', self.conn, '', 'select * from table')
 
but obviously it will not work.
 
TIA,
  ngw
 
p.s. Sorry for top-postingMarco Bizzarri <[EMAIL PROTECTED]> ha scritto: 
I can't talk for best practise. You can put your queries also outside ofthe init, in this way:class YourProduct:_my_query = SQL('doMyQuery', '','your_connection', '', 'select * from data')def __init__(self):passAlso, if you have a *LOT* of queries, consider in building your query onthe fly.
		Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3___
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] product organization

2005-07-27 Thread Dieter Maurer
Nicholas Wieland wrote at 2005-7-27 13:54 +0200:
>Well, not exactly - just a way to separate access to data from everything else 
>in the product.
>Maybe a separate class that needs the connection as argument and that just 
>returns the data I need in appropriate data structures by calling class 
>methods.
> 
>class DataModel (object):
> 
>  def __init__ (self, conn):
>self.conn = conn
>self.sqlFetchSomething = SQL (.)

I think, a class variable "sqlFetchSomething" would do a better
job -- unless "SQL" depends on "conn".

Advantages:

  *  fewer objects in the ZODB, fewer loads, faster operations

  *  easier evolution of your SQL (in you need to change the
 SQL executed)


-- 
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] product organization

2005-07-27 Thread J Cameron Cooper

Nicholas Wieland wrote:


As usual, my question is rather simple :)
I'd like to know what are the best practices for product organization 
- for example I have _tons_ of queries to sqlserver, and my main 
class is becoming less manageble every time I look at it :/
I like the way SQL integrates in Zope, what I don't like is having a 
giant __init__ and a lot of _sqlSomething at the end of the class.
 
Can I associate queries to something else than a _variable ? 
Something like a dictionary or a class ? Can I move SQL calls outside 
the initializer ? I'd prefer to have a class for data access and 
another one to glue all the parts together, maybe I'm plain wrong but 
I think that my product would be a lot cleaner.
What are the best practices for FS based products ? 




If you're writing SQL queries attached to a Product and using them in 
said Product, you should look at ExtZSQL:


http://www.zope.org/Members/jccooper/extzsql

It was made for precisely this problem.

   --jcc


--
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com

___
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] product organization

2005-07-27 Thread Nicholas Wieland

Well, not exactly - just a way to separate access to data from everything else in the product.
Maybe a separate class that needs the connection as argument and that just returns the data I need in appropriate data structures by calling class methods.
 
class DataModel (object):
 
  def __init__ (self, conn):
    self.conn = conn
    self.sqlFetchSomething = SQL (.)
 
  def fetchSomething (self):
    return self.sqlFetchSomething
 
This is really simple, but I think it gives the idea.
Obviously I'd like to perform various operation at the data level, for example return a list of lists for reportlab tables and so on.
 
TIA,
  ngw
		Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3___
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] product organization

2005-07-27 Thread Marco Bizzarri
Nicholas Wieland wrote:
> As usual, my question is rather simple :)
> I'd like to know what are the best practices for product organization -
> for example I have _tons_ of queries to sqlserver, and my main class is
> becoming less manageble every time I look at it :/
> I like the way SQL integrates in Zope, what I don't like is having a
> giant __init__ and a lot of _sqlSomething at the end of the class.
>  
> Can I associate queries to something else than a _variable ? Something
> like a dictionary or a class ? Can I move SQL calls outside the
> initializer ? I'd prefer to have a class for data access and another one
> to glue all the parts together, maybe I'm plain wrong but I think that
> my product would be a lot cleaner.
> What are the best practices for FS based products ? 
> 
> 
> *Yahoo! Mail*
> :
> gratis 1GB per i messaggi, antispam, antivirus, POP3
> 
> 
> 
> 
> ___
> 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 )

I can't talk for best practise. You can put your queries also outside of
the init, in this way:

class YourProduct:

_my_query = SQL('doMyQuery', '',
'your_connection', '', 'select * from data')

def __init__(self):
pass


Also, if you have a *LOT* of queries, consider in building your query on
the fly.

Regards
Marco
begin:vcard
fn:Marco Bizzarri
n:Bizzarri;Marco
org:Icube S.r.l.
adr:;;via Ridolfi 15;Pisa;PI;56124;Italy
email;internet:[EMAIL PROTECTED]
title:Amministratore Delegato
tel;work:+39-050-970-207
tel;fax:+39-050-3136-588
tel;cell:+39-348-640-4861
x-mozilla-html:FALSE
url:http://notenotturne.blogspot.com/
version:2.1
end:vcard

___
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 )


[Zope] product organization

2005-07-27 Thread Nicholas Wieland
As usual, my question is rather simple :)
I'd like to know what are the best practices for product organization - for example I have _tons_ of queries to sqlserver, and my main class is becoming less manageble every time I look at it :/
I like the way SQL integrates in Zope, what I don't like is having a giant __init__ and a lot of _sqlSomething at the end of the class.
 
Can I associate queries to something else than a _variable ? Something like a dictionary or a class ? Can I move SQL calls outside the initializer ? I'd prefer to have a class for data access and another one to glue all the parts together, maybe I'm plain wrong but I think that my product would be a lot cleaner.
What are the best practices for FS based products ? 
		Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3___
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 )