• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python User.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中model.User.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

  def setUp( self ):
    Test_controller.setUp( self )
    Groups.urllib2 = Stub_urllib2

    self.group_name = u"my group"
    self.group_name2 = u"other group"
    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"[email protected]"
    self.username2 = u"scully"
    self.password2 = u"trustsome1"
    self.email_address2 = u"[email protected]"
    self.username3 = u"skinner"
    self.password3 = u"trustne1"
    self.email_address3 = u"[email protected]"

    self.group = Group.create( self.database.next_id( Group ), self.group_name )
    self.database.save( self.group, commit = False )

    self.group2 = Group.create( self.database.next_id( Group ), self.group_name )
    self.database.save( self.group2, commit = False )

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user, commit = False )
    self.database.execute( self.user.sql_save_group( self.group.object_id, admin = False ) )

    self.user2 = User.create( self.database.next_id( User ), self.username2, self.password2, self.email_address2 )
    self.database.save( self.user2, commit = False )
    self.database.execute( self.user2.sql_save_group( self.group.object_id, admin = True ) )

    self.user3 = User.create( self.database.next_id( User ), self.username3, self.password3, self.email_address3 )
    self.database.save( self.user3, commit = False )
    self.database.execute( self.user3.sql_save_group( self.group.object_id, admin = False ) )

    self.database.commit()
开发者ID:osborne6,项目名称:luminotes,代码行数:35,代码来源:Test_groups.py


示例2: setUp

  def setUp( self ):
    Test_controller.setUp( self )

    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" )
    self.database.save( self.notebook )

    self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes" )
    self.database.save( self.anon_notebook )
    self.anon_note = Note.create(
      self.database.next_id( Note ), u"<h3>my note</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.anon_note )

    self.login_note = Note.create(
      self.database.next_id( Note ), u"<h3>login</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.login_note )

    self.blog_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes blog" )
    self.database.save( self.blog_notebook )
    self.blog_note = Note.create(
      self.database.next_id( Note ), u"<h3>my blog entry</h3>",
      notebook_id = self.blog_notebook.object_id,
    )
    self.database.save( self.blog_note )

    self.guide_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes user guide" )
    self.database.save( self.guide_notebook )
    self.guide_note = Note.create(
      self.database.next_id( Note ), u"<h3>it's all self-explanatory</h3>",
      notebook_id = self.guide_notebook.object_id,
    )
    self.database.save( self.guide_note )

    self.privacy_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes privacy policy" )
    self.database.save( self.privacy_notebook )
    self.privacy_note = Note.create(
      self.database.next_id( Note ), u"<h3>yay privacy</h3>",
      notebook_id = self.privacy_notebook.object_id,
    )
    self.database.save( self.privacy_note )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"[email protected]"
    self.user = None
    self.session_id = None

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user )
    self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) )

    self.anonymous = User.create( self.database.next_id( User ), u"anonymous" )
    self.database.save( self.anonymous )
    self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id, read_write = False, owner = False, rank = 0 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.blog_notebook.object_id, read_write = False, owner = False, rank = 1 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.guide_notebook.object_id, read_write = False, owner = False, rank = 2 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.privacy_notebook.object_id, read_write = False, owner = False, rank = 3 ) )
开发者ID:osborne6,项目名称:luminotes,代码行数:60,代码来源:Test_root.py


示例3: post

    def post(self):
        validcode = self.get_request("validcode", "")
        if "validcode" in self.session:
            if validcode != self.session['validcode'] :
                self.print_result(False, "ValidCode is incorrect!!")
                return
        else:
            self.print_result(False, "ValidCode is incorrect!!")
            return
        user = User().getByID(self.userID, False)
        if  user :
            # found it
            # send email
            activationKey = user.getEncodeStr(str(user.user_login)+"-"+ str(time.time()))
            user.user_activation_key = activationKey
            if user.update() :
                self.print_result(True, "Done")
                """
                    Send Email to register
                """
                msg = self.render_string("email/register.html",activationKey=activationKey, login_user = user.user_login, website_url= self.webroot_url("", True), web_title = self.web_title() )
                subject = "["+self.web_title()+"] ReSend Activation Key"
                qm = SingleMail.get_instance()
                qm.send_email(user.user_email,subject, msg, 'html')

            else :
                self.print_result(False, "Failed to Update DB")

        else:
            # find failed
            self.print_result(False, "Can not find any record")
开发者ID:bluemastodon66,项目名称:metis,代码行数:31,代码来源:client.py


示例4: post

 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     usr = User(username)
     if usr.key and usr.validate_pw(password):
         self.set_user_cookie(username)
         self.redirect("/")
         return None
     self.formpost(username, "Wrong Username or Password")
开发者ID:macntouch,项目名称:putzplaner,代码行数:9,代码来源:user_handler.py


示例5: GetUserId

 def GetUserId(self):
     
     if endpoints.get_current_user() == None:
         raise endpoints.UnauthorizedException("Must log in")
     
     user = User.query(User.username == endpoints.get_current_user().email()).get()
     if user == None:
         user = User(username = endpoints.get_current_user().email())
         user.put()
     return user.key
开发者ID:Leonidpopob,项目名称:tasks,代码行数:10,代码来源:task_api.py


示例6: RemoveHandler

class RemoveHandler(tornado.web.RequestHandler):
    def initialize(self, mysql_handler, LOG):
        self.mysql_handler = mysql_handler
        self.LOG = LOG
        self.user = User(mysql_handler, LOG)
        self.device = Device(mysql_handler, LOG)
        self.favorite = Favorite(mysql_handler, LOG)
        self.rsp_handler = CommResponse()
        return

    def post(self):
        self.LOG.debug('this is %s' % self.__class__.__name__)
        try:
            request_json = json.loads(self.request.body)
            user_phone = request_json['user_phone']
            user_login_mobile_uuid = request_json['user_login_mobile_uuid']
            collection_type = request_json['collection_type']
            collection_name = request_json['collection_name']
        except Exception as e:
            self.LOG.error('parameters error.')
            self.rsp_msg = self.rsp_handler.generate_rsp_msg('21001', None)
            self.write(self.rsp_msg)
            return

        if not self.user.check_login_status(user_phone, user_login_mobile_uuid):
            self.LOG.error('user [%s] not login.' % user_phone)
            self.mysql_handler.rollback_db()
            self.rsp_msg = self.rsp_handler.generate_rsp_msg('21006', None)
            self.write(self.rsp_msg)
            return

        (ret, num) = self.favorite.remove_collection(user_phone, collection_name, collection_type)
        if not ret:
            self.LOG.error('delete collection from mysql failed.')
            self.rsp_msg = self.rsp_handler.generate_rsp_msg('21999', None)
            self.mysql_handler.rollback_db()
            self.write(self.rsp_msg)
            return

        if num:
            modify_info = {
                'collected': 'collected - 1'
            }
            if collection_type == 'user':
                self.user.modify_user(collection_name, modify_info)
            elif collection_type == 'device':
                self.device.modify_device(collection_name, modify_info)
        
        self.rsp_msg = self.rsp_handler.generate_rsp_msg('200', None)
        self.mysql_handler.commit_db()
        self.write(self.rsp_msg)
        return
开发者ID:yufajieluo,项目名称:cloud_factory,代码行数:52,代码来源:favoriteHandler.py


示例7: get

    def get(self):

        user = users.get_current_user()
        #checks to see if we have a user signed in
        if user:
            userProfile = User.getByEmail(user.email())
            #if user profile is empty create one
            if not userProfile:
                userProfile = User()
                userProfile.email = user.email()
                userProfile.nickname = 'Anonymous'
                userProfile.score = 0
                userProfile.played = 0
                userProfile.put()

            template_values = {
                'user': userProfile
            }

            template = jinja_environment.get_template('profile.html')
            self.response.out.write(template.render(template_values))
        #if not is ask them to sign in
        else:
            template_values = {
                'signinurl' : users.create_login_url("/")
            }

            template = jinja_environment.get_template('signin.html')
            self.response.out.write(template.render(template_values))
开发者ID:erniearl,项目名称:levelblocks,代码行数:29,代码来源:Home.py


示例8: get

 def get(self):
     tid = self.get_request("id", "")
     user = None
     if (id != ""):
         user = User().getByActivateToken(tid, False)
     success = False
     login = ""
     if not user is None:
         user.user_status = 1
         user.user_activation_key = ""
         login = user.user_login
         if user.update():
             success = True
     self.render("public/activate_account.html", login_name=login, title="Activate Account", isSuccess=success)
开发者ID:bluemastodon66,项目名称:metis,代码行数:14,代码来源:auth.py


示例9: post

 def post(self):
     user_account = self.get_request("account","")
     email = self.get_request("email", "")
     user_url = self.get_request("personal_url", "")
     displayName = self.get_request("display_name", "")
     password = self.get_request("password", "")
     role = self.get_request("role","")
     status = self.get_int_request("status",0)
     if user_account == "":
         self.print_result(False, "User Account Cannot be blank!")
         return
     if user_url != "":
         tmp = user_url.lower()
         if not tmp.startswith("http"):
             user_url = "http://"+user_url
         if not pyUtility.isURL(user_url):
             self.print_result(False, "The Format of URL is wrong!")
             return
     if email == "":
         self.print_result(False, "Email Cannot be blank!")
         return
     if not pyUtility.isEmail(email):
         self.print_result(False, "Email Format is incorrect!")
         return
     if password == "":
         self.print_result(False, "Password is empty!")
         return
     user_account = user_account.lower()
     email = email.lower()
     if not pyUtility.isAccountLegal(user_account):
         self.print_result(False, "The Format of Account is not legal")
         return
     if not User().isUnique(email=email, acc=user_account):
         self.print_result(False, "Account or Email Has been used")
         return
     user = User()
     newPwd = user.getEncodeStr(password)
     user.user_login = user_account
     user.user_pass = newPwd
     user.user_email = email
     user.user_url = user_url
     user.role = role
     user.user_status = status
     user.display_name = displayName
     newID = user.save()
     if newID >0:
         self.print_result(True, "Done", self.get_webroot_url()+"admin/users/")
     else:
         self.print_result(False, "Failed to Add Account to DB")
开发者ID:bluemastodon66,项目名称:metis,代码行数:49,代码来源:admin.py


示例10: test_db

def test_db():
    # INSERT
    if not session.query(exists().where(User.email == '[email protected]')).scalar():
        u1 = User()
        u1.name = "Test user"
        u1.email = "[email protected]"

        a1 = Address()
        a1.street = "Str 123"
        a1.city = "City WTF"

        u1.address = a1
        session.add(a1)
        session.add(u1)
        session.commit()

    # check if record exists in db:
    # print session.query(Address).filter_by(city='City WTF').count()
    # print bool( session.query(Address).filter_by(city='City WTF').count() )

    #   SELECT
    if session.query(exists().where(Address.city == 'City WTF')).scalar():
        a2 = session.query(Address).filter_by(city='City WTF').first()
        print a2.city

    if bool(session.query(Address).filter_by(city='City WTF').count()):
        a2 = session.query(Address).filter_by(city='City WTF').first()
        print a2.city


    # UPDATE
    if session.query(exists().where(User.email == '[email protected]')).scalar():
        session.query(User).filter_by(email='te[email protected]').update({"nick": "a"})
        session.commit()

    if session.query(exists().where(User.email == '[email protected]')).scalar():
        u = session.query(User).filter_by(email='[email protected]').first()
        u.nick = "b"
        session.commit()


    # DELETE
    if session.query(exists().where(User.email == '[email protected]')).scalar():
        session.query(User).filter_by(email='[email protected]').delete()
        session.commit()

    if session.query(exists().where(Address.city == 'City WTF')).scalar():
        session.query(Address).filter_by(city='City WTF').delete()
        session.commit()
开发者ID:tuxmartin,项目名称:flask-example-project,代码行数:49,代码来源:db_test.py


示例11: initialize

 def initialize(self, mysql_handler, redis_handler, LOG):
     self.mysql_handler = mysql_handler
     self.redis_handler = redis_handler
     self.LOG = LOG
     self.user = User(mysql_handler, LOG)
     self.picture = Picture(mysql_handler, LOG)
     return
开发者ID:yufajieluo,项目名称:cloud_factory,代码行数:7,代码来源:userHandler.py


示例12: post

 def post(self):
     loggedIn= False
     username=self.request.get('username')
     password=self.request.get('password')
     use = User.all().filter('username',username)
     if use.count() == 1:
         #user found
         user = use.get()
         if(user.password == password):
             i = uuid.uuid1()
             sess = Session(user=user.username,sessId=str(i))
             sess.put()
             self.session['sessId']=str(i)
             loggedIn = True
             template_params={'loggedIn':loggedIn,
                             'user': user.username}
             render_template(self,'login.html',template_params)
         else:
             #no user found/something went wrong
             loginError = True
             template_params={
                 'loggedIn': loggedIn,
                 'loginError': loginError,
             }
             render_template(self,'login.html',template_params)
     else:
         #no user found/something went wrong
         loginError = True
         template_params={
             'loggedIn': loggedIn,
             'loginError': loginError,
         }
         render_template(self,'login.html',template_params)
开发者ID:aquafemi,项目名称:Jirga,代码行数:33,代码来源:jirgaSettings.py


示例13: get

 def get(self,jirgaId):
     loggedIn= False
     user = self.getuser()
     if(user is not None):
         jirga = Jirga.all().filter('jirgaId', jirgaId).get()
         public = jirga.publicJirga
         if(public == 0):
             #private jirga
             template_params = {
                 'public':public,
             }
         else:
             #public
             if(user in jirga.members):
                 #user is a member
                 member = 1
             else:
                 #user is not a member
                 member = 0
             template_params = {
                 'public':public,
                 'member':member
             }
         member = User.get(jirga.members)
         obj2={'members':member}
         template_params.update(obj2)
         template_params.update({'user':user})
         template_params.update({'jirga':jirga})
         render_template(self,"jirgaSettings.html",template_params)
     else:
         self.response.write("FAIL - you need to be logged in for this")
开发者ID:aquafemi,项目名称:Jirga,代码行数:31,代码来源:jirgaSettings.py


示例14: post

 def post(self):
     loggedIn= True
     username=self.request.get('username')
     password=self.request.get('password')
     android=self.request.get('android')
     use = User.all().filter('username',username)
     self.session.delete(username)
开发者ID:aquafemi,项目名称:Jirga,代码行数:7,代码来源:logout.py


示例15: setUp

  def setUp( self ):
    self.database = Database(
      Connection_wrapper( sqlite.connect( ":memory:", detect_types = sqlite.PARSE_DECLTYPES, check_same_thread = False ) ),
      cache = Stub_cache(),
    )
    self.database.execute_script( file( "model/schema.sqlite" ).read(), commit = True )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"[email protected]"
    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user, commit = False )

    self.trash = Notebook.create( self.database.next_id( Notebook ), u"trash" )
    self.database.save( self.trash, commit = False )
    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"notebook", self.trash.object_id, user_id = self.user.object_id )
    self.database.save( self.notebook, commit = False )

    note_id = self.database.next_id( Note )
    self.note1 = Note.create( note_id, u"<h3>my title</h3>blah", notebook_id = self.notebook.object_id, startup = True, user_id = self.user.object_id )
    self.database.save( self.note1, commit = False )

    note_id = self.database.next_id( Note )
    self.note2 = Note.create( note_id, u"<h3>other title</h3>whee", notebook_id = self.notebook.object_id, user_id = self.user.object_id )
    self.database.save( self.note2, commit = False )
开发者ID:osborne6,项目名称:luminotes,代码行数:25,代码来源:Test_export_csv.py


示例16: initialize

 def initialize(self, mysql_handler, LOG):
     self.mysql_handler = mysql_handler
     self.LOG = LOG
     self.user = User(mysql_handler, LOG)
     self.order = Order(mysql_handler, LOG)
     self.rsp_handler = CommResponse()
     return
开发者ID:yufajieluo,项目名称:cloud_factory,代码行数:7,代码来源:orderHandler.py


示例17: post

 def post(self):
     loggedIn= False
     username=self.request.headers.get('Username')
     password=self.request.headers.get('Password')
     print("username="+username)
     print("password="+password)
     use = User.all().filter('username',username)
     if use.count() == 1:
         #user found
         user = use.get()
         if(user.password == password):
             print("match")
             i = uuid.uuid1()
             sess = Session(user=user.username,sessId=str(i))
             sess.put()
             self.response.headers['Content-Type'] = 'application/json'
             obj = {
                 'sessKey':str(i)
             }
             self.response.out.write(json.dumps(obj))
         else:
             #no user found/something went wrong
             print("badpass")
     else:
         print("badname")
开发者ID:aquafemi,项目名称:Jirga,代码行数:25,代码来源:jsonLogin.py


示例18: UserHandler

class UserHandler(tornado.web.RequestHandler):
    def initialize(self, mysql_handler, redis_handler, LOG):
        self.mysql_handler = mysql_handler
        self.redis_handler = redis_handler
        self.LOG = LOG
        self.user = User(mysql_handler, LOG)
        self.picture = Picture(mysql_handler, LOG)
        return
    def get_self_info(self, user_phone):
        user_info = self.user.check_user_exist(user_phone)
        if user_info:
            image_info = self.picture.get_image_by_phone(user_phone, 'user')
            try:
                image_big_mame = image_info['pic_big_name']
                image_sml_mame = image_info['pic_sml_name']
            except:
                image_big_mame = None
                image_sml_mame = None
            
            user_info['pic_big_name'] = image_big_mame
            user_info['pic_sml_name'] = image_sml_mame
            #del user_info['login_status']

            image_info = self.picture.get_image_by_phone(user_phone, 'license')
            try:
                image_big_mame = image_info['pic_big_name']
                image_sml_mame = image_info['pic_sml_name']
            except:
                image_big_mame = None
                image_sml_mame = None
            user_info['license_big_name'] = image_big_mame
            user_info['license_sml_name'] = image_sml_mame
        return user_info
开发者ID:yufajieluo,项目名称:cloud_factory,代码行数:33,代码来源:userHandler.py


示例19: create_thread

  def create_thread( self, user_id ):
    """
    Create a new forum thread with a blank post, and give the thread a default name. Then redirect
    to that new thread.

    @type user_id: unicode or NoneType
    @param user_id: id of current logged-in user (if any)
    @rtype dict
    @return { 'redirect': new_notebook_url }
    @raise Access_error: the current user doesn't have access to create a post
    @raise Validation_error: one of the arguments is invalid
    """
    if user_id is None:
      raise Access_error()

    user = self.__database.load( User, user_id )
    if user is None or not user.username or user.username == "anonymous":
      raise Access_error()

    anonymous = self.__database.select_one( User, User.sql_load_by_username( u"anonymous" ), use_cache = True )
    if anonymous is None:
      raise Access_error()

    # for now, crappy hard-coding to prevent just anyone from creating a blog thread
    if self.__name == u"blog" and user.username != u"witten":
      raise Access_error()

    # create the new notebook thread
    thread_id = self.__database.next_id( Notebook, commit = False )
    thread = Notebook.create( thread_id, self.DEFAULT_THREAD_NAME, user_id = user.object_id )
    self.__database.save( thread, commit = False )

    # associate the forum tag with the new notebook thread
    tag = self.__database.select_one( Tag, Tag.sql_load_by_name( u"forum", user_id = anonymous.object_id ) )
    self.__database.execute(
      anonymous.sql_save_notebook_tag( thread_id, tag.object_id, value = self.__name ),
      commit = False,
    )

    # give the anonymous user access to the new notebook thread
    self.__database.execute(
      anonymous.sql_save_notebook( thread_id, read_write = True, owner = False, own_notes_only = True ),
      commit = False,
    )

    # create a blank post in which the user can  start off the thread
    note_id = self.__database.next_id( Notebook, commit = False )
    note = Note.create( note_id, u"<h3>", notebook_id = thread_id, startup = True, rank = 0, user_id = user_id )
    self.__database.save( note, commit = False )

    self.__database.commit()

    if self.__name == "blog":
      return dict(
        redirect = u"/blog/%s" % thread_id,
      )

    return dict(
      redirect = u"/forums/%s/%s" % ( self.__name, thread_id ),
    )
开发者ID:osborne6,项目名称:luminotes,代码行数:60,代码来源:Forums.py


示例20: post

    def post(self, level_id):
        user = User.getLevelBlockUser(users.get_current_user())

        if user:
            level = self.request.get('level')
            name = self.request.get('name')
            if level_id:
                l = Level.getById(int(level_id))
                #only modify if you are the original author
                if l.user.id == user.key.id:
                    l.name = name
                    l.user = user.key
                    l.score = 0
                    l.published = False
                    l.level = str(level)
                    l.put()
            else:
                l = Level()
                l.name = name
                l.user = user.key
                l.score = 0
                l.published = False
                l.level = str(level)
                l.put()

            self.response.out.write(level)

        else:
            template_values = {
                'signinurl': users.create_login_url("/")
            }

            template = jinja_environment.get_template('signin.html')
            self.response.out.write(template.render(template_values))
开发者ID:erniearl,项目名称:levelblocks,代码行数:34,代码来源:Home.py



注:本文中的model.User.User类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python anno.Anno类代码示例发布时间:2022-05-27
下一篇:
Python model.User类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap