##// END OF EJS Templates
events: Add a method to model base class for sending events....
johbo -
r229:a33067ed default
parent child Browse files
Show More
@@ -43,6 +43,7 The application's model objects
43 import logging
43 import logging
44
44
45 from pylons import config
45 from pylons import config
46 from pyramid.threadlocal import get_current_registry
46
47
47 from rhodecode.model import meta, db
48 from rhodecode.model import meta, db
48 from rhodecode.lib.utils2 import obfuscate_url_pw
49 from rhodecode.lib.utils2 import obfuscate_url_pw
@@ -144,6 +145,17 class BaseModel(object):
144 return self._get_instance(
145 return self._get_instance(
145 db.Permission, permission, callback=db.Permission.get_by_key)
146 db.Permission, permission, callback=db.Permission.get_by_key)
146
147
148 def send_event(self, event):
149 """
150 Helper method to send an event. This wraps the pyramid logic to send an
151 event.
152 """
153 # For the first step we are using pyramids thread locals here. If the
154 # event mechanism works out as a good solution we should think about
155 # passing the registry into the constructor to get rid of it.
156 registry = get_current_registry()
157 registry.notify(event)
158
147 @classmethod
159 @classmethod
148 def get_all(cls):
160 def get_all(cls):
149 """
161 """
General Comments 0
You need to be logged in to leave comments. Login now