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


Python current.request方法代码示例

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


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

示例1: _

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def _():
    """
    load language file into language table
    """
    import os
    import csv
    f_name = os.path.join(
        request.folder,
        os.path.join('private', 'language-codes.csv'))
    with open(f_name) as lang_codes:
        reader = csv.DictReader(lang_codes)
        for row in reader:
            db.languages.insert(
                language_tag=row['alpha2'],
                english_name=row['English']
            ) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:18,代码来源:dc.py

示例2: edit_form

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def edit_form():
    item = application.getItemByUUID(request.args(0))
    content = db.plugin_photoset_content(item_id=item.unique_id)

    db.plugin_photoset_content.photoset.readable = False
    db.plugin_photoset_content.photoset.writable = False
    db.plugin_photoset_content.item_id.readable = False
    db.plugin_photoset_content.item_id.writable = False
    db.plugin_photoset_content.credit_line.requires = IS_NOT_EMPTY()

    form = SQLFORM(
        db.plugin_photoset_content,
        record=content,
        showid=False,
        submit_button=T('Save')
    )

    if form.process().accepted:
        application.notifyChanges(item.unique_id)
        application.indexItem(item.unique_id)
        response.flash = T('Saved')

    return form 
开发者ID:ybenitezf,项目名称:nstock,代码行数:25,代码来源:plugin_photoset.py

示例3: index

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def index():
    """
    Edit/Show package content
    """
    pkg_item = application.getItemByUUID(request.args(0))
    content = db.plugin_package_content(item_id=pkg_item.unique_id)

    form = SQLFORM(
        db.plugin_package_content,
        record=content,
        showid=False)

    if form.process().accepted:
        application.indexItem(pkg_item.unique_id)
        redirect(URL('default', 'index'))

    return locals() 
开发者ID:ybenitezf,项目名称:nstock,代码行数:19,代码来源:plugin_package.py

示例4: item_list

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def item_list():
    """Show the list of items in this desk"""
    desk = db.desk(request.args(0))

    if desk.id == application.getUserDesk().id:
        session.org_id = None
    session.desk_id = desk.id

    if not request.vars.item_per_load:
        item_per_load = 5
    else:
        item_per_load = int(request.vars.item_per_load)

    # make a query and load the items
    item_list = db(db.item.id.belongs(desk.item_list)).select(
        orderby=[~db.item.created_on],
        limitby=(0, item_per_load+1)
    )

    return locals() 
开发者ID:ybenitezf,项目名称:nstock,代码行数:22,代码来源:desk.py

示例5: process

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def process(self):
        """
        $ curl http://127.0.0.1:8000/collection/default/api
        $ curl http://127.0.0.1:8000/collection/default/api/book
        $ curl http://127.0.0.1:8000/collection/default/api/book?page=1&per_page=20
        $ curl http://127.0.0.1:8000/collection/default/api/book?search=title contains "the"
        $ curl http://127.0.0.1:8000/collection/default/api/bookcase
        $ curl http://127.0.0.1:8000/collection/default/api/bookcase/1
        $ curl -X POST -d 'title=GEB' http://127.0.0.1:8000/collection/default/api/book
        {"row": {"id": 91}}
        $ curl -X DELETE http://127.0.0.1:8000/collection/default/api/book/93
        {"count": 1}
        $ curl -X DELETE http://127.0.0.1:8000/collection/default/api/book/93
        {"count": 0}
        """
        # this is the only part web2py specific!
        from gluon import URL, current
        request, response = current.request, current.response
        res = self.handle_request(URL(), request.env.request_method,
                                  request.args(0), request.args(1), request.vars)
        if 'status' in res and res['status'] != 200:
            response.status = res['status']
        response.headers['Content-Type'] = 'application/json'
        return response.json(res, indent=2)+'\n' 
开发者ID:mdipierro,项目名称:collection2,代码行数:26,代码来源:apimaker.py

示例6: pyfpdf_from_html

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def pyfpdf_from_html(html):
    request = current.request

    def image_map(path):
        if path.startswith('/%s/static/' % request.application):
            return os.path.join(request.folder, path.split('/', 2)[2])
        return 'http%s://%s%s' % (request.is_https and 's' or '', request.env.http_host, path)

    class MyFPDF(FPDF, HTMLMixin):
        pass
    pdf = MyFPDF()
    pdf.add_page()
    # pyfpdf needs some attributes to render the table correctly:
    html = sanitize(
        html, allowed_attributes={
            'a': ['href', 'title'],
            'img': ['src', 'alt'],
            'blockquote': ['type'],
            'td': ['align', 'bgcolor', 'colspan', 'height', 'width'],
            'tr': ['bgcolor', 'height', 'width'],
            'table': ['border', 'bgcolor', 'height', 'width'],
        }, escape=False)
    pdf.write_html(html, image_map=image_map)
    return XML(pdf.output(dest='S')) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:26,代码来源:generics.py

示例7: __init__

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def __init__(self, redis_conn=None, debug=False,
                 with_lock=False, fail_gracefully=False):
        self.request = current.request
        self.debug = debug
        self.with_lock = with_lock
        self.fail_gracefully = fail_gracefully
        self.prefix = "w2p:cache:%s:" % self.request.application
        if self.request:
            app = self.request.application
        else:
            app = ''

        if app not in self.meta_storage:
            self.storage = self.meta_storage[app] = {
                CacheAbstract.cache_stats_name: {
                    'hit_total': 0,
                    'misses': 0,
                }}
        else:
            self.storage = self.meta_storage[app]

        self.cache_set_key = 'w2p:%s:___cache_set' % self.request.application

        self.r_server = redis_conn
        self._release_script = register_release_lock(self.r_server) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:27,代码来源:redis_cache.py

示例8: __init__

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def __init__(self,
                 pk, sk,
                 amount, # in cents
                 description,
                 currency = 'usd',
                 currency_symbol = '$',
                 security_notice = True,
                 disclosure_notice = True,
                 template = None):
        from gluon import current, redirect, URL
        if not (current.request.is_local or current.request.is_https):
            redirect(URL(args=current.request.args,scheme='https'))
        self.pk = pk
        self.sk = sk
        self.amount = amount
        self.description = description
        self.currency = currency
        self.currency_symbol = currency_symbol
        self.security_notice = security_notice
        self.disclosure_notice = disclosure_notice
        self.template = template or TEMPLATE
        self.accepted = None
        self.errors = None
        self.signature = sha1(repr((self.amount,self.description))).hexdigest() 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:26,代码来源:stripe.py

示例9: __redirect_uri

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def __redirect_uri(self, next=None):
        """
        Build the uri used by the authenticating server to redirect
        the client back to the page originating the auth request.
        Appends the _next action to the generated url so the flows continues.
        """

        r = current.request
        http_host = r.env.http_host

        if r.env.https == 'on':
            url_scheme = 'https'
        else:
            url_scheme = r.env.wsgi_url_scheme
        if next:
            path_info = next
        else:
            path_info = r.env.path_info
        uri = '%s://%s%s' % (url_scheme, http_host, path_info)
        if r.get_vars and not next:
            uri += '?' + urlencode(r.get_vars)
        return uri 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:oauth20_account.py

示例10: __redirect_uri

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def __redirect_uri(self, next=None):
        """Build the uri used by the authenticating server to redirect
        the client back to the page originating the auth request.
        Appends the _next action to the generated url so the flows continues.
        """
        r = self.request
        http_host = r.env.http_host

        url_scheme = r.env.wsgi_url_scheme
        if next:
            path_info = next
        else:
            path_info = r.env.path_info
        uri = '%s://%s%s' % (url_scheme, http_host, path_info)
        if r.get_vars and not next:
            uri += '?' + urlencode(r.get_vars)
        return uri 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:19,代码来源:oauth10a_account.py

示例11: login_url

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def login_url(self, next="/"):
        d = saml2_handler(current.session, current.request)
        if 'url' in d:
            redirect(d['url'])
        elif 'error' in d:
            current.session.flash = d['error']
            redirect(URL('default','index'))
        elif 'response' in d:            
            # a['assertions'][0]['attribute_statement'][0]['attribute']
            # is list of
            # {'name': 'http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname', 'name_format': None, 'text': None, 'friendly_name': None, 'attribute_value': [{'text': 'CAA\\dev-mdp', 'extension_attributes': "{'{http://www.w3.org/2001/XMLSchema-instance}type': 'xs:string'}", 'extension_elements': []}], 'extension_elements': [], 'extension_attributes': '{}'}
            try:
                attributes = d['response'].assertions[0].attribute_statement[0].attribute
            except:
                attributes = d['response'].assertion.attribute_statement[0].attribute
            current.session.saml2_info = dict(
                (a.name, [i.text for i in a.attribute_value]) for a in attributes)
        return next 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:20,代码来源:saml2_auth.py

示例12: writefunction

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def writefunction(self, content, initlines=None):
        from gluon import current
        fdest = os.path.join(current.request.folder, 'models', 'scheduler.py')
        if initlines is None:
            initlines = """
import os
import time
from gluon.scheduler import Scheduler
db_dal = os.path.abspath(os.path.join(request.folder, '..', '..', 'dummy2.db'))
sched_dal = DAL('sqlite://%s' % db_dal, folder=os.path.dirname(db_dal))
sched = Scheduler(sched_dal, max_empty_runs=15, migrate=False, heartbeat=1)
def termination():
    sched.terminate()
    sched_dal.commit()
            """
        with open(fdest, 'w') as q:
            q.write(initlines)
            q.write(content) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:20,代码来源:test_scheduler.py

示例13: test_appconfig

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def test_appconfig(self):
        """
        Test for the appconfig module
        """
        from gluon import current
        s = Storage({'application': 'admin',
                     'folder': 'applications/admin'})
        current.request = s
        simple_config = '{"config1" : "abc", "config2" : "bcd", "config3" : { "key1" : 1, "key2" : 2} }'
        with open('appconfig.json', 'w') as g:
            g.write(simple_config)
        myappconfig = AppConfig('appconfig.json')
        self.assertEqual(myappconfig['config1'], 'abc')
        self.assertEqual(myappconfig['config2'], 'bcd')
        self.assertEqual(myappconfig.take('config1'), 'abc')
        self.assertEqual(myappconfig.take('config3.key1', cast=str), '1')
        # once parsed, can't be casted to other types
        self.assertEqual(myappconfig.take('config3.key1', cast=int), '1')

        self.assertEqual(myappconfig.take('config3.key2'), 2)

        current.request = {} 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:test_contribs.py

示例14: setUp

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def setUp(self):
        from gluon.tools import AuthJWT

        from gluon import current

        self.request = Request(env={})
        self.request.application = 'a'
        self.request.controller = 'c'
        self.request.function = 'f'
        self.request.folder = 'applications/admin'
        self.current = current
        self.current.request = self.request

        self.db = DAL(DEFAULT_URI, check_reserved=['all'])
        self.auth = Auth(self.db)
        self.auth.define_tables(username=True, signature=False)
        self.user_data = dict(username='jwtuser', password='jwtuser123')
        self.db.auth_user.insert(username=self.user_data['username'],
                                 password=str(
                                     self.db.auth_user.password.requires[0](
                                         self.user_data['password'])[0]))
        self.jwtauth = AuthJWT(self.auth, secret_key='secret', verify_expiration=True) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:test_tools.py

示例15: __init__

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import request [as 别名]
def __init__(self, redis_conn=None, debug=False,
                 with_lock=False, fail_gracefully=False):
        self.request = current.request
        self.debug = debug
        self.with_lock = with_lock
        self.fail_gracefully = fail_gracefully
        self.prefix = "w2p:cache:%s:" % (self.request.application)
        if self.request:
            app = self.request.application
        else:
            app = ''

        if app not in self.meta_storage:
            self.storage = self.meta_storage[app] = {
                CacheAbstract.cache_stats_name: {
                    'hit_total': 0,
                    'misses': 0,
                }}
        else:
            self.storage = self.meta_storage[app]

        self.cache_set_key = 'w2p:%s:___cache_set' % (self.request.application)

        self.r_server = redis_conn
        self._release_script = register_release_lock(self.r_server) 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:27,代码来源:redis_cache.py


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