app/soc/models/user.py
author Todd Larsen <tlarsen@google.com>
Fri, 18 Jul 2008 18:22:23 +0000
changeset 54 03e267d67478
parent 7 soc/models/user.py@5c72db822ebb
child 78 206e6eeed6c4
permissions -rw-r--r--
Major reorganization of the soc svn repo, to merge into a single App Engine image (to make development easier, now that only a single app will run all Google Open Source programs).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
# 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
# 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""This module contains the User Model."""
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
]
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
from google.appengine.ext import db
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
class User(db.Model):
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
  """A user and associated login credentials, the fundamental identity entity.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
  User is a separate Model class from Person because the same login 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
  ID may be used to, for example, serve as Contributor in one Program 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
  and a Reviewer in another.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
  Also, this allows a Person to, in the future, re-associate that 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
  Person entity with a different Google Account if necessary.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
  A User entity participates in the following relationships implemented 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  as a db.ReferenceProperty elsewhere in another db.Model:
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
   persons)  a 1:many relationship of Person entities identified by the
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
     User.  This relation is implemented as the 'persons' back-reference
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
     Query of the Person model 'user' reference.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  """
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
  #: A Google Account, which also provides a "private" email address.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
  #: This email address is only used in an automated fashion by 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
  #: Melange web applications and is not made visible to other users 
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
  #: of any Melange application.
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
  id = db.UserProperty(required=True)
5c72db822ebb Initial revision of the user.py module, containing the User Model, from the
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51