當前位置: 首頁>>代碼示例>>Python>>正文


Python werkzeug.utils方法代碼示例

本文整理匯總了Python中werkzeug.utils方法的典型用法代碼示例。如果您正苦於以下問題:Python werkzeug.utils方法的具體用法?Python werkzeug.utils怎麽用?Python werkzeug.utils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在werkzeug的用法示例。


在下文中一共展示了werkzeug.utils方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def main():
    '''A simple command-line interface for :py:func:`run_simple`.'''

    # in contrast to argparse, this works at least under Python < 2.7
    import optparse
    from werkzeug.utils import import_string

    parser = optparse.OptionParser(
        usage='Usage: %prog [options] app_module:app_object')
    parser.add_option('-b', '--bind', dest='address',
                      help='The hostname:port the app should listen on.')
    parser.add_option('-d', '--debug', dest='use_debugger',
                      action='store_true', default=False,
                      help='Use Werkzeug\'s debugger.')
    parser.add_option('-r', '--reload', dest='use_reloader',
                      action='store_true', default=False,
                      help='Reload Python process if modules change.')
    options, args = parser.parse_args()

    hostname, port = None, None
    if options.address:
        address = options.address.split(':')
        hostname = address[0]
        if len(address) > 1:
            port = address[1]

    if len(args) != 1:
        sys.stdout.write('No application supplied, or too much. See --help\n')
        sys.exit(1)
    app = import_string(args[0])

    run_simple(
        hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
        application=app, use_reloader=options.use_reloader,
        use_debugger=options.use_debugger
    ) 
開發者ID:jpush,項目名稱:jbox,代碼行數:38,代碼來源:serving.py

示例2: web_login

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def web_login(self, *args, **kw):
        if request.httprequest.method == 'GET':
            if request.session.uid and request.params.get('redirect'):
                return http.redirect_with_hash(request.params.get('redirect'))
            fm = request.params.get('_fm', None)
            if not request.session.uid and fm!=None:
                fragment = base64.urlsafe_b64decode(fm.encode('utf-8')).decode('utf-8')
                if '_ftype=wo' in fragment:
                    auth_link = self._get_auth_link_wo()
                    return werkzeug.utils.redirect(auth_link, 303)

        response = super(AuthSignupHome, self).web_login(*args, **kw)

        from .controllers import QR_DICT
        qr_id = str(request.session.get('qr_id', ''))#kw.get('qr_id', False)
        if qr_id and (request.params['login_success'] or request.session.uid):
            from .controllers import QR_DICT
            if qr_id in QR_DICT:
                qr = QR_DICT[qr_id]
                if 1:#qr['state']=='fail' and qr['openid']:
                    # 綁定當前登錄的用戶
                    if request.session.uid:
                        user = request.env["res.users"].sudo().search(([('id','=',request.session.uid)]))
                    else:
                        user = request.env.user
                    user.write({
                        'oauth_provider_id': qr['data']['oauth_provider_id'],
                        'oauth_uid': qr['data']['user_id'],
                    })
                    request.env.cr.commit()

        return response 
開發者ID:JoneXiong,項目名稱:weodoo,代碼行數:34,代碼來源:oauth_login_ext.py

示例3: web_client

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def web_client(self, s_action=None, **kw):
        res = super(AuthSignupHome, self).web_client(s_action, **kw)
        if not request.session.uid:
            fm = request.params.get('_fm', None)
            if fm!=None:
                res = werkzeug.utils.redirect('/web/login?_fm=%s'%fm, 303)
        return res 
開發者ID:JoneXiong,項目名稱:weodoo,代碼行數:9,代碼來源:oauth_login_ext.py

示例4: mail_action_view

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def mail_action_view(self, **kwargs):
        _logger.info('>>> %s'%request.httprequest.url)
        _logger.info('>>>mail_action_view %s'%kwargs)
        if not request.session.uid:
            # X2Z0eXBlPXdv
            return werkzeug.utils.redirect('/web/login?_fm=X2Z0eXBlPXdv&redirect=%s'%werkzeug.url_quote_plus(request.httprequest.url), 303)
        res = super(MailControllerExt, self).mail_action_view(**kwargs)
        return res 
開發者ID:JoneXiong,項目名稱:weodoo,代碼行數:10,代碼來源:mail.py

示例5: main

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def main():
    '''A simple command-line interface for :py:func:`run_simple`.'''

    # in contrast to argparse, this works at least under Python < 2.7
    import optparse
    from werkzeug.utils import import_string

    parser = optparse.OptionParser(usage='Usage: %prog [options] app_module:app_object')
    parser.add_option('-b', '--bind', dest='address',
                      help='The hostname:port the app should listen on.')
    parser.add_option('-d', '--debug', dest='use_debugger',
                      action='store_true', default=False,
                      help='Use Werkzeug\'s debugger.')
    parser.add_option('-r', '--reload', dest='use_reloader',
                      action='store_true', default=False,
                      help='Reload Python process if modules change.')
    options, args = parser.parse_args()

    hostname, port = None, None
    if options.address:
        address = options.address.split(':')
        hostname = address[0]
        if len(address) > 1:
            port = address[1]

    if len(args) != 1:
        sys.stdout.write('No application supplied, or too much. See --help\n')
        sys.exit(1)
    app = import_string(args[0])

    run_simple(
        hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
        application=app, use_reloader=options.use_reloader,
        use_debugger=options.use_debugger
    ) 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:37,代碼來源:serving.py

示例6: test_old_imports

# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import utils [as 別名]
def test_old_imports(self):
        from werkzeug.utils import Headers, MultiDict, CombinedMultiDict, \
             Headers, EnvironHeaders
        from werkzeug.http import Accept, MIMEAccept, CharsetAccept, \
             LanguageAccept, ETags, HeaderSet, WWWAuthenticate, \
             Authorization 
開發者ID:GeekTrainer,項目名稱:Flask,代碼行數:8,代碼來源:compat.py


注:本文中的werkzeug.utils方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。