Beispiel #1
0
def populate():
    """
    Create the root node (:class:`~kotti.resources.Document`) and the 'about'
    subnode in the nodes tree if there are no nodes yet.
    """
    lrm = LocalizerRequestMixin()
    lrm.registry = get_current_registry()
    # noinspection PyPropertyAccess
    lrm.locale_name = get_settings()["pyramid.default_locale_name"]
    localizer = lrm.localizer

    if DBSession.query(Node.id).count() == 0:
        localized_root_attrs = {
            k: localizer.translate(v)
            for k, v in _ROOT_ATTRS.items()
        }
        root = Document(**localized_root_attrs)
        root.__acl__ = SITE_ACL
        DBSession.add(root)
        localized_about_attrs = {
            k: localizer.translate(v)
            for k, v in _ABOUT_ATTRS.items()
        }
        root["about"] = Document(**localized_about_attrs)

        wf = get_workflow(root)
        if wf is not None:
            DBSession.flush()  # Initializes workflow
            wf.transition_to_state(root, None, "public")

    populate_users()
Beispiel #2
0
def populate():
    """
    Create the root node (:class:`~kotti.resources.Document`) and the 'about'
    subnode in the nodes tree if there are no nodes yet.
    """
    lrm = LocalizerRequestMixin()
    lrm.registry = get_current_registry()
    lrm.locale_name = get_settings()['pyramid.default_locale_name']
    localizer = lrm.localizer

    if DBSession.query(Node).count() == 0:
        localized_root_attrs = dict(
            [(k, localizer.translate(v)) for k, v in _ROOT_ATTRS.iteritems()])
        root = Document(**localized_root_attrs)
        root.__acl__ = SITE_ACL
        DBSession.add(root)
        localized_about_attrs = dict(
            [(k, localizer.translate(v)) for k, v in _ABOUT_ATTRS.iteritems()])
        root['about'] = Document(**localized_about_attrs)

        wf = get_workflow(root)
        if wf is not None:
            DBSession.flush()  # Initializes workflow
            wf.transition_to_state(root, None, u'public')

    populate_users()
Beispiel #3
0
 def _makeOne(self):
     from pyramid.i18n import LocalizerRequestMixin
     request = LocalizerRequestMixin()
     request.registry = self.config.registry
     request.cookies = {}
     request.params = {}
     return request
Beispiel #4
0
def populate():
    """
    Create the root node (:class:`~kotti.resources.Document`) and the 'about'
    subnode in the nodes tree if there are no nodes yet.
    """
    lrm = LocalizerRequestMixin()
    lrm.registry = get_current_registry()
    lrm.locale_name = get_settings()['pyramid.default_locale_name']
    localizer = lrm.localizer

    if DBSession.query(Node.id).count() == 0:
        pkgdir = os.path.dirname(__file__)
        pagesdir = os.path.join(pkgdir, 'static/pages')
        #import pdb ; pdb.set_trace()
        root_filename = os.path.join(pagesdir, 'index.md')
        root_atts = make_markdown_attrs('', root_filename,
                                        title='Welcome to XYZZY',
                                        description='Home Page')
        root_atts['body'] = markdown.markdown(root_atts['body'])
        root = Document(**root_atts)
        root.__acl__ = SITE_ACL
        DBSession.add(root)
        webatts = make_markdown_attrs('webdesign',
                                      os.path.join(
                                          pagesdir, 'webdesign/index.md'),
                                      title='Web Design',
                                      description='Pages on Web Design')
        root['webdesign'] = MarkDownDocument(**webatts)
        wpages = ['history', 'development', 'stylesheets',
                  'javascript-components']
        for wp in wpages:
            wpfn = os.path.join(pagesdir, 'webdesign/%s.md' % wp)
            wptitle = ' '.join([p.capitalize() for p in wp.split('-')])
            wpatts = make_markdown_attrs(wp, wpfn, title=wptitle)
            root['webdesign'][wp] = MarkDownDocument(**wpatts)
        
        wf = get_workflow(root)
        if wf is not None:
            DBSession.flush()  # Initializes workflow
            wf.transition_to_state(root, None, u'public')

    populate_users()
Beispiel #5
0
def populate():
    """
    Create the root node (:class:`~kotti.resources.Document`) and the 'about'
    subnode in the nodes tree if there are no nodes yet.
    """
    lrm = LocalizerRequestMixin()
    lrm.registry = get_current_registry()
    lrm.locale_name = get_settings()['pyramid.default_locale_name']
    localizer = lrm.localizer

    if DBSession.query(Node.id).count() == 0:
        localized_root_attrs = dict([(k, localizer.translate(v))
                                     for k, v in _ROOT_ATTRS.iteritems()])
        root = Document(**localized_root_attrs)
        root.__acl__ = SITE_ACL
        DBSession.add(root)
        localized_about_attrs = dict([(k, localizer.translate(v))
                                      for k, v in _ABOUT_ATTRS.iteritems()])
        root['about'] = Document(**localized_about_attrs)
        DBSession.flush()

    populate_users()