def __get_api_handler(self): service_handler_path = self._document.attrib["ApiHandler"] service_handler = _helpers.load(service_handler_path) if not callable(service_handler): raise ImproperlyConfigured( "`{0}` is not callable".format(service_handler_path)) return service_handler
def _create_app(self, app_name): app_el = self._document.Applications.find( '*[@name="{0}"]'.format(app_name)) service_name = app_el.attrib["service"] service_el = self._document.Services.find( '*[@code="{0}"]'.format(service_name)) api = {} service_meta = {} for api_id in service_el.xpath("*/@id"): method_ = self._document.ApiRegistry.xpath( '*[@id="{0}"]'.format(api_id))[0] api.update( {method_.get("code"): _helpers.load(method_.get("module"))}) service_meta.update({ method_.get('code'): { 'method_verbose_name': method_.get('name'), 'protocol': app_el.InProtocol.get('code'), }, }) api.update({'METHOD_VERBOSE_NAMES': service_meta}) service = type(str(service_name), (self.ServiceBase, ), dict(api)) in_protocol, out_protocol = self._create_app_protocols(app_el) app = _helpers.create_application(self.Application, self.WsgiApplication, app_name, app_el.get("tns", self.DEFAULT_TNS), service, in_protocol, out_protocol) self._app_cache[app_name] = app return app
def _create_protocol(self, code, params, security=None): proto_el = self._document.Protocols.find('*[@code="{0}"]'.format(code)) proto_params = parse_params(proto_el.getchildren()) proto_params.update(params) if security: security_el = self._document.SecurityProfile.find( '*[@code="{0}"]'.format(security)) security_params = parse_params( security_el.findall(".//{{{0}}}Param".format(self.NAMESPACE))) security_cls = _helpers.load( self._document.SecurityProfile.Modules.xpath( '*[@code="{0}"]/@path'.format( security_el.attrib["module"]))[0]) proto_params["wsse_security"] = security_cls(**security_params) proto_cls = _helpers.load(proto_el.attrib["module"]) return proto_cls(**proto_params)
def __get_service_class(self): service_cls_path = self._document.attrib["ServiceClass"] from spyne.service import ServiceBase service_cls = _helpers.load(service_cls_path) if not issubclass(service_cls, ServiceBase): raise ImproperlyConfigured( "{0} is not subclass of spyne ServiceBase".format( service_cls.__name__)) return service_cls
def __get_wsgi_class(self): wsgi_cls_path = self._document.attrib["WsgiClass"] from spyne.server.django import DjangoApplication wsgi_app_cls = _helpers.load(wsgi_cls_path) if not issubclass(wsgi_app_cls, DjangoApplication): raise ImproperlyConfigured( "{0} is not subclass of spyne DjangoApplication".format( wsgi_app_cls.__name__)) return wsgi_app_cls
def __get_app_class(self): app_cls_path = self._document.attrib["ApplicationClass"] from spyne.application import Application app_cls = _helpers.load(app_cls_path) if not issubclass(app_cls, Application): raise ImproperlyConfigured( "{0} is not subclass of spyne Application".format( app_cls.__name__)) return app_cls
def _create_app(self, app_name): app_el = self._document.Applications.find( '*[@name="{0}"]'.format(app_name)) service_name = app_el.attrib["service"] service_el = self._document.Services.find( '*[@code="{0}"]'.format(service_name)) api = {} for api_id in service_el.xpath("*/@id"): method_ = self._document.ApiRegistry.xpath( '*[@id="{0}"]'.format(api_id) )[0] api.update({ method_.get("code"): _helpers.load(method_.get("module"))}) service = type(str(service_name), (self.ServiceBase,), dict(api)) in_protocol, out_protocol = self._create_app_protocols(app_el) app = _helpers.create_application( self.Application, self.WsgiApplication, app_name, app_el.get("tns", self.DEFAULT_TNS), service, in_protocol, out_protocol) self._app_cache[app_name] = app return app