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


Python input_filter.InputFilter类代码示例

本文整理汇总了Python中dNG.data.text.input_filter.InputFilter的典型用法代码示例。如果您正苦于以下问题:Python InputFilter类的具体用法?Python InputFilter怎么用?Python InputFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute_delete

	def execute_delete(self):
	#
		"""
Action for "delete"

:since: v0.1.00
		"""

		form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id", "")).strip()
		form_field_entry_position = InputFilter.filter_int(self.request.get_dsd("oform_field_entry_position", -1))

		if (form_field_entry_position > -1):
		#
			form_store = self._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, [ ])
			if (len(entry_list) > form_field_entry_position): del(entry_list[form_field_entry_position])

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

		redirect_request = PredefinedHttpRequest()
		redirect_request.set_module(self.request.get_module())
		redirect_request.set_service(self.request.get_service())
		redirect_request.set_action("get")
		redirect_request.set_dsd_dict(self.request.get_dsd_dict())

		self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:pas_http_dynamic_form,代码行数:31,代码来源:abstract.py

示例2: parse_dsd

    def parse_dsd(dsd):
        """
DSD stands for dynamic service data and should be used for transfering IDs for
news, topics, ... Take care for injection attacks!

:param dsd: DSD string for parsing

:return: (dict) Parsed DSD
:since:  v1.0.0
        """

        dsd = InputFilter.filter_control_chars(dsd)

        if ("+" not in dsd and VirtualRoute.RE_PLUS_ENCODED_CHAR.search(dsd) is not None): dsd = Uri.decode_query_value(dsd)
        elif (" " in dsd): dsd = Uri.encode_query_value(dsd)

        dsd = VirtualRoute.RE_DSD_PLUS_SPAM_CHAR.sub("++", dsd)

        dsd_list = dsd.split("++")
        _return = { }

        for dsd in dsd_list:
            dsd_element = dsd.strip().split("+", 1)

            if (len(dsd_element) > 1):
                _return[dsd_element[0]] = InputFilter.filter_control_chars(Uri.decode_query_value(dsd_element[1]))
            elif (len(dsd_element[0]) > 0): _return[dsd_element[0]] = ""
        #

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

示例3: execute_new

	def execute_new(self, is_save_mode = False):
	#
		"""
Action for "new"

:since: v0.1.00
		"""

		# pylint: disable=star-args

		tid = InputFilter.filter_file_path(self.request.get_dsd("dtid", ""))
		oid = InputFilter.filter_file_path(self.request.get_dsd("doid", ""))

		source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
		target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

		if (source_iline == ""):
		#
			source_iline = ("m=discuss;dsd=dpid+{0}".format(Link.encode_query_value(oid))
			                if (tid == "") else
			                "m=discuss;dsd=dtid+{0}".format(Link.encode_query_value(tid))
			               )
		#

		if (target_iline == ""): target_iline = "m=discuss;dsd=dpid+__id_d__"

		if (tid != ""): oid = tid

		self._execute_new("new",
		                  oid,
		                  source_iline = source_iline,
		                  target_iline = target_iline,
		                  is_save_mode = is_save_mode
		                 )
开发者ID:dNG-git,项目名称:pas_http_discuss,代码行数:34,代码来源:post.py

示例4: execute_new

	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,代码行数:55,代码来源:abstract.py

示例5: execute_delete

    def execute_delete(self):
        """
Action for "delete"

:since: v0.2.00
        """

        cid = InputFilter.filter_file_path(self.request.get_dsd("mcid", ""))

        source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
        target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

        if (source_iline == ""): source_iline = "m=mp;a=list_root_containers"
        if (target_iline == ""): target_iline = source_iline

        L10n.init("mp_core")

        session = (self.request.get_session() if (self.request.is_supported("session")) else None)
        user_profile = (None if (session is None) else session.get_user_profile())

        if (user_profile is None
            or (not user_profile.is_type("ad"))
           ): raise TranslatableError("core_access_denied", 403)

        try: mp_entry = MpEntry.load_id(cid)
        except NothingMatchedException as handled_exception: raise TranslatableError("mp_core_cid_invalid", 404, _exception = handled_exception)

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

        Link.set_store("servicemenu",
                       Link.TYPE_RELATIVE_URL,
                       L10n.get("core_back"),
                       { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                       icon = "mini-default-back",
                       priority = 7
                      )

        if (not DatabaseTasks.is_available()): raise TranslatableException("pas_core_tasks_daemon_not_available")

        mp_entry.delete()

        database_tasks = DatabaseTasks.get_instance()
        database_tasks.add("dNG.pas.upnp.Resource.onDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onDeleted", 1, container_id = cid)
        database_tasks.add("dNG.pas.upnp.Resource.onRootContainerDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onRootContainerDeleted", 1, container_id = cid)

        target_iline = re.sub("\\_\\w+\\_\\_", "", target_iline)

        NotificationStore.get_instance().add_completed_info(L10n.get("mp_core_done_root_container_delete"))

        Link.clear_store("servicemenu")

        redirect_request = PredefinedHttpRequest()
        redirect_request.set_iline(target_iline)
        self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:mp_core,代码行数:54,代码来源:root_container.py

示例6: execute_logout

    def execute_logout(self):
        """
Action for "logout"

:since: v0.2.00
        """

        source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
        target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

        if (target_iline == ""):
            if (Settings.is_defined("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))): target_iline = Settings.get("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))
            elif (Settings.is_defined("pas_http_user_logout_default_target")): target_iline = Settings.get("pas_http_user_logout_default_target")
            else: target_iline = source_iline
        #

        L10n.init("pas_http_user")

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

        Link.set_store("servicemenu",
                       Link.TYPE_RELATIVE_URL,
                       L10n.get("core_back"),
                       { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                       icon = "mini-default-back",
                       priority = 7
                      )

        if (not self.request.is_supported("session")): raise TranslatableError("core_unknown_error", 500)

        session = Session.load(session_create = False)

        if (session is not None):
            session.delete()
            self.request.set_session(None)
        #

        Link.clear_store("servicemenu")

        target_iline = re.sub("\\_\\_\\w+\\_\\_", "", target_iline)

        redirect_request = PredefinedHttpRequest()
        redirect_request.set_module("output")
        redirect_request.set_service("http")
        redirect_request.set_action("done")

        redirect_request.set_parameter_chained("title", L10n.get("pas_http_user_logout"))
        redirect_request.set_parameter_chained("message", L10n.get("pas_http_user_done_logout"))
        redirect_request.set_parameter_chained("target_iline", target_iline)

        self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:51,代码来源:status.py

示例7: execute

	def execute(self):
	#
		"""
Executes the processor.

:since: v0.1.00
		"""

		if (self.form is None or (not self.validate_settings(self.settings))): raise ValueException("Processor is not configured")

		lang = (self.settings['email_lang']
		        if ("email_lang" in self.settings) else
		        L10n.get_instance().get_lang()
		       )

		sender = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_sender_field_name']))
		          if ("email_sender_field_name" in self.settings) else
		          None
		         )

		subject = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_subject_field_name']))
		           if ("email_subject_field_name" in self.settings) else
		           self.settings['email_subject_title']
		          )

		if (subject is None or len(subject.strip()) < 1): raise ValueException("Given e-mail subject is invalid")

		content_list = [ ]
		titles = self.settings.get("form_field_titles", { })

		for field_name in self.settings['email_content_field_names']:
		#
			value = InputFilter.filter_control_chars(self.form.get_input(field_name))

			content_list.append("{0}:\n{1}".format((titles[field_name] if (field_name in titles) else field_name),
			                                       value
			                                      )
			                   )
		#

		content = "\n\n".join(content_list)

		DatabaseTasks.get_instance().add("dNG.pas.http.Form.sendEMail.{0}".format(Binary.str(hexlify(urandom(16)))),
		                                 "dNG.pas.http.Form.sendEMail",
		                                 1,
		                                 lang = lang,
		                                 sender = sender,
		                                 subject = subject,
		                                 content = content
		                                )
开发者ID:dNG-git,项目名称:pas_http_file_form,代码行数:50,代码来源:file_form_mailer.py

示例8: execute_register

    def execute_register(self, is_save_mode = False):
        """
Action for "register"

:since: v0.2.00
        """

        source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
        target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

        self._execute_register(source_iline = source_iline,
                               target_iline = target_iline,
                               is_save_mode = is_save_mode
                              )
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:14,代码来源:index.py

示例9: get_view

    def get_view(self):
        """
Action for "view"

:since: v1.0.0
        """

        cid = InputFilter.filter_file_path(self.request.get_parameter("cid", ""))

        source_iline = InputFilter.filter_control_chars(self.request.get_parameter("source", "")).strip()

        L10n.init("pas_http_core_contentfile")

        Settings.read_file("{0}/settings/pas_http_contentfiles.json".format(Settings.get("path_data")))

        contentfiles = Settings.get("pas_http_contentfiles_list", { })
        if (type(contentfiles) is not dict): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        if (source_iline != ""):
            if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.css")

            Link.set_store("servicemenu",
                           Link.TYPE_RELATIVE_URL,
                           L10n.get("core_back"),
                           { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                           icon = "mini-default-back",
                           priority = 7
                          )
        #

        if (cid not in contentfiles
            or "title" not in contentfiles[cid]
            or "filepath" not in contentfiles[cid]
           ): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        file_content = FileContent.read(contentfiles[cid]['filepath'])
        if (file_content is None): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        if (path.splitext(contentfiles[cid]['filepath'])[1].lower() == ".ftg"): file_content = FormTags.render(file_content)

        content = { "title": contentfiles[cid]['title'],
                    "content": file_content
                  }

        self.response.init()
        self.response.page_title = contentfiles[cid]['title']

        self.response.add_oset_content("core.simple_content", content)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:48,代码来源:contentfile.py

示例10: execute_subscribe

	def execute_subscribe(self):
	#
		"""
Action for "subscribe"

:since: v0.1.00
		"""

		_id = InputFilter.filter_file_path(self.request.get_dsd("oid", ""))

		source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()

		L10n.init("pas_http_datalinker")
		L10n.init("pas_http_subscription")

		if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

		if (len(source_iline) > 0):
		#
			Link.set_store("servicemenu",
			               Link.TYPE_RELATIVE_URL,
			               L10n.get("core_back"),
			               { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
			               icon = "mini-default-back",
			               priority = 7
			              )
		#

		session = (self.request.get_session() if (self.request.is_supported("session")) else None)
		subscription_handler = self._get_subscription_handler(_id)

		if (subscription_handler is None): NotificationStore.get_instance().add_error(L10n.get("errors_pas_http_subscription_not_subscribable"))
		elif (not subscription_handler.is_subscribable_for_session_user(session)): NotificationStore.get_instance().add_error(L10n.get("errors_pas_http_subscription_not_subscribable"))
		else:
		#
			subscription_handler.set_session(session)
			if (not subscription_handler.is_subscribed()): subscription_handler.subscribe()

			NotificationStore.get_instance().add_completed_info(L10n.get("pas_http_subscription_done_subscribe"))
		#

		source_iline = re.sub("\\_\\_\\w+\\_\\_", "", source_iline)

		Link.clear_store("servicemenu")

		redirect_request = PredefinedHttpRequest()
		redirect_request.set_iline(source_iline)
		self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:pas_http_subscription,代码行数:48,代码来源:datalinker.py

示例11: theme

    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,代码行数:32,代码来源:renderer.py

示例12: validate_settings

	def validate_settings(self, data):
	#
		"""
Called to validate the given settings.

:param data: Setting dict to be verified

:since: v0.1.00
		"""

		_return = False

		if (isinstance(data, dict)
		    and DatabaseTasks.is_available()
		    and "recipient" in data
		    and "email_content_field_names" in data
		    and ("email_subject_field_name" in data or "email_subject_title" in data)
		   ):
		#
			_return = True

			recipient = InputFilter.filter_email_address(data['recipient'])
			if (recipient == ""): _return = False

			if (type(data['email_content_field_names']) is not list): _return = False
			if ("email_subject_title" in data and len(data['email_subject_title']) < 1): _return = False
		#

		return _return
	#
#

##j## EOF
开发者ID:dNG-git,项目名称:pas_http_file_form,代码行数:33,代码来源:file_form_mailer.py

示例13: execute_get

	def execute_get(self):
	#
		"""
Action for "get"

:since: v0.1.00
		"""

		if (not self.response.is_supported("dict_result_renderer")): raise IOException("Unsupported response object for action")
		form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id"))
		form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id"))

		try: form_store = Processor.load_form_store_id(form_id)
		except NothingMatchedException as handled_exception: raise TranslatableException("core_access_denied", 403, _exception = handled_exception)

		self._handle_get_choices(form_store, form_field_id)
开发者ID:dNG-git,项目名称:pas_http_dynamic_form,代码行数:16,代码来源:abstract.py

示例14: _set_append_dom_result

    def _set_append_dom_result(self, dom_value, **kwargs):
        """
Returns the DOM value given and activates the client API "append_dom".
"append_dom_id" is used in case the client target DOM ID does not correspond
to the one calling the server API.

:param dom_value: DOM value to response

:since: v0.2.00
        """

        api_call = "append_dom"
        dom_id = self.dom_id

        if (dom_id is None): dom_id = InputFilter.filter_file_path(self.request.get_dsd("ddom_id", ""))
        elif (self.request.get_dsd("ddom_id", "") != dom_id): api_call = "append_dom_id"

        result = kwargs

        result.update({ "api_call": api_call,
                        "dom_id": dom_id,
                        "dom_value": dom_value
                      })

        self.response.set_result(result)
开发者ID:dNG-git,项目名称:pas_http_dom_editor,代码行数:25,代码来源:abstract_dom_editor.py

示例15: get_app_configuration

    def get_app_configuration(self, api_version, template_type, client_details):
        """
Returns ApiEndpoint settings based on the given API version.

:param api_version: API version requested
:param template_type: Template type requested by the client
:param client_details: JSON encoded client details

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

        if (template_type == ""): template_type = "ten_foot_web"
        template_type = "leanback_{0}".format(InputFilter.filter_control_chars(template_type).strip())

        session = Session.load()

        if (session.get("mp.leanback.user_agent") != self.client_user_agent):
            session.set("mp.leanback.access_granted", True)
            session.set("mp.leanback.user_agent", self.client_user_agent)
            session.set("mp.leanback.template_type", template_type)

            session.save()
        #

        url_parameters = { "m": "mp", "s": "leanback", "a": "dashboard", "uuid": session.get_uuid() }
        url = Link.get_preferred("upnp").build_url(Link.TYPE_ABSOLUTE_URL, url_parameters)

        return JsonResource().data_to_json({ "url": url })
开发者ID:dNG-git,项目名称:mp_core,代码行数:29,代码来源:api_endpoint_service.py


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