At 17:50 14/10/99 , Pavlos Christoforou wrote:
I am familiar with the model Martijn, however the whole point of the story is *not* to register the change with the ZODB.
Sorry Pavlos. I did not mean to imply that you were not a seasoned Zope developer (I know you've been playing with it before I even knew about it).
It would be nice if I could have a temporary in memory storage, accessible from all the threads and this used to be a simple matter in the pre-concurrent era. Anyway you have answered my question, ie each thread gets a copy of the class instance. Do you think I can get away by creating a class that participates in transactions and where instances of this class modify some class attribute, like:
class InMemory:
dict_visible_from_all={}
def set(self,k,v): self.dict_visible_from_all[k]=v
(transaction and garbage collection code ommited)
Are class attributes deepcopied too for each thread? (in which case it won't solve my problem). If not would such operations (ie calling an instance set method) be thread safe?
This won't solve your problem. Either you manage to convince the ZODB that your object is still clean, and won't get stored (no access for other threads), or if you tell the ZODB it is dirty, you get stored _including_ your dict, and you create another transaction for the instance.
I also noticed a module for in memory storage in the ZODB directory, but I am not sure how to combine the regular FileStorage with the in memory one.
How about creating a module level instance of a MemoryStorage ZODB for your product's use? Any instance of your product can call a method in the module that'll return a new connection to the storage, and store that into a _v_ variable. That way any thread safety is taken care of by your product ZODB. You'll only have to code for the ConflictError exception. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------