class DatastreamProfile(_FedoraBase): """:class:`~eulxml.xmlmap.XmlObject` for datastream profile information returned by :meth:`REST_API.getDatastream`.""" # default namespace is fedora manage ROOT_NAME = 'datastreamProfile' label = xmlmap.StringField('m:dsLabel') "datastream label" version_id = xmlmap.StringField('m:dsVersionID') "current datastream version id" created = FedoraDateField('m:dsCreateDate') "date the datastream was created" state = xmlmap.StringField('m:dsState') "datastream state (A/I/D - Active, Inactive, Deleted)" mimetype = xmlmap.StringField('m:dsMIME') "datastream mimetype" format = xmlmap.StringField('m:dsFormatURI') "format URI for the datastream, if any" control_group = xmlmap.StringField('m:dsControlGroup') "datastream control group (inline XML, Managed, etc)" size = xmlmap.IntegerField( 'm:dsSize') # not reliable for managed datastreams as of Fedora 3.3 "integer; size of the datastream content" versionable = xmlmap.SimpleBooleanField('m:dsVersionable', 'true', 'false') "boolean; indicates whether or not the datastream is currently being versioned" # infoType ? # location ? checksum = xmlmap.StringField('m:dsChecksum') "checksum for current datastream contents" checksum_type = xmlmap.StringField('m:dsChecksumType') "type of checksum" checksum_valid = xmlmap.SimpleBooleanField('m:dsChecksumValid', 'true', 'false') '''Boolean flag indicating if the current checksum is valid. Only
class _BaseMessage(_BaseCerp): '''Common message elements''' local_id = xmlmap.IntegerField('xm:LocalId') message_id = xmlmap.StringField('xm:MessageId') message_id_supplied = xmlmap.SimpleBooleanField('xm:MessageId/@Supplied', true='1', false=None) mime_version = xmlmap.StringField('xm:MimeVersion') orig_date_list = xmlmap.StringListField('xm:OrigDate') # FIXME: really datetime # NOTE: eulxml.xmlmap.DateTimeField supports specifying format, # but we might need additional work since %z only works with # strftime, not strptime from_list = xmlmap.StringListField('xm:From') sender_list = xmlmap.StringListField('xm:Sender') to_list = xmlmap.StringListField('xm:To') cc_list = xmlmap.StringListField('xm:Cc') bcc_list = xmlmap.StringListField('xm:Bcc') in_reply_to_list = xmlmap.StringListField('xm:InReplyTo') references_list = xmlmap.StringListField('xm:References') subject_list = xmlmap.StringListField('xm:Subject') comments_list = xmlmap.StringListField('xm:Comments') keywords_list = xmlmap.StringListField('xm:Keywords') headers = xmlmap.NodeListField('xm:Header', Header) single_body = xmlmap.NodeField('xm:SingleBody', SingleBody) multi_body = xmlmap.NodeField('xm:MultiBody', MultiBody) @property def body(self): return self.single_body or self.multi_body incomplete_list = xmlmap.NodeField('xm:Incomplete', Incomplete) def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self.message_id or self.local_id or '(no id)')
class TestObject(xmlmap.XmlObject): ROOT_NAME = 'foo' id = xmlmap.StringField('@id', verbose_name='My Id', help_text='enter an id') int = xmlmap.IntegerField('bar[2]/baz') bool = xmlmap.SimpleBooleanField('boolean', 'yes', 'no') longtext = xmlmap.StringField('longtext', normalize=True, required=False) date = xmlmap.DateField('date') child = xmlmap.NodeField('bar[1]', TestSubobject, verbose_name='Child bar1') children = xmlmap.NodeListField('bar', TestSubobject) other_child = xmlmap.NodeField('plugh', OtherTestSubobject) my_opt = xmlmap.StringField('opt', choices=['a', 'b', 'c']) text = xmlmap.StringListField('text') numbers = xmlmap.IntegerListField('number')
class Date(Common): ''':class:`~eulxml.xmlmap.XmlObject` for MODS date element (common fields for the dates under mods:originInfo).''' # this class not meant for direct use; should be extended for specific dates. date = xmlmap.StringField('text()') key_date = xmlmap.SimpleBooleanField('@keyDate', 'yes', false=None) encoding = xmlmap.SchemaField('@encoding', 'dateEncodingAttributeDefinition') point = xmlmap.SchemaField('@point', 'datePointAttributeDefinition') qualifier = xmlmap.SchemaField('@qualifier', 'dateQualifierAttributeDefinition') def is_empty(self): '''Returns False if no date value is set; returns True if any date value is set. Attributes are ignored for determining whether or not the date should be considered empty, as they are only meaningful in reference to a date value.''' return not self.node.text def __str__(self): return self.date
class ExtBodyContent(_BaseExternal, _BaseContent): ROOT_NAME = 'ExtBodyContent' local_id = xmlmap.IntegerField('xm:LocalId') xml_wrapped = xmlmap.SimpleBooleanField('xm:XMLWrapped', true='1', false='0')