app/soc/logic/key_name.py
author Todd Larsen <tlarsen@google.com>
Sat, 04 Oct 2008 07:17:00 +0000
changeset 282 600e0a9bfa06
parent 263 9b39d93b677f
child 298 c76a366c7ab4
permissions -rw-r--r--
A site layout ("site map") of the web application, including URL regular expression patterns, Django views, and metadata for constructing sidebar menus and (eventually) breadcrumbs. One function, soc.logic.site.map.getDjangoUrlPatterns(), converts these details into urlpatterns for use by Django. Patch by: Todd Larsen Review by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
251
8f23804302d0 Move path and link_name related functions and regex patterns to a new
Todd Larsen <tlarsen@google.com>
parents: 222
diff changeset
    26
from soc.logic import path_linkname
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    27
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    28
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    29
class Error(Exception):
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    30
  """Base class for all exceptions raised by this module."""
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    31
  pass
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    32
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    33
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    34
def nameDocument(partial_path, link_name=None):
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    35
  """Returns a Document key name constructed from a path and link name.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    36
    
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    37
  Args:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    38
    partial_path: the first portion of the path to the Document that uniquely
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    39
      identifies it
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    40
    link_name: optional link name to append to path (when omitted,
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    41
      partial_path is actually the entire path, with the link_name already
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    42
      appended)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    43
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    44
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    45
    Error if partial_path and link_Name produce a "False" path (None,
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    46
    empty string, etc.)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    47
  """
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    48
  path = [partial_path]
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    49
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    50
  if link_name:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    51
    path.append(link_name)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    52
251
8f23804302d0 Move path and link_name related functions and regex patterns to a new
Todd Larsen <tlarsen@google.com>
parents: 222
diff changeset
    53
  path = path_linkname.combinePath(path)
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    54
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    55
  if not path:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    56
    raise Error('"path" must be non-False: "%s"' % path)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    57
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    58
  return 'Document:%s' % path
202
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
def nameSiteSettings(path):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    62
  """Returns a SiteSettings key name constructed from a supplied path.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    63
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    64
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    65
    Error if path is "False" (None, empty string, etc.)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    66
  """
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    67
  if not path:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    68
    raise Error('"path" must be non-False: "%s"' % 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
    69
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    70
  return 'SiteSettings:%s' % path
202
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
b8b4a83788d4 A key_name controller module to collect all of the name...() functions that
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
def nameUser(email):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    74
  """Returns a User key name constructed from a supplied email address.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    75
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    76
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    77
    Error if email is "False" (None, empty string, etc.)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    78
  """
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    79
  if not email:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    80
    raise Error('"email" must be non-False: "%s"' % email)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    81
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    82
  return 'User:%s' % email
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
    83
213
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
    84
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
    85
def nameSponsor(link_name):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    86
  """Returns a Sponsor key name constructed from a supplied link name.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    87
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    88
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    89
    Error if link_name is "False" (None, empty string, etc.)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    90
  """
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    91
  if not link_name:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    92
    raise Error('"link_name" must be non-False: "%s"' % link_name)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    93
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    94
  return 'Group/Sponsor:%s' % link_name
213
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
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
    97
def nameSchool(sponsor_ln, program_ln, link_name):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    98
  """Returns a School key name constructed from link names.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
    99
     
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   100
  Args:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   101
    sponsor_ln: Sponsor link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   102
    program_ln: Program link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   103
    link_name: School link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   104
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   105
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   106
    Error if sponsor_ln, program_ln, and link_Name combine to produce
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   107
    a "False" path (None, empty string, etc.)
213
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   108
  """
251
8f23804302d0 Move path and link_name related functions and regex patterns to a new
Todd Larsen <tlarsen@google.com>
parents: 222
diff changeset
   109
  path = path_linkname.combinePath([[sponsor_ln, program_ln], link_name])
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   110
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   111
  if not path:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   112
    raise Error('"path" must be non-False: "%s"' % path)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   113
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   114
  return 'Group/School:%s' % path
213
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   115
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   116
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   117
def nameOrganization(sponsor_ln, program_ln, link_name):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   118
  """Returns a Organization key name constructed from link names.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   119
     
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   120
  Args:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   121
    sponsor_ln: Sponsor link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   122
    program_ln: Program link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   123
    link_name: Organization link name
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   124
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   125
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   126
    Error if sponsor_ln, program_ln, and link_Name combine to produce
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   127
    a "False" path (None, empty string, etc.)
213
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   128
  """
251
8f23804302d0 Move path and link_name related functions and regex patterns to a new
Todd Larsen <tlarsen@google.com>
parents: 222
diff changeset
   129
  path = path_linkname.combinePath([[sponsor_ln, program_ln], link_name])
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   130
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   131
  if not path:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   132
    raise Error('"path" must be non-False: "%s"' % path)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   133
  
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   134
  return 'Group/Organization:%s' % path 
213
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   135
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   136
75a8cc0200ad Add key naming function for Sponsor, School, Organization, Club key_names.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 206
diff changeset
   137
def nameClub(link_name):
222
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   138
  """Returns a Club key name constructed from a supplied link name.
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   139
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   140
  Raises:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   141
    Error if link_name is "False" (None, empty string, etc.)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   142
  """
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   143
  if not link_name:
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   144
    raise Error('"link_name" must be non-False: "%s"' % link_name)
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   145
63e5f42e2e83 Add lots of new functions to key_name.py, including path/link_name processing.
Todd Larsen <tlarsen@google.com>
parents: 213
diff changeset
   146
  return 'Group/Club:%s' % link_name