本文整理汇总了Python中static.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_resource
def generate_resource(cls, page, resource, action='post'):
curr_page = models.Page.get_by_id(resource);
if ( curr_page ):
# Handle deletion
if action == 'delete':
static.remove(curr_page.path);
curr_page.delete();
return;
# Generate a list of links to print a breadcrumb
breadcrumb_stack = []
# Start from the first parent
parent_page = curr_page.parent_page
while ( parent_page ):
# Put the current parent page on the stack
breadcrumb_stack.append(parent_page)
# Move to the parent's parent
parent_page = parent_page.parent_page
template_vals = {
'page': curr_page,
'breadcrumb_stack' : breadcrumb_stack
}
rendered = utils.render_template("page.html", template_vals)
static.set(curr_page.path, rendered, config.html_mime_type, last_modified=curr_page.updated, type=static.TYPE_PAGE)
示例2: site_verification
def site_verification(previous_version):
static.set(
"/" + config.google_site_verification,
utils.render_template("site_verification.html"),
config.html_mime_type,
False,
)
示例3: generate_resource
def generate_resource(cls, post, resource, pagenum=1, start_ts=None):
# Seems that 'post' is not used. Delete?
import models
q = models.BlogPost.all().order("-published")
q.filter("published <", start_ts or datetime.datetime.max)
cls._filter_query(resource, q)
posts = q.fetch(config.posts_per_page + 1)
more_posts = len(posts) > config.posts_per_page
path_args = {"resource": resource}
_get_path = lambda: cls.first_page_path if path_args["pagenum"] == 1 else cls.path
path_args["pagenum"] = pagenum - 1
prev_page = _get_path() % path_args
path_args["pagenum"] = pagenum + 1
next_page = cls.path % path_args
template_vals = {
"generator_class": cls.__name__,
"posts": posts[: config.posts_per_page],
"prev_page": prev_page if pagenum > 1 else None,
"next_page": next_page if more_posts else None,
}
rendered = utils.render_template("listing.html", template_vals)
path_args["pagenum"] = pagenum
static.set(_get_path() % path_args, rendered, config.html_mime_type)
if more_posts:
deferred.defer(cls.generate_resource, None, resource, pagenum + 1, posts[-2].published)
示例4: generate_resource
def generate_resource(cls, post, resource, pagenum=1, start_ts=None):
import models
q = models.BlogPost.all().order('-published')
q.filter('published <', start_ts or datetime.datetime.max)
cls._filter_query(resource, q)
posts = q.fetch(config.posts_per_page + 1)
more_posts = len(posts) > config.posts_per_page
path_args = {
'resource': resource,
}
_get_path = lambda: \
cls.first_page_path if path_args['pagenum'] == 1 else cls.path
path_args['pagenum'] = pagenum - 1
prev_page = _get_path() % path_args
path_args['pagenum'] = pagenum + 1
next_page = cls.path % path_args
template_vals = {
'generator_class': cls.__name__,
'posts': posts[:config.posts_per_page],
'prev_page': prev_page if pagenum > 1 else None,
'next_page': next_page if more_posts else None,
}
rendered = utils.render_template("listing.html", template_vals)
path_args['pagenum'] = pagenum
static.set(_get_path() % path_args, rendered, config.html_mime_type)
if more_posts:
deferred.defer(cls.generate_resource, None, resource, pagenum + 1,
posts[-2].published)
示例5: post
def post(self):
import static
atom = static.get('/stage/atom.xml')
static.set('/feed/atom.xml', atom.body,
'application/atom+xml; charset=utf-8', indexed=False,
last_modified=datetime.datetime.now())
self.redirect('/admin/')
示例6: _regenerate_sitemap
def _regenerate_sitemap():
"""Regenerate the site map (contains all the paths of the indexed
static content), put it on /sitemap.xml and /sitemap.xml.gz and
tell Google if required by 'config'."""
import static
import gzip
from StringIO import StringIO
# Get all indexed paths in the list 'paths'.
paths = _get_all_paths()
# Use the Django 'sitemap.xml' template and fill it with
# all indexed paths of the app.
rendered = render_template(
'sitemap.xml', {'paths': paths, 'host': config.host}
)
# Set the map as SataticContent at /sitemap.xml and don't index it
# (to prevent entering an infinite loop).
static.set('/sitemap.xml', rendered, 'application/xml', False)
# Also gzip it, and set this at /sitemap.xml.gz.
s = StringIO()
gzip.GzipFile(fileobj=s, mode='wb').write(rendered)
s.seek(0)
rendrdgz = s.read()
static.set('/sitemap.xml.gz', rendrdgz, 'application/x-gzip', False)
# If required by 'config', tell Google where we put it.
if config.google_sitemap_ping:
ping_googlesitemap()
示例7: generate_resource
def generate_resource(cls, post, resource):
assert resource == post.path
template_vals = {
'post': post
}
rendered = utils.render_template("post.html", template_vals)
static.set(post.path, rendered, config.html_mime_type)
示例8: generate_resource
def generate_resource(cls, post, resource):
from models import BlogPost
# Query all posts, and filter out drafts.
q = BlogPost.all().order("-published")
q.filter("published !=", datetime.datetime.max)
html = utils.render_template("labnotes.html", {"generator_class": cls.__name__, "posts": q})
static.set("/labnotes", html, config.html_mime_type)
示例9: regenerate_static_pages
def regenerate_static_pages():
PAGES = os.path.join(os.path.dirname(__file__), 'pages')
for (base, ignore, pages) in os.walk(PAGES):
for page in pages:
path = re.sub('.*/pages', '', os.path.join('/', base, page).lower())
try:
rendered = utils.render_template(path)
static.set(re.sub(r'\..*?$', '', path), rendered,
config.html_mime_type, True)
except Exception as e:
logging.warn('could not create page from %s: %s' % (page, str(e)))
示例10: generate_resource
def generate_resource(cls, post, resource):
import models
if not post:
post = models.BlogPost.get_by_id(resource)
else:
assert resource == post.key().id()
template_vals = {
'post': post,
}
rendered = utils.render_template("post.html", template_vals)
static.set(post.path, rendered, config.html_mime_type)
示例11: generate_resource
def generate_resource(cls, post, resource):
import models
q = models.BlogPost.all().order('-updated')
posts = q.fetch(10)
template_vals = {
'posts': posts,
}
rendered = utils.render_template("atom.xml", template_vals)
static.set('/feeds/atom.xml', rendered,
'application/atom+xml; charset=utf-8', indexed=False)
if config.hubbub_hub_url:
cls.send_hubbub_ping(config.hubbub_hub_url)
示例12: update_lastpost
def update_lastpost():
q = models.BlogPost.all().order('-published')
q.filter('published !=', datetime.datetime.max)# Filter drafts out
post = q.get()
postobj = {}
postobj['path'] = post.path
postobj['title'] = post.title
postobj['summary'] = utils.absolutify_url(post.summary)
postobj['tag_pairs'] = post.tag_pairs
postobj['pubdate'] = post.published.strftime('%B %d, %Y')
static.set('/lastpost.json', json.dumps(postobj, indent=4),
'text/plain; charset=utf-8', indexed=False,
last_modified=post.published_tz.replace(second=0, microsecond=0))
示例13: generate_resource
def generate_resource(cls, post, resource):
import models
q = models.BlogPost.all().order('-updated')
# Fetch the 10 most recently updated non-draft posts
posts = list(itertools.islice((x for x in q if x.path), 10))
template_vals = {
'posts': posts,
}
rendered = utils.render_template("atom.xml", template_vals)
static.set('/feeds/atom.xml', rendered,
'application/atom+xml; charset=utf-8', indexed=False)
if config.hubbub_hub_url:
cls.send_hubbub_ping(config.hubbub_hub_url)
示例14: _regenerate_sitemap
def _regenerate_sitemap():
import static
import gzip
from StringIO import StringIO
paths = _get_all_paths()
rendered = render_template('sitemap.xml', {'paths': paths})
static.set('/sitemap.xml', rendered, 'application/xml', False)
s = StringIO()
gzip.GzipFile(fileobj=s,mode='wb').write(rendered)
s.seek(0)
renderedgz = s.read()
static.set('/sitemap.xml.gz',renderedgz, 'application/x-gzip', False)
if config.google_sitemap_ping:
ping_googlesitemap()
示例15: generate_resource
def generate_resource(cls, post, resource):
import models
post = models.BlogPost.get_by_id(resource)
if post is None:
return
template_vals = {
'post': post,
}
prev, next = cls.get_prev_next(post)
if prev is not None:
template_vals['prev']=prev
if next is not None:
template_vals['next']=next
rendered = utils.render_template("post.html", template_vals)
static.set(post.path, rendered.encode('utf-8'), config.html_mime_type)