當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。