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


Python static.set函数代码示例

本文整理汇总了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)
开发者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


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