Hi,

  This might be a generic pythin question, but since I'm running into
an issue on GAE with memcache, this is probably a good place to ask.

I've got the following code

opGlobals = {}
exec(requestHandlerCode, opGlobals)
requestHandler = opGlobals["RequestHandler"]()
memcache.add(key="requestHandler", value=requestHandler)

where 'requestHandlerCode' from the second line is just a python class
definition retrieved from a TextProperty in the datastore.  Lines 1-3
execute fine, and I can call methods on the class instantiated in line
3.  However, trying to put the instance into memcache as in line 4
generates the following error -

PicklingError: Can't pickle <class __builtin__.RequestHandler at
0x17ef0c0>: it's not found as __builtin__.RequestHandler

Which is fine - I understand that it needs to be able to find the
class definition in order to pickle/unpickle the object - what I'm not
sure of is the best approach to resolving the problem.  I could put
the code in memcache, but then I'd be compiling and instantiating it
every request, which is no good.

The obvious options seem to be -

1. Install the class definition in __builtin__ so pickle does know
what to do with it (feels like a hack?)
2. Tell pickle to also look elsewhere for the information it needs

If someone who knows python better than I do could point me in the
right direction, that would be great.  Cheers,

Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to