Commits

Anonymous committed b412492

store extra options from settings.ini and pass them to the database,
fix asset download handling

Comments (0)

Files changed (1)

                 asset['md5'] == filename):
                 break
         else:
-            return req.send_status('404 File not Found',
-                                   'The asset "%s" does not exist' % filename)
+            return req.send_status(
+                '404 File not Found',
+                'The asset "%s" does not exist' % filename)
             
-        assetpath = config.get_asset_path(id, asset)
+        if not os.path.isfile(asset['path']):
+            return req.send_status(
+                '404 File not Found',
+                'The asset file "%s" does not exist' % filename)
 
-        if not os.path.isfile(assetpath):
-            return req.send_status('404 File not Found',
-                                   'The asset file "%s" does not exist' % filename)
-
-        
-        return req.send_file(assetpath,
+        return req.send_file(asset['path'],
                              asset['mimetype'].encode('ascii'))
 
     def allow_download(self, url, config):
         
         oai_server = OAIServer(self._db, config)
         try:
-            header, metadata, descriptio = oai_server.getRecord(
-                'oai_dc', config.get_oai_id(id))
+            header, metadata, description = oai_server.getRecord(
+                'oai_dc', config.oai_id_prefix + id)
         except oaipmh.error.IdDoesNotExistError:
             # record is not in the oai feed, don't download
             return False
         return False
             
     def handle_request(self, req):
-
         if not req.url().startswith(self.base_url):
-            return req.send_status('500 Internal Server Error',
-                 'The url "%s" does not start with base url "%s".' % (req.url(),
-                                                                      self.base_url))
+            return req.send_status(
+                '500 Internal Server Error',
+                'The url "%s" does not start with base url "%s".' % (
+                req.url(), self.base_url))
         url = req.url()[len(self.base_url):]
         
         if url.startswith('/'):
                  sets_disallowed = None,
                  sets_deleted = None,
                  filter_sets = None,
-                 delay = 0,
-                 base_asset_path=None,
-                 ):
-        
+                 extra_args = None):
+        extra_args = extra_args or {}
         self.name = repository_name
         self.url = base_url
         self.admins = admin_emails or []
         self.sets_disallowed = set(sets_disallowed or [])
         self.sets_deleted = set(sets_deleted or [])
         self.filter_sets = set(filter_sets or [])
-        self.delay = delay
-        self.base_asset_path = base_asset_path or tempfile.gettempdir()
+        self.delay = extra_args.get('delay', 0)
+        self.base_asset_path = extra_args.get('base_asset_path',
+                                              tempfile.gettempdir())
+        self.oai_id_prefix = extra_args.get('oai_id_prefix', '')
+        
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.