コード例 #1
0
	def get_library(self, name):
		if not is_valid_identifier(name):
			raise SOAPpy.faultType(lib_name_error, _("Incorrect library name"), "")
		self.__sem.lock()
		try:
			library = None
			for child in self.libraries_element.children:
				if name == child.attributes["name"]:
					library = child
					break
			if not library:
				raise SOAPpy.faultType(lib_name_error, _("No such library '%s'" % name), "")
			return library.toxml(encode = False)
		finally:
			self.__sem.unlock()
コード例 #2
0
 def _methodNotFound(self, request, methodName):
     response = SOAPpy.buildSOAP(
         SOAPpy.faultType("%s:Client" % SOAPpy.NS.ENV_T,
                          "Method %s not found" % methodName),
         encoding=self.encoding,
     )
     self._sendResponse(request, response, status=500)
コード例 #3
0
	def set_library(self, name, data):
		if not is_valid_identifier(name):
			raise SOAPpy.faultType(lib_name_error, _("Incorrect library name"), "")
		self.__sem.lock()
		try:
			item = None
			for child in self.libraries_element.children:
				if name == child.attributes["name"]:
					item = child
					break
			if item:
				item.value = data
			else:
				x = xml_object(name="Library")
				x.attributes["Name"] = name
				self.libraries_element.children.append(x)
				x.value = data
			if "vscript" == self.scripting_language:
				try:
					x, y = vcompile(data, bytecode = 0)
					managers.file_manager.write_lib(self.id, name, x)
					self.libs[name] = y
				except:
					pass
			else:
				value="from scripting import server, application, log, session, request, response, VDOM_object, obsolete_request\n%s\n"%data
				managers.file_manager.write_lib(self.id, name, value)
				self.libs[name] = None
			self.invalidate_libraries()
		finally:
			self.__sem.unlock()
コード例 #4
0
 def _skeleton(self,*parameters,**kparameters):
     """ Dynamically generated method. Protocol: SOAP.
          Method name: METHOD_NAME. Documentation: DOCUMENTATION """
     try:
         if SERIALIZE:
             parameters_instance = pickle.loads(parameters[0])
             if SERIALIZE_MAPPING:
                 parameters_instance = mapper.load_from_dto(parameters_instance)
             params, kparams = parameters_instance
             result = getattr(self._parent,'do_'+METHOD_NAME)(
                         *params,
                         **kparams
                     )
             if SERIALIZE_MAPPING:
                 result = mapper.dto_generator(result)
             dumped_result = pickle.dumps(result)
             return dumped_result
         else:
             return getattr(self._parent,'do_'+METHOD_NAME)(*parameters,**kparameters)
     except Exception as e:
         # TODO: watch out, if server gets a Control + C, the exception is going to propagate
         tb = traceback.format_exc()
         if type(e) == types.InstanceType:
             class_name = str(e.__class__)
         else:
             class_name = type(e).__module__ + '.' + type(e).__name__
         log.log(self,log.level.Info,"Exception : " + class_name + "; " + e.args[0] + "; " + tb)
         raise SOAPpy.faultType(
                 faultcode=class_name,
                 faultstring=e.args[0],
                 detail=tb
             )
コード例 #5
0
 def _gotError(self, failure, request, methodName):
     e = failure.value
     if isinstance(e, SOAPpy.faultType):
         fault = e
     else:
         fault = SOAPpy.faultType("%s:Server" % SOAPpy.NS.ENV_T, "Method %s failed." % methodName)
     response = SOAPpy.buildSOAP(fault, encoding=self.encoding)
     self._sendResponse(request, response, status=500)
コード例 #6
0
 def _gotError(self, failure, request, methodName):
     e = failure.value
     if isinstance(e, SOAPpy.faultType):
         fault = e
     else:
         fault = SOAPpy.faultType("%s:Server" % SOAPpy.NS.ENV_T,
                                  "Method %s failed." % methodName)
     response = SOAPpy.buildSOAP(fault, encoding=self.encoding)
     self._sendResponse(request, response, status=500)
コード例 #7
0
	def dispatch_remote(self, app_id, object_id, func_name, xml_param, session_id=None):
		"""Processing remote methods call"""
		try:
			object = managers.xml_manager.search_object(app_id, object_id)
			if object.type.id in self.__remote_index and func_name in self.__remote_index[object.type.id]:
				module=__import__(utils.id.guid2mod(object.type.id))
				if func_name in module.__dict__:
					if session_id:
						return getattr(module, func_name)(app_id, object_id, xml_param,session_id)
					else:
						return getattr(module, func_name)(app_id, object_id, xml_param)
		except Exception, e:
			if getattr(e, "message", None) and isinstance(e.message, unicode):
				msg = unicode(e).encode("utf8")
			else:
				msg = str(e)
			
			raise SOAPpy.faultType(remote_method_call_error, _("Remote method call error"), msg)
コード例 #8
0
	def dispatch_action(self, app_id, object_id, func_name,xml_param,xml_data):
		"""Processing action call"""
		try:
			request = managers.request_manager.get_request()
			request.arguments().arguments({"xml_param":[xml_param],"xml_data":[xml_data]})
			app = managers.xml_manager.get_application(app_id)
			obj = app.search_object(object_id)
			if not obj:
				raise Exception("Container id:%s not found"%object_id)
			request.container_id = object_id
			managers.engine.execute(app, obj, None, func_name, True)
			ret = request.wholeAnswer
			request.wholeAnswer = None
			request.session().remove("response")
			return ret or ""
		except Exception, e:
			if getattr(e, "message", None) and isinstance(e.message, unicode):
				msg = unicode(e).encode("utf8")
			else:
				msg = str(e)
			raise SOAPpy.faultType(remote_method_call_error, _("Action call error"), msg)
コード例 #9
0
			if object.type.id in self.__remote_index and func_name in self.__remote_index[object.type.id]:
				module=__import__(utils.id.guid2mod(object.type.id))
				if func_name in module.__dict__:
					if session_id:
						return getattr(module, func_name)(app_id, object_id, xml_param,session_id)
					else:
						return getattr(module, func_name)(app_id, object_id, xml_param)
		except Exception, e:
			if getattr(e, "message", None) and isinstance(e.message, unicode):
				msg = unicode(e).encode("utf8")
			else:
				msg = str(e)
			
			raise SOAPpy.faultType(remote_method_call_error, _("Remote method call error"), msg)
			#return "<Error><![CDATA[%s]]></Error>"%str(e)
		raise SOAPpy.faultType(remote_method_call_error, _("Handler not found"), str(func_name))
		#return "<Error><![CDATA[Handler not found]]></Error>"
		
	def dispatch_action(self, app_id, object_id, func_name,xml_param,xml_data):
		"""Processing action call"""
		try:
			request = managers.request_manager.get_request()
			request.arguments().arguments({"xml_param":[xml_param],"xml_data":[xml_data]})
			app = managers.xml_manager.get_application(app_id)
			obj = app.search_object(object_id)
			if not obj:
				raise Exception("Container id:%s not found"%object_id)
			request.container_id = object_id
			managers.engine.execute(app, obj, None, func_name, True)
			ret = request.wholeAnswer
			request.wholeAnswer = None
コード例 #10
0
 def _methodNotFound(self, request, methodName):
     response = SOAPpy.buildSOAP(SOAPpy.faultType("%s:Client" % SOAPpy.NS.ENV_T,
                                              "Method %s not found" % methodName),
                               encoding=self.encoding)
     self._sendResponse(request, response, status=500)
コード例 #11
0
 def method3(self):
     raise SOAPpy.faultType(
         faultcode='this.class.does.not.exist',
         faultstring="this won't be read",
         detail="it doesn't really matter")
コード例 #12
0
 def method2(self):
     raise SOAPpy.faultType(faultcode='exceptions.TypeError',
                            faultstring=exc_msg,
                            detail="it doesn't really matter")
コード例 #13
0
 def method3(self):
     raise SOAPpy.faultType(
             faultcode='this.class.does.not.exist',
             faultstring="this won't be read",
             detail = "it doesn't really matter"
         )
コード例 #14
0
 def method2(self):
     raise SOAPpy.faultType(
             faultcode='exceptions.TypeError',
             faultstring=exc_msg,
             detail = "it doesn't really matter"
         )