formdata: restore formdef class in sys.modules namespace before saving (#7239)
This commit is contained in:
parent
84ef7a452e
commit
1c4a9f7cde
|
@ -17,6 +17,7 @@
|
|||
import copy
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
from quixote import get_request, get_publisher, get_session
|
||||
|
@ -172,6 +173,16 @@ class FormData(StorableObject):
|
|||
if changed:
|
||||
self.store()
|
||||
|
||||
def store(self, *args, **kwargs):
|
||||
# make sure the class set under the formdef name in the sys.modules
|
||||
# namespaces is the exact one that was used when creating this
|
||||
# particular object, as it is required by pickle (or it will raise
|
||||
# "Can't pickle %r: it's not the same object as %s.%s" if the class
|
||||
# object has been changed in the course of the request).
|
||||
setattr(sys.modules['formdef'], self._formdef.url_name.title(), self.__class__)
|
||||
setattr(sys.modules['wcs.formdef'], self._formdef.url_name.title(), self.__class__)
|
||||
super(FormData, self).store(*args, **kwargs)
|
||||
|
||||
def get_user(self):
|
||||
if self.user_id and self.user_id != 'ultra-user':
|
||||
return get_publisher().user_class.get(self.user_id, ignore_errors=True)
|
||||
|
|
Loading…
Reference in New Issue