Ejemplo n.º 1
0
 def call(self, method, args=(), errorValue=ERROR_MARKER):
     path = self.servicePath[:] + [method]
     response = Response()
     env = {
         'SERVER_NAME': 'dummy',
         'SERVER_PORT': '8080',
         'PATH_INFO': '/' + '/'.join(path)
     }
     request = HTTPRequest(None, env, response)
     request.args = args
     conn = self.db.open()
     root = conn.root()
     request['PARENTS'] = [root['Application']]
     try:
         try:
             ZPublisher.Publish.publish(request, 'Zope2', [None])
         except Exception, error:
             # This thread should never crash, thus a blank except
             log.error('Processor: ``%s()`` caused an error!' % method)
             log.exception(error)
             return errorValue is ERROR_MARKER and error or errorValue
     finally:
         request.close()
         conn.close()
         return request.response.body
Ejemplo n.º 2
0
 def call(self, method, args=(), errorValue=ERROR_MARKER):
     path = self.servicePath[:] + [method]
     response = Response()
     env = {'SERVER_NAME': 'dummy',
             'SERVER_PORT': '8080',
             'PATH_INFO': '/' + '/'.join(path)}
     request = HTTPRequest(None, env, response)
     request.args = args
     conn = self.db.open()
     result = ''
     try:
         try:
             root = conn.root()
             request['PARENTS'] = [root['Application']]
             ZPublisher.Publish.publish(request, 'Zope2', [None])
             result = request.response.body
         except NotFound, error:
             log.warning('NotFound when traversing to %s' % '/'.join(path))
         except Exception, error:
             # This thread should never crash, thus a blank except
             log.error('Processor: ``%s()`` caused an error!' % method)
             log.exception(error)
             result = errorValue is ERROR_MARKER and error or errorValue