Changeset 4244 for exist


Ignore:
Timestamp:
29/09/08 12:41:03 (11 years ago)
Author:
cbyrom
Message:

Add code to allow input/edit of online references + fix author/contributor
data to conform to the Atom 'email' convention - i.e. using an email
attribute instead of a uri one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4240 r4244  
    4747        self.role = "" 
    4848         
     49        # NB, the atom format specifies slightly different data contents 
     50        self.uriTagName = "email" 
    4951        # NB, responsible party data is always stored in the moles section 
    5052        if self.type == self.RESPONSIBLE_PARTY_TYPE: 
    5153            self.ns = 'moles' 
     54            self.uriTagName = "uri" 
    5255 
    5356    def __str__(self): 
     
    6265        self.name = personTag.findtext('name') or "" 
    6366        self.role = personTag.findtext('role') or "" 
    64         self.uri = personTag.findtext('uri') or "" 
    65         logging.debug("Added name: '%s', role: '%s', uri: '%s'" \ 
    66                       %(self.name, self.role, self.uri)) 
     67        self.uri = personTag.findtext(self.uriTagName) or "" 
     68        logging.debug("Added name: '%s', role: '%s', %s: '%s'" \ 
     69                      %(self.name, self.role, self.uriTagName, self.uri)) 
    6770 
    6871    def toXML(self): 
     
    7881         
    7982        if self.uri: 
    80             uri = ET.SubElement(author, prefix + "uri") 
     83            uri = ET.SubElement(author, prefix + self.uriTagName) 
    8184            uri.text = self.uri 
    8285         
     
    123126        return link 
    124127 
     128    def hasValue(self): 
     129        if self.href or self.title or self.rel: 
     130            return True 
     131        return False 
     132 
     133 
    125134 
    126135class Category(): 
     
    151160class Atom(object): 
    152161 
     162    # labels for use with the atom categories 
    153163    ATOM_TYPE = "ATOM_TYPE" 
    154164    ATOM_SUBTYPE = "ATOM_SUBTYPE" 
     165 
     166    # labels for use with the templates to set/extract specific inputs 
     167    ONLINE_REF_LABEL = "online_ref" 
     168 
    155169 
    156170    def __init__(self, atomType = None, vocabTermData = None, ndgObject = None, \ 
     
    399413         
    400414        for relatedLink in self.relatedLinks: 
    401             root.append(relatedLink.toXML()) 
     415            if relatedLink.hasValue(): 
     416                root.append(relatedLink.toXML()) 
    402417         
    403418        for logo in self.logos: 
    404             root.append(logo.toXML()) 
     419            if logo.hasValue(): 
     420                root.append(logo.toXML()) 
    405421     
    406422    def toXML(self): 
Note: See TracChangeset for help on using the changeset viewer.