コード例 #1
0
class TicketForm(BaseModifyForm):
    meta = TicketMetaForm
    backrefs = TicketBackRefForm
    message = OptionalMultilineText.using(label=L_("Message")).with_properties(rows=8, cols=80)
    data_file = File.using(optional=True, label=L_('Upload file:'))

    def _load(self, item):
        meta = item.prepare_meta_for_modify(item.meta)
        self['meta'].set(meta, 'duck')
        # XXX need a more explicit way to test for item creation/modification
        if ITEMID in item.meta:
            self['backrefs']._load(item)
コード例 #2
0
ファイル: content.py プロジェクト: rffontenelle/moin
    class ModifyForm(Form):
        """
        The content part of the ModifyForm of an Item subclass. See also the
        doc of Item._ModifyForm.
        """
        template = 'modify_binary.html'
        data_file = File.using(optional=True, label=L_('Upload file:'))

        def _load(self, item):
            pass

        def _dump(self, item):
            data_file = self['data_file'].value
            if data_file:
                data = data_file.stream
                # this is likely a guess by the browser, based on the filename
                contenttype_guessed = data_file.content_type  # comes from form multipart data
                return data, contenttype_guessed
            else:
                return None, None