Beispiel #1
0
    def __call__(self, env, start_response):
        """
		env["enkel.reuse.admin.stylesheet"] must contain the
		URL to the XSLT stylesheet.
		"""

        path = env["SCRIPT_NAME"] + env["PATH_INFO"]
        appid = None
        if not path.endswith("start/"):
            match = self.patt.match(path)
            if match:
                appid, action = match.groups()
                app, label, args, kw = self.apps[appid]
            else:
                raise Http404()

        w = XmlWriter(pretty=self.pretty)
        w.pi("xml", version="1.0", encoding=self.encoding)
        w.pi("xml-stylesheet", type="text/xsl", href=self.stylesheet)
        w.start_element("admin", xmlns=XMLNS_ADMIN)
        w.raw_node(self.applist_xml)

        if appid:
            w.empty_element("selected", app=appid, action=action)
        w.start_element("section", xmlns=XMLNS_MARKUP)
        if appid:
            app(env, w, appid, action, label, *args, **kw)
        else:
            self.startpage(env, w)
        w.end_element()

        start_response(
            "200 OK",
            [("content-type", "text/xml; charset=%s" % self.encoding)])
        yield w.create().encode(self.encoding)
Beispiel #2
0
	def save(self):
		manip = forminput_to_manip(self.MODEL, FormInput(self.env), "e_")
		try:
			manip.validate()
		except base.FieldValidationError:
			self._create_edit_form(manip, validate=True)
		else:
			p = XmlWriter(pretty=True)
			p.pi("xml", version="1.0", encoding=ENCODING)
			p.start_element("post", xmlns=XMLNS_STATICBLOG)

			p.start_element("summary")
			p.text_node(manip.summary)
			p.end_element()

			for tag in manip.tags.split(","):
				p.start_element("tag")
				p.text_node(tag.strip())
				p.end_element()

			p.start_element("section", xmlns=XMLNS_MARKUP,
					attrdict={"xmlns:s": XMLNS_STATICBLOG})
			p.start_element("h")
			p.text_node(manip.heading)
			p.end_element()
			p.raw_node(manip.post)
			p.end_element()

			p.end_element() # </post>

			path = join(self.posts_folder, manip.id)

			post = self.UNIVERSAL_NEWLINE_PATT.sub(r"\n", p.create())
			codecs.open(path, "wb", ENCODING).write(post)

			self.w.start_element("p")
			self.w.text_node(N_("Save successful"))
			self.w.end_element()
Beispiel #3
0
	def __call__(self, env, start_response):
		"""
		env["enkel.reuse.admin.stylesheet"] must contain the
		URL to the XSLT stylesheet.
		"""

		path = env["SCRIPT_NAME"] + env["PATH_INFO"]
		appid = None
		if not path.endswith("start/"):
			match = self.patt.match(path)
			if match:
				appid, action = match.groups()
				app, label, args, kw = self.apps[appid]
			else:
				raise Http404()


		w = XmlWriter(pretty=self.pretty)
		w.pi("xml", version="1.0", encoding=self.encoding)
		w.pi("xml-stylesheet", type="text/xsl", href=self.stylesheet)
		w.start_element("admin", xmlns=XMLNS_ADMIN)
		w.raw_node(self.applist_xml)

		if appid:
			w.empty_element("selected", app=appid, action=action)
		w.start_element("section", xmlns=XMLNS_MARKUP)
		if appid:
			app(env, w, appid, action, label, *args, **kw)
		else:
			self.startpage(env, w)
		w.end_element()

		start_response("200 OK", [
			("content-type", "text/xml; charset=%s" % self.encoding)
		])
		yield w.create().encode(self.encoding)