Return the ToS Document of the supplied Presence entity, if there is one.
authorTodd Larsen <tlarsen@google.com>
Tue, 20 Jan 2009 21:37:30 +0000
changeset 850 05e376c84e08
parent 849 c193ac0ef593
child 851 506752de2e19
Return the ToS Document of the supplied Presence entity, if there is one. Patch by: Todd Larsen Review by: to-be-reviewed
app/soc/logic/models/presence.py
--- a/app/soc/logic/models/presence.py	Tue Jan 20 21:26:34 2009 +0000
+++ b/app/soc/logic/models/presence.py	Tue Jan 20 21:37:30 2009 +0000
@@ -41,5 +41,22 @@
     super(Logic, self).__init__(model, base_model=base_model,
                                 scope_logic=scope_logic)
 
+  def getToS(self, entity):
+    """Returns the ToS Document of the Presence entity, or None if no ToS.
+
+    Args:
+      entity:  Presence (or one of its sub-classes) entity that may or may
+        not have a ToS Document attached
+    """
+    if not entity:
+      return None
+
+    try:
+      tos_doc = entity.tos
+    except db.Error:
+      return None
+
+    return tos_doc
+
 
 logic = Logic()