Skip to content

Commit

Permalink
slightly modify start
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Oct 8, 2011
1 parent 0011609 commit b7cbaed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion memphis/view/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def initialize(*args):

if chameleon_template:
chameleon_template.AUTO_RELOAD = TEMPLATE.chameleon_reload
chameleon_template.BaseTemplateFile.auto_reload = TEMPLATE.chameleon_reload
chameleon_template.BaseTemplateFile.auto_reload = \
TEMPLATE.chameleon_reload


@config.shutdownHandler
Expand Down
35 changes: 17 additions & 18 deletions memphis/view/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,25 @@ def buildTree(path, not_allowed=re.compile('^[.~$#]')):
return data


@config.subscriber(config.SettingsInitializing)
@config.subscriber(config.ApplicationStarting)
def initialize(ev):
if ev.config is not None:
url = STATIC.url
if urlparse(url)[0]:
# it's a URL
STATIC.isurl = True
for name, data in registry.items():
dirs[name] = (0, urljoin(url, name))
url = STATIC.url
if urlparse(url)[0]:
# it's a URL
STATIC.isurl = True
for name, data in registry.items():
dirs[name] = (0, urljoin(url, name))

else:
for name, (abspath, pkg) in registry.items():
prefix = '%s/%s'%(url, name)
rname = '%s-%s'%(url, name)
pattern = '%s/*subpath'%prefix

ev.config.add_route(rname, pattern)
ev.config.add_view(
route_name=rname,
view=StaticView(abspath, buildTree(abspath), prefix))
else:
for name, (abspath, pkg) in registry.items():
prefix = '%s/%s'%(url, name)
rname = '%s-%s'%(url, name)
pattern = '%s/*subpath'%prefix

ev.config.add_route(rname, pattern)
ev.config.add_view(
route_name=rname,
view=StaticView(abspath, buildTree(abspath), prefix))


class StaticView(object):
Expand Down
1 change: 1 addition & 0 deletions memphis/view/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def _init_memphis(self, settings={}, handler=None, *args, **kw):
config.initialize(('memphis.view', self.__class__.__module__),
reg = Components('test'))
config.initializeSettings(settings, self.p_config)
config.start(self.p_config)

def _setup_pyramid(self):
self.request = request = testing.DummyRequest()
Expand Down

0 comments on commit b7cbaed

Please sign in to comment.