Changeset 18 for trunk

Show
Ignore:
Timestamp:
11/29/09 17:58:55 (9 months ago)
Author:
guillaume
Message:

. Update API callbacks parameters (filename => docid, fileid => docid)
. Correct minor bug: if pagenum < 0 or pagenum >= pages

Location:
trunk/backend/python-wsgi
Files:
1 modified
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/backend/python-wsgi/dare-dare.wsgi

    r2 r18  
    4242                """ 
    4343                self.callbacks = { 
    44                         'open'  : (self.open    , ('!filename',)), 
    45                         'read'  : (self.read    , ('!fileid', '!pagenum', '?resolution')), 
    46                         'close' : (self.close   , ('!fileid',)), 
     44                        'open'  : (self.open    , ('!docid',)), 
     45                        'read'  : (self.read    , ('!docid', '!pagenum', '?resolution')), 
     46                        'close' : (self.close   , ('!docid',)), 
    4747                } 
    4848 
     
    9898                return data 
    9999 
    100         def open(self, fileid): 
     100        def open(self, docid): 
    101101                """Open a new pdf document. 
    102102 
     
    110110                """ 
    111111                if '/' in fileid: 
    112                         return('400 Bad Request', [], ['"', fileid, '" contains invalid caracters']) 
     112                        return('400 Bad Request', [], ['"', fileid, '" contains invalid characters']) 
    113113                         
    114114                lgname = '/'.join((self.tempdir, fileid, 'src.pdf')) 
     
    128128                        [json.encode({'fileid': fileid, 'numpages': numpages, 'width': x, 'height': y})]) 
    129129 
    130         def read(self, fileid, pagenum, resolution=None): 
     130        def read(self, docid, pagenum, resolution=None): 
    131131                """Read a page of an opened pdf document. 
    132132                        The result is return as a pdf image 
     
    157157                pages = doc.get_n_pages() 
    158158 
    159                 if pagenum < 0 or pagenum > pages: 
     159                if pagenum < 0 or pagenum >= pages: 
    160160                        return('404 Not Found', [], ['pagenum out of bounds']) 
    161161 
     
    206206                ) 
    207207 
    208         def close(self, fileid): 
     208        def close(self, docid): 
    209209                """Closing a document.  
    210210                        We should remove the document temp directory and all associated files