[Moin-devel] virtual pages

Alexander Bernauer moin at copton.net
Sat Nov 6 05:41:37 EST 2004


Hi 

I'm helping the ffii [1] developing a web application called
gauss. It is a web accessable database of software patents.

The site will consist of mainly two parts:
1) Patent information stored in a SQL database
2) User annotations stored as ordinary wiki pages.

To have a common user interface we unite both contents through the wiki
engine. 

The first idea was to write a macro which accesses the SQL db and
generates the wiki page for a patent. But this would result in having
thousands of wiki pages with all having the same structure. Obviously
one can do better.

So I had the idea of virtual pages:
The user can browse the wiki page EP1234 for details on the european
patent with number 1234. But this side does not exist as wiki page.
Instead some python script is called which queries the SQL database and
generates wiki markup on the fly. This markup is then parsed and
formatted as usual. So EP1234 is a virtual page.

For a first approach I introduced the class VirtualPage

---8<--- file: VirtualPage.py ---8<---

from Page import Page

class VirtualPage(Page):
    def __init__(self, page_name, data, **kw):
        apply(Page.__init__, (self, page_name), kw)
        self.data = data;

    def get_raw_body(self):
        return self.data

    def set_raw_body(self, body, modified=0):
        self.data = body

    def isWritable(self):
        return False

    def exists(self):
        return True

    def size(self):
        return len(self.data)

    def mtime(self):
        return 0


-------------->8----------------------

This class is used by the action plugin "virtual".  The main
disadvantage is, that one always has to browse EP1234?action=virtual
instead of just EP1234. This is annoying. Furthermore we are going to
have much more virtual pages for indexed search, such like
Inventor/A-E.



So I was thinking of a general approach on virtual pages. This is my
idea:

1) There is a dispatcher for virtual pages
2) Plugins for virtual pages provide a regular expression on the page
name to the dispatcher.
3) If Page.get_raw_body failes to find the demanded page in the file system it
askes the dispatcher. If there is a responsible plugin it is called and
supposed to return wiki markup. If there is no responsible plugin the
dispatcher returns None and Page continues as usual, thus sending the
normal "Create this page" to the user.

What do you think? Will this fit into Moins design? Do you see any
problems? 

I want to implement this feature. If you want, I will contribute it.

cu

Alexander Bernauer


[1] http://www.ffii.org

-- 
Alexander Bernauer




More information about the Moin-devel mailing list