示例#1
0
 def handle_request(self, request):
     response = Response(request)
     try:
         h = self.find_handler(request)
         h.handle(request)
     except Exception,e:
         msglog.exception()
         response.send_error(500)
示例#2
0
 def handle_request(self, request):
     response = Response(request)
     try:
         h = self.find_handler(request)
         h.handle(request)
     except Exception, e:
         msglog.exception()
         response.send_error(500)
示例#3
0
 def handle_request(self, request):
     user = request.user_object()
     response = Response(request)
     node = self.get_node(request.get_path())
     try:
         domnode = IDomNode(node)
         webnode = IWebContent(domnode)
     except ComponentLookupError, error:
         response['Content-Type'] = 'text/plain'
         response.send_error(404, 'No adapter for requested node.')
示例#4
0
 def handle_request(self, request):
     user = request.user_object()
     response = Response(request)
     node = self.get_node(request.get_path())
     try:
         domnode = IDomNode(node)
         webnode = IWebContent(domnode)
     except ComponentLookupError, error:
         response['Content-Type'] = 'text/plain'
         response.send_error(404, 'No adapter for requested node.')
示例#5
0
 def handle_request(self, request):
     response = Response(request)
     data = request.get_post_data_as_dictionary()
     data.update(request.get_query_string_as_dictionary())
     if data.has_key("node"):
         nodeurl = urllib.unquote_plus(data["node"][0])
     else:
         nodeurl = "/services/time/local"
     try:
         adapt = self.__handle_by_context(nodeurl, request, data)
     except TypeError, error:
         msglog.exception(prefix="handled")
         response.send_error(500, str(error))
示例#6
0
 def handle_request(self, request):
     response = Response(request)
     data = request.get_post_data_as_dictionary()
     data.update(request.get_query_string_as_dictionary())
     if data.has_key("node"):
         nodeurl = urllib.unquote_plus(data["node"][0])
     else:
         nodeurl = "/services/time/local"
     try:
         adapt = self.__handle_by_context(nodeurl, request, data)
     except TypeError, error:
         msglog.exception(prefix="handled")
         response.send_error(500, str(error))
示例#7
0
 def handle(self,request):
     response = Response(request)
     qd = request.get_query_dictionary()
     data = self.get_data(qd)   
     request_path = urllib.unquote(string.lower(request.get_path()))
     file_path = os.path.join(self.parent.http_published_root, request_path[1:])
     if os.path.isfile(file_path):
         html = open(file_path).read()
         tokens = {}
         tokens['RECORDS'] = self.get_html(data)
         html = self.replace_tokens(html,tokens)
         response.send(html)
     else:
         response.send_error(404)
示例#8
0
 def handle(self, request):
     response = Response(request)
     qd = request.get_query_dictionary()
     data = self.get_data(qd)
     request_path = urllib.unquote(string.lower(request.get_path()))
     file_path = os.path.join(self.parent.http_published_root,
                              request_path[1:])
     if os.path.isfile(file_path):
         html = open(file_path).read()
         tokens = {}
         tokens['RECORDS'] = self.get_html(data)
         html = self.replace_tokens(html, tokens)
         response.send(html)
     else:
         response.send_error(404)
示例#9
0
 def handle_request(self, request):
     user = request.user_object()
     if user is not None and user.name() == 'eweb':
         request.error(401)
     response = Response(request)
     response_sent = 0
     try:
         html = self._get_pre_body_tag()
         html += '<body>'
         if self.debug:
             mpx.lib.msglog.log('broadway',mpx.lib.msglog.types.INFO,
                                 'handler_request called for device_viewer')
         if not self.enabled:
             html += '<span class="disabled_msg">Sorry, the handler for your request is currently disabled.</span>\n'
         else:
             path = request.get_path()
             if path[-1] == '/':
                 path = path[0:-1]
             node_url = path[len(self.request_path):]
             if node_url=='':
                 node_url = '/'
             html += self._make_links(node_url) + '<p>\n'
             if request.has_query():
                 # This request was for an action becuause it has
                 # parameters.
                 parameters = request.get_query_dictionary()
                 if parameters['action'] == 'get_override':
                     try:
                         value = self._get(node_url)
                     except Exception,e:
                         value = self._get_exception_name(e)
                     html  += string.join(self.override_form(path,value))
                 elif parameters['action'] == 'set_override':
                     if parameters.has_key('value'):
                         value = parameters['value']
                     else:
                         value = ""
                     value = _holistic_conversion(value)
                     self._as_node(node_url).set(value)
                     html += '<h3>Your override has been sent</h3>'
                 elif parameters['action'] == 'debug_on' or parameters['action'] == 'debug_off':
                     try:
                         node = mpx.lib.node.as_internal_node(node_url)
                         if parameters['action'] == 'debug_on':
                             node.debug = 1
                             html += 'Debugging turned on'
                         else:
                             node.debug = 0
                             html += 'Debugging turned off'
                     except Exception,e:
                         msg = self._get_exception_msg(e)
                         html += msg
                 elif parameters['action'] == 'invoke':
                     args = ()
                     method = None
                     if parameters.has_key('method'):
                         method = parameters['method']
                     if parameters.has_key('Content-Type'):
                         content_type = parameters['Content-Type']
                     else:
                         content_type = 'text/plain'
                     try:
                         node = mpx.lib.node.as_internal_node(node_url)
                         if method is not None:
                             if parameters.get('parameters',0):
                                 result = getattr(node,method)(*args, **parameters)
                             else:
                                 result = getattr(node,method)(*args)
                         else:
                             result = node(*args)
                         if hasattr(result,'read'):
                             from mpx.service.network.http import producers
                             if hasattr(result,'close'):
                                 result = producers.FileProducer(result)
                             else:
                                 result = producers.StreamingProducer(
                                     result
                                     )
                         else:
                             result = str(result)
                         response['Content-Type'] = content_type
                         response.send(result)
                         response_sent = 1
                         return
                     except Exception,e:
                         message = "%s: %s" % (e.__class__, str(e))
                         response['Content-Type'] = 'text/plain'
                         response.send_error(400,message)
                         response_sent = 1
                         return