SitePage.py :  » Web-Frameworks » Webware » Webware-1.0.2 » MiddleKit » WebBrowser » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Frameworks » Webware 
Webware » Webware 1.0.2 » MiddleKit » WebBrowser » SitePage.py
import os

from MiscUtils.Configurable import Configurable
from WebKit.Page import Page

debug = 0


class SitePage(Page, Configurable):

  def __init__(self):
    Page.__init__(self)
    Configurable.__init__(self)

  def configFilename(self):
    return self.request().serverSidePath('Properties.config')

  def printDict(self, dict):
    for key, value in dict.items():
      print '  %s = %s' % (key, value)

  def writeHTML(self):
    if debug:
      req = self.request()
      print '>> About to writeHTML()'
      print '>> fields:'
      self.printDict(req.fields())
      print '>> cookies:'
      self.printDict(req.cookies())
      print
    Page.writeHTML(self)

  def writeStyleSheet(self):
    self.writeln('<link rel="stylesheet" href="StyleSheet.css" type="text/css">')

  def writeBodyParts(self):
    wr = self.writeln
    wr('<table border="0" cellpadding="2" cellspacing="0" width="100%">')

    wr('<tr><td colspan="2" class="TitleBar">')
    self.writeTitleBar()
    wr('</td></tr>')

    wr('<tr><td colspan="2" class="TopBar">')
    self.writeTopBar()
    wr('</td></tr>')

    wr('<tr>')
    wr('<td valign="top" width="5%" class="SideBar">')
    self.writeSideBar()
    wr('</td>')

    wr('<td valign="top" width="95%" class="ContentWell">')
    self.writeContent()
    wr('</td>')
    wr('</tr>')

    wr('</table>')

  def writeTitleBar(self):
    self.writeln('MiddleKit Browser')

  def writeTopBar(self):
    self.writeln('&nbsp;')

  def writeSideBar(self):
    pass

  def writeHeading(self, heading, level=4):
    self.writeln('<h%d class="Heading">%s</h%d>' % (level, heading, level))

  def writeHelp(self):
    self.writeHeading('Help')
    self.writeln(self.help())

  def help(self, name=None):
    """Returns the body text for help on this page. Loaded from SelectModelHelp.htmlf."""
    if not name:
      name = self.__class__.__name__
    filename = self.request().serverSidePath('Help/%s.htmlf' % name)
    help = open(filename).read()
    help = '<span class="Help">%s</span>' % help
    return help

  def saveFieldsToCookies(self):
    res = self.response()
    for name, value in self.request().fields().items():
      res.setCookie(name, value)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.