[Zope] InvalidObjectReference strikes

Chris Withers chris at simplistix.co.uk
Mon Aug 23 07:08:38 EDT 2004


Jurgen Defurne wrote:
> I don't think that that is necessary anymore. Your comment about the
> persistent object finally makes everything clear 

Cool :-)

> what I have been reading in
> the Zope documentation, but nowhere in the documentation is it explicitly
> stated that the result of a query is a persistent object.

It isn't, but if you call brain.getObject(), you have a persistent object.

> Also, the comments in the Zope book about "Mounted Transient Object
> Container Caveats" are not really clear and they certainly give no clue on
> what to do.

If you can suggest changes, and tell me where they need to be made, I'll 
see about making them...

> The error I made in my code was that a) I do need what I call a 'browse'
> object, which keeps the reference to the ZSQL method,

Ouch. That reference should be a path to the ZSQL method that's resolved 
when you use it, otherwise, at best, you're trying to storea persisten 
method in a session ;-)

> the number of lines to
> query and the offset, and this object should (and can) be kept in a session,
> but b) I do not need to have the result of the query in session storage. This
> is clearly a mistake.

Agreed.

> So the lesson is, do not use the session storage for just passing a result!

Sessions are not a generic bin for data, imagine if a thousand users did 
a search on your site ;-)

> It is much better to declare a global variable myself into which I should pass
> intermediate values and query results between methods.

eh?

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list