def __init__(self, import_name): self.name = pool.get_package_name(import_name) self.path = os.path.abspath( os.path.dirname(sys.modules[import_name].__file__)) options = dict(NAME=self.name) try: execfile(os.path.join(self.path, 'settings.py'), {}, options) except IOError: pass self.settings = Settings(package_settings, **options) # static directory self._static_dir = os.path.join(self.path, 'static') # add rule for static urls self.add_rule('/%s/static/<filename>' % self.package.name, 'static', build_only=True) # template directory self._template_dir = os.path.join(self.path, 'templates')
def from_view_function(cls, func): """A factory method to create package instance from the view function. """ return cls(pool.get_package_name(func.__module__))