Esempio n. 1
0
 def operation_report_result_set(self, req, args):
     """
     Run a report, generating a result set.
     """
     dbconn = self._connect_db()
     table_name = args['report']
     del args['report']
     server_modified = DBQueries.get_table_lastupdate(dbconn, table_name)
     headers = [(
         'Last-Modified',
         format_date_time(mktime(server_modified.timetuple()))
     )]
     # Handle conditional requests
     if not args:
         if (
             req.if_modified_since and
             req.if_modified_since >= server_modified
         ):
             return (webob.exc.HTTPNotModified(), headers)
     try:
         result_set = DBQueries.filter_table(dbconn, table_name, args)
         # Pylint warns about catch-all exception handlers like that below.
         # The rationale is that this "prohibits the use of tailored
         # responses" - but that is exactly what we are attempting to do.
         # So just disable the warning.
         # pylint: disable=W0702
     except:
         # Don't leak information about the database
         return (webob.exc.HTTPBadRequest(), [])
     return (result_set, headers)
Esempio n. 2
0
 def _get_report_details(self, dbconn, report_name):
     """
     Return details about the given-named report.
     """
     return dict(
         name=report_name,
         description=DBQueries.get_table_comment(
             dbconn, self.dbname, report_name
         ),
         lastUpdated=DBQueries.get_table_lastupdate(
             dbconn, report_name
         ),
         links=self._get_report_links(report_name)
     )