Beispiel #1
0
 def createUser(self, twitter_user, account_status, messages_per_day):
     user = User()
     user.twitter = twitter_user
     user.username = twitter_user
     user.account_status = account_status
     user.messages_per_day = messages_per_day
     user.put()
     return user
Beispiel #2
0
    def post(self):
        twitter = Twitter.getInstance()
        model = model_from_request(self.request, RegisterModel)

        # validate data; on error, redisplay form with error messages
        if not model.validate():
            self.view(model)
            return

        # save new user
        user = User()
        user.username = model.twitter_name
        user.twitter = model.twitter_name
        user.email = ""
        pwd_hash = hashlib.md5()
        pwd_hash.update(model.password)
        user.password = pwd_hash.hexdigest()
        user.timezone = ""
        user.next_run_time = 0
        user.message_type = "reply"
        user.account_status = "enabled"
        user.repeat_times = 6
        user.followed_by = ""
        user.i_follow = ""
        user.messages_per_day = 10
        user.default_source_lang = "en"
        user.follow_lang_list = "en"
        user.total_points = 0

        user.put()
        try:
            twitter.api.CreateFriendship(model.twitter_name)
        except:
            pass
        # put him into session
        set_current_user(user)
        # redirect to the home page
        self.redirect("/profile")