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


Python Service.addCallback方法代码示例

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


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

示例1: requestAvatarId

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import addCallback [as 别名]
    def requestAvatarId(self, credentials):
        key = Key.fromString(credentials.blob)
        fingerprint = key.fingerprint().replace(':', '')
        self.meta.fingerprint = fingerprint
        if (credentials.username == 'git'):
            # Todo, maybe verify the key with a process protocol call
            # (drush or http)
            def success():
                return credentials.username
            d = defer.maybeDeferred(success)
            d.addCallback(self.verify, credentials, key)
            return d
        else:
            """ If a user specified a non-git username, check that the user's key matches their username

            so that we can request a password if it does not."""
            service = Service(AuthProtocol('drupalorg-ssh-user-key'))
            service.request_bool({"username":credentials.username},
                                 {"fingerprint":fingerprint})
            def auth_callback(result):
                if result:
                    return credentials.username
                else:
                    return Failure(UnauthorizedLogin(credentials.username))
            service.addCallback(auth_callback)
            service.addCallback(self.verify, credentials, key)
            return service.deferred
开发者ID:nguyennamtien,项目名称:Drupal.org-Git-Daemons,代码行数:29,代码来源:drupalGitSSHDaemon.py

示例2: fetchHash

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import addCallback [as 别名]
 def fetchHash(credentials):
     service = Service(AuthProtocol('drupalorg-vcs-auth-fetch-user-hash'))
     service.request_json({"username":credentials.username})
     def auth_callback(result):
         if result:
             self.meta.password = DrupalHash(result, credentials.password).get_hash()
             return checkAuth(credentials)
     service.addCallback(auth_callback)
     return service.deferred
开发者ID:sdboyer,项目名称:Drupal.org-Git-Daemons,代码行数:11,代码来源:drupalGitSSHDaemon.py

示例3: checkAuth

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import addCallback [as 别名]
 def checkAuth(credentials):
     service = Service(AuthProtocol('drupalorg-vcs-auth-check-user-pass'))
     service.request_bool({"username":credentials.username},
                          {"password":self.meta.password})
     def auth_callback(result):
         if result:
             return credentials.username
         else:
             return Failure(UnauthorizedLogin(credentials.username))
     service.addCallback(auth_callback)
     return service.deferred
开发者ID:sdboyer,项目名称:Drupal.org-Git-Daemons,代码行数:13,代码来源:drupalGitSSHDaemon.py

示例4: identify

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import addCallback [as 别名]
 def identify(self,credentials):
     passwd = hashlib.md5(credentials.password).hexdigest()
     service = Service(AuthProtocol('drupalorg-vcs-auth-check-user-pass'))
     service.request_bool({"username":credentials.username},
                         {"password":passwd})
     def auth_callback(result):
         if result:
             return credentials.username
         else:
             return Failure(UnauthorizedLogin(credentials.username))
     service.addCallback(auth_callback)
     return service.deferred
开发者ID:lonehacker,项目名称:Drupal.org-Git-Daemons,代码行数:14,代码来源:identifiers.py


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