[Zope-DB] passing an handler to a python script

Giorgio Andreoletti - mentelocale giorgio.andreoletti@mentelocale.it
Mon, 25 Feb 2002 17:31:25 +0100

i'm a new subscriber to the list and the netiquette impose me to say
something like

 hi, i'm giorgio, i'm 25, from italy, i'm a zope web developer since the
middle of the last year.
 i work as a sysadmin and web developer, and you can see my best works at
www.mentelocale.it, www.palazzocicala.it , www.millenniumsim.it ; these are
the result of the work of the team i administrate. Ouch, they're all in
italian... sorry :-)

this is my problem: i'm writing a python script to handle the publishing of
some adv banners, using zope 2.5.0, postgresql 7.0.3, python 2.1.2, on my
linux slackware 2.4.17. I'm using psycopg as DB adapter.

everything is ok but the speed : the problem, i think, is due to the fact
that the script itself opens and closes a connection to the DB everytime
it's called; i'd like to pass the script something like an handle of a DB
connection created in zope, but i cannot realize how to pass this handle...

now i do:

  conn = psycopg.connect(conn.string)
  curs = conn.cursor()

but i think i need something like:

  conn = self.banners_db
  curs = conn.cursos()

(banners_db is the name of an active connection inside zope)
the first row doesn't give any error, but the second does .... where am i
wrong ?
Will it be different if i use a "Python (Script)" instead of an "Ext Method"

tnx to all for your help
have a nice day

Giorgio Andreoletti - mentelocale S.r.l.
responsabile hardware e networking
responsabile sviluppo web