Use proper in-line imports where possible in the Notifications helper.
--- a/app/soc/logic/helper/notifications.py Thu Jul 23 18:28:49 2009 -0700
+++ b/app/soc/logic/helper/notifications.py Fri Jul 24 15:23:45 2009 +0200
@@ -36,9 +36,6 @@
from soc.logic import mail_dispatcher
from soc.views.helper import redirects
-import soc.views.models as model_view
-import soc.logic.models as model_logic
-
DEF_NEW_NOTIFICATION_MSG = ugettext(
"You have received a new Notification.")
@@ -70,9 +67,11 @@
entity : A request containing the information needed to create the message
"""
+ from soc.logic.models.user import logic as user_logic
+
# get the user the request is for
properties = {'link_id': entity.link_id }
- to_user = model_logic.user.logic.getForFields(properties, unique=True)
+ to_user = user_logic.getForFields(properties, unique=True)
invitation_url = "http://%(host)s%(index)s" % {
'host' : os.environ['HTTP_HOST'],
@@ -92,7 +91,7 @@
template = DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE
- from_user = model_logic.user.logic.getForCurrentAccount()
+ from_user = user_logic.getForCurrentAccount()
sendNotification(to_user, from_user, message_properties, subject, template)
@@ -167,10 +166,13 @@
template : template used for generating notification
"""
+ from soc.logic.models.notification import logic as notification_logic
+ from soc.logic.models.site import logic as site_logic
+
if from_user:
sender_name = from_user.name
else:
- site_entity = model_logic.site.logic.getSingleton()
+ site_entity = site_logic.getSingleton()
sender_name = 'The %s Team' % (site_entity.site_name)
new_message_properties = {
@@ -191,12 +193,10 @@
'scope_path': to_user.link_id
}
- # pylint: disable-msg=W0612
- import soc.logic.models.notification
- key_name = model_logic.notification.logic.getKeyNameFromFields(fields)
+ key_name = notification_logic.getKeyNameFromFields(fields)
# create and put a new notification in the datastore
- model_logic.notification.logic.updateOrCreateFromKeyName(fields, key_name)
+ notification_logic.updateOrCreateFromKeyName(fields, key_name)
def sendNewNotificationMessage(notification_entity):
@@ -205,17 +205,18 @@
Args:
notification_entity: Notification about which the message should be sent
"""
- # pylint: disable-msg=W0612
- import soc.views.models.notification
+
+ from soc.logic.models.site import logic as site_logic
+ from soc.views.models.notification import view as notification_view
# create the url to show this notification
notification_url = "http://%(host)s%(index)s" % {
'host' : os.environ['HTTP_HOST'],
'index': redirects.getPublicRedirect(notification_entity,
- model_view.notification.view.getParams())}
+ notification_view.getParams())}
sender = mail_dispatcher.getDefaultMailSender()
- site_entity = model_logic.site.logic.getSingleton()
+ site_entity = site_logic.getSingleton()
site_name = site_entity.site_name
# get the default mail sender
@@ -253,8 +254,10 @@
user_entity: User entity which the message should be send to
"""
+ from soc.logic.models.site import logic as site_logic
+
# get site name
- site_entity = model_logic.site.logic.getSingleton()
+ site_entity = site_logic.getSingleton()
site_name = site_entity.site_name
# get the default mail sender