Module Expr Str Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad decorator_list Assign NameStore NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore NameLoad decorator_list Return NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Dict FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareIs NameLoad NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type TupleLoad NameLoad NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Str NameLoad NameLoad Assign NameStore Str Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str Return TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type TupleLoad NameLoad NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str Return Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body Assign SubscriptStore AttributeLoad AttributeLoad NameLoad attr attr Index Str NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad decorator_list Assign NameStore Num Assign NameStore NameLoad FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad AttributeLoad NameLoad attr attr Index Str Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign NameStore ListLoad If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Assign SubscriptStore AttributeLoad AttributeLoad NameLoad attr attr Index Str Call AttributeLoad Str attr NameLoad decorator_list decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr ListLoad TupleLoad Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A Serve static files from a zipfile.

This is a solution for apps that want to serve 1000s of small static
files while staying withing the 1000 file limit.

The simplest use case is driven purely from the handlers section in
app.yaml, e.g.:

  - url: /images/.*
    script: $PYTHON_LIB/google/appengine/ext/zipserve

This would invoke a main() within zipserve/__init__.py.  This code
would then take the URL path, and look for a .zip file under the first
component of the path, in this case "images.zip" in the app's working
directory.  If found, it will then serve any matching paths below that
from the zip file.  In other words, /images/foo/icon.gif would map to
foo/icon.gif in the zip file images.zip.

You can also customize the behavior by adding a custom line to your
WSGIApplication() invocation:

  def main():
    app = webapp.WSGIApplication(
            [('/', MainPage),
             ('/static/(.*)', zipserve.make_zip_handler('staticfiles.zip')),
            ])

You can pass max_age=N to the make_zip_handler() call to override the
expiration time in seconds, which defaults to 600.

To customize the behavior even more, you can subclass ZipHandler and
override the get() method, or override it and call ServeFromZipFile()
directly.

Note that by default, a Cache-control is added that makes these pages
cacheable even if they require authentication.  If this is not what
you want, override ZipHandler.SetCachingHeaders().
 N/A email.Utils N/A logging N/A mimetypes N/A time N/A zipfile google.appengine.ext webapp google.appengine.ext.webapp util make_zip_handler N/A N/A zipfilename max_age public N/A None None N/A N/A Factory function to construct a custom ZipHandler instance.

  Args:
    zipfilename: The filename of a zipfile.
    max_age: Optional expiration time; defaults to ZipHandler.MAX_AGE.
    public: Optional public flag; defaults to ZipHandler.PUBLIC.

  Returns:
    A ZipHandler subclass.
   CustomZipHandler N/A ZipHandler N/A get N/A N/A self name N/A N/A N/A N/A N/A self ServeFromZipFile N/A self ZIPFILENAME name N/A N/A ZIPFILENAME zipfilename N/A N/A max_age None N/A N/A MAX_AGE max_age N/A N/A public None N/A N/A PUBLIC public N/A N/A CustomZipHandler N/A ZipHandler N/A N/A webapp RequestHandler N/A N/A Request handler serving static files from zipfiles. N/A zipfile_cache N/A get N/A N/A self prefix name N/A N/A N/A GET request handler.

    Typically the arguments are passed from the matching groups in the
    URL pattern passed to WSGIApplication().

    Args:
      prefix: The zipfilename without the .zip suffix.
      name: The name within the zipfile.
     N/A N/A N/A self ServeFromZipFile N/A prefix .zip name N/A ServeFromZipFile N/A N/A self zipfilename name N/A N/A N/A Helper for the GET request handler.

    This serves the contents of file 'name' from zipfile
    'zipfilename', logging a message and returning a 404 response if
    either the zipfile cannot be opened or the named file cannot be
    read from it.

    Args:
      zipfilename: The name of the zipfile.
      name: The name within the zipfile.
     N/A zipfile_object N/A N/A N/A self zipfile_cache get zipfilename N/A N/A zipfile_object None N/A N/A N/A N/A zipfile_object N/A N/A zipfile ZipFile zipfilename N/A N/A N/A N/A IOError RuntimeError N/A err N/A N/A N/A N/A logging error Can't open zipfile %s: %s zipfilename err N/A zipfile_object N/A N/A N/A self zipfile_cache N/A zipfilename zipfile_object N/A N/A zipfile_object N/A N/A N/A N/A self error 404 N/A N/A N/A N/A N/A self response out write Not found N/A N/A N/A N/A data N/A N/A zipfile_object read name N/A N/A N/A N/A KeyError RuntimeError N/A err N/A N/A N/A N/A self error 404 N/A N/A N/A N/A N/A self response out write Not found N/A N/A N/A content_type encoding N/A N/A mimetypes guess_type name N/A content_type N/A N/A N/A N/A N/A self response headers N/A Content-Type content_type N/A N/A N/A self SetCachingHeaders N/A N/A N/A N/A N/A self response out write data N/A N/A MAX_AGE 600 N/A PUBLIC True SetCachingHeaders N/A N/A self N/A N/A N/A Helper to set the caching headers.

    Override this to customize the headers beyond setting MAX_AGE.
     N/A max_age N/A self MAX_AGE N/A N/A N/A N/A self response headers N/A Expires N/A N/A N/A email Utils formatdate N/A N/A N/A time time max_age usegmt True N/A cache_control N/A N/A N/A self PUBLIC N/A N/A N/A N/A cache_control append public N/A N/A N/A cache_control append N/A max-age=%d max_age N/A N/A N/A N/A self response headers N/A Cache-Control N/A N/A ,  join cache_control N/A N/A main N/A N/A N/A N/A N/A Main program.

  This is invoked when this package is referenced from app.yaml.
   N/A application N/A N/A webapp WSGIApplication N/A N/A /([^/]+)/(.*) ZipHandler N/A N/A N/A util run_wsgi_app application N/A N/A N/A __name__ __main__ N/A N/A N/A main