Beispiel #1
0
    def get_class_schema(cls, request=None):
        schema = Content.get_class_schema(request)
        #schema.add(colander.SchemaNode(colander_types.DateUS(), name='dateline', default=today_for_request_tz(request)))
        schema.add(colander.SchemaNode(colander_types.DateTimeUS(get_timezone_for_request(request)), name='dateline', default=utcnow()))
        schema.add(colander.SchemaNode(colander.String(), name='body', widget=widgets.get_html_widget()))
        # Single file upload:
        #schema.add(colander.SchemaNode(deform.FileData(), name='attachment', widget=widgets.get_fileupload_widget(request)))

        # Sequence of file uploads:
        schema.add(colander.SchemaNode(colander.Sequence(), colander.SchemaNode(deform.FileData(), widget=widgets.get_fileupload_widget(request)), name='attachments', missing=[], default=[]))
        schema.add(colander.SchemaNode(colander.Boolean(), name='list_attachments', title="List attachments after body?", default=False, missing=False))

        return schema
Beispiel #2
0
 def localize_datetime_attribute(self, name):
     value = getattr(self, name, None)
     if value:
         return dateutil.convert_from_utc(value, dateutil.get_timezone_for_request(self.request))
     else:
         return None