当前位置: 首页>>代码示例>>Python>>正文


Python User.find_user方法代码示例

本文整理汇总了Python中bespin.database.User.find_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_user方法的具体用法?Python User.find_user怎么用?Python User.find_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bespin.database.User的用法示例。


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

示例1: check_access

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
    def check_access(self, name, handle):
        """Check to see what level of access user has over an owner's project.
        Returns one of: Access.Denied, Access.ReadOnly or Access.ReadWrite
        Note that if user==owner then no check of project_name is performed, and
        Access.ReadWrite is returned straight away"""
        try:
            (user_name, project_name, path) = name.split("/", 2)

            requester = get_username_from_handle(handle)
            user = User.find_user(requester)
            owner = User.find_user(user_name)

            if user == owner:
                return Access.ReadWrite
            if user != owner:
                if owner.is_project_shared(project_name, user, require_write=True):
                    return Access.ReadWrite
                if owner.is_project_shared(project_name, user, require_write=False):
                    return Access.ReadOnly
                else:
                    return Access.Denied
        except:
            log.exception("Error in Persister.check_access() for name=%s, handle=%s", 
                            name, handle)
            return Access.Denied
开发者ID:dineshkummarc,项目名称:Bespin,代码行数:27,代码来源:integrate.py

示例2: test_delete_setting

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def test_delete_setting():
    resp = app.post('/settings/', {'newone' : 'hi there'})
    resp = app.delete('/settings/newone')
    user = User.find_user('BillBixby')
    session.expunge(user)
    user = User.find_user('BillBixby')
    assert 'newone' not in user.settings
    
开发者ID:mozilla,项目名称:bespinserver,代码行数:9,代码来源:test_settings.py

示例3: check_access

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
  def check_access(self, name):
    from bespin.database import User, get_project
    (user_name, project_name, path) = name.split("/", 2)

    user = User.find_user(user_name)

    parts = project_name.partition('+')
    if parts[1] == '':
      owner = user
    else:
      owner = User.find_user(parts[0])
      project_name = parts[2]

    project = get_project(user, owner, project_name)
    return (project, path)
开发者ID:Jangts,项目名称:bespin,代码行数:17,代码来源:mobwrite_daemon.py

示例4: _split_path

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
 def _split_path(self, path, handle):
     """Extract user, owner, project name, and path and return it as a tuple."""
     requester = get_username_from_handle(handle)
     user = User.find_user(requester)
     if path[0] == "/":
         path = path[1:]
     result = path.split('/', 1)
     parts = result[0].partition('+')
     if parts[1] == '':
         result.insert(0, user)
     else:
         result.insert(0, User.find_user(parts[0]))
         result[1] = parts[2]
     result.insert(0, user)
     return result
开发者ID:mozilla,项目名称:bespinserver,代码行数:17,代码来源:integrate.py

示例5: _split

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
 def _split(self, name):
     """Cut a name into the username, projectname, path parts and lookup
     a project under the given user"""
     (user_name, project_name, path) = name.split("/", 2)
     user = User.find_user(user_name)
     project = get_project(user, user, project_name)
     return (project, path)
开发者ID:dineshkummarc,项目名称:Bespin,代码行数:9,代码来源:integrate.py

示例6: vcs_error

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def vcs_error(qi, e):
    """Handles exceptions that come up during VCS operations.
    A message is added to the user's message queue."""
    log.debug("Handling VCS error: %s", e)
    s = database._get_session()
    user = qi.message['user']
    # if the user hadn't already been looked up, go ahead and pull
    # them out of the database
    if isinstance(user, basestring):
        user = User.find_user(user)
    else:
        s.add(user)
    
    # if we didn't find the user in the database, there's not much
    # we can do.
    if user:
        if isinstance(e, (FSException, main.UVCError)):
            # for exceptions that are our types, just display the
            # error message
            tb = str(e)
        else:
            # otherwise, it looks like a programming error and we
            # want more information
            tb = format_exc()
        message = dict(jobid=qi.id, output=tb, error=True)
        message['asyncDone'] = True
        retval = Message(user_id=user.id, message=simplejson.dumps(message))
        s.add(retval)
开发者ID:Jangts,项目名称:bespin,代码行数:30,代码来源:vcs.py

示例7: test_register_and_verify_user

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def test_register_and_verify_user():
    config.activate_profile()
    _clear_db()
    s = _get_session()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
                                                    password="notangry"))
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    assert data == {}
    assert resp.cookies_set['auth_tkt']
    assert app.cookies
    billbixby = User.find_user("BillBixby")
    sample_project = get_project(billbixby, billbixby, "SampleProject")
    files = [file.name for file in sample_project.list_files()]
    assert "readme.txt" in files
    
    # should be able to run again without an exception appearing
    resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
                                                    password="notangry"),
                    status=409)
    
    # with the cookie set, we should be able to retrieve the 
    # logged in name
    resp = app.get('/register/userinfo/')
    assert resp.content_type == 'application/json'
    data = simplejson.loads(resp.body)
    assert data['username'] == 'BillBixby'
    assert 'quota' in data
    assert data['quota'] == 15728640
    assert 'amountUsed' in data
    
    resp = app.get("/file/at/BespinSettings/config")
    app.post("/file/close/BespinSettings/config")
开发者ID:Jangts,项目名称:bespin,代码行数:37,代码来源:test_users.py

示例8: user

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
 def user(self):
     if self._user:
         return self._user
     if self.username:
         self._user = User.find_user(self.username)
         return self._user
     return None
开发者ID:bbrowning,项目名称:bespin_couch,代码行数:9,代码来源:framework.py

示例9: lost

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def lost(request, response):
    """Generates lost password email messages"""
    email = request.POST.get('email')
    username = request.POST.get('username')
    if username:
        user = User.find_user(username)
        if not user:
            raise BadRequest("Unknown user: " + username)
            
        verify_code = _get_password_verify_code(user)
        change_url = c.base_url + "?pwchange=%s;%s" % (username, verify_code)
        context = dict(username=username, base_url=c.base_url,
                        change_url=change_url)
        
        send_email_template(user.email, "Requested password change for " + c.base_url,
                            "lost_password.txt", context)
        
    elif email:
        users = User.find_by_email(email)
        context = dict(email=email,
            usernames=[dict(username=user.username) for user in users],
            base_url=c.base_url)
        send_email_template(email, "Your username for " + c.base_url,
                            "lost_username.txt", context)
    else:
        raise BadRequest("Username or email is required.")
        
    return response()
开发者ID:Jangts,项目名称:bespin,代码行数:30,代码来源:controllers.py

示例10: _init_data

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def _init_data():
    global macgyver, someone_else, murdoc
    config.activate_profile()
    
    fsroot = config.c.fsroot
    if fsroot.exists() and fsroot.basename() == "testfiles":
        fsroot.rmtree()
    fsroot.makedirs()
    
    app.reset()
    
    Base.metadata.drop_all(bind=config.c.dbengine)
    Base.metadata.create_all(bind=config.c.dbengine)
    s = config.c.session_factory()
    
    someone_else = User.create_user("SomeoneElse", "", "[email protected]")
    murdoc = User.create_user("Murdoc", "", "[email protected]")
    
    otherproject = get_project(someone_else, someone_else,
                                            "otherproject", create=True)
    otherproject.save_file('foo', 'Just a file to reserve a project')
    
    app.post("/register/new/MacGyver", 
        dict(password="richarddean", email="[email protected]"))
        
    macgyver = User.find_user("MacGyver")
开发者ID:mozilla,项目名称:bespinserver,代码行数:28,代码来源:test_files.py

示例11: test_setup

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def test_setup(request, response):
    for name in test_users:
        user = User.find_user(name)
        if (user == None):
            user = User.create_user(name, name, name)
    response.body = ""
    response.content_type = "text/plain"
    return response()
开发者ID:Jangts,项目名称:bespin,代码行数:10,代码来源:controllers.py

示例12: test_set_settings

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def test_set_settings():
    resp = app.post('/settings/', {'antigravity' : 'on', 'write_my_code' : 'on'})
    assert not resp.body
    user = User.find_user('BillBixby')
    session.expunge(user)
    user = User.find_user('BillBixby')
    assert user.settings['antigravity'] == 'on'
    assert user.settings['write_my_code'] == 'on'
    
    resp = app.get('/settings/')
    assert resp.content_type == 'application/json'
    data = simplejson.loads(resp.body)
    assert data == {'antigravity' : 'on', 'write_my_code' : 'on'}
    
    resp = app.get('/settings/antigravity')
    assert resp.content_type == "application/json"
    assert resp.body == '"on"'
开发者ID:mozilla,项目名称:bespinserver,代码行数:19,代码来源:test_settings.py

示例13: test_password_change_with_confirmation_code

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def test_password_change_with_confirmation_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="[email protected]",
                                                    password="notangry"))
    app.reset()
    
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    resp = app.post('/register/password/BillBixby', dict( 
                                            code=verify_code,
                                            newPassword="hatetraffic"))
    
    user = User.find_user('BillBixby', 'hatetraffic')
    assert user
开发者ID:Jangts,项目名称:bespin,代码行数:21,代码来源:test_users.py

示例14: clone_run

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def clone_run(qi):
    """Runs the queued up clone job."""
    message = qi.message
    s = database._get_session()
    user = User.find_user(message['user'])
    message['user'] = user
    result = _clone_impl(**message)
    result.update(dict(jobid=qi.id, asyncDone=True))
    retvalue = Message(user_id=user.id, message=simplejson.dumps(result))
    s.add(retvalue)
    config.c.stats.incr('vcs_DATE')
开发者ID:Jangts,项目名称:bespin,代码行数:13,代码来源:vcs.py

示例15: password_change

# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_user [as 别名]
def password_change(request, response):
    """Changes a user's password."""
    username = request.kwargs.get('username')
    user = User.find_user(username)
    if not user:
        raise BadRequest("Unknown user: " + username)
    verify_code = _get_password_verify_code(user)
    code = request.POST.get('code')
    if verify_code != code:
        raise BadRequest("Invalid verification code for password change.")
    user.password = User.generate_password(request.POST['newPassword'])
    return response()
开发者ID:Jangts,项目名称:bespin,代码行数:14,代码来源:controllers.py


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