Replace almost all occurences of linkname with link_name
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 12 Oct 2008 00:08:54 +0000
changeset 298 c76a366c7ab4
parent 297 35211afcd563
child 299 a1cc853a56e5
Replace almost all occurences of linkname with link_name In an attempt to have some atomicness in these commits this patch does a rename for the sake of consistency. Not all were changed, but the next commit will address that. Patch by: Sverre Rabbelier Reviewed by: to-be-reviewed
app/ghop/templates/ghop/person/profile/edit.html
app/soc/logic/key_name.py
app/soc/logic/path_link_name.py
app/soc/logic/path_linkname.py
app/soc/logic/site/map.py
app/soc/logic/validate.py
app/soc/models/group.py
app/soc/models/user.py
app/soc/templates/soc/group/list/group_row.html
app/soc/templates/soc/group/profile/public.html
app/soc/templates/soc/site/docs/list/docs_row.html
app/soc/templates/soc/site/user/list/user_row.html
app/soc/templates/soc/site/user/profile/lookup.html
app/soc/templates/soc/user/profile/public.html
app/soc/views/docs/show.py
app/soc/views/person/profile.py
app/soc/views/site/docs/edit.py
app/soc/views/site/sponsor/profile.py
app/soc/views/site/user/profile.py
app/soc/views/sponsor/profile.py
app/soc/views/user/profile.py
app/soc/views/user/roles.py
--- a/app/ghop/templates/ghop/person/profile/edit.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/ghop/templates/ghop/person/profile/edit.html	Sun Oct 12 00:08:54 2008 +0000
@@ -19,7 +19,7 @@
 <img src="/ghop/content/images/ghop.jpg" alt="GHOP" />
 {% endblock %}
 {% block 'greeting' %}
-Welcome, {{linkname}} ({{user.nickname}}).
+Welcome, {{link_name}} ({{user.nickname}}).
 {% endblock %}
 {% block 'instructions' %}
 Please update your profile for the {{program}} program:
--- a/app/soc/logic/key_name.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/logic/key_name.py	Sun Oct 12 00:08:54 2008 +0000
@@ -23,7 +23,7 @@
   ]
 
 
-from soc.logic import path_linkname
+from soc.logic import path_link_name
 
 
 class Error(Exception):
@@ -50,7 +50,7 @@
   if link_name:
     path.append(link_name)
 
-  path = path_linkname.combinePath(path)
+  path = path_link_name.combinePath(path)
 
   if not path:
     raise Error('"path" must be non-False: "%s"' % path)
@@ -106,7 +106,7 @@
     Error if sponsor_ln, program_ln, and link_Name combine to produce
     a "False" path (None, empty string, etc.)
   """
-  path = path_linkname.combinePath([[sponsor_ln, program_ln], link_name])
+  path = path_link_name.combinePath([[sponsor_ln, program_ln], link_name])
   
   if not path:
     raise Error('"path" must be non-False: "%s"' % path)
@@ -126,7 +126,7 @@
     Error if sponsor_ln, program_ln, and link_Name combine to produce
     a "False" path (None, empty string, etc.)
   """
-  path = path_linkname.combinePath([[sponsor_ln, program_ln], link_name])
+  path = path_link_name.combinePath([[sponsor_ln, program_ln], link_name])
   
   if not path:
     raise Error('"path" must be non-False: "%s"' % path)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/logic/path_link_name.py	Sun Oct 12 00:08:54 2008 +0000
@@ -0,0 +1,103 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Path and link name manipulation functions.
+"""
+
+__authors__ = [
+  '"Todd Larsen" <tlarsen@google.com>',
+  ]
+
+
+import re
+
+
+# start with ASCII digit or lowercase
+#   (additional ASCII digit or lowercase
+#     -OR-
+#   underscore and ASCII digit or lowercase)
+#     zero or more of OR group
+LINKNAME_PATTERN_CORE = r'[0-9a-z](?:[0-9a-z]|_[0-9a-z])*'
+LINKNAME_ARG_PATTERN = r'(?P<link_name>%s)' % LINKNAME_PATTERN_CORE
+LINKNAME_PATTERN = r'^%s$' % LINKNAME_PATTERN_CORE
+LINKNAME_REGEX = re.compile(LINKNAME_PATTERN)
+
+# partial path is multiple link_name chunks,
+#   each separated by a trailing /
+#     (at least 1)
+# followed by a single link_name with no trailing /
+PATH_LINKNAME_ARGS_PATTERN = (
+    r'(?P<partial_path>%(link_name)s(?:/%(link_name)s)*)/'
+     '(?P<link_name>%(link_name)s)' % {
+        'link_name': LINKNAME_PATTERN_CORE})
+
+PATH_LINKNAME_PATTERN = r'^%s$' % PATH_LINKNAME_ARGS_PATTERN
+PATH_LINKNAME_REGEX = re.compile(PATH_LINKNAME_PATTERN)
+
+
+def getPartsFromPath(path):
+  """Splits path string into partial_path and link_name.
+  
+  Returns:
+    {'partial_path': 'everything/but',
+     'link_name': 'link_name'}
+    or {} (empty dict) if string did not match PATH_LINKNAME_PATTERN.
+  """
+  path_link_name_match = PATH_LINKNAME_REGEX.match(path)
+  
+  if not path_link_name_match:
+    return {}
+
+  return path_link_name_match.groupdict()
+
+
+def combinePath(path_parts):
+  """Returns path components combined into a single string.
+  
+  Args:
+    path_parts: a single path string, or a list of path part strings,
+      or a nested list of path part strings (where the zeroeth element in
+      the list is itself a list); for example:
+        'a/complete/path/in/one/string'
+        ['some', 'path', 'parts']
+        [['path', 'parts', 'and', 'a'], 'link name']
+
+  Returns:
+    None if path_parts is False (None, empty string, etc.) or if
+    any list elements are False (an empty list, empty string, etc.);
+    otherwise, the combined string with the necessary separators.
+  """
+  if not path_parts:
+    # completely empty input, so return early
+    return None
+
+  if not isinstance(path_parts, (list, tuple)):
+    # a single path string, so just return it as-is (nothing to do)
+    return path_parts
+  
+  flattened_parts = []
+  
+  for part in path_parts:
+    if not part:
+      # encountered a "False" element, which invalidates everything else
+      return None    
+  
+    if isinstance(part, (list, tuple)):
+      flattened_parts.extend(part)
+    else:
+      flattened_parts.append(part)
+
+  return '/'.join(flattened_parts)
--- a/app/soc/logic/path_linkname.py	Fri Oct 10 13:14:24 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Path and link name manipulation functions.
-"""
-
-__authors__ = [
-  '"Todd Larsen" <tlarsen@google.com>',
-  ]
-
-
-import re
-
-
-# start with ASCII digit or lowercase
-#   (additional ASCII digit or lowercase
-#     -OR-
-#   underscore and ASCII digit or lowercase)
-#     zero or more of OR group
-LINKNAME_PATTERN_CORE = r'[0-9a-z](?:[0-9a-z]|_[0-9a-z])*'
-LINKNAME_ARG_PATTERN = r'(?P<linkname>%s)' % LINKNAME_PATTERN_CORE
-LINKNAME_PATTERN = r'^%s$' % LINKNAME_PATTERN_CORE
-LINKNAME_REGEX = re.compile(LINKNAME_PATTERN)
-
-# partial path is multiple linkname chunks,
-#   each separated by a trailing /
-#     (at least 1)
-# followed by a single linkname with no trailing /
-PATH_LINKNAME_ARGS_PATTERN = (
-    r'(?P<partial_path>%(linkname)s(?:/%(linkname)s)*)/'
-     '(?P<linkname>%(linkname)s)' % {
-        'linkname': LINKNAME_PATTERN_CORE})
-
-PATH_LINKNAME_PATTERN = r'^%s$' % PATH_LINKNAME_ARGS_PATTERN
-PATH_LINKNAME_REGEX = re.compile(PATH_LINKNAME_PATTERN)
-
-
-def getPartsFromPath(path):
-  """Splits path string into partial_path and link_name.
-  
-  Returns:
-    {'partial_path': 'everything/but',
-     'link_name': 'link_name'}
-    or {} (empty dict) if string did not match PATH_LINKNAME_PATTERN.
-  """
-  path_linkname_match = PATH_LINKNAME_REGEX.match(path)
-  
-  if not path_linkname_match:
-    return {}
-
-  return path_linkname_match.groupdict()
-
-
-def combinePath(path_parts):
-  """Returns path components combined into a single string.
-  
-  Args:
-    path_parts: a single path string, or a list of path part strings,
-      or a nested list of path part strings (where the zeroeth element in
-      the list is itself a list); for example:
-        'a/complete/path/in/one/string'
-        ['some', 'path', 'parts']
-        [['path', 'parts', 'and', 'a'], 'link name']
-
-  Returns:
-    None if path_parts is False (None, empty string, etc.) or if
-    any list elements are False (an empty list, empty string, etc.);
-    otherwise, the combined string with the necessary separators.
-  """
-  if not path_parts:
-    # completely empty input, so return early
-    return None
-
-  if not isinstance(path_parts, (list, tuple)):
-    # a single path string, so just return it as-is (nothing to do)
-    return path_parts
-  
-  flattened_parts = []
-  
-  for part in path_parts:
-    if not part:
-      # encountered a "False" element, which invalidates everything else
-      return None    
-  
-    if isinstance(part, (list, tuple)):
-      flattened_parts.extend(part)
-    else:
-      flattened_parts.append(part)
-
-  return '/'.join(flattened_parts)
--- a/app/soc/logic/site/map.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/logic/site/map.py	Sun Oct 12 00:08:54 2008 +0000
@@ -30,7 +30,7 @@
 from django.conf.urls import defaults
 from django.utils import datastructures
 
-from soc.logic import path_linkname
+from soc.logic import path_link_name
 from soc.logic.site import page
 
 
@@ -82,7 +82,7 @@
 
 user_edit = page.Page(
   page.Url(
-    r'^user/profile/%s$' % path_linkname.LINKNAME_ARG_PATTERN,
+    r'^user/profile/%s$' % path_link_name.LINKNAME_ARG_PATTERN,
     'soc.views.user.profile.edit'),
   'User: Modify Existing User Profile',
   parent=user_signout)
@@ -123,7 +123,7 @@
 
 site_user_edit = page.Page(
   page.Url(
-    r'^site/user/profile/%s$' % path_linkname.LINKNAME_ARG_PATTERN,
+    r'^site/user/profile/%s$' % path_link_name.LINKNAME_ARG_PATTERN,
     'soc.views.site.user.profile.edit'),
   'Site: Modify Existing User Profile',
   short_name='Modify Site User',
@@ -140,7 +140,7 @@
 # Document views
 docs_show = page.Page(
   page.Url(
-    r'^docs/show/%s$' % path_linkname.PATH_LINKNAME_ARGS_PATTERN,
+    r'^docs/show/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
     'soc.views.docs.show.public'),
   'Show Document',
   parent=home)
@@ -156,7 +156,7 @@
 
 site_docs_edit = page.Page(
   page.Url(
-    r'^site/docs/edit/%s$' % path_linkname.PATH_LINKNAME_ARGS_PATTERN,
+    r'^site/docs/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
     'soc.views.site.docs.edit.edit'),
   'Site: Modify Existing Document',
   short_name='Modify Site Document',
@@ -173,7 +173,7 @@
 # Sponsor Group public view
 sponsor_profile = page.Page(
   page.Url(
-    r'^sponsor/profile/%s' % path_linkname.LINKNAME_ARG_PATTERN,
+    r'^sponsor/profile/%s' % path_link_name.LINKNAME_ARG_PATTERN,
     'soc.views.sponsor.profile.public'),
   'Public Profile',
   parent=home)
@@ -189,7 +189,7 @@
 
 site_sponsor_delete = page.Page(
   page.Url(
-    r'^site/sponsor/profile/%s/delete$' % path_linkname.LINKNAME_ARG_PATTERN,
+    r'^site/sponsor/profile/%s/delete$' % path_link_name.LINKNAME_ARG_PATTERN,
     'soc.views.site.sponsor.profile.delete'),
   'Site: Delete Existing Sponsor',
   short_name='Delete Site Sponsor',
@@ -197,7 +197,7 @@
 
 site_sponsor_edit = page.Page(
   page.Url(
-    r'^site/sponsor/profile/%s' % path_linkname.LINKNAME_ARG_PATTERN,
+    r'^site/sponsor/profile/%s' % path_link_name.LINKNAME_ARG_PATTERN,
     'soc.views.site.sponsor.profile.edit'),
   'Site: Modify Existing Sponsor',
   short_name='Modify Site Sponsor',
@@ -213,10 +213,10 @@
 
 
 # these are not really used...
-#    (r'^org/profile/(?P<program>ghop[_0-9a-z]+)/(?P<linkname>[_0-9a-z]+)/$',
+#    (r'^org/profile/(?P<program>ghop[_0-9a-z]+)/(?P<link_name>[_0-9a-z]+)/$',
 #     'soc.views.person.profile.edit',
 #     {'template': 'ghop/person/profile/edit.html'}),
-#    (r'^org/profile/(?P<program>[_0-9a-z]+)/(?P<linkname>[_0-9a-z]+)/$',
+#    (r'^org/profile/(?P<program>[_0-9a-z]+)/(?P<link_name>[_0-9a-z]+)/$',
 #     'soc.views.person.profile.edit'),
 
     
--- a/app/soc/logic/validate.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/logic/validate.py	Sun Oct 12 00:08:54 2008 +0000
@@ -28,7 +28,7 @@
 
 import feedparser
 
-from soc.logic import path_linkname
+from soc.logic import path_link_name
 
 
 def isFeedURLValid(feed_url=None):
@@ -52,6 +52,6 @@
   Args:
     link_name: link name used in URLs for identification
   """
-  if path_linkname.LINKNAME_REGEX.match(link_name):
+  if path_link_name.LINKNAME_REGEX.match(link_name):
     return True
   return False
\ No newline at end of file
--- a/app/soc/models/group.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/models/group.py	Sun Oct 12 00:08:54 2008 +0000
@@ -40,7 +40,7 @@
       verbose_name=ugettext_lazy('Name'))
   name.help_text = ugettext_lazy('Complete, formal name of the group.')  
   
-  #: Required field storing linkname used in URLs to identify group.
+  #: Required field storing link_name used in URLs to identify group.
   #: Lower ASCII characters only.
   link_name = db.StringProperty(required=True,
       verbose_name=ugettext_lazy('Link name'))
--- a/app/soc/models/user.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/models/user.py	Sun Oct 12 00:08:54 2008 +0000
@@ -75,7 +75,7 @@
   nick_name = db.StringProperty(required=True,
       verbose_name=ugettext_lazy('Nick name'))
       
-  #: Required field storing linkname used in URLs to identify user.
+  #: Required field storing link_name used in URLs to identify user.
   #: Lower ASCII characters only.
   link_name = db.StringProperty(required=True,
       verbose_name=ugettext_lazy('Link name'))
--- a/app/soc/templates/soc/group/list/group_row.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/group/list/group_row.html	Sun Oct 12 00:08:54 2008 +0000
@@ -4,6 +4,6 @@
          href="/site/{{ group_type|lower }}/profile/{{ data_element.link_name }}">{{ data_element.name }}</a>
      </div>
   </td>
-  <td><div class="linkname">{{ data_element.link_name }}</a></div></td>
+  <td><div class="link_name">{{ data_element.link_name }}</a></div></td>
   <td><div class="shortname">{{ data_element.short_name }}</div></td>
 </tr>
--- a/app/soc/templates/soc/group/profile/public.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/group/profile/public.html	Sun Oct 12 00:08:54 2008 +0000
@@ -15,20 +15,20 @@
 {% load forms_helpers %}
 {% block page_title %}{% if group_type %}{{ group_type }}{% else %}Group{% endif %} Public Profile{% endblock %}
 {% block header_title %}
-{% if group_type %}{{ group_type }}{% else %}Group{% endif %} Public Profile for {{ linkname_group.name }}
+{% if group_type %}{{ group_type }}{% else %}Group{% endif %} Public Profile for {{ link_name_group.name }}
 {% endblock %}
 {% block body %}
 <p>
  <table>
-  {% readonly_field_as_table_row linkname_group.fields.name.label linkname_group.name %}
-  {% readonly_field_as_table_row linkname_group.fields.home_page.label linkname_group.home_page %}
-  {% readonly_field_as_table_row linkname_group.fields.description.label linkname_group.description %}
-  {% readonly_field_as_table_row linkname_group.fields.street.label linkname_group.street %}
-  {% readonly_field_as_table_row linkname_group.fields.city.label linkname_group.city %}
-  {% readonly_field_as_table_row linkname_group.fields.state.label linkname_group.state %}
-  {% readonly_field_as_table_row linkname_group.fields.country.label linkname_group.country %}
-  {% readonly_field_as_table_row linkname_group.fields.postalcode.label linkname_group.postalcode %}
-  {% readonly_field_as_table_row linkname_group.fields.phone.label linkname_group.phone %}
+  {% readonly_field_as_table_row link_name_group.fields.name.label link_name_group.name %}
+  {% readonly_field_as_table_row link_name_group.fields.home_page.label link_name_group.home_page %}
+  {% readonly_field_as_table_row link_name_group.fields.description.label link_name_group.description %}
+  {% readonly_field_as_table_row link_name_group.fields.street.label link_name_group.street %}
+  {% readonly_field_as_table_row link_name_group.fields.city.label link_name_group.city %}
+  {% readonly_field_as_table_row link_name_group.fields.state.label link_name_group.state %}
+  {% readonly_field_as_table_row link_name_group.fields.country.label link_name_group.country %}
+  {% readonly_field_as_table_row link_name_group.fields.postalcode.label link_name_group.postalcode %}
+  {% readonly_field_as_table_row link_name_group.fields.phone.label link_name_group.phone %}
  </table>
 </p>
 {% endblock %}
\ No newline at end of file
--- a/app/soc/templates/soc/site/docs/list/docs_row.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/site/docs/list/docs_row.html	Sun Oct 12 00:08:54 2008 +0000
@@ -8,7 +8,7 @@
   </td>
   <td><div class="title">{{ data_element.title }}</div></td>
   <td><div class="partialpath">{{ data_element.partial_path }}</div></td>
-  <td><div class="linkname">{{ data_element.link_name }}</div></td>
+  <td><div class="link_name">{{ data_element.link_name }}</div></td>
   <td><div class="created">{{ data_element.created }}</div></td>
   <td><div class="modified">{{ data_element.modified }}</div></td>
 </tr>
--- a/app/soc/templates/soc/site/user/list/user_row.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/site/user/list/user_row.html	Sun Oct 12 00:08:54 2008 +0000
@@ -6,5 +6,5 @@
   </td>
   <td><div class="email">{{ data_element.id.email }}</a></div></td>
   <td><div class="nickname">{{ data_element.nick_name }}</div></td>
-  <td><div class="linkname">{{ data_element.link_name }}</div></td>
+  <td><div class="link_name">{{ data_element.link_name }}</div></td>
 </tr>
--- a/app/soc/templates/soc/site/user/profile/lookup.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/site/user/profile/lookup.html	Sun Oct 12 00:08:54 2008 +0000
@@ -40,11 +40,11 @@
 </tr>
 {% endif %}
   {% field_as_table_row form.id %}
-{% if linkname_error %}
+{% if link_name_error %}
 <tr>
  <td>&nbsp;</td>
  <td colspan="3" class="formfielderror">
-  {{ linkname_error }}
+  {{ link_name_error }}
  </td>
 </tr>
 {% endif %}
--- a/app/soc/templates/soc/user/profile/public.html	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/templates/soc/user/profile/public.html	Sun Oct 12 00:08:54 2008 +0000
@@ -15,13 +15,13 @@
 {% load forms_helpers %}
 {% block page_title %}User Public Profile{% endblock %}
 {% block header_title %}
-User Public Profile for {{ linkname_user.nick_name }}
+User Public Profile for {{ link_name_user.nick_name }}
 {% endblock %}
 {% block body %}
 <p>
  <table>
-  {% readonly_field_as_table_row linkname_user.fields.nick_name.label linkname_user.nick_name %}
-  {% readonly_field_as_table_row linkname_user.fields.link_name.label linkname_user.link_name %}
+  {% readonly_field_as_table_row link_name_user.fields.nick_name.label link_name_user.nick_name %}
+  {% readonly_field_as_table_row link_name_user.fields.link_name.label link_name_user.link_name %}
  </table>
 </p>
 {% endblock %}
--- a/app/soc/views/docs/show.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/docs/show.py	Sun Oct 12 00:08:54 2008 +0000
@@ -36,7 +36,7 @@
 
 DEF_DOCS_PUBLIC_TMPL = 'soc/docs/public.html'
 
-def public(request, partial_path=None, linkname=None,
+def public(request, partial_path=None, link_name=None,
            template=DEF_DOCS_PUBLIC_TMPL):
   """How the "general public" sees a Document.
 
@@ -63,9 +63,9 @@
   # TODO: based on the User's Roles, Documents that the User can edit
   #   should display a link to a document edit form
 
-  # try to fetch User entity corresponding to linkname if one exists    
+  # try to fetch User entity corresponding to link_name if one exists
   try:
-    doc = document.getDocumentIfPath(partial_path, link_name=linkname)
+    doc = document.getDocumentIfPath(partial_path, link_name=link_name)
   except out_of_band.ErrorResponse, error:
     # show custom 404 page when Document path doesn't exist in Datastore
     return simple.errorResponse(request, error, template, context)
--- a/app/soc/views/person/profile.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/person/profile.py	Sun Oct 12 00:08:54 2008 +0000
@@ -73,7 +73,7 @@
   #   query for the human-readable program name and pass that to the form
   
   # TODO(tlarsen)
-  # if linkname:
+  # if link_name:
   #   query for a site-wide user profile for a friendly display name
   #      to use in the greeting
   # else:
@@ -89,4 +89,4 @@
 
   return shortcuts.render_to_response(
       template, dictionary={'template': template, 'form': form, 'user': user,
-                            'program': program, 'linkname': linkname})
+                            'program': program, 'link_name': link_name})
--- a/app/soc/views/site/docs/edit.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/site/docs/edit.py	Sun Oct 12 00:08:54 2008 +0000
@@ -30,7 +30,7 @@
 
 from soc.logic import document
 from soc.logic import out_of_band
-from soc.logic import path_linkname
+from soc.logic import path_link_name
 from soc.logic.helper import access
 from soc.logic.site import id_user
 from soc.views import helper
@@ -105,7 +105,7 @@
 
   doc = None  # assume that no Document entity will be found
 
-  path = path_linkname.combinePath([partial_path, linkname])
+  path = path_link_name.combinePath([partial_path, link_name])
 
   # try to fetch Document entity corresponding to path if one exists    
   try:
@@ -134,7 +134,7 @@
       if not doc:
         return http.HttpResponseRedirect('/')
 
-      new_path = path_linkname.combinePath([new_partial_path, new_linkname])
+      new_path = path_link_name.combinePath([new_partial_path, new_link_name])
         
       # redirect to new /site/docs/edit/new_path?s=0
       # (causes 'Profile saved' message to be displayed)
@@ -172,7 +172,7 @@
           
         context['lookup_error'] = ugettext_lazy(
             'Document with that path not found.')
-        form = EditForm(initial={'link_name': linkname})
+        form = EditForm(initial={'link_name': link_name})
     else:  # no link name specified in the URL
       if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
         # redirect to aggressively remove 'Profile saved' query parameter
@@ -252,7 +252,7 @@
       if not doc:
         return http.HttpResponseRedirect('/')
 
-      new_path = path_linkname.combinePath([new_partial_path, new_linkname])
+      new_path = path_link_name.combinePath([doc.partial_path, doc.link_name])
         
       # redirect to new /site/docs/edit/new_path?s=0
       # (causes 'Profile saved' message to be displayed)
--- a/app/soc/views/site/sponsor/profile.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/site/sponsor/profile.py	Sun Oct 12 00:08:54 2008 +0000
@@ -83,12 +83,12 @@
                           ' <a href="/site/sponsor/profile">Create ' \
                           'a New Sponsor</a> page.'
 
-def edit(request, linkname=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL):
+def edit(request, link_name=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL):
   """View for a Developer to modify the properties of a Sponsor Model entity.
 
   Args:
     request: the standard django request object
-    linkname: the Sponsor's site-unique "linkname" extracted from the URL
+    link_name: the Sponsor's site-unique "link_name" extracted from the URL
     template: the "sibling" template (or a search list of such templates)
       from which to construct the public.html template name (or names)
 
@@ -110,7 +110,7 @@
   sponsor_form = None
   existing_sponsor = None
 
-  # try to fetch Sponsor entity corresponding to linkname if one exists    
+  # try to fetch Sponsor entity corresponding to link_name if one exists
   try:
     existing_sponsor = soc.logic.sponsor.getSponsorIfLinkName(linkname)
   except out_of_band.ErrorResponse, error:
@@ -125,11 +125,11 @@
       sponsor_form = CreateForm(request.POST)
 
     if sponsor_form.is_valid():
-      if linkname:
-        # Form doesn't allow to change linkname but somebody might want to 
-        # abuse that manually, so we check if form linkname is the same as 
-        # url linkname
-        if sponsor_form.cleaned_data.get('link_name') != linkname:
+      if link_name:
+        # Form doesn't allow to change link_name but somebody might want to
+        # abuse that manually, so we check if form link_name is the same as
+        # url link_name
+        if sponsor_form.cleaned_data.get('link_name') != link_name:
           msg = DEF_SPONSOR_NO_LINKNAME_CHANGE_MSG
           error = out_of_band.ErrorResponse(msg)
           return simple.errorResponse(request, error, template, context)
@@ -161,7 +161,7 @@
       # is 'Profile saved' parameter present, but referrer was not ourself?
       # (e.g. someone bookmarked the GET that followed the POST submit) 
       if (request.GET.get(profile.SUBMIT_MSG_PARAM_NAME)
-          and (not helper.requests.isReferrerSelf(request, suffix=linkname))):
+          and (not helper.requests.isReferrerSelf(request, suffix=link_name))):
         # redirect to aggressively remove 'Profile saved' query parameter
         return http.HttpResponseRedirect(request.path)
       
@@ -192,17 +192,17 @@
 DEF_SITE_SPONSOR_PROFILE_CREATE_TMPL = 'soc/group/profile/edit.html'
 
 def create(request, template=DEF_SITE_SPONSOR_PROFILE_CREATE_TMPL):
-  """create() view is same as edit() view, but with no linkname supplied.
+  """create() view is same as edit() view, but with no link_name supplied.
   """
-  return edit(request, linkname=None, template=template)
+  return edit(request, link_name=None, template=template)
 
 
-def delete(request, linkname=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL):
+def delete(request, link_name=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL):
   """Request handler for a Developer to delete Sponsor Model entity.
 
   Args:
     request: the standard django request object
-    linkname: the Sponsor's site-unique "linkname" extracted from the URL
+    link_name: the Sponsor's site-unique "link_name" extracted from the URL
     template: the "sibling" template (or a search list of such templates)
       from which to construct the public.html template name (or names)
 
@@ -221,9 +221,9 @@
 
   existing_sponsor = None
 
-  # try to fetch Sponsor entity corresponding to linkname if one exists    
+  # try to fetch Sponsor entity corresponding to link_name if one exists
   try:
-    existing_sponsor = soc.logic.sponsor.getSponsorIfLinkName(linkname)
+    existing_sponsor = soc.logic.sponsor.getSponsorIfLinkName(link_name)
   except out_of_band.ErrorResponse, error:
     # show custom 404 page when link name doesn't exist in Datastore
     error.message = error.message + DEF_CREATE_NEW_SPONSOR_MSG
--- a/app/soc/views/site/user/profile.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/site/user/profile.py	Sun Oct 12 00:08:54 2008 +0000
@@ -141,21 +141,21 @@
                 nearest_user_range_start, range_width)
       if not user:
         # user not found yet, so see if link name was provided
-        linkname = form.cleaned_data.get('link_name')
+        link_name = form.cleaned_data.get('link_name')
         
-        if linkname:
+        if link_name:
           # link name provided, so try to look up by link name 
-          user = id_user.getUserFromLinkName(linkname)
+          user = id_user.getUserFromLinkName(link_name)
         
           if user:
             lookup_message = ugettext_lazy('User found by link name.')
             email_error = None  # clear previous error, since User was found
           else:
-            context['linkname_error'] = ugettext_lazy(
+            context['link_name_error'] = ugettext_lazy(
                 'User with that link name not found.')
             range_width = helper.lists.getPreferredListPagination()
             nearest_user_range_start = id_user.findNearestUsersOffset(
-                range_width, link_name=linkname)
+                range_width, link_name=link_name)
             
             if nearest_user_range_start is not None:
               context['lookup_link'] = './list?offset=%s&limit=%s' % (
@@ -238,12 +238,12 @@
                           ' <a href="/site/user/profile">Create ' \
                           'a New User</a> page.'
 
-def edit(request, linkname=None, template=DEF_SITE_USER_PROFILE_EDIT_TMPL):
+def edit(request, link_name=None, template=DEF_SITE_USER_PROFILE_EDIT_TMPL):
   """View for a Developer to modify the properties of a User Model entity.
 
   Args:
     request: the standard django request object
-    linkname: the User's site-unique "linkname" extracted from the URL
+    link_name: the User's site-unique "link_name" extracted from the URL
     template: the "sibling" template (or a search list of such templates)
       from which to construct the public.html template name (or names)
 
@@ -262,45 +262,44 @@
 
   user = None  # assume that no User entity will be found
 
-  # try to fetch User entity corresponding to linkname if one exists    
-  try:
-    user = id_user.getUserIfLinkName(linkname)
-  except out_of_band.ErrorResponse, error:
-    # show custom 404 page when link name doesn't exist in Datastore
-    error.message = error.message + DEF_CREATE_NEW_USER_MSG
-    return simple.errorResponse(request, error, template, context)
+  # try to fetch User entity corresponding to link_name if one exists
+  if link_name:
+    user = id_user.getUserFromLinkName(link_name)
 
   if request.method == 'POST':
     form = EditForm(request.POST)
 
     if form.is_valid():
-      form_id = form.cleaned_data.get('id')
-      new_linkname = form.cleaned_data.get('link_name')
-      nickname = form.cleaned_data.get('nick_name')
-      is_developer = form.cleaned_data.get('is_developer')
       key_name = form.cleaned_data.get('key_name')
+      new_link_name = form.cleaned_data.get('link_name')
+
+      properties = {}
+      properties['id'] = form.cleaned_data.get('id')
+      properties['link_name']  = new_link_name
+      properties['nick_name']  = form.cleaned_data.get('nick_name')
+      properties['is_developer'] = form.cleaned_data.get('is_developer')
       
-      user = id_user.updateUserForKeyName(key_name=key_name, id=form_id, 
-          link_name=new_linkname, nick_name=nickname, 
-          is_developer=is_developer)
+      user = soc.logic.user_logic.updateOrCreateFromKeyName(properties, key_name)
+
+      #raise forms.ValidationError("lesseee: " + new_link_name + " " +  user.link_name)
 
       if not user:
         return http.HttpResponseRedirect('/')
         
-      # redirect to new /site/user/profile/new_linkname?s=0
+      # redirect to new /site/user/profile/new_link_name?s=0
       # (causes 'Profile saved' message to be displayed)
       return helper.responses.redirectToChangedSuffix(
-          request, linkname, new_linkname,
+          request, link_name, new_link_name,
           params=profile.SUBMIT_PROFILE_SAVED_PARAMS)
   else: # method == 'GET':
     # try to fetch User entity corresponding to link name if one exists
-    if linkname:
+    if link_name:
       if user:
         # is 'Profile saved' parameter present, but referrer was not ourself?
         # (e.g. someone bookmarked the GET that followed the POST submit) 
         if (request.GET.get(profile.SUBMIT_MSG_PARAM_NAME)
             and (not helper.requests.isReferrerSelf(request,
-                                                    suffix=linkname))):
+                                                    suffix=link_name))):
           # redirect to aggressively remove 'Profile saved' query parameter
           return http.HttpResponseRedirect(request.path)
     
@@ -322,7 +321,7 @@
           
         context['lookup_error'] = ugettext_lazy(
             'User with that link name not found.')
-        form = EditForm(initial={'link_name': linkname})
+        form = EditForm(initial={'link_name': link_name})
     else:  # no link name specified in the URL
       if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
         # redirect to aggressively remove 'Profile saved' query parameter
--- a/app/soc/views/sponsor/profile.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/sponsor/profile.py	Sun Oct 12 00:08:54 2008 +0000
@@ -32,12 +32,12 @@
 
 DEF_SPONSOR_PUBLIC_TMPL = 'soc/group/profile/public.html'
 
-def public(request, linkname=None, template=DEF_SPONSOR_PUBLIC_TMPL):
+def public(request, link_name=None, template=DEF_SPONSOR_PUBLIC_TMPL):
   """How the "general public" sees the Sponsor profile.
 
   Args:
     request: the standard django request object.
-    linkname: the Sponsor's site-unique "linkname" extracted from the URL
+    link_name: the Sponsor's site-unique "link_name" extracted from the URL
     template: the template path to use for rendering the template.
 
   Returns:
@@ -47,15 +47,15 @@
   context = helper.responses.getUniversalContext(request)
 
   try:
-    linkname_sponsor = sponsor.getSponsorIfLinkName(linkname)
+    link_name_sponsor = sponsor.sponsor_logic.getIfFields(link_name=link_name)
   except out_of_band.ErrorResponse, error:
     # show custom 404 page when link name doesn't exist in Datastore
     return simple.errorResponse(request, error, template, context)
 
-  linkname_sponsor.description = \
-      helper.templates.unescape(linkname_sponsor.description)
+  link_name_sponsor.description = \
+      helper.templates.unescape(link_name_sponsor.description)
   
-  context.update({'linkname_group': linkname_sponsor,
+  context.update({'link_name_group': link_name_sponsor,
                   'group_type': 'Sponsor'})
 
   return helper.responses.respond(request, template, context)
\ No newline at end of file
--- a/app/soc/views/user/profile.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/user/profile.py	Sun Oct 12 00:08:54 2008 +0000
@@ -75,12 +75,12 @@
   SUBMIT_MSG_PARAM_NAME: SUBMIT_MSG_PROFILE_SAVED,
 }
 
-def edit(request, linkname=None, template=DEF_USER_PROFILE_EDIT_TMPL):
+def edit(request, link_name=None, template=DEF_USER_PROFILE_EDIT_TMPL):
   """View for a User to modify the properties of a User Model entity.
 
   Args:
     request: the standard django request object
-    linkname: the User's site-unique "linkname" extracted from the URL
+    link_name: the User's site-unique "link_name" extracted from the URL
     template: the template path to use for rendering the template
 
   Returns:
@@ -92,7 +92,7 @@
   # create default template context for use with any templates
   context = helper.responses.getUniversalContext(request)
 
-  if (not id) and (not linkname):
+  if (not id) and (not link_name):
     # not logged in, and no link name, so request that the user sign in 
     return simple.requestLogin(request, template, context,
         # TODO(tlarsen): /user/profile could be a link to a help page instead
@@ -101,22 +101,24 @@
                           ' or modify an existing one, you must first'
                           ' <a href="%(sign_in)s">sign in</a>.')
 
-  if (not id) and linkname:
-    # not logged in, so show read-only public profile for linkname user
-    return simple.public(request, template, linkname, context)
+  if (not id) and link_name:
+    # not logged in, so show read-only public profile for link_name user
+    return simple.public(request, template, link_name, context)
 
-  # try to fetch User entity corresponding to linkname if one exists    
+  link_name_user = None
+
+  # try to fetch User entity corresponding to link_name if one exists
   try:
     linkname_user = id_user.getUserIfLinkName(linkname)
   except out_of_band.ErrorResponse, error:
     # show custom 404 page when link name doesn't exist in Datastore
     return simple.errorResponse(request, error, template, context)
   
-  # linkname_user will be None here if link name was already None...
-  if linkname_user and (linkname_user.id != id):
-    # linkname_user exists but is not the currently logged in Google Account,
+  # link_name_user will be None here if link name was already None...
+  if link_name_user and (link_name_user.id != id):
+    # link_name_user exists but is not the currently logged in Google Account,
     # so show public view for that (other) User entity
-    return simple.public(request, template, linkname, context)
+    return simple.public(request, template, link_name, context)
 
   if request.method == 'POST':
     form = UserForm(request.POST)
@@ -128,10 +130,10 @@
       user = id_user.updateOrCreateUserFromId(
           id, link_name=new_linkname, nick_name=nickname)
 
-      # redirect to new /user/profile/new_linkname?s=0
+      # redirect to new /user/profile/new_link_name?s=0
       # (causes 'Profile saved' message to be displayed)
       return helper.responses.redirectToChangedSuffix(
-          request, linkname, new_linkname, params=SUBMIT_PROFILE_SAVED_PARAMS)
+          request, link_name, new_link_name, params=SUBMIT_PROFILE_SAVED_PARAMS)
   else: # request.method == 'GET'
     # try to fetch User entity corresponding to Google Account if one exists    
     user = id_user.getUserFromId(id)
@@ -141,7 +143,7 @@
       # (e.g. someone bookmarked the GET that followed the POST submit) 
       if (request.GET.get(SUBMIT_MSG_PARAM_NAME)
           and (not helper.requests.isReferrerSelf(request,
-                                                  suffix=linkname))):
+                                                  suffix=link_name))):
         # redirect to aggressively remove 'Profile saved' query parameter
         return http.HttpResponseRedirect(request.path)
     
@@ -166,6 +168,6 @@
 
 
 def create(request, template=DEF_USER_PROFILE_EDIT_TMPL):
-  """create() view is same as edit() view, but with no linkname supplied.
+  """create() view is same as edit() view, but with no link_name supplied.
   """
-  return edit(request, linkname=None, template=template)
+  return edit(request, link_name=None, template=template)
--- a/app/soc/views/user/roles.py	Fri Oct 10 13:14:24 2008 +0000
+++ b/app/soc/views/user/roles.py	Sun Oct 12 00:08:54 2008 +0000
@@ -31,13 +31,13 @@
 from soc.views.helpers import response_helpers
 
 
-def dashboard(request, linkname=None,
+def dashboard(request, link_name=None,
               template='soc/user/roles/dashboard.html'):
   """A per-User dashboard of that User's Roles on the site.
 
   Args:
     request: the standard django request object.
-    linkname: the User's site-unique "linkname" extracted from the URL
+    link_name: the User's site-unique "link_name" extracted from the URL
     template: the template path to use for rendering the template.
 
   Returns:
@@ -45,7 +45,7 @@
   """
   #TODO(tlarsen): this module is currently a placeholder for future work
   
-  # TODO: check that user is logged in and "owns" the linkname;
+  # TODO: check that user is logged in and "owns" the link_name;
   #   if not, call public() view instead
   #   This might be tricky, since we want to use the same style
   #   of template that was passed to us, but how do we figure out
@@ -58,13 +58,13 @@
       template, {'template': template})
 
 
-def public(request, linkname=None,
+def public(request, link_name=None,
            template='soc/user/roles/public.html'):
   """A "general public" view of a User's Roles on the site.
 
   Args:
     request: the standard django request object.
-    linkname: the User's site-unique "linkname" extracted from the URL
+    link_name: the User's site-unique "link_name" extracted from the URL
     template: the template path to use for rendering the template.
 
   Returns: