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


Python Client._website方法代码示例

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


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

示例1: compile_assets

# 需要导入模块: from aspen.testing.client import Client [as 别名]
# 或者: from aspen.testing.client.Client import _website [as 别名]
def compile_assets(website):
    client = Client(website.www_root, website.project_root)
    client._website = website
    for spt in find_files(website.www_root+'/assets/', '*.spt'):
        filepath = spt[:-4]                         # /path/to/www/assets/foo.css
        urlpath = spt[spt.rfind('/assets/'):-4]     # /assets/foo.css
        try:
            # Remove any existing compiled asset, so we can access the dynamic
            # one instead (Aspen prefers foo.css over foo.css.spt).
            os.unlink(filepath)
        except:
            pass
        content = client.GET(urlpath).body
        tmpfd, tmpfpath = mkstemp(dir='.')
        os.write(tmpfd, content)
        os.close(tmpfd)
        os.rename(tmpfpath, filepath)
开发者ID:webmaven,项目名称:gratipay.com,代码行数:19,代码来源:wireup.py

示例2: compile_assets

# 需要导入模块: from aspen.testing.client import Client [as 别名]
# 或者: from aspen.testing.client.Client import _website [as 别名]
def compile_assets(website):
    client = Client(website.www_root, website.project_root)
    client._website = website
    for spt in find_files(website.www_root+'/assets/', '*.spt'):
        filepath = spt[:-4]                         # /path/to/www/assets/foo.css
        urlpath = spt[spt.rfind('/assets/'):-4]     # /assets/foo.css
        try:
            # Remove any existing compiled asset, so we can access the dynamic
            # one instead (Aspen prefers foo.css over foo.css.spt).
            os.unlink(filepath)
        except:
            pass
        headers = {}
        if website.base_url:
            url = urlparse.urlparse(website.base_url)
            headers[b'HTTP_X_FORWARDED_PROTO'] = str(url.scheme)
            headers[b'HTTP_HOST'] = str(url.netloc)
        content = client.GET(urlpath, **headers).body
        tmpfd, tmpfpath = mkstemp(dir='.')
        os.write(tmpfd, content.encode('utf8'))
        os.close(tmpfd)
        os.rename(tmpfpath, filepath)
    atexit.register(lambda: clean_assets(website.www_root))
开发者ID:cyberjacob,项目名称:www.gittip.com,代码行数:25,代码来源:wireup.py

示例3: client

# 需要导入模块: from aspen.testing.client import Client [as 别名]
# 或者: from aspen.testing.client.Client import _website [as 别名]
def client():
    client = Client(www_root='www', project_root='.')
    client._website = website
    yield client
开发者ID:gratipay,项目名称:inside.gratipay.com,代码行数:6,代码来源:test_security.py


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