On Thu, October 26, 2006 16:03, Jürgen Herrmann wrote:
>
>
> On Thu, October 26, 2006 15:25, Jürgen Herrmann wrote:
>>
>> On Thu, October 26, 2006 15:00, Marco Bizzarri wrote:
>>> On 10/26/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>>>>
>>>> On Thu, October 26, 2006 14:53, Marco Bizzarri wrote:
>>>> > Storing persistent object in object outside of ZODB can incur in the
>>>> > problem of passing
> object(s) between threads, and, therefore, passing one object which is
> related to a
> connection on the ZODB to another context with a different connection.
>>>
>>>> ok, this is probably the problem here, so would haveing a cache dict for
>>>> each thread help?
> there are only about 50-100 containers so the memory overhead would be
> neglible compared to
> the performance gained.
>>>
>>> Yes, this should probably resolve your issue.
>>>
>> ok, just reimplemented my _classContainer(className) method as follows:
>>
>> def _classContainer(self, className):
>> """ return the instances folder for className """
>> thread = currentThread()
>> containerDict = getattr(thread, '_relClsContainerDict', None) if
>> containerDict is None:
>> containerDict = {}
>> thread._relClsContainerDict = containerDict
>> container = containerDict.get(className, None)
>> if container is None:
>> container =
>> self.unrestrictedTraverse(self._classContainerPath(className))
> containerDict[className] = container
>> return container
>>
>> it seems to work fine, all tests pass, though i have a somewhat bad feeliong
>> of setting an
> attribute on the thread object directly.
>> comments?
>>
> uhm, ran some more tests, seems this works fine for the first thread but not
> for the others, i get
> an error when loading a framed page
> for example (obviously the browser sends two concurrent requests).
>
> the error is as follows:
> ...
> * Module Products.Relateable.Relateable, line 96, in relatedObjectIDs *
> Module
> ZODB.Connection, line 729, in setstate
>
> ConnectionStateError: Shouldn't load state for 0x010f98 when the connection
> is closed
>
> the above code can obvioulsy only work if there is exactly one single
> connection tied to one
> thread and it's not closed while the thread is alive.
>
> anybody have suggestions on how to tackle this?
>
> best regards, jürgen herrmann