コード例 #1
0
ファイル: models.py プロジェクト: shentonfreude/DubCore
def appmaker(zodb_root):
    if not 'app_root' in zodb_root:
        app_root = Pages()
        zodb_root['app_root'] = app_root

        dublincore = {'title':'Page 1',
                      'date': datetime.date.today(),
                      'description': 'Not much to say',
                      }
        page1 = Page("This is the first page", dublincore)
        __name__ = canonize(page1.dublincore['title'])
        app_root[__name__] = page1

        import transaction
        transaction.commit()
    return zodb_root['app_root']
コード例 #2
0
ファイル: views.py プロジェクト: shentonfreude/DubCore
def page_add(context, request):
    add_or_edit = 'Add'
    schema = PageSchema()
    form = Form(schema, buttons=('submit',))
    form['data'].widget = widget.RichTextWidget(width=390, theme="advanced")
    if 'submit' in request.params:
        controls = request.POST.items()
        try:
            appstruct = form.validate(controls)
        except ValidationFailure, e:
            return {'project': PROJECT,
                    'form': e.render(),
                    'add_or_edit': add_or_edit}
        # Is there a way to get this -- the date especialy -- from the schema?
        dublincore = {'title': appstruct['title'],
                      'description': appstruct['description'],
                      'date': datetime.date.today(),
                      }
        page = Page(appstruct['data'], dublincore=dublincore)
        __name__ = canonize(appstruct['title'])
        context[__name__] = page
        return HTTPFound(location=model_url(page, request))