author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 01 Feb 2009 23:36:50 +0000 | |
changeset 1169 | c0294f3c28db |
parent 864 | 53101d2fcdee |
child 1307 | 091a21cf3627 |
permissions | -rw-r--r-- |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
530
diff
changeset
|
17 |
"""Presence (Model) query functions. |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
""" |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
429
e50e18936f06
Fixed typo in e-mail address
Sverre Rabbelier <srabbelier@gmail.com>
parents:
334
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
443
94568ac6e3e1
Implements base.Logic functions in home_settings, site_settings and work
Sverre Rabbelier <srabbelier@gmail.com>
parents:
436
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>' |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
] |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
|
864
53101d2fcdee
Fix missing import identified by pylint.
Todd Larsen <tlarsen@google.com>
parents:
850
diff
changeset
|
26 |
from google.appengine.ext import db |
53101d2fcdee
Fix missing import identified by pylint.
Todd Larsen <tlarsen@google.com>
parents:
850
diff
changeset
|
27 |
|
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
from soc.logic.models import base |
678
b982d9175605
Added a linkable logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
674
diff
changeset
|
29 |
from soc.logic.models import linkable as linkable_logic |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
30 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
530
diff
changeset
|
31 |
import soc.models.presence |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
32 |
|
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
33 |
|
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
class Logic(base.Logic): |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
530
diff
changeset
|
35 |
"""Logic methods for the Presence model. |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
36 |
""" |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
37 |
|
535
9045b8888772
Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents:
534
diff
changeset
|
38 |
def __init__(self, model=soc.models.presence.Presence, |
678
b982d9175605
Added a linkable logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
674
diff
changeset
|
39 |
base_model=None, scope_logic=linkable_logic): |
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
40 |
"""Defines the name, key_name and model for this entity. |
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
41 |
""" |
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
535
diff
changeset
|
42 |
|
674
0158b11cbf6d
More DI on scope_logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
43 |
super(Logic, self).__init__(model, base_model=base_model, |
0158b11cbf6d
More DI on scope_logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
44 |
scope_logic=scope_logic) |
443
94568ac6e3e1
Implements base.Logic functions in home_settings, site_settings and work
Sverre Rabbelier <srabbelier@gmail.com>
parents:
436
diff
changeset
|
45 |
|
850
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
46 |
def getToS(self, entity): |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
47 |
"""Returns the ToS Document of the Presence entity, or None if no ToS. |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
48 |
|
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
49 |
Args: |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
50 |
entity: Presence (or one of its sub-classes) entity that may or may |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
51 |
not have a ToS Document attached |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
52 |
""" |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
53 |
if not entity: |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
54 |
return None |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
55 |
|
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
56 |
try: |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
57 |
tos_doc = entity.tos |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
58 |
except db.Error: |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
59 |
return None |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
60 |
|
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
61 |
return tos_doc |
05e376c84e08
Return the ToS Document of the supplied Presence entity, if there is one.
Todd Larsen <tlarsen@google.com>
parents:
678
diff
changeset
|
62 |
|
334
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
63 |
|
0d0e96b12551
Add nameHomeSettings function to key_name module. Add HomeSettings logic.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
64 |
logic = Logic() |