python - Listing pyramid template files from a view -


i want make of templates user editable inside web app (the actual template, not replacing content via replacement variables). can't figure out how list of template files.

obviously if know real path can regular python tools. there way actual file location some.package:templates/template.pt syntax?

i want list of template files in, let's some.package:templates/email/. there way of doing that?

to go dotted asset specification may use pyramid.path.assetresolver, documentation states, looks this:

from pyramid.path import assetresolver  = assetresolver() resolver = a.resolve('myproject:templates/foo.pt') print(resolver.abspath()) # -> /path/to/myproject/templates/foo.pt 

specifically has resolving paths:

if spec absolute filename (e.g. /path/to/myproject/templates/foo.pt) or absolute asset spec (e.g. myproject:templates/foo.pt), asset descriptor returned without taking account package passed class' constructor.


however highly recommend against letting users modify template files inside package directly. recommend instead in installation procedures have way of copying templates out of package, , using pyramids asset override mechanism sub out existing asset specs new location. @ point can use standard python open/close file methods have user update templates.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -