def __init__(self, config): self.TEMPLATE_FOLDER = Parameter() self.TEMPLATE_EXTENSION = Parameter() tweak(self, "Templates", config) logger.debug("loader configured to use folder '%s'" , self.TEMPLATE_FOLDER) self.index = [x for x in os.listdir(self.TEMPLATE_FOLDER) if not x.startswith(".") or not x.startswith("_")] self.tplExt = self.TEMPLATE_EXTENSION
def __init__(self, config=None): #поля конфигурационного файла self.PROVIDER = Parameter() self.LOCATION = Parameter() self.USER = Parameter() self.PASSWD = Parameter() self.CONNECT_WITH = Parameter() self.DATA_TYPE = Parameter(Data) tweak(self, "Database", config) self.connection = None
def __init__(self, site_config): self.storages = {} self.FOLDERS = Parameter() tweak(self, "Site", site_config) assert isinstance(self.FOLDERS, Section) self.FOLDERS.preload() for name, params in self.FOLDERS.items(): path = params["path"] extensions = params["extensions"] conversions = params["conversions"] fakepath = params["fakepath"] assert extensions self.add_storage(Storage(name, path, extensions, conversions=conversions, fakepath=fakepath))
def __init__(self, config, site): self.site = site self.ROUTES = Parameter() self.VIEWS = Parameter() tweak(self, "Site", config) assert isinstance(self.VIEWS, Section) #у секций ленивый импорт self.VIEWS.preload() self.rules = [] self.make_rule = RuleFactory() #rule = self.make_rule(name) for name, value in self.VIEWS.items(): view = value() view.Site = site self.VIEWS[name] = view for pattern, tpl in self.ROUTES.items(): rule = self.make_rule(pattern) arr = tpl.split(".") if len(arr) == 2: view_name, method_name = arr elif len(arr) == 1: view_name, method_name = arr[0], "__call__" elif len(arr) > 2: raise Exception("Слишком детальный маршрут: " + tpl) assert view_name in self.VIEWS.keys() rule.setObject(self.VIEWS[view_name]) rule.setMethod(method_name) self.rules.append(rule)
def __init__(self, config=None): self.DEFINITIONS = Parameter() tweak(self, "Database", config) self.cache = {} if not isinstance(self.DEFINITIONS, dict): self.DEFINITIONS = self.DEFINITIONS.__dict__
def __init__(self): self.NEXT_NODE = Parameter() tweak(self, "Loader") self.program = self.NEXT_NODE()