コード例 #1
0
ファイル: form.py プロジェクト: runyaga/ptah

class DisplayForm(Form):

    mode = FORM_DISPLAY

    def form_params(self):
        return self.params


FORM_VIEW = 'form-view'
FORM_ACTIONS = 'form-actions'
FORM_WIDGET = 'form-widget'
FORM_DISPLAY_WIDGET = 'form-display-widget'

ptah.register_snippet(FORM_VIEW, Form, renderer='ptah.form:templates/form.pt')

ptah.register_snippet(FORM_VIEW,
                      DisplayForm,
                      renderer='ptah.form:templates/form-display.pt')

ptah.register_snippet(FORM_ACTIONS,
                      Form,
                      renderer='ptah.form:templates/form-actions.pt')

ptah.register_snippet(FORM_WIDGET,
                      Field,
                      renderer='ptah.form:templates/widget.pt')

ptah.register_snippet(FORM_DISPLAY_WIDGET,
                      Field,
コード例 #2
0
ファイル: form.py プロジェクト: runyaga/ptah
class DisplayForm(Form):

    mode = FORM_DISPLAY

    def form_params(self):
        return self.params


FORM_VIEW = 'form-view'
FORM_ACTIONS = 'form-actions'
FORM_WIDGET = 'form-widget'
FORM_DISPLAY_WIDGET = 'form-display-widget'

ptah.register_snippet(
    FORM_VIEW, Form,
    renderer='ptah.form:templates/form.pt')

ptah.register_snippet(
    FORM_VIEW, DisplayForm,
    renderer='ptah.form:templates/form-display.pt')

ptah.register_snippet(
    FORM_ACTIONS, Form,
    renderer='ptah.form:templates/form-actions.pt')

ptah.register_snippet(
    FORM_WIDGET, Field,
    renderer='ptah.form:templates/widget.pt')

ptah.register_snippet(
コード例 #3
0
        content = self.create(**data)

        self.message('New content has been created.')
        return HTTPFound(location=self.get_next_url(content))

    @form.button('Cancel')
    def cancel_handler(self):
        return HTTPFound(location='.')

    def get_next_url(self, content):
        return self.request.resource_url(content)


ptah.register_snippet('form-actions',
                      AddForm,
                      renderer='ptah.cms:form-actions.pt')


class EditForm(form.Form):
    @reify
    def label(self):
        return 'Modify content: %s' % self.tinfo.title

    @reify
    def fields(self):
        return self.tinfo.fieldset

    def form_content(self):
        data = {}
        for name, field in self.tinfo.fieldset.items():
コード例 #4
0
ファイル: forms.py プロジェクト: runyaga/ptah
            return

        content = self.create(**data)

        self.message('New content has been created.')
        return HTTPFound(location=self.get_next_url(content))

    @form.button('Cancel')
    def cancel_handler(self):
        return HTTPFound(location='.')

    def get_next_url(self, content):
        return self.request.resource_url(content)


ptah.register_snippet(
    'form-actions', AddForm, renderer='ptah.cms:form-actions.pt')


class EditForm(form.Form):

    @reify
    def label(self):
        return 'Modify content: %s'%self.tinfo.title

    @reify
    def fields(self):
        return self.tinfo.fieldset

    def form_content(self):
        data = {}
        for name, field in self.tinfo.fieldset.items():