app/soc/models/linkable.py
author Lennard de Rijk <ljvderijk@gmail.com>
Tue, 30 Jun 2009 08:54:39 +0200
changeset 2461 c3e3df63e683
parent 2162 03ed2fa5ccc8
permissions -rw-r--r--
Removed setting of the scope in the ProjectSurvey init. This is because it is not possible to query for another entity outside your entity group in the __init__ fucntion.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
1308
35b75ffcbb37 Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1307
diff changeset
     3
# Copyright 2008 the Melange authors.
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
# 
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
# 
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""This module contains the Linkable base class Model."""
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
]
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
475
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    24
import re
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    25
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
from google.appengine.ext import db
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
    28
from django.utils.translation import ugettext
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
568
6713617751b4 Remove inheritance from PolyModel in Answer and Linkable model. Replace PolyModel inheritance with base.ModelWithFieldAttributes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 549
diff changeset
    30
from soc.models import base
6713617751b4 Remove inheritance from PolyModel in Answer and Linkable model. Replace PolyModel inheritance with base.ModelWithFieldAttributes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 549
diff changeset
    31
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
1058
6acbbb68f032 Fix regexp for link id format validation. Link id needs to start with ASCII lowercase and not with digit, which caused User Profile view to crash.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 970
diff changeset
    33
# start with ASCII lowercase
475
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    34
#   (additional ASCII digit or lowercase
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    35
#     -OR-
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    36
#   underscore and ASCII digit or lowercase)
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    37
#     zero or more of OR group
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    38
#
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    39
# * starting or ending underscores are *not* permitted
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    40
# * double internal underscores are *not* permitted
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    41
#
1058
6acbbb68f032 Fix regexp for link id format validation. Link id needs to start with ASCII lowercase and not with digit, which caused User Profile view to crash.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 970
diff changeset
    42
LINK_ID_PATTERN_CORE = r'[a-z](?:[0-9a-z]|_[0-9a-z])*'
475
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    43
LINK_ID_ARG_PATTERN = r'(?P<link_id>%s)' % LINK_ID_PATTERN_CORE
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    44
LINK_ID_PATTERN = r'^%s$' % LINK_ID_PATTERN_CORE
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    45
LINK_ID_REGEX = re.compile(LINK_ID_PATTERN)
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    46
533
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    47
# scope path is multiple link_id chunks,
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    48
# each separated by a trailing /
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    49
# (at least 1)
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    50
SCOPE_PATH_ARG_PATTERN = (r'(?P<scope_path>%(link_id)s'
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    51
                             '(?:/%(link_id)s)*)' % {
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    52
                               'link_id': LINK_ID_PATTERN_CORE})
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    53
SCOPE_PATH_PATTERN = r'^%s$' % SCOPE_PATH_ARG_PATTERN
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    54
SCOPE_PATH_REGEX = re.compile(SCOPE_PATH_PATTERN)
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    55
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    56
# path is multiple link_id chunks,
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    57
#   each separated by a trailing /
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    58
#     (at least 1)
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    59
# followed by a single link_id with no trailing /
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    60
PATH_LINK_ID_ARGS_PATTERN = (
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    61
    r'%(scope_path)s/'
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    62
     '(?P<link_id>%(link_id)s)' % {
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    63
       'scope_path' : SCOPE_PATH_ARG_PATTERN,
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    64
       'link_id': LINK_ID_PATTERN_CORE})
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    65
PATH_LINK_ID_PATTERN = r'^%s$' % PATH_LINK_ID_ARGS_PATTERN
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    66
PATH_LINK_ID_REGEX = re.compile(PATH_LINK_ID_PATTERN)
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 524
diff changeset
    67
475
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
    68
568
6713617751b4 Remove inheritance from PolyModel in Answer and Linkable model. Replace PolyModel inheritance with base.ModelWithFieldAttributes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 549
diff changeset
    69
class Linkable(base.ModelWithFieldAttributes):
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
  """A base class for Model classes that are "linkable".
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
  
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
  Many entities in Melange are identified by a "link path" that is formed
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
  by two components:  a "link scope" and a "link ID".
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
  
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
  The link scope is a reference to another Linkable entity, but its exact
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
  usage varies depending on:
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    77
  
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
   * the Model type of the entity
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
   * the "ownership" of the entity
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
   
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
  This scope represents the "context" of the entity and is *not* user-
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
  editable (site Developers will be able to *carefully* edit the scope
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
  of a Linkable entity, but implementing this will be tricky).
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
  
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
  Appended to this "link path prefix" generated from the transitive
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
  closure of the link scopes is a link ID.  Unlike the rest of the link
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
  path, this ID, which must be unique within the scope defined by the link
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
  path, is *not* determined by context and *is* supplied by the user.
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
  
468
198105fb00bc Fix typo in linkable model and add some missing comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 467
diff changeset
    90
  For example, a Document containing the FAQs for the Apache Software 
198105fb00bc Fix typo in linkable model and add some missing comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 467
diff changeset
    91
  Foundation participation in GSoC 2009 program sponsored
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
  by Google could be given a link ID by the Apache organization
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
  administrator of "faqs", but the rest of the link path would be
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
  determined by the transitive closure of the scopes of the Document:
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
  
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
    google/gsoc2009/asf/faqs
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
      ^       ^      ^   ^
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
      |       |      |   +---------  link ID assigned by Apache admin
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
      |       |      |
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
      |       |      +-------------  Apache org link ID (immutable)
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
      |       |
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
      |       +--------------------  GSoC 2009 program link ID (immutable)
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   103
      |
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   104
      +----------------------------  Google sponsor link ID (immutable)
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
      
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
  For many entities, link IDs, once specified, are immutable, since
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
  changing them can break bookmarked URLs.  Changing the link IDs of
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
  "leaf" entities (such as the Document in the example above) could
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
  be allowed. 
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
  """
2162
03ed2fa5ccc8 Lower ASCII fix
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1970
diff changeset
   111
  #: Required field storing "ID" used in URL links. ASCII characters,
475
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
   112
  #: digits and underscores only.  Valid link IDs successfully match
8bd9db1d7a30 Copy the link_name regex patterns into linkable.py, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 468
diff changeset
   113
  #: the LINK_ID_REGEX.
510
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   114
  link_id = db.StringProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   115
      verbose_name=ugettext('Link ID'))
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   116
  link_id.help_text = ugettext(
549
00a9ce3dc082 Fix some broken help_text bubbles (they are truncated or not displayed if they
Todd Larsen <tlarsen@google.com>
parents: 533
diff changeset
   117
      'Link ID is used as part of various URL links throughout the site.'
2162
03ed2fa5ccc8 Lower ASCII fix
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1970
diff changeset
   118
      ' <a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> '
03ed2fa5ccc8 Lower ASCII fix
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1970
diff changeset
   119
      ' characters, digits, and underscores only.'
1970
385ce0c25bd0 Explain better what a link_id should look like
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1308
diff changeset
   120
      ' The regexp used to validate is "%s".') % LINK_ID_PATTERN_CORE
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
468
198105fb00bc Fix typo in linkable model and add some missing comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 467
diff changeset
   122
  #: Optional Self Reference property to another Linkable entity which defines
198105fb00bc Fix typo in linkable model and add some missing comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 467
diff changeset
   123
  #: the "scope" of this Linkable entity. The back-reference in the Linkable 
198105fb00bc Fix typo in linkable model and add some missing comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 467
diff changeset
   124
  #: model is a Query named 'links'.
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
  scope = db.SelfReferenceProperty(required=False,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   126
      collection_name='links', verbose_name=ugettext('Link Scope'))
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   127
  scope.help_text = ugettext(
467
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
      'Reference to another Linkable entity that defines the "scope" of'
07441582717a Initial thoughts on a Linkable Model class. Please comment.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
      ' this Linkable entity.')
510
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   130
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   131
  #: Hidden (not displayed to users or editable in forms) cache of the string
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   132
  #: representation of the transitive closure of scopes, for use in URLs.
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   133
  #: The multiple queries required to produce this string for entities in
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   134
  #: deeply-nested scopes can be prohibitively expensive.  The scope of an
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   135
  #: entity is not expected to change frequently (only for move, copy, and
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   136
  #: maybe re-parenting operations), so this property is not likely to need
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   137
  #: updating.
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   138
  scope_path = db.StringProperty(required=False,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   139
      verbose_name=ugettext('Scope path'))
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 568
diff changeset
   140
  scope_path.help_text = ugettext(
510
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   141
      'Cache of the string form of the entity scope.')
6cd4f44891e5 id() is a built-in function in Python, so rename the property to link_id. Add
Todd Larsen <tlarsen@google.com>
parents: 503
diff changeset
   142