Zope Product and Global Module Help
Two issues: 1) I have a product that I wrote in zope which is just a big hash. It loads in company names as keys, and from a text file, adds ticker items as each value for a particular key. Now I only want this huge dictionary to load once, which is when zope starts up (possibly in a global space), as I need one copy of it and I need that one copy to update every x number of minutes. Currently, I think, each user that views this product, loads his own copy of the hash, which makes it slow and a memory hog. I only want a single copy available to all users, and the data refresh time to be determined by the system or the user. 2) In the same python product, I am trying to access an ODBC database connection. I have tried 2 ways of accessing it, and both have failed. First I created a Z SQL method in the same directory as the Product, and tried to access that Z SQL method. My product subclasses SimpleItem, and so I tried self.getattr(name_of_Z_SQL_meth)(). The Z SQL method doesn't take any arguments, so that should have worked. Then I tried import SQL from Zope: from Products.ZSQLMethods.SQL import SQL, and running the SQL method directly. It always complains about the formation of the connection ID which I cannot seem to get right. Help on either of these issues would be greatly appreciated. I am using: Zope 2.5.1 with Python 2.1.3 on win 2k professional. -- _______________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup Meet Singles http://corp.mail.com/lavalife
sameer chaudhry wrote:
I have a product that I wrote in zope which is just a big hash. It loads in company names as keys, and from a text file, adds ticker items as each value for a particular key. Now I only want this huge dictionary to load once, which is when zope starts up (possibly in a global space), as I need one copy of it and I need that one copy to update every x number of minutes. Currently, I think, each user that views this product, loads his own copy of the hash, which makes it slow and a memory hog.
How is this hash defined? If it's defined in a module or class-level variable you should only have one copy loaded for eveyone.
Product, and tried to access that Z SQL method. My product subclasses SimpleItem, and so I tried self.getattr(name_of_Z_SQL_meth)().
What did you get when you tried this?
any arguments, so that should have worked. Then I tried import SQL from Zope: from Products.ZSQLMethods.SQL import SQL, and running the SQL method directly.
This sounds dodgy.
It always complains about the formation of the connection ID which I cannot seem to get right. Help on either of these issues would be greatly appreciated.
The format of the connection string depends on the DA you're using. What DA are you using? cheers, Chris
participants (2)
-
Chris Withers -
sameer chaudhry