Hello, Since a month or three, I am writing a transactional application using Zope and postgreSQL. My progress is not very high, because of learning Zope and its idiosyncracies, and because of our little daughter, born two months ago. However, I could see advancement in it. I am writing this as an MVC application, using events to find out which script to run, and a table driven screen flow manager to decide what should be the next screen. I very much like TAL, because it makes it possible for me to generate some default screens based upon the database table descriptions. In my application, I first need to build up my resulting data before I instantiate a screen from a template. Since I am only now beginning to add real functionality to my system (as previously making sure that my basic structure was allright), I only got now to the following problem. I need some 'batch' programming, for which I use a ZSQL object. I can query the object fine, but I cannot assign any part of the result into my session. Even if I try to copy separate fields from the result into another array, I always get the Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection error. Does anyone have a clue how I can copy the contents of the query result into a Python array or dictionary in Zope ? Regards, Jurgen
Jurgen Defurne wrote:
Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection error.
You're attempting to storea persistent object in a session this is "bad" (tm).
Does anyone have a clue how I can copy the contents of the query result into a Python array or dictionary in Zope ?
Show us the code of what you're trying to do and maybe we can sugges an alternative... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Sat, Aug 21, 2004 at 09:23:57AM +0200, Chris Withers wrote:
Jurgen Defurne wrote:
Error Type: InvalidObjectReference Error Value: Attempt to store an object from a foreign database connection error.
You're attempting to storea persistent object in a session this is "bad" (tm).
Does anyone have a clue how I can copy the contents of the query result into a Python array or dictionary in Zope ?
Show us the code of what you're trying to do and maybe we can sugges an alternative...
I don't think that that is necessary anymore. Your comment about the persistent object finally makes everything clear 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. 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. However, because of your question about the code, I started thinking 'what is my real objective here ?'. My objective is to create a batch query thing, so that I can browse forward and backward through a query. I have generic procedures for initialising the browsing, going forward and going backward. These take a dictionary of fields and a ZSQL method. 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, 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. So the lesson is, do not use the session storage for just passing a result! It is much better to declare a global variable myself into which I should pass intermediate values and query results between methods. Thanks for clearing things up and making me think. Regards, Jurgen
Chris
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
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
participants (2)
-
Chris Withers -
jurgen.defurne@pandora.be