Changeset 8cae994


Ignore:
Timestamp:
Oct 17, 2011 11:59:52 AM (3 years ago)
Author:
yomguy <yomguy@…>
Branches:
master, crem, crem2, crem3, dev, dev2, diadems, dj1.6, feature/breadcrumbs, feature/ts-0.5, feature/ts-0.5.4, feature/writecache, forma, generic, instru_search, lam, lam2, mapsv3, merge, nlivemulti, production, release/1.4.4, sabiod, search, security, server, social, storage, telecaster, test, video
Children:
2959f8a
Parents:
c664814
git-author:
yomguy <yomguy@…> (17/10/2011 11:59:52)
git-committer:
yomguy <yomguy@…> (17/10/2011 11:59:52)
Message:

OAI fix : better id management (database id by default), split multiple coverage, repositoryName becomes settings.TELEMETA_ORGANIZATION

Location:
telemeta
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • telemeta/interop/oai.py

    rfac4a3b r8cae994  
    409409            container.appendChild(self.make_record(id, dc, ctime)) 
    410410 
     411    def format_id_header(self, id): 
     412        organization = self.identity[0][1]  
     413        if 'http' in id: 
     414            return ':'.join(['oai', organization.lower(), 'items', id.split('/')[-1]]) 
     415        else: 
     416            return id 
     417     
    411418    def list_records(self, from_time, until_time, token = None, ids_only = False): 
    412419        """Append ListIdentifiers or ListRecords result""" 
     
    457464                dc, ctime = item 
    458465                id, dc = self.parse_dc(dc) 
     466                id = self.format_id_header(id) 
    459467                if id == None: 
    460468                    raise Exception("DataSource.list_records() didn't provide an 'identifier' dublin core element") 
  • telemeta/models/dublincore.py

    ra0b0f45 r8cae994  
    163163 
    164164    resource = Resource( 
     165        Element('record_identifier', collection.public_id, related=collection), 
    165166        Element('identifier',       media_identifier(collection), related=collection), 
    166167        Element('type',             'Collection'), 
     
    214215 
    215216    resource = Resource( 
     217        Element('record_identifier', item.public_id, related=item), 
    216218        Element('identifier',       media_identifier(item), related=item), 
    217219        Element('type',             'Sound'), 
     
    227229        date, 
    228230        Date(item.collection.year_published, refinement='issued'), 
    229         Element.multiple('coverage', item.location and item.location.fullnames(), 'spatial'), 
     231        Element.multiple('coverage', item.location and item.location.listnames(), 'spatial'), 
    230232        Element('coverage',         item.location_comment, 'spatial'), 
    231233        Element('rights',           item.collection.legal_rights, 'license'), 
     
    249251def lookup_resource(media_id): 
    250252    try: 
    251         type, code = media_id.split(':', 1) 
     253        id = media_id.split(':') 
     254        type = id[-2] 
     255        code = id[-1] 
    252256    except ValueError: 
    253257        raise MalformedMediaIdentifier("Media identifier must be in type:code format") 
    254258     
    255     if (type == 'collection'): 
     259    if (type == 'collection') or (type == 'collections'): 
    256260        try: 
    257261            return MediaCollection.objects.get(code=code) 
    258262        except MediaCollection.DoesNotExist: 
    259263            return None 
    260     elif (type == 'item'): 
     264    elif (type == 'item') or (type == 'items'): 
    261265        try: 
    262266            return MediaItem.objects.get(code=code) 
     
    265269                return MediaItem.objects.get(old_code=code) 
    266270            except MediaItem.DoesNotExist: 
    267                 return None 
     271                try: 
     272                    return MediaItem.objects.get(id=code) 
     273                except MediaItem.DoesNotExist: 
     274                    return None 
    268275    else: 
    269276        raise MalformedMediaIdentifier("No such type in media identifier: " + type) 
  • telemeta/models/location.py

    r9acae9b r8cae994  
    145145            names.append(u', '.join([unicode(l) for l in path])) 
    146146        return names 
     147         
     148    def listnames(self): 
     149        names = [] 
     150        for path in self.paths(): 
     151            for l in path: 
     152                names.append(unicode(l)) 
     153        return names 
    147154 
    148155class LocationType(ModelCore): 
  • telemeta/urls.py

    ra313776 r8cae994  
    238238 
    239239    # Authentication 
    240     url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'}, 
     240    url(r'^login/$', 'ipauth.views.login', {'template_name': 'telemeta/login.html'}, 
    241241        name="telemeta-login"), 
    242242    url(r'^logout/$', general_view.logout, name="telemeta-logout"), 
  • telemeta/web/base.py

    rc664814 r8cae994  
    205205        host = request.META['HTTP_HOST'] 
    206206        datasource  = TelemetaOAIDataSource() 
    207         repository_name = settings.TELEMETA_DESCRIPTION 
     207        repository_name = settings.TELEMETA_ORGANIZATION 
    208208        url         = 'http://' + host + request.path 
    209209        admin       = settings.ADMINS[0][1] 
Note: See TracChangeset for help on using the changeset viewer.