author | Todd Larsen <tlarsen@google.com> |
Mon, 29 Sep 2008 15:31:50 +0000 | |
changeset 206 | 832335761384 |
parent 202 | b8b4a83788d4 |
child 213 | 75a8cc0200ad |
permissions | -rw-r--r-- |
202
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2 |
# |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
4 |
# |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
8 |
# |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
10 |
# |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
16 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
17 |
"""Functions for composing Model entity key names. |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
18 |
""" |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
19 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
21 |
'"Todd Larsen" <tlarsen@google.com>', |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
22 |
] |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
23 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
24 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
25 |
import soc.models.document |
202
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
26 |
import soc.models.site_settings |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
27 |
import soc.models.user |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
28 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
29 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
30 |
def nameSiteSettings(path): |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
31 |
"""Returns a SiteSettings key name constructed from a supplied path.""" |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
32 |
return '%(type)s:%(path)s' % { |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
33 |
'type': soc.models.site_settings.SiteSettings.__name__, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
34 |
'path': path, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
35 |
} |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
36 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
37 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
38 |
def nameDocument(path, link_name): |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
39 |
"""Returns a Document key name constructed from a path and link name.""" |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
40 |
return '%(type)s:%(path)s/%(link_name)s' % { |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
41 |
'type': soc.models.document.Document.__name__, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
42 |
'path': path, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
43 |
'link_name': link_name, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
44 |
} |
202
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
45 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
46 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
47 |
def nameUser(email): |
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
48 |
"""Returns a User key name constructed from a supplied email address.""" |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
49 |
return '%(type)s:%(email)s' % { |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
50 |
'type': soc.models.user.User.__name__, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
51 |
'email': email, |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
52 |
} |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
53 |