def Servant(self, request): if len(request) < _GIOP_HEADER_LENGTH: _LOGGER.debug("header incomplete") return None, request def checkHeaderField(name, got, expected): if got != expected: _LOGGER.error("bad header field: %s got=%s expected=%s", name, got, expected) raise CORBA.SystemException('IDL:CORBA/INTERNAL:1.0', 8, CORBA.CORBA_COMPLETED_MAYBE) input_buffer = CDR.InputBuffer(request) magic = '' magic += CORBA.demarshal(input_buffer, 'char') magic += CORBA.demarshal(input_buffer, 'char') magic += CORBA.demarshal(input_buffer, 'char') magic += CORBA.demarshal(input_buffer, 'char') checkHeaderField("magic", magic, 'GIOP') GIOP_version = GIOP.Version.demarshal(input_buffer) checkHeaderField("major version", GIOP_version.major, 1) checkHeaderField("minor version", GIOP_version.minor, 2) flags = CORBA.demarshal(input_buffer, 'octet') endian = flags & 0x01 input_buffer.endian = endian # now, endian is known message_type = CORBA.demarshal(input_buffer, 'octet') message_size = CORBA.demarshal(input_buffer, 'unsigned_long') message_data = input_buffer.read(message_size) if len(message_data) < message_size: _LOGGER.debug("message incomplete") return None, request # From now on consume the data.. message = CDR.InputBuffer(message_data) message.endian = endian remaining_data = input_buffer.read() if message_type != 0: _LOGGER.error("unexpected message type %s (expected 0)", message_type) return None, remaining_data request_header = GIOP.RequestHeader_1_2.demarshal(message) interface = request_header.target._v if self.itf.has_key(interface) == False: _LOGGER.warning("unknown interface '%s'.", interface) reply_status = GIOP.SYSTEM_EXCEPTION reply_body = CDR.OutputBuffer() CORBA.marshal(reply_body, 'string', 'IDL:CORBA/NO_IMPLEMENT:1.0') CORBA.marshal(reply_body, 'unsigned_long', 11) CORBA.marshal(reply_body, 'unsigned_long', 1) # COMPLETED_NO else: classname = self.itf[interface] oper = request_header.operation if not hasattr(classname, oper): _LOGGER.error("unknown operation '%s'.", oper) reply_status = GIOP.SYSTEM_EXCEPTION reply_body = CDR.OutputBuffer() CORBA.marshal(reply_body, 'string', 'IDL:CORBA/BAD_OPERATION:1.0') CORBA.marshal(reply_body, 'unsigned_long', 13) CORBA.marshal(reply_body, 'unsigned_long', 1) # COMPLETED_NO else: srv_op = '_skel_' + oper (reply_status, reply_body) = getattr(classname, srv_op)(message) if reply_status == None: return (None, remaining_data) # oneway reply = CDR.OutputBuffer() GIOP.ReplyHeader_1_2( request_id=request_header.request_id, reply_status=reply_status, service_context=IOP.ServiceContextList([]) ).marshal(reply) reply.write(reply_body.getvalue()) reply_body.close() buff = CDR.OutputBuffer() GIOP.MessageHeader_1_1( magic='GIOP', GIOP_version=GIOP.Version(major=1, minor=2), flags=0x01, # flags : little endian message_type=1, # Reply message_size=len(reply.getvalue()) ).marshal(buff) buff.write(reply.getvalue()) reply.close() str_ = buff.getvalue() buff.close() return (str_, remaining_data)
def marshal(self, output): self.tag.marshal(output) _e0 = self.profile_data CORBA.marshal(output, 'long', len(_e0)) for _e1 in _e0: CORBA.marshal(output, 'octet', ord(_e1))
def marshal(self, output): _e0 = self CORBA.marshal(output, 'long', len(_e0)) for _e1 in _e0: _e1.marshal(output)
def marshal(self, output): self.context_id.marshal(output) _e0 = self.context_data CORBA.marshal(output, 'long', len(_e0)) for _e1 in _e0: CORBA.marshal(output, 'octet', ord(_e1))
def marshal(self, output): CORBA.marshal(output, 'unsigned_long', self)
def marshal(self, output): CORBA.marshal(output, 'string', self.type_id) _e0 = self.profiles CORBA.marshal(output, 'long', len(_e0)) for _e1 in _e0: _e1.marshal(output)