Server
The server itself is split into a part waiting for tcp commections and a RequestHandler. It is based on the SimpleHTTPServer from python and enhanced with notifier support and htdocs and cgi settings. The freevo webserver has two htdoc dirs. One is share/htdocs, the other Docs/html for the doc module. Right now src/www/htdocs is also a htdoc dir, but that will be removed in the future. The cgi directory is src/www itself. When requesting 'foo', the webserver will load src/www/foo.py.
PleaseUpdate: more documentation needed
Pages
Right now all pages must be added to src/www/base.py in the function print_header to add them to the tab bar on top of a page. The handler for a page is split into two classes: FreevoResource and HTMLResource. The first one is based on resources for the webserver itself, the second is a helper for creating pages in Freevo.
PleaseUpdate: more documentation needed
Example
The doc resource is a good example how to create a page
# import the needed ressources
from base import HTMLResource, FreevoResource
class DocResource(FreevoResource):
"""
A ressource based on FreevoResource
"""
def _render(self, request):
"""
The render function. Since FreevoResource creates the real render
function and adds some basic stuff, the real files need to define
_render.
"""
# Check arguments. if doc is called doc?file=foo, request query
# is {'file': 'foo'}.
if request.query.has_key('file'):
page = request.query['file']
else:
page = 'Index.html'
# create the HTMLResource
fv = HTMLResource()
# add the header
fv.printHeader(_('Documentation'), 'styles/main.ccs', selected=_('Doc'))
fv.res += '<p>Content of the page</p>\n'
fv.printLinks()
fv.printFooter()
return String( fv.res )
# init the resource, the variable must be called resource
resource = DocResource()
TODO
There is much to do on the webserver. It is running, but not very good.
- Create all missing pages from the old rpy files
- Move all needed htdoc files to share/htdocs
Merge HTMLResource and FreevoResource, it is confusing that way
- Remove the fv.res string. The server uses a cIOString for the content, why should we need an extra string, it will only slow things down.
- Make all pages plugins and auto-create the tab bar
- rename _render to something better
- make authorization work again (test code is working)
