def test_singleton(self): from rctk.resourceregistry import getResourceRegistry rr1 = getResourceRegistry() rr2 = getResourceRegistry() assert rr1 is rr2
def serve(self, name): # serve a app-specific, dynamic resource if name.startswith('dynamic/'): elements = name.split('/') resource = getResourceRegistry().get_resource(elements[1], elements) return (resource.type, resource.data) raise KeyError(name)
def index_html(cls): """ return the main index.html template """ import rctk.zk.resources path = os.path.join(cls.workingdir(), 'main.html') tpl = open(path, "r").read() header = getResourceRegistry().header() return tpl.replace('<!-- rctk-header -->', header)
def index_html(cls): ## basically the same as serve_static("/media/index.html")[1] header = getResourceRegistry().header() tpl = open(os.path.join(cls.workingdir(), "source/index.html"), "r").read() return tpl.replace('<!-- rctk-header -->', header)
def __init__(self, tk): self.rr = getResourceRegistry() self.tk = tk
def serve_resource(cls, name): # name starts with resource/ elements = name.split('/') resource = getResourceRegistry().get_resource(elements[1], elements) return (resource.type, resource.data)