app/soc/cron/unique_user_id_adder.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Mon, 25 May 2009 22:59:56 +0200
changeset 2345 f78caf12f32d
child 2356 7c0a55e8e46f
permissions -rw-r--r--
Add helper functions, model update and jobs for unique user ids.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2345
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
#
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
#
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
#
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
#
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    17
"""Cron job handler for adding unique user id.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    18
"""
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    19
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
__authors__ = [
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
    '"Pawel Solyga" <pawel.solyga@gmail.com>',
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
  ]
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    24
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    25
from google.appengine.ext import db
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    26
from google.appengine.api import users
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    27
from soc.logic.models.job import logic as job_logic
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    28
from soc.logic.models.priority_group import logic as priority_logic
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    29
from soc.logic.models.user import logic as user_logic
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    30
from soc.models.user import User
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    31
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    32
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    33
# amount of users to create jobs for before updating
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    34
DEF_USER_STEP_SIZE = 10
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    35
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    36
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    37
class TempUserWithUniqueId(db.Model):
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    38
  """Helper model for temporary storing User Property with unique id.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    39
  """
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    40
  user = db.UserProperty(required=True)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    41
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    42
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    43
def emailToAccountAndUserId(address):
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    44
  """Return a stable user_id string based on an email address, or None if
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    45
  the address is not a valid/existing google account.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    46
  """
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    47
  user = users.User(address)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    48
  key = TempUserWithUniqueId(user=user).put()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    49
  obj = TempUserWithUniqueId.get(key)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    50
  return (obj, obj.user.user_id())
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    51
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    52
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    53
def setupUniqueUserIdAdder(job_entity):
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    54
  """Job that setup jobs that will add unique user ids to all Users.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    55
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    56
  Args:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    57
    job_entity: a Job entity with key_data set to 
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    58
                [last_completed_user]
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    59
  """
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    60
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    61
  from soc.cron.job import FatalJobError
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    62
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    63
  user_fields = {'user_id': None}
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    65
  if len(key_data) == 1:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    66
    # start where we left off
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    67
    user_fields['__key__ >'] = key_data[0]
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    68
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    69
  m_users = user_logic.getForFields(user_fields,
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    70
                                    limit=DEF_USER_STEP_SIZE)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    71
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    72
  # set the default fields for the jobs we are going to create
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    73
  priority_group = priority_logic.getGroup(priority_logic.CONVERT)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    74
  job_fields = {
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    75
      'priority_group': priority_group,
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    76
      'task_name': 'addUniqueUserIds'}
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    77
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    78
  job_query_fields = job_fields.copy()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    79
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    80
  while m_users:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    81
    # for each user create a adder job
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    82
    for user in m_users:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    83
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    84
      job_query_fields['key_data'] = user.key()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    85
      adder_job = job_logic.getForFields(job_query_fields, unique=True)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    86
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    87
      if not adder_job:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    88
        # this user doesn't have unique id yet
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    89
        job_fields['key_data'] = [user.key()]
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    90
        job_logic.updateOrCreateFromFields(job_fields)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    91
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    92
    # update our own job
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    93
    last_user_key = m_users[-1].key()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    94
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    95
    if len(key_data) == 1:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    96
      key_data[0] = last_student_key
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    97
    else:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    98
      key_data.append(last_student_key)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    99
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   100
    updated_job_fields = {'key_data': key_data}
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   101
    job_logic.updateEntityProperties(job_entity, updated_job_fields)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   102
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   103
    # rinse and repeat
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   104
    user_fields['__key__ >'] = last_user_key
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   105
    m_users = student_logic.getForFields(user_fields,
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   106
                                         limit=DEF_USER_STEP_SIZE)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   107
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   108
  # we are finished
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   109
  return
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   110
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   111
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   112
def addUniqueUserIds(job_entity):
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   113
  """Job that will add unique user id to a User.
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   114
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   115
  Args:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   116
    job_entity: a Job entity with key_data set to [user_key]
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   117
  """
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   118
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   119
  from soc.cron.job import FatalJobError
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   120
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   121
  user_keyname = job_entity.key_data[0].name()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   122
  user_entity = user_logic.getFromKeyName(user_keyname)
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   123
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   124
  if not user_entity:
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   125
    raise FatalJobError('The User with keyname %s does not exist!' % (
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   126
        user_keyname))
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   127
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   128
  # add unique user id
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   129
  account, user_id = emailToAccountAndUserId(user_entity.account.email())
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   130
  user_entity.account = account
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   131
  user_entity.user_id = user_id
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   132
  user_entity.put()
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   133
  
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   134
  # we are done here
f78caf12f32d Add helper functions, model update and jobs for unique user ids.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   135
  return