本文整理汇总了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)
示例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))
示例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