diff rhodecode/model/notification.py @ 1723:64e91067b996 beta

- refactoring to overcome poor usage of global pylons config - db transaction fixes - fixed tests - garden
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 26 Nov 2011 02:16:21 +0200
parents e7eef7a1db6a
children 31e6eb2fb4b2
line wrap: on
line diff
--- a/rhodecode/model/notification.py	Sat Nov 26 00:11:32 2011 +0200
+++ b/rhodecode/model/notification.py	Sat Nov 26 02:16:21 2011 +0200
@@ -29,9 +29,9 @@
 import traceback
 import datetime
 
-from pylons import config
 from pylons.i18n.translation import _
 
+import rhodecode
 from rhodecode.lib import helpers as h
 from rhodecode.model import BaseModel
 from rhodecode.model.db import Notification, User, UserNotification
@@ -41,7 +41,6 @@
 
 class NotificationModel(BaseModel):
 
-
     def __get_user(self, user):
         if isinstance(user, basestring):
             return User.get_by_username(username=user)
@@ -58,7 +57,6 @@
                 raise Exception('notification must be int or Instance'
                                 ' of Notification got %s' % type(notification))
 
-
     def create(self, created_by, subject, body, recipients,
                type_=Notification.TYPE_MESSAGE):
         """
@@ -90,7 +88,6 @@
                                     body=body, recipients=recipients_objs,
                                     type_=type_)
 
-
         # send email with notification
         for rec in recipients_objs:
             email_subject = NotificationModel().make_description(notif, False)
@@ -176,7 +173,8 @@
     TYPE_DEFAULT = 'default'
 
     def __init__(self):
-        self._template_root = config['pylons.paths']['templates'][0]
+        self._template_root = rhodecode.CONFIG['pylons.paths']['templates'][0]
+        self._tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
 
         self.email_types = {
             self.TYPE_CHANGESET_COMMENT:'email_templates/changeset_comment.html',
@@ -191,10 +189,9 @@
         
         :param type_:
         """
+
         base = self.email_types.get(type_, self.TYPE_DEFAULT)
-
-        lookup = config['pylons.app_globals'].mako_lookup
-        email_template = lookup.get_template(base)
+        email_template = self._tmpl_lookup.get_template(base)
         # translator inject
         _kwargs = {'_':_}
         _kwargs.update(kwargs)