40 # XXX should disappear |
40 # XXX should disappear |
41 class FormMixIn(object): |
41 class FormMixIn(object): |
42 """abstract form mix-in |
42 """abstract form mix-in |
43 XXX: you should inherit from this FIRST (obscure pb with super call) |
43 XXX: you should inherit from this FIRST (obscure pb with super call) |
44 """ |
44 """ |
|
45 force_session_key = None |
45 |
46 |
46 def session_key(self): |
47 def session_key(self): |
47 """return the key that may be used to store / retreive data about a |
48 """return the key that may be used to store / retreive data about a |
48 previous post which failed because of a validation error |
49 previous post which failed because of a validation error |
49 """ |
50 """ |
50 return '%s#%s' % (self.req.url(), self.domid) |
|
51 |
51 |
52 def __init__(self, req, rset, **kwargs): |
52 def __init__(self, req, rset, **kwargs): |
53 super(FormMixIn, self).__init__(req, rset, **kwargs) |
53 super(FormMixIn, self).__init__(req, rset, **kwargs) |
54 self.restore_previous_post(self.session_key()) |
54 self.restore_previous_post(self.session_key()) |
|
55 try: |
|
56 return self.force_session_key |
|
57 except AttributeError: |
|
58 return '%s#%s' % (self.req.url(), self.domid) |
55 |
59 |
56 def restore_previous_post(self, sessionkey): |
60 def restore_previous_post(self, sessionkey): |
57 # get validation session data which may have been previously set. |
61 # get validation session data which may have been previously set. |
58 # deleting validation errors here breaks form reloading (errors are |
62 # deleting validation errors here breaks form reloading (errors are |
59 # no more available), they have to be deleted by application's publish |
63 # no more available), they have to be deleted by application's publish |