Create the pool as a module level variable, import the module into each
servlet.

search the list,
I posted an example a while ago.

-Aaron

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> hi,
>
> i just started to play around with webware.
> iut know iam stuck, where to register the dbpool
> to have it avaible on every page.
> i get it working that each servlet has always it's
> pool but i want the whole context to share the pool object.
> i suspect the application object to handle this.
> maybe some one can point the right direction or
> give some sample scipts how to handle context
> wide resources.
>
> regards david
>
>
>  BaseClass:
>
> class SecurePage(SidebarPage, Configurable):
>
>       def __init__(self):
>               SidebarPage.__init__(self)
>               Configurable.__init__(self)
>               self.dbPool = None
>
>       def awake(self, trans):
>               # Awaken our superclass
>               SidebarPage.awake(self, trans)
>               if self.dbPool is None:
>                       self.dbPool = 
> DBPool(DataBaseConnection,5,self.setting('mysql_dsn'))
> self.writeDebugLog('init dbpool:%s' % self.dbPool)
>               else:
>                       self.writeDebugLog('found dbpool:%s' % self.dbPool)
>               if self.setting('RequireLogin'):
>                       ....
> Child Class:
>
>
> class TestPage(SecurePage):
>
>       def __init__(self):
>               SecurePage.__init__(self)
>
>       def awake(self, trans):
>               SecurePage.awake(self, trans)
>
>       def writeContent(self):
>               m = self.dbPool.getConnection()
>               self.writeDebugLog('got connection %s' % m)
>               m.select("select * from account")
>               res = m.getAll()
>               for row in res:
>                       self.writeln("%s <br>" % row)
>
>
>
> - --
> Best regards
> David Voswinkel
> ___________________________________________
>
> Centrium GmbH
> Vogelsanger Weg 80
> 40470 Düsseldorf
>
> fon: +49 (0211) 74 845 231
> fax: +49 (0211) 74 845 299
> email:  [EMAIL PROTECTED]
> web:    www.centrium.de
>
> ___________________________________________
>
> Please avoid sending me Word or PowerPoint attachments.
> See http://www.fsf.org/philosophy/no-word-attachments.html
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQE/U1ITBZgDeBOnyUURAjvsAJ9Q3qiIBxYsf6nau3EDURJlZ68A6wCdGSXY
> MtclqIx2ZwRSdLKEvrhzU7g=m/cX
> -----END PGP SIGNATURE-----
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to