Ejemplo n.º 1
0
    def process_request(self, req):
        if req.path_info == '/mindmap/status':
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            try:
                cursor.execute('SELECT hash,content FROM mindmapcache')
                content = tag.html(
                    tag.body(
                        tag.dd([[
                            tag.dt(tag.a(k, href=req.href.mindmap(k + '.mm'))),
                            tag.dd(tag.pre(v))
                        ] for k, v in cursor.fetchall()])))
            except Exception, e:
                content = tag.html(
                    tag.body(tag.strong("DB Error: " + unicode(e))))
            html = content.generate().render("xhtml")
            req.send_response(200)
            req.send_header('Cache-control', 'must-revalidate')
            req.send_header('Content-Type', 'text/html;charset=utf-8')
            req.send_header('Content-Length', len(html))
            req.end_headers()

            if req.method != 'HEAD':
                req.write(html)
            raise RequestDone
Ejemplo n.º 2
0
 def extract_href(fragment):
   if isinstance(fragment, (Element, Fragment)):
     stream = tag.body(fragment).generate()
   else :
     self.log.debug("Extracting href from %s", fragment)
     stream = XML('<body>%s</body>' % (unicode(fragment),))
   for x in stream.select('a[@href]') :
     if x[0] == 'START' :
        return x[1][1].get('href')
Ejemplo n.º 3
0
    def process_request(self, req):
        if req.path_info == '/mindmap/status':
          db = self.env.get_db_cnx()
          cursor = db.cursor()
          try:
              cursor.execute('SELECT hash,content FROM mindmapcache')
              content = tag.html(tag.body(tag.dd(
                  [ [tag.dt(tag.a(k,href=req.href.mindmap(k + '.mm'))),tag.dd(tag.pre(v))] for k,v in cursor.fetchall()]
                )))
          except Exception, e:
              content = tag.html(tag.body(tag.strong("DB Error: " + unicode(e))))
          html = content.generate().render("xhtml")
          req.send_response(200)
          req.send_header('Cache-control', 'must-revalidate')
          req.send_header('Content-Type', 'text/html;charset=utf-8')
          req.send_header('Content-Length', len(html))
          req.end_headers()

          if req.method != 'HEAD':
             req.write(html)
          raise RequestDone
Ejemplo n.º 4
0
 def __init__(self, title='BaseDocument', **kwargs):
     BaseElement.__init__(self, 'html', **kwargs)
     self.head = tag.head()
     self.body = tag.body()
     self(self.head, self.body)
     self.header = None
     self.title = None
     self.stylesheet = None
     if title:
         self.setTitle(title)
     if self.stylesheet:
         self.setStylesheet(self.stylesheet)