Changeset a3fc2e in indico for indico/web/http_api/api.py


Ignore:
Timestamp:
09/19/11 14:40:44 (21 months ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.99, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 10eafd9ae230cbad5d99d5aaf22c24724fb6c98f
Children:
2cb1cc
Parents:
03c6d2d (diff), b2a7f8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'v0.98b2' into v0.98-series

Conflicts:

indico/web/http_api/api.py
indico/web/http_api/handlers.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/web/http_api/api.py

    r03c6d2d ra3fc2e  
    4545from indico.web.http_api.fossils import IConferenceMetadataFossil,\ 
    4646    IConferenceMetadataWithContribsFossil, IConferenceMetadataWithSubContribsFossil,\ 
    47     IConferenceMetadataWithSessionsFossil, IPeriodFossil 
     47    IConferenceMetadataWithSessionsFossil, IPeriodFossil, ICategoryMetadataFossil,\ 
     48    ICategoryProtectedMetadataFossil 
    4849from indico.web.http_api.responses import HTTPAPIError 
    4950from indico.web.wsgi import webinterface_handler_config as apache 
     
    5152# indico legacy imports 
    5253from MaKaC.common.db import DBMgr 
     54from MaKaC.conference import CategoryManager 
    5355from MaKaC.common.indexes import IndexesHolder 
    5456from MaKaC.common.info import HelperMaKaCInfo 
     
    204206            raise NotImplementedError(self.PREFIX + '_' + self._type) 
    205207 
     208        extraFunc = getattr(self, self.PREFIX + '_' + self._type + '_extra', None) 
     209        extra = extraFunc(aw) if extraFunc else None 
     210 
    206211        if not self.COMMIT: 
    207212            # Just execute the function, we'll never have to repeat it 
     
    222227                raise HTTPAPIError('An unresolvable database conflict has occured', apache.HTTP_INTERNAL_SERVER_ERROR) 
    223228 
    224         return resultList, complete, self.SERIALIZER_TYPE_MAP 
     229        return resultList, extra, complete, self.SERIALIZER_TYPE_MAP 
    225230 
    226231 
     
    408413        return expInt.category(self._idList) 
    409414 
     415    def export_categ_extra(self, aw): 
     416        return { 
     417            'categHierarchy': CategoryEventFetcher.getCategoryPath(self._idList, aw) 
     418        } 
     419 
    410420    def export_event(self, aw): 
    411421        expInt = CategoryEventFetcher(aw, self) 
     
    429439    def _postprocess(self, obj, fossil, iface): 
    430440        return self._addOccurrences(fossil, obj, self._fromDT, self._toDT) 
     441 
     442    @classmethod 
     443    def getCategoryPath(cls, idList, aw): 
     444        paths = {} 
     445        for id in idList: 
     446            paths['categ_' + id] = cls._getCategoryPath(id, aw) 
     447        return paths 
     448 
     449    @staticmethod 
     450    def _getCategoryPath(id, aw): 
     451        path = [] 
     452        cat = CategoryManager().getById(id) 
     453        while cat: 
     454            iface = ICategoryMetadataFossil if cat.canAccess(aw) else ICategoryProtectedMetadataFossil 
     455            path.append(fossilize(cat, iface)) 
     456            cat = cat.getOwner() 
     457        path.reverse() 
     458        return path 
    431459 
    432460    @staticmethod 
Note: See TracChangeset for help on using the changeset viewer.