示例#1
0
文件: models.py 项目: Xalior/conrad
    def __init__(self, site, path, source=None):
        '''Initialize an entry

        This involves change of base class by running static method Class.check
        of every member of models.TYPE_LIST.

        Arguments:

         - `site`: site this entry belongs to
         - `path`: relative path to source template and to result
         - `source`: optional source template path. Can be used to trick
            system to have virtual entries (with no real equivalent in
            source directory)
        '''
        self.site = site
        self.path = path
        self.source = source
        self.mtime = self.get_mtime()

        self.settings = Settings(parent=self.site.settings)

        base = '_%s.html' % self.__class__.__name__.lower()
        if os.path.exists(os.path.join(self.site.root, base)):
            self.settings.parent_tmpl = base

        self.template = self.get_template()
        self.settings.base, self.settings.slug = os.path.split(self.path)
        self.collect()
        if hasattr(self, 'init'):
            self.init()
示例#2
0
    def __init__(self, root, dest):
        self.root = root
        if op.exists(dest):
            shutil.rmtree(dest)

        self.settings = Settings(parent_tmpl='_base.html')
        conf = op.join(self.root, 'settings.cfg')
        if op.exists(conf):
            self.settings.read(file(conf).read().decode('utf-8'))

        site_base_path = base_path(self.url)
        self.dest = op.join(dest, url2path(site_base_path[1:]))

        self.env = initialize_env(root)
        self.env.globals['site'] = self
        self.entries = []

        self.settings.meta = {}
        self.settings.meta['generator'] = "Conrad 2.6alpha"

        if self.settings.get('sitecallback'):
            callback = impcallback(self.settings.sitecallback, self.root)
            callback(self)

        self._traverse()