13 |
13 |
14 class AddUpdateCWUserHook(Hook): |
14 class AddUpdateCWUserHook(Hook): |
15 """ensure user logins are stripped""" |
15 """ensure user logins are stripped""" |
16 events = ('before_add_entity', 'before_update_entity',) |
16 events = ('before_add_entity', 'before_update_entity',) |
17 accepts = ('CWUser',) |
17 accepts = ('CWUser',) |
18 |
18 |
19 def call(self, session, entity): |
19 def call(self, session, entity): |
20 if 'login' in entity and entity['login']: |
20 if 'login' in entity and entity['login']: |
21 entity['login'] = entity['login'].strip() |
21 entity['login'] = entity['login'].strip() |
22 |
22 |
23 |
23 |
28 if not self.beid in session.query_data('pendingeids', ()): |
28 if not self.beid in session.query_data('pendingeids', ()): |
29 if not session.unsafe_execute('Any X WHERE X bookmarked_by U, X eid %(x)s', |
29 if not session.unsafe_execute('Any X WHERE X bookmarked_by U, X eid %(x)s', |
30 {'x': self.beid}, 'x'): |
30 {'x': self.beid}, 'x'): |
31 session.unsafe_execute('DELETE Bookmark X WHERE X eid %(x)s', |
31 session.unsafe_execute('DELETE Bookmark X WHERE X eid %(x)s', |
32 {'x': self.beid}, 'x') |
32 {'x': self.beid}, 'x') |
33 |
33 |
34 class DelBookmarkedByHook(Hook): |
34 class DelBookmarkedByHook(Hook): |
35 """ensure user logins are stripped""" |
35 """ensure user logins are stripped""" |
36 events = ('after_delete_relation',) |
36 events = ('after_delete_relation',) |
37 accepts = ('bookmarked_by',) |
37 accepts = ('bookmarked_by',) |
38 |
38 |
39 def call(self, session, subj, rtype, obj): |
39 def call(self, session, subj, rtype, obj): |
40 AutoDeleteBookmark(session, beid=subj) |
40 AutoDeleteBookmark(session, beid=subj) |
41 |
41 |
42 |
42 |
43 class TidyHtmlFields(Hook): |
43 class TidyHtmlFields(Hook): |