Did I find the right examples for you? yes no

All Samples(12)  |  Call(12)  |  Derive(0)  |  Import(0)
publish as whiff configuration templates any file in directory from_path ending in extension in in_globals.

        def publish_templates(from_path, in_globals, extension=".whiff", mime_extensions=False, directory_middleware="index"):
    "publish as whiff configuration templates any file in directory from_path ending in extension in in_globals."
    from whiff.middleware import redirect
    len_ext = len(extension)
    filenames = os.listdir(from_path)
    nameToInfo = {}
    nameToUrl = {}
    urlToPage = {}
    for filename in filenames:
        splitfn = filename.split(".")
        filepath = pathjoin(from_path, filename)
        if os.path.isdir(filepath):
            nameToInfo[filename] = "sub-directory"
            nameToUrl[filename] = filename
        elif filename.endswith(extension):
            #filepath = os.path.join(from_path, filename)
            page = LazyPageFromFile(filepath)
            component_name = filename[:-len_ext]
            variable_name = clean_component_name(component_name)
            #pr "for", in_globals.get("__name__")
            #pr "....setting", variable_name, "whiff template to", page
            in_globals[variable_name] = page
            nameToInfo[filename] = "whiff configuration template"
            nameToUrl[filename] = component_name
            urlToPage[component_name] = page
        elif len(splitfn)==2 and splitfn[1] in ("py", "pyc"):
            nameToInfo[filename] = "python code file"
            nameToUrl[filename] = splitfn[0]
        elif mime_extensions:
            # try to guess mime type
            (mime_type, encoding) = mimetypes.guess_type(filename)
            if encoding and mime_type:
                mime_type = "%s/%s" % (mime_type, encoding)
            elif mime_type is None:
                mime_type = "text/plain" # default
            variable_name = clean_component_name(filename)
            page = FileContentApplication(filepath, mime_type)
            #pr "recognized mime type", variable_name, "set to", page
            in_globals[variable_name] = page
            nameToInfo[filename] = "static file of type "+mime_type
            nameToUrl[filename] = filename
            urlToPage[filename] = page
    if directory_middleware and in_globals.get(DEFAULT_WSGI_INTERPRETATION_NAME) is None:
        directory_page = None
        if directory_middleware==True:
            #pr "for", in_globals.get("__file__"), "using table"
            directory_middleware = directoryTable
        if type(directory_middleware) in types.StringTypes:
            if urlToPage.has_key(directory_middleware):
                #pr "for", in_globals.get("__file__"), "using index page", directory_middleware
                directory_middleware = urlToPage[directory_middleware]
            else:
                directory_middleware = None # no index page found
        if directory_page is None and directory_middleware is not None:
            #pr "for", in_globals.get("__file__"), "using provided middleware", directory_middleware
            wrapped_directory_middleware = wrapMiddleware(directory_middleware)
            directory_page = wrapped_directory_middleware.makeWsgiComponent(
                nameToInfo=nameToInfo, nameToUrl=nameToUrl)
        if directory_page is not None:
            
            directory_url = "__whiff_directory_listing__"
            redirect_directory = listingRedirect(directory_url)
            #pr "for", in_globals.get("__file__"), "setting", directory_url, directory_page
            in_globals[directory_url] = directory_page
            in_globals[DEFAULT_WSGI_INTERPRETATION_NAME] = redirect_directory
        


src/w/h/whiff-1.1/whiff/middleware/jquery/css/ui-lightness/images/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/jquery/css/smoothness/images/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/jquery/css/ui-lightness/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/jquery/css/smoothness/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/jquery/js/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/jquery/css/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/middleware/ofc/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True,
                           #directory_middleware=True
                           )

src/w/h/whiff-1.1/whiff/middleware/mako/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True,
                           #directory_middleware=True
                           )

src/w/h/whiff-1.1/whiff/middleware/jquery/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals(), mime_extensions=True)
 

src/w/h/whiff-1.1/whiff/servers/fsCSI/fsCSIroot/__init__.py   whiff(Download)
__wsgi_directory__ = True
 
resolver.publish_templates(__path__[0], globals())
 

  1 | 2  Next