当前位置: 首页>>代码示例>>Python>>正文


Python Binary.str方法代码示例

本文整理汇总了Python中dNG.data.binary.Binary.str方法的典型用法代码示例。如果您正苦于以下问题:Python Binary.str方法的具体用法?Python Binary.str怎么用?Python Binary.str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dNG.data.binary.Binary的用法示例。


在下文中一共展示了Binary.str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_metadata_xml_tree

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def init_metadata_xml_tree(self, device_identifier, url_base, xml_resource):
        """
Initialize the service metadata from a UPnP description.

:param device_identifier: Parsed UPnP device identifier
:param url_base: HTTP base URL
:param xml_resource: UPnP description XML parser instance

:return: (bool) True if parsed successfully
:since:  v0.2.00
        """

        _return = True

        if (xml_resource.count_node("upnp:service") > 0): xml_resource.set_cached_node("upnp:service")
        else: _return = False

        if (_return):
            value = xml_resource.get_node_value("upnp:service upnp:serviceType")
            re_result = (None if (value is None) else Service.RE_USN_URN.match(value))

            if (re_result is None or re_result.group(2) != "service"): _return = False
            else:
                self.name = "{0}:service:{1}".format(re_result.group(1), re_result.group(3))
                urn = "{0}:{1}".format(self.name, re_result.group(4))

                self._set_identifier({ "device": device_identifier['device'],
                                       "bootid": device_identifier['bootid'],
                                       "configid": device_identifier['configid'],
                                       "uuid": device_identifier['uuid'],
                                       "class": "service",
                                       "usn": "uuid:{0}::{1}".format(device_identifier['uuid'], value),
                                       "urn": urn,
                                       "domain": re_result.group(1),
                                       "type": re_result.group(3),
                                       "version": re_result.group(4)
                                     })
            #
        #

        if (_return):
            value = xml_resource.get_node_value("upnp:service upnp:serviceId")
            re_result = (None if (value is None) else Service.RE_SERVICE_ID_URN.match(value))

            if (re_result is None or re_result.group(2) != "serviceId"): _return = False
            else: self.service_id = { "urn": value[4:], "domain": re_result.group(1), "id": re_result.group(3) }
        #

        if (_return):
            self.url_scpd = Binary.str(urljoin(url_base, xml_resource.get_node_value("upnp:service upnp:SCPDURL")))
            self.url_control = Binary.str(urljoin(url_base, xml_resource.get_node_value("upnp:service upnp:controlURL")))

            value = xml_resource.get_node_value("upnp:service upnp:eventSubURL")
            self.url_event_control = (None if (value.strip == "") else Binary.str(urljoin(url_base, value)))
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:59,代码来源:service.py

示例2: get_upnp_value

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def get_upnp_value(variable, value):
        """
Returns a valid UPnP encoded value for the given variable definition and
value.

:param variable: Variable definition
:param value: Native python value

:return: (str) UPnP encoded value
:since:  v0.2.00
        """

        native_type = Variable.get_native_type(variable)

        if (type(native_type) is tuple):
            value_normalized = (Binary.str(value) if (native_type[0] == str) else value)
            value_normalized_type = type(value_normalized)

            if (value_normalized_type != native_type[0]): raise ValueException("Given value mismatches defined format")
            elif (len(native_type) > 2):
                if (native_type[1] != "xmlns"): raise ValueException("Invalid native type definition")
                _return = value_normalized
            elif (len(native_type[1]) > 1):
                if (native_type[1] == "base64"): _return = Binary.str(b64encode(Binary.bytes(value) if (value == value_normalized) else value))
                elif (native_type[1] == "f14.4"): _return = "{0:14.4g}".format(value).strip()
                elif (native_type[1] == "date"): _return = strftime("%Y-%m-%d", localtime(value))
                elif (native_type[1] == "dateTime"): _return = strftime("%Y-%m-%dT%H:%M:%S", localtime(value))
                elif (native_type[1] == "dateTime.tz"): _return = strftime("%Y-%m-%dT%H:%M:%S%Z", localtime(value))
                elif (native_type[1] == "hex"): _return = Binary.str(hexlify(Binary.bytes(value) if (value == value_normalized) else value))
                elif (native_type[1] == "time"): _return = strftime("%H:%M:%S", localtime(value))
                elif (native_type[1] == "time.tz"): _return = strftime("%H:%M:%S%Z", localtime(value))
                elif (native_type[1] == "uri" and len(urlsplit(value).scheme.strip()) < 1): raise ValueException("Given value is not a valid URI")
                elif (native_type[1] == "uuid" and Variable.RE_UUID.match(value_normalized) is None): raise ValueException("Given value is not a valid UUID")
                else: _return = value_normalized
            else:
                pack("={0}".format(native_type[1]),
                                   (Binary.utf8_bytes(value)
                                    if (value_normalized_type == str and value == value_normalized) else
                                    value
                                   )
                                  )

                _return = "{0}".format(value_normalized)
            #
        else:
            if (native_type is str): value = Binary.str(value)
            if (type(value) is not native_type): raise ValueException("Given value mismatches defined format")

            if (native_type is bool): _return = "{0:b}".format(value)
            elif (native_type is int): _return = str(value)
            elif (native_type is float): _return = "{0:f}".format(value)
            else: _return = value
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:57,代码来源:variable.py

示例3: get_url_base

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def get_url_base(self, _type, parameters):
        """
Returns the base URL for the given type and parameters.

:param _type: Link type (see constants)
:param parameters: Link parameters

:return: (str) Base URL
:since:  v0.2.00
        """

        _return = ""

        if (_type & Link.TYPE_PREDEFINED_URL == Link.TYPE_PREDEFINED_URL):
            if ("__link__" not in parameters): raise ValueException("Required parameter not defined for the predefined URL")
            _return = parameters['__link__']
        elif (self.path is not None):
            if (_type & Link.TYPE_RELATIVE_URL != Link.TYPE_RELATIVE_URL):
                if (self.scheme is None): raise ValueException("Can't construct an absolute URL without an URI scheme")
                _return = "{0}://".format(Binary.str(self.scheme))

                if (self.host is None): raise ValueException("Can't construct an absolute URL without a host")
                _return += Binary.str(self.host)

                if (self.port is not None):
                    port = Link.filter_well_known_port(self.scheme, self.port)
                    if (port > 0): _return += ":{0:d}".format(port)
                #
            #

            path = ("/" if (self.path is None) else Binary.str(self.path))
            _return += ("/" if (path == "") else path)
        else:
            request = AbstractHttpRequest.get_instance()
            if (request is None): raise ValueException("Can't construct an URL from a request instance if it is not provided")

            if (_type & Link.TYPE_ABSOLUTE_URL == Link.TYPE_ABSOLUTE_URL):
                scheme = request.get_server_scheme()

                _return = "{0}://".format(Binary.str(scheme))

                host = request.get_server_host()
                if (host is not None): _return += Binary.str(host)

                port = Link.filter_well_known_port(scheme, request.get_server_port())
                if (port > 0): _return += ":{0:d}".format(port)

                if (_type & Link.TYPE_BASE_PATH == Link.TYPE_BASE_PATH
                    or _type & Link.TYPE_VIRTUAL_PATH == Link.TYPE_VIRTUAL_PATH
                   ): _return += self._get_url_path(request, False)
                else: _return += self._get_url_path(request)
            else: _return = self._get_url_path(request)
        #

        return _return
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:57,代码来源:link.py

示例4: request

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def request(self, _hook, **kwargs):
        """
Requests the IPC aware application to call the given hook.

:param _hook: Hook
:param args: Parameters

:return: (mixed) Result data; None on error
:since:  v0.3.00
        """

        _hook = Binary.str(_hook)

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.request({1})- (#echo(__LINE__)#)", self, _hook, context = "pas_bus")
        _return = None

        if (not self.connected): raise IOException("Connection already closed")

        request_message = self._get_message_call_template()
        if (_hook == "dNG.pas.Status.stop"): request_message.set_flags(Message.FLAG_NO_REPLY_EXPECTED)

        request_message_body = { "method": _hook }
        if (len(kwargs) > 0): request_message_body['params'] = TypeObject("a{sv}", kwargs)

        request_message.set_body(request_message_body)

        if (not self._write_message(request_message)): raise IOException("Failed to transmit request")

        if (_hook == "dNG.pas.Status.stop"): self.connected = False
        else:
            response_message = self._get_response_message()

            if (((not response_message.is_error()) and (not response_message.is_method_reply()))
                or response_message.get_reply_serial() != 1
                or response_message.get_serial() != 2
               ): raise IOException("IPC response received is invalid")

            if (response_message.is_error()):
                response_body = response_message.get_body()

                raise IOException(Binary.str(response_body)
                                  if (type(response_body) == Binary.BYTES_TYPE) else
                                  response_message.get_error_name()
                                 )
            else: _return = response_message.get_body()
        #

        return _return
开发者ID:dNG-git,项目名称:pas_bus,代码行数:50,代码来源:client.py

示例5: parse

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def parse(self):
        """
Parses the content of the request body.

:since: v1.0.0
        """

        byte_buffer = self.get_buffer()

        field_arrays = { }

        parsed_fields = ([ ]
                         if (byte_buffer is None or byte_buffer.size < 1) else
                         parse_qsl(Binary.str(byte_buffer.read()), True, True)
                        )

        for parsed_field in parsed_fields:
            re_result = Urlencoded.RE_ARRAY.match(parsed_field[0])

            if (re_result is None): self.parsed_data[parsed_field[0]] = parsed_field[1]
            elif (re_result.group(1) in field_arrays): field_arrays[re_result.group(1)].append({ "key": re_result.group(2), "value": parsed_field[1] })
            else: field_arrays[re_result.group(1)] = [ { "key": re_result.group(2), "value": parsed_field[1] } ]
        #

        for field in field_arrays:
            element_position = 0
            if (field in self.parsed_data): field_arrays[field].insert(0, self.parsed_data[field])
            self.parsed_data[field] = { }

            for element in field_arrays[field]:
                if (len(element['key']) > 0): self.parsed_data[field][element['key']] = element['value']
                else:
                    self.parsed_data[field][element_position] = element['value']
                    element_position += 1
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:36,代码来源:urlencoded.py

示例6: read

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def read(self, n = 0):
        """
Reads data using the given body reader and parse the JSON response. Chunked
transfer-encoded data is handled automatically.

:param n: Bytes to read

:return: (bytes) Data received
:since:  v1.0.0
        """

        # pylint: disable=access-member-before-definition, attribute-defined-outside-init, not-callable, used-before-assignment

        if (n > 0): raise OperationNotSupportedException()

        if (self.json_resource is None):
            json_data = self.body_reader()
            self.body_reader = None

            self.json_resource = JsonResource()
            self.json_resource.parse(Binary.str(json_data))
            if (self.json_resource.data is None): raise ValueException("Data received is not a valid JSON encoded response")

            _return = Binary.bytes(json_data)
        else: _return = Binary.bytes("")

        return _return
开发者ID:dNG-git,项目名称:pas_json_clients,代码行数:29,代码来源:json_response.py

示例7: theme

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def theme(self, theme):
        """
Sets the theme to use.

:param theme: Output theme

:since: v1.0.0
        """

        theme = Binary.str(theme)

        """
Set theme or reset to None to use the default one configured
        """

        if (theme is None): self._theme = None
        else:
            theme_path = InputFilter.filter_file_path(theme).replace(".", path.sep)
            file_path_name = path.join(self.path, theme_path, "site.tsc")

            if (os.access(file_path_name, os.R_OK)): self._theme = theme
            else: self._theme = None
        #

        """
Read corresponding theme configuration
        """

        if (self._theme is None): file_path_name = path.join(self.path, self.theme.replace(".", path.sep), "site.tsc")

        file_path_name = file_path_name[:-3] + "json"
        Settings.read_file(file_path_name)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:34,代码来源:renderer.py

示例8: __init__

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def __init__(self, url, gst_stream_metadata):
        """
Constructor __init__(GstAudioStreamMetadata)

:since: v0.2.00
        """

        # pylint: disable=star-args

        mimetype_definition = MimeType.get_instance().get(mimetype = gst_stream_metadata['codec'])
        if (mimetype_definition is None): mimetype_definition = { "type": gst_stream_metadata['codec'], "class": gst_stream_metadata['codec'].split("/", 1)[0] }
        if (mimetype_definition['class'] != "audio"): LogLine.debug("Metadata '{0}' do not correspond to audio".format(mimetype_definition['type']), context = "pas_media")

        kwargs = { }

        kwargs['codec'] = gst_stream_metadata['codec']
        if (gst_stream_metadata['bitrate'] > 0): kwargs['bitrate'] = gst_stream_metadata['bitrate']
        if (gst_stream_metadata['bits_per_sample'] > 0): kwargs['bps'] = gst_stream_metadata['bits_per_sample']
        if (gst_stream_metadata['channels'] > 0): kwargs['channels'] = gst_stream_metadata['channels']

        if ("profile" in gst_stream_metadata):
        #
            profile = Binary.str(gst_stream_metadata['profile']).lower()
            if ("level" in gst_stream_metadata): profile += "-{0}".format(gst_stream_metadata['level'].lower())
            kwargs['codec_profile'] = profile
        #
        elif ("format" in gst_stream_metadata): kwargs['codec_profile'] = gst_stream_metadata['format'].lower()

        if ("language-code" in gst_stream_metadata['tags']): kwargs['lang'] = GstMetadataMixin._parse_tag(gst_stream_metadata['tags']['language-code'])
        kwargs['mimeclass'] = mimetype_definition['class']
        kwargs['mimetype'] = mimetype_definition['type']
        if (gst_stream_metadata['sample_rate'] > 0): kwargs['sample_rate'] = gst_stream_metadata['sample_rate']

        AudioStreamMetadata.__init__(self, url, **kwargs)
开发者ID:dNG-git,项目名称:pas_gapi_gstreamer,代码行数:36,代码来源:gst_audio_stream_metadata.py

示例9: _handle_mime_part_headers

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def _handle_mime_part_headers(self, mime_part_id, data):
        """
Handles MIME part header.

:param mime_part_id: MIME part ID
:param data: Data read from input

:since: v1.0.0
        """

        mime_headers = Header.get_headers(Binary.str(data))

        if (mime_part_id not in self.parts):
            part_position = len(self.parts)
            self.parts[mime_part_id] = { "headers": mime_headers, "position": part_position }
        elif ("list" in self.parts[mime_part_id]): self.parts[mime_part_id]['list'].append({ "headers": mime_headers })
        else:
            single_mime_part = { "headers": self.parts[mime_part_id]['headers'] }
            if ("data" in self.parts[mime_part_id]): single_mime_part['data'] = self.parts[mime_part_id]['data']

            self.parts[mime_part_id] = { "position": self.parts[mime_part_id]['position'],
                                         "list": [ single_mime_part,
                                                   { "headers": mime_headers }
                                                 ]
                                       }
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:27,代码来源:multipart.py

示例10: _add_metadata_to_didl_xml_node

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def _add_metadata_to_didl_xml_node(self, xml_resource, xml_node_path, parent_id = None):
        """
Uses the given XML resource to add the DIDL metadata of this UPnP resource.

:param xml_resource: XML resource
:param xml_base_path: UPnP resource XML base path (e.g. "DIDL-Lite
       item")

:since: v0.2.00
        """

        if (self.get_type() & AbstractResource.TYPE_CDS_RESOURCE == AbstractResource.TYPE_CDS_RESOURCE):
            attributes = { }
            didl_fields = self.get_didl_fields()
            res_protocol = self.get_didl_res_protocol()
            size = self.get_size()

            if (res_protocol is not None): attributes['protocolInfo'] = res_protocol
            if (size is not None): attributes['size'] = size

            didl_fields_filtered = (len(didl_fields) > 0)

            metadata = self.get_metadata()

            for key in metadata:
                if ((not didl_fields_filtered) or "[email protected]{0}".format(key) in didl_fields): attributes[key] = metadata[key]
            #

            url = Binary.str(self.get_content(0))
            value = (url if (type(url) is str) else "")

            xml_resource.add_node(xml_node_path, value, attributes)
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:34,代码来源:abstract_resource.py

示例11: _get_hook_proxy_params

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def _get_hook_proxy_params(self, hook, timeout = None, kwargs = None):
        """
Returns serializable parameters for the persistent proxy.

:param hook: Task hook to be called
:param timeout: Timeout in seconds; None to use global task timeout
:param kwargs: Keyword arguments

:return: (dict)
:since:  v0.2.00
        """

        _return = { }

        if (isinstance(hook, PersistentLrtHook)):
            _return['hook'] = hook.get_hook()

            _return['kwargs'] = ({ } if (kwargs is None) else kwargs)
            _return['kwargs'].update(hook.get_params())
            _return['kwargs']['_lrt_hook'] = True
        else:
            hook = Binary.str(hook)
            if (type(hook) is not str): raise TypeException("Hook given is invalid")

            _return['hook'] = hook
            if (kwargs is not None): _return['kwargs'] = kwargs
        #

        if (timeout is not None): _return['timeout'] = timeout

        return _return
开发者ID:dNG-git,项目名称:pas_tasks,代码行数:33,代码来源:persistent_proxy.py

示例12: request_soap_action

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def request_soap_action(self, action, arguments):
        """
Request the given SOAP action with the given arguments from a remote UPnP
device.

:param action: SOAP action
:param arguments: SOAP action arguments

:return: (dict) SOAP action response
:since:  v0.2.00
        """

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.request_soap_action({1})- (#echo(__LINE__)#)", self, action, context = "pas_upnp")

        _return = None

        urn = "urn:{0}".format(self.get_urn())

        xml_resource = self._init_xml_resource()
        xml_resource.register_ns("s", "http://schemas.xmlsoap.org/soap/envelope/")
        xml_resource.register_ns("u", urn)
        xml_resource.set_parse_only(False)

        xml_resource.add_node("s:Envelope", attributes = { "xmlns:s": "http://schemas.xmlsoap.org/soap/envelope/", "encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/" })
        xml_resource.add_node("s:Envelope s:Body")

        xml_base_path = "s:Envelope s:Body u:{0}".format(action)

        xml_resource.add_node(xml_base_path, attributes = { "xmlns:u": urn })
        xml_resource.set_cached_node("s:Envelope s:Body")

        for argument in arguments: xml_resource.add_node("{0} {1}".format(xml_base_path, argument['name']), argument['value'])

        http_client = HttpClient(self.url_control, event_handler = self.log_handler)
        http_client.set_header("Content-Type", "text/xml; charset=UTF-8")
        http_client.set_header("SoapAction", "\"{0}#{1}\"".format(urn, action))
        http_client.set_header("User-Agent", Service.get_pas_upnp_http_client_identifier_string())

        post_data = "<?xml version='1.0' encoding='UTF-8' ?>{0}".format(xml_resource.export_cache(True))
        http_response = http_client.request_post(post_data)
        xml_response_variables = None

        if (http_response.is_readable()):
            xml_resource.parse(Binary.str(http_response.read()))
            xml_response_variables = xml_resource.get_node("{0}Response".format(xml_base_path))
        elif (self.log_handler is not None): self.log_handler.error(http_response.get_error_message(), context = "pas_upnp")

        if (xml_response_variables is not None):
            _return = { }

            for key in xml_response_variables:
                _return[key] = xml_response_variables[key]['value']
            #
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:58,代码来源:service.py

示例13: theme_subtype

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def theme_subtype(self, subtype):
        """
Sets the theme subtype to use.

:param subtype: Output theme subtype

:since: v1.0.0
        """

        self._theme_subtype = Binary.str(subtype)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:12,代码来源:renderer.py

示例14: get_user_agent_settings

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
    def get_user_agent_settings(user_agent):
        """
Returns the user agent specific client settings dictionary.

:param user_agent: User agent

:return: (dict) User agent specific client settings; None on error
:since:  v0.2.00
        """

        _return = { }

        settings = None
        user_agent = Binary.str(user_agent)

        if (type(user_agent) is str):
            settings = Hook.call("dNG.pas.upnp.Client.getUserAgentSettings", user_agent = user_agent)

            if (not isinstance(settings, dict)):
                identifier = ClientSettings.get_user_agent_identifiers(user_agent)
                settings_file_name = "{0}.json".format(identifier)

                settings = JsonFileContent.read(path.join(Settings.get("path_data"),
                                                          "upnp",
                                                          "user_agents",
                                                          settings_file_name
                                                         )
                                               )

                if (settings is None):
                    log_line = "pas.upnp.ClientSettings reporting: No client settings found for user agent '{0}' with identifier '{1}'"

                    if (Settings.get("pas_upnp_log_missing_user_agent", False)): LogLine.warning(log_line, user_agent, identifier, context = "pas_upnp")
                    else: LogLine.debug(log_line, user_agent, identifier, context = "pas_upnp")
                #
            #
        #

        if (settings is not None):
            if ("client_file" in settings):
                base_settings = JsonFileContent.read(path.join(Settings.get("path_data"),
                                                               "upnp",
                                                               "user_agents",
                                                               InputFilter.filter_file_path(settings['client_file'])
                                                              )
                                                    )

                if (type(base_settings) is dict): _return.update(base_settings)
                del(settings['client_file'])
            #

            _return.update(settings)
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:57,代码来源:client_settings.py

示例15: execute_new

# 需要导入模块: from dNG.data.binary import Binary [as 别名]
# 或者: from dNG.data.binary.Binary import str [as 别名]
	def execute_new(self, is_save_mode = False):
	#
		"""
Action for "new"

:since: v0.1.00
		"""

		form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id", "")).strip()
		form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id", "")).strip()

		L10n.init("pas_http_core_form")

		form = FormProcessor(form_id)
		form.set_form_render_id(Binary.str(hexlify(urandom(16))))

		if (is_save_mode): form.set_input_available()

		self._apply_new_form(form)

		if (is_save_mode and form.check()):
		#
			entry_data = self._save_new_form(form)

			form_store = form.get_form_store()
			form_store_dict = form_store.get_value_dict()
			form_store_field_id = "form_api_dynamic_{0}".format(form_field_id)

			entry_list = form_store_dict.get(form_store_field_id, [ ])
			entry_list.append(entry_data)

			form_store_dict[form_store_field_id] = entry_list
			form_store.set_value_dict(form_store_dict)

			self._set_destroy_dom_result()
		#
		else:
		#
			content = { "title": self._get_form_action_new_title(),
			            "on_closed_query": Link().build_url(Link.TYPE_QUERY_STRING, { "__request__": True, "a": "get" })
			          }

			content['form'] = { "object": form,
			                    "url_parameters": { "__request__": True,
			                                        "a": "new-save"
			                                      },
			                    "button_title": "core_continue"
			                  }

			method = (self._set_replace_dom_oset_result
			          if (is_save_mode) else
			          self._set_append_overlay_dom_oset_result
			         )

			method("dynamic_form.overlay", content)
开发者ID:dNG-git,项目名称:pas_http_dynamic_form,代码行数:57,代码来源:abstract.py


注:本文中的dNG.data.binary.Binary.str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。