Changeset d160e4d in indico


Ignore:
Timestamp:
08/23/11 15:38:54 (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.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
4dd9bd0
Parents:
c5fcd0
git-author:
Pedro Ferreira <jose.pedro.ferreira@…> (05/25/11 09:09:23)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (08/23/11 15:38:54)
Message:

[IMP] HTTP API - Several small fixes

Location:
indico
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • indico/util/fossilize/__init__.py

    rcfffdf8 rd160e4d  
    5757        zope.interface.classImplements(klazz, fossil) 
    5858 
     59 
    5960def clearCache(): 
    6061    """ 
     
    6364    Fossilizable.clearCache() 
    6465 
     66 
    6567class NonFossilizableException(Exception): 
    6668    """ 
    6769    Object is not fossilizable (doesn't implement Fossilizable) 
    6870    """ 
     71 
    6972 
    7073class InvalidFossilException(Exception): 
     
    7477    """ 
    7578 
     79 
    7680class IFossil(zope.interface.Interface): 
    7781    """ 
    7882    Fossil base interface. All fossil classes should derive from this one. 
    7983    """ 
     84 
    8085 
    8186class Fossilizable(object): 
     
    187192        return interface 
    188193 
     194 
    189195    @classmethod 
    190196    def clearCache(cls): 
     
    193199        """ 
    194200        cls.__fossilAttrsCache = {} 
     201 
    195202 
    196203    @classmethod 
  • indico/util/metadata/serializer.py

    ra71221 rd160e4d  
    1818## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 
    1919## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
     20 
    2021 
    2122class Serializer(object): 
  • indico/web/http_api/handlers.py

    rdb9819 rd160e4d  
    2626import hashlib 
    2727import hmac 
    28 import itertools 
    2928import re 
    3029import time 
     
    3231from urlparse import parse_qs 
    3332from ZODB.POSException import ConflictError 
    34 import pytz 
    3533 
    3634# indico imports 
    37 from indico.web.http_api import ExportInterface, LimitExceededException, Exporter 
     35from indico.web.http_api import Exporter 
    3836from indico.web.http_api.auth import APIKeyHolder 
    3937from indico.web.http_api.cache import RequestCache 
    4038from indico.web.http_api.responses import HTTPAPIResult, HTTPAPIError 
    4139from indico.web.http_api.util import remove_lists, get_query_parameter 
    42 from indico.web.http_api import API_MODE_KEY, API_MODE_ONLYKEY, API_MODE_SIGNED, API_MODE_ONLYKEY_SIGNED, API_MODE_ALL_SIGNED 
     40from indico.web.http_api import API_MODE_ONLYKEY, API_MODE_SIGNED, API_MODE_ONLYKEY_SIGNED, API_MODE_ALL_SIGNED 
    4341from indico.web.wsgi import webinterface_handler_config as apache 
    4442from indico.util.metadata.serializer import Serializer 
     
    4644# indico legacy imports 
    4745from MaKaC.common import DBMgr 
    48 from MaKaC.common.fossilize import fossilizes, fossilize, Fossilizable 
     46from MaKaC.common.logger import Logger 
     47from MaKaC.common.fossilize import fossilize 
    4948from MaKaC.accessControl import AccessWrapper 
    5049from MaKaC.common.info import HelperMaKaCInfo 
    51 from MaKaC.plugins.base import PluginsHolder 
    52  
    53 # Maximum number of records that will get exported for each detail level 
    54 MAX_RECORDS = { 
    55     'events': 10000, 
    56     'contributions': 500, 
    57     'subcontributions': 500, 
    58     'sessions': 100, 
    59 } 
    60  
    61 # Valid URLs for export handlers. the last group has to be the response type 
    62 EXPORT_URL_MAP = { 
    63     r'/export/(event|categ)/(\w+(?:-\w+)*)\.(\w+)$': 'handler_event_categ' 
    64 } 
    65  
    66 # Compile url regexps 
    67 EXPORT_URL_MAP = dict((re.compile(pathRe), handlerFunc) for pathRe, handlerFunc in EXPORT_URL_MAP.iteritems()) 
     50 
     51 
    6852# Remove the extension at the end or before the querystring 
    6953RE_REMOVE_EXTENSION = re.compile(r'\.(\w+)(?:$|(?=\?))') 
     
    135119 
    136120def handler(req, **params): 
     121    logger = Logger.get('httpapi') 
    137122    path, query = req.URLFields['PATH_INFO'], req.URLFields['QUERY_STRING'] 
    138123    # Parse the actual query string 
     
    173158 
    174159        obj = None 
    175         add_to_cache = True 
     160        addToCache = True 
    176161        cache_key = RE_REMOVE_EXTENSION.sub('', cache_key) 
    177162        if not no_cache: 
     
    180165                result, complete, typeMap = obj.getContent() 
    181166                ts = obj.getTS() 
    182                 add_to_cache = False 
     167                addToCache = False 
    183168        if result is None: 
    184169            # Perform the actual exporting 
    185170            result, complete, typeMap = func(aw) 
    186         if result is not None and add_to_cache: 
     171        if result is not None and addToCache: 
    187172            cache.cacheObject(cache_key, (result, complete, typeMap)) 
    188173    except HTTPAPIError, e: 
     
    222207 
    223208        req.headers_out['Content-Type'] = serializer.getMIMEType() 
    224         return serializer(resultFossil) 
     209 
     210        try: 
     211            return serializer(resultFossil) 
     212        except: 
     213            logger.exception('Serialization error in request %s?%s' % (path, query)) 
     214            raise 
Note: See TracChangeset for help on using the changeset viewer.