Cleanups to the logic module
authorSverre Rabbelier <srabbelier@gmail.com>
Wed, 03 Dec 2008 21:26:16 +0000
changeset 655 9635cbaa2dcd
parent 654 68bafa9f719f
child 656 a76f1b443ea4
Cleanups to the logic module Mainly converting to super(Logic, self) and adding some missing empty lines while at it. Patch by: Sverre Rabbelier
app/soc/logic/models/base.py
app/soc/logic/models/document.py
app/soc/logic/models/group.py
app/soc/logic/models/host.py
app/soc/logic/models/presence.py
app/soc/logic/models/program.py
app/soc/logic/models/request.py
app/soc/logic/models/role.py
app/soc/logic/models/site.py
app/soc/logic/models/sponsor.py
app/soc/logic/models/user.py
app/soc/logic/models/work.py
--- a/app/soc/logic/models/base.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/base.py	Wed Dec 03 21:26:16 2008 +0000
@@ -43,21 +43,22 @@
   """Base logic for entity classes.
 
   The BaseLogic class functions specific to Entity classes by relying
-  on the the child-classes to implement _model, _name and _key_name
+  on arguments passed to __init__.
   """
 
   def __init__(self, model, base_model=None,
                name=None, skip_properties=None):
     """Defines the name, key_name and model for this entity.
     """
+
     self._model = model
     self._base_model = base_model
-    
+
     if name:
       self._name = name
     else:
       self._name =  self._model.__name__
-    
+
     if skip_properties:
       self._skip_properties = skip_properties
     else:
--- a/app/soc/logic/models/document.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/document.py	Wed Dec 03 21:26:16 2008 +0000
@@ -36,7 +36,8 @@
                base_model=soc.models.work.Work):
     """Defines the name, key_name and model for this entity.
     """
-    work.Logic.__init__(self, model=model, base_model=base_model)
+
+    super(Logic, self).__init__(model=model, base_model=base_model)
 
 
 logic = Logic()
--- a/app/soc/logic/models/group.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/group.py	Wed Dec 03 21:26:16 2008 +0000
@@ -34,7 +34,8 @@
   def __init__(self, model=soc.models.group.Group, base_model=None):
     """Defines the name, key_name and model for this entity.
     """
-    base.Logic.__init__(self, model, base_model=base_model)
+
+    super(Logic, self).__init__(model, base_model=base_model)
 
   def getKeyValues(self, entity):
     """Extracts the key values from entity and returns them.
--- a/app/soc/logic/models/host.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/host.py	Wed Dec 03 21:26:16 2008 +0000
@@ -35,8 +35,9 @@
   def __init__(self):
     """Defines the name, key_name and model for this entity.
     """
-    role.Logic.__init__(self, model=soc.models.host.Host,
-                        base_model=soc.models.role.Role)
+
+    super(Logic, self).__init__(model=soc.models.host.Host,
+                                base_model=soc.models.role.Role)
 
 
 logic = Logic()
--- a/app/soc/logic/models/presence.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/presence.py	Wed Dec 03 21:26:16 2008 +0000
@@ -36,7 +36,8 @@
                base_model=None):
     """Defines the name, key_name and model for this entity.
     """
-    base.Logic.__init__(self, model, base_model=base_model)
+
+    super(Logic, self).__init__(model, base_model=base_model)
 
 
 logic = Logic()
--- a/app/soc/logic/models/program.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/program.py	Wed Dec 03 21:26:16 2008 +0000
@@ -34,6 +34,7 @@
   def __init__(self, model=soc.models.program.Program, base_model=None):
     """Defines the name, key_name and model for this entity.
     """
+
     super(Logic, self).__init__(model=model, base_model=base_model)
 
 
--- a/app/soc/logic/models/request.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/request.py	Wed Dec 03 21:26:16 2008 +0000
@@ -37,7 +37,7 @@
     """Defines the name, key_name and model for this entity.
     """
 
-    base.Logic.__init__(self, model, base_model=base_model)
+    super(Logic, self).__init__(model, base_model=base_model)
 
   def getKeyValues(self, entity):
     """See base.Logic.getKeyNameValues.
--- a/app/soc/logic/models/role.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/role.py	Wed Dec 03 21:26:16 2008 +0000
@@ -34,7 +34,8 @@
   def __init__(self, model=soc.models.role.Role, base_model=None):
     """Defines the name, key_name and model for this entity.
     """
-    base.Logic.__init__(self, model, base_model=base_model)
+
+    super(Logic, self).__init__(model, base_model=base_model)
 
 
 logic = Logic()
--- a/app/soc/logic/models/site.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/site.py	Wed Dec 03 21:26:16 2008 +0000
@@ -41,7 +41,8 @@
                base_model=soc.models.presence.Presence):
     """Defines the name, key_name and model for this entity.
     """
-    presence.Logic.__init__(self, model=model, base_model=base_model)
+
+    super(Logic, self).__init__(model=model, base_model=base_model)
 
   def getKeyValues(self, unused_entity):
     """Returns the default key values for the site settings.
--- a/app/soc/logic/models/sponsor.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/sponsor.py	Wed Dec 03 21:26:16 2008 +0000
@@ -36,7 +36,8 @@
                base_model=soc.models.group.Group):
     """Defines the name, key_name and model for this entity.
     """
-    group.Logic.__init__(self, model=model, base_model=base_model)
+
+    super(Logic, self).__init__(model=model, base_model=base_model)
 
   def isDeletable(self, entity):
     """Returns whether the specified Sponsor entity can be deleted.
@@ -44,6 +45,7 @@
     Args:
       entity: an existing Sponsor entity in datastore
     """
+
     # TODO(pawel.solyga): Check if Sponsor can be deleted (no Hosts, Programs)
     return True
 
--- a/app/soc/logic/models/user.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/user.py	Wed Dec 03 21:26:16 2008 +0000
@@ -35,21 +35,23 @@
   def __init__(self):
     """Defines the name, key_name and model for this entity.
     """
-    base.Logic.__init__(self, soc.models.user.User,
+
+    super(Logic, self).__init__(soc.models.user.User,
                         skip_properties=['former_accounts'])
 
   def isFormerAccount(self, account):
     """Returns true if account is a former account of some User.
     """
+
     # TODO(pawel.solyga): replace 1000 with solution that works for any
     #   number of queries
     users_with_former_accounts = soc.models.user.User.gql(
         'WHERE former_accounts != :1', None).fetch(1000)
-    
+
     for former_account_user in users_with_former_accounts: 
       if account in former_account_user.former_accounts:
         return True
-    
+
     return False
 
   def getKeyValues(self, entity):
--- a/app/soc/logic/models/work.py	Tue Dec 02 22:05:13 2008 +0000
+++ b/app/soc/logic/models/work.py	Wed Dec 03 21:26:16 2008 +0000
@@ -35,7 +35,8 @@
   def __init__(self, model=soc.models.work.Work, base_model=None):
     """Defines the name, key_name and model for this entity.
     """
-    base.Logic.__init__(self, model, base_model=base_model)
+
+    super(Logic, self).__init__(model, base_model=base_model)
 
 
 logic = Logic()