Re: [documancer] Working on ".book" file support
Status: Beta
Brought to you by:
vaclavslavik
|
From: Vaclav S. <vac...@ma...> - 2004-06-14 12:18:35
|
Hi,
Kevin Ollivier wrote:
> I've finally had a chance to get back to my little project of
> integrating Documancer and EClass, and I have made some progress.
> I've extended book.py so that it can save and load data to an
> XML-based config file. This allows me to successfully load an
> EClass into Documancer by passing the .book file into the command
> line. (As a side benefit, it could be used for import/export of
> configs, like when moving to a new computer.)
Yes, I agree it would be useful for this -- I treat books definitions=20
as settings now (i.e. I store them in registry/dotfile) while in fact=20
they are _data_ that Documancer works on. OTOH, they are not portable=20
to other computers (yet) because they contain absolute filenames.
> I looked through the source to learn more about how Documancer
> handles URLs, but it was a bit like magic to me, so maybe I need a
> higher level explanation. ;-) Basically, it seems that Documancer
> wants to use a combination of a standard http URL with an absolute
> URL built in (i.e.
> http://localhost:port/book//C/Documents%20and%20Settings/...)
Documancer doesn't really use URLs internally, it's just a way to talk=20
to Mozilla. There are three kinds of objects in Documancer:
1. Book objects contain information about book type ("provider" -=20
html, man, info etc.) and type-specific definition (in case of HTML,=20
filename of the main page)
2. Providers are classes that are able to present data of certain type=20
(html, man, info, ...) as HTML. When asked for a page, the provider=20
is given two arguments: the book to work with and what I'll call=20
"virtual filename" for lack of better term ("url" in=20
Provider.serve(), but it's a little misleading). This filename is=20
provider-specific and can be interpreted in any way; usually, it's=20
something convenient for the provider (e.g. filename of HTML file on=20
the disk).
3. HTTP server running on random port and accepting only local=20
connections. This server is used to serve the pages to Mozilla-based=20
UI. You can ask it for documents with URLs in certain form:
http://localhost:rnd_port/book/virt_filename
The server strips the URL into parts, finds the book with this name,=20
looks its provider up and calls its serve() method with given (book,=20
virt_filename) tuple. UI (which includes fulltext search results) is=20
the only place where this kind of URLs is used, providers use=20
virt_filenames and book definitions may use something else altogether=20
(in case of HTML books, there's only 'rootfile' attribute which is=20
same thing as HtmlProvider's virtual filename).
Does it answer your questions about URLs?
> However, whenever I click on one of these links, nothing happens
> (except I get a busy cursor), and I eventually get a message that
> there is no server on "localhost:<portnumber>".
=46rom within Documancer? It's possible that the HTTP server running=20
under the hood crashed -- watch stderr for any output.
Regards,
Vaclav
=2D-=20
PGP key: 0x465264C9, available from http://pgp.mit.edu/
|