本文整理汇总了Python中static.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:bholtsclaw,项目名称:bloggart,代码行数:26,代码来源:generators.py
示例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,
)
开发者ID:Gert-Jan,项目名称:DoubleDutchGamesBlog,代码行数:7,代码来源:post_deploy.py
示例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)
开发者ID:gui11aume,项目名称:thegrandlocus,代码行数:29,代码来源:generators.py
示例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)
开发者ID:Direct7Design,项目名称:rognotes,代码行数:31,代码来源:generators.py
示例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/')
开发者ID:gui11aume,项目名称:thegrandlocus,代码行数:7,代码来源:handlers.py
示例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()
开发者ID:gui11aume,项目名称:thegrandlocus,代码行数:32,代码来源:utils.py
示例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)
开发者ID:nant29,项目名称:bloggie,代码行数:7,代码来源:generators.py
示例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)
开发者ID:gui11aume,项目名称:genomearchitecturelab,代码行数:9,代码来源:generators.py
示例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)))
开发者ID:gui11aume,项目名称:genomearchitecturelab,代码行数:11,代码来源:post_deploy.py
示例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)
开发者ID:andrewarrow,项目名称:bloggart,代码行数:11,代码来源:generators.py
示例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)
开发者ID:cabhishek,项目名称:old-blog,代码行数:12,代码来源:generators.py
示例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))
开发者ID:gui11aume,项目名称:thegrandlocus,代码行数:13,代码来源:post_deploy.py
示例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)
开发者ID:Onbeperkt,项目名称:bloggart,代码行数:13,代码来源:generators.py
示例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()
开发者ID:npdoty,项目名称:bloggart,代码行数:14,代码来源:utils.py
示例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)
开发者ID:Gert-Jan,项目名称:DoubleDutchGamesBlog,代码行数:15,代码来源:generators.py
示例16: _regenerate_sitemap
def _regenerate_sitemap():
import static
import gzip
from StringIO import StringIO
static_contents = _get_all_static_content_data()
rendered = render_template('sitemap.xml', {'static_contents': static_contents})
static.set('/sitemap.xml', rendered, 'application/xml', indexed=False, type=static.TYPE_OTHER)
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', indexed=False, type=static.TYPE_OTHER)
# Ping Google only if configured to do so and NOT on localhost
if ( config.google_sitemap_ping and not (config.host.find("localhost") > -1) ):
ping_googlesitemap();
开发者ID:singhj,项目名称:bloggart,代码行数:16,代码来源:utils.py
示例17: post
def post(self, id):
import os, static, hashlib
from models import StoryAuthor, Story, StoryDocument
from django.template.defaultfilters import slugify
from google.appengine.runtime.apiproxy_errors import RequestTooLargeError
content = self.request.get('content')
title = self.request.get('title')
story = Story.get_by_id(int(id, 10))
story.content = content
story.title = title
story.put()
try:
request_document = self.request.get('document')
document_file = self.request.POST['document']
if request_document:
document_body = document_file.value
document_digest = hashlib.sha1(document_body).hexdigest()
split_name = os.path.splitext(os.path.basename(document_file.filename))
filename = slugify(split_name[0]) or document_digest
document_name = filename + split_name[1]
document_path = '/story/%d/document/%s/%s' % (story.key().id(), document_digest, document_name)
logging.info(document_path)
story_document = StoryDocument(story=story, path=document_path, name=document_name)
story_document.put()
document = static.set(document_path, document_body, document_file.type)
self.get(id)
except RequestTooLargeError, message:
self.render_to_response("story_edit.html",
story=Story.get_by_id(int(id, 10)),
request_too_large_error=True)
开发者ID:yesudeep,项目名称:cmc,代码行数:34,代码来源:handlers.py
示例18: generate_resource
def generate_resource(cls, post, resource):
import models
post = models.BlogPost.get_by_id(resource)
if post is None:
return
pages = models.BlogPost.gql("WHERE page = True")
template_vals = {
'post': post,
'pages': pages,
}
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, config.html_mime_type)
开发者ID:tuxcanfly,项目名称:bloggart,代码行数:17,代码来源:generators.py
示例19: generate_resource
def generate_resource(cls, post, resource):
""" Updates the counts for each tag in a given post. """
import models
# resource is the ID of the post.
if not post:
post = models.BlogPost.get_by_id(resource)
else:
assert resource == post.key().id()
import logging
for tag in post.normalized_tags:
logging.debug('TagCloudContentGenerator.generate_resource in generators.py, tag = ' + tag)
tag_counter = models.TagCounter.get_by_key_name( key_names=str(tag) )
if not tag_counter:
tag_counter = models.TagCounter(key_name=str(tag), tagname=str(tag), tagcount=0)
tag_counter.tagcount += 1
tag_counter.put()
# Build triples of (tag, url, count) by extract the 'tag_cloud_max_size' most popular tags.
q = models.TagCounter.all().order('-tagcount')
tags_and_counts = list(itertools.islice((x.tag_and_count for x in q if x.tagcount != 0), config.tag_cloud_max_size))
# Calculate font sizes for tags
from math import log
tags_and_counts_dict=dict(tags_and_counts)
logging.debug('TagCloudContentGenerator.generate_resource in generators.py, tags_and_counts_dict = ' + str(tags_and_counts_dict))
min_count = min(tags_and_counts_dict.values())
max_count = max(tags_and_counts_dict.values())
c = log( max_count - (min_count-1) ) / (config.tag_cloud_max_fontsize - config.tag_cloud_min_fontsize or 1) # scaling constant
c = c or 1 # Avoid div by zero if min and max are equal.
logging.debug('TagCloudContentGenerator.generate_resource in generators.py, min_count = ' + str(min_count) + ', max_count = ' + str(max_count) + ', c = ' + str(c))
tagcloud = []
for tag_name, tag_count in tags_and_counts_dict.items():
size = log( tag_count - (min_count-1) ) / c + config.tag_cloud_min_fontsize
tagcloud.append({'tag':tag_name, 'url':tag_name, 'count':tag_count, 'fontsize':round(size)})
# Pass these tag pairs and counts as template variables to the tag cloud template.
template_vals = {
'tagcloud': tagcloud,
}
rendered = utils.render_template('tagcloud.html', template_vals)
# Store the tagcloud HTML in the static store undrthe path 'tagcloud'.
static.set('tagcloud', rendered, config.html_mime_type, indexed=False)
开发者ID:CodeProBono,项目名称:wikiblog,代码行数:44,代码来源:generators.py
注:本文中的static.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论