bugfix
This commit is contained in:
parent
01bbb82b5d
commit
07c5711165
@ -43,7 +43,7 @@ class ConfiguredServer:
|
|||||||
for p,prefix in config.website.paths:
|
for p,prefix in config.website.paths:
|
||||||
res = ProcessorResource(prefix,p,show_index=True,
|
res = ProcessorResource(prefix,p,show_index=True,
|
||||||
follow_symlinks=True,
|
follow_symlinks=True,
|
||||||
indexs=configure.website.indexes,
|
indexes=config.website.indexes,
|
||||||
processors=configure.website.processors)
|
processors=config.website.processors)
|
||||||
self.app.router.register_resource(res)
|
self.app.router.register_resource(res)
|
||||||
|
|
||||||
|
@ -49,8 +49,11 @@ def setupTemplateEngine():
|
|||||||
config = getConfig()
|
config = getConfig()
|
||||||
subffixes = [ i[0] for i in config.website.processors if i[1] == 'tmpl' ]
|
subffixes = [ i[0] for i in config.website.processors if i[1] == 'tmpl' ]
|
||||||
print(subffixes)
|
print(subffixes)
|
||||||
paths = [ os.path.abspath(p) for p,prefix in config.website.paths ]
|
# paths = [ os.path.abspath(p) for p,prefix in config.website.paths ]
|
||||||
loader = TmplLoader(paths,config.website.indexes,subffixes,inherit=True)
|
loader = TmplLoader(config.website.paths,
|
||||||
|
config.website.indexes,
|
||||||
|
subffixes,
|
||||||
|
inherit=True)
|
||||||
engine = TemplateEngine(loader)
|
engine = TemplateEngine(loader)
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
g.tmpl_engine = engine
|
g.tmpl_engine = engine
|
||||||
|
@ -52,7 +52,7 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
show_index: bool=False, follow_symlinks: bool=False,
|
show_index: bool=False, follow_symlinks: bool=False,
|
||||||
append_version: bool=False,
|
append_version: bool=False,
|
||||||
indexes:list=[],
|
indexes:list=[],
|
||||||
processors:dict={}) None:
|
processors:dict={}) -> None:
|
||||||
StaticResource.__init__(self,prefix, directory,
|
StaticResource.__init__(self,prefix, directory,
|
||||||
name=name,
|
name=name,
|
||||||
expect_handler=expect_handler,
|
expect_handler=expect_handler,
|
||||||
@ -67,10 +67,10 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
self._routes.update({'OPTIONS':gr})
|
self._routes.update({'OPTIONS':gr})
|
||||||
self._routes.update({'DELETE':gr})
|
self._routes.update({'DELETE':gr})
|
||||||
self._routes.update({'TRACE':gr})
|
self._routes.update({'TRACE':gr})
|
||||||
self.y_processors = []
|
self.y_processors = processors
|
||||||
self.y_prefix = prefix
|
self.y_prefix = prefix
|
||||||
self.y_directory = directory
|
self.y_directory = directory
|
||||||
self.y_indexes = []
|
self.y_indexes = indexes
|
||||||
self.y_env = DictObject()
|
self.y_env = DictObject()
|
||||||
|
|
||||||
def setProcessors(self, processors):
|
def setProcessors(self, processors):
|
||||||
|
@ -27,8 +27,8 @@ class Url2File:
|
|||||||
real_path = os.path.abspath(rp)
|
real_path = os.path.abspath(rp)
|
||||||
if os.path.isdir(real_path):
|
if os.path.isdir(real_path):
|
||||||
return True
|
return True
|
||||||
else
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
def isFile(self,url:str) ->bool:
|
def isFile(self,url:str) ->bool:
|
||||||
if url.startswith(self.starts):
|
if url.startswith(self.starts):
|
||||||
@ -36,8 +36,7 @@ class Url2File:
|
|||||||
real_path = os.path.abspath(rp)
|
real_path = os.path.abspath(rp)
|
||||||
if os.path.isfile(real_path):
|
if os.path.isfile(real_path):
|
||||||
return True
|
return True
|
||||||
else
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def defaultIndex(self,url: str) -> str:
|
def defaultIndex(self,url: str) -> str:
|
||||||
@ -87,12 +86,21 @@ class Url2File:
|
|||||||
|
|
||||||
class TmplUrl2File(Url2File):
|
class TmplUrl2File(Url2File):
|
||||||
def __init__(self,paths,indexes, subffixes=['.tmpl'],inherit=False):
|
def __init__(self,paths,indexes, subffixes=['.tmpl'],inherit=False):
|
||||||
Url2File.__init__(self,paths,indexes=indexes,inherit=inherit)
|
self.paths = paths
|
||||||
|
self.u2fs = [ Url2File(p,prefix,indexes,inherit=inherit) \
|
||||||
|
for p,prefix in paths ]
|
||||||
self.subffixes = subffixes
|
self.subffixes = subffixes
|
||||||
|
|
||||||
|
def url2file(self,url):
|
||||||
|
for u2f in self.u2fs:
|
||||||
|
fp = u2f.url2file(url)
|
||||||
|
if fp:
|
||||||
|
return fp
|
||||||
|
return None
|
||||||
|
|
||||||
def list_tmpl(self):
|
def list_tmpl(self):
|
||||||
ret = []
|
ret = []
|
||||||
for rp in self.paths:
|
for rp,_ in self.paths:
|
||||||
p = os.path.abspath(rp)
|
p = os.path.abspath(rp)
|
||||||
[ ret.append(i) for i in listFile(p,suffixs=self.subffixes,rescursive=True) ]
|
[ ret.append(i) for i in listFile(p,suffixs=self.subffixes,rescursive=True) ]
|
||||||
return sorted(ret)
|
return sorted(ret)
|
||||||
|
Loading…
Reference in New Issue
Block a user