author | Pawel Solyga <Pawel.Solyga@gmail.com> |
Tue, 30 Sep 2008 16:49:54 +0000 | |
changeset 215 | d020c95b17b1 |
parent 213 | 75a8cc0200ad |
child 222 | 63e5f42e2e83 |
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>', |
213
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
22 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
202
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 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
25 |
|
213
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
26 |
import soc.models.club |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
27 |
import soc.models.group |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
28 |
import soc.models.organization |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
29 |
import soc.models.school |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
30 |
import soc.models.sponsor |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
35 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
36 |
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
|
37 |
"""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
|
38 |
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
|
39 |
'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
|
40 |
'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
|
41 |
} |
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 |
|
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 |
|
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 |
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
|
45 |
"""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
|
46 |
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
|
47 |
'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
|
48 |
'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
|
49 |
'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
|
50 |
} |
202
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
51 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
52 |
|
b8b4a83788d4
A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
53 |
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
|
54 |
"""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
|
55 |
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
|
56 |
'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
|
57 |
'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
|
58 |
} |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
202
diff
changeset
|
59 |
|
213
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
60 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
61 |
def nameSponsor(link_name): |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
62 |
"""Returns a Sponsor key name constructed from a supplied link name.""" |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
63 |
return '%(group)s/%(type)s:%(link_name)s' % { |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
64 |
'group': soc.models.group.Group.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
65 |
'type': soc.models.sponsor.Sponsor.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
66 |
'link_name': link_name, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
67 |
} |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
68 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
69 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
70 |
def nameSchool(sponsor_ln, program_ln, link_name): |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
71 |
"""Returns a School key name constructed from a supplied sponsor, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
72 |
program and school link names. |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
73 |
""" |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
74 |
return '%(group)s/%(type)s:%(sponsor)s/%(program)s/%(link_name)s' % { |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
75 |
'group': soc.models.group.Group.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
76 |
'type': soc.models.school.School.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
77 |
'sponsor': sponsor_ln, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
78 |
'program': program_ln, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
79 |
'link_name': link_name, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
80 |
} |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
81 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
82 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
83 |
def nameOrganization(sponsor_ln, program_ln, link_name): |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
84 |
"""Returns a Organization key name constructed from a supplied sponsor, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
85 |
program and organization link names. |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
86 |
""" |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
87 |
return '%(group)s/%(type)s:%(sponsor)s/%(program)s/%(link_name)s' % { |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
88 |
'group': soc.models.group.Group.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
89 |
'type': soc.models.organization.Organization.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
90 |
'sponsor': sponsor_ln, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
91 |
'program': program_ln, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
92 |
'link_name': link_name, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
93 |
} |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
94 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
95 |
|
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
96 |
def nameClub(link_name): |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
97 |
"""Returns a Club key name constructed from a supplied link name.""" |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
98 |
return '%(group)s/%(type)s:%(link_name)s' % { |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
99 |
'group': soc.models.group.Group.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
100 |
'type': soc.models.sponsor.Sponsor.__name__, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
101 |
'link_name': link_name, |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
102 |
} |
75a8cc0200ad
Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
206
diff
changeset
|
103 |