1 """
2 User-defined renderers.
3 """
4
5
6
7
8
9
10
11 import imp
12
13 from nevow import url
14
15 from gavo import svcs
16 from gavo.web import grend
20 """A renderer defined in a python module.
21
22 To define a custom renderer write a python module and define a
23 class MainPage inheriting from gavo.web.ServiceBasedPage.
24
25 This class basically is a nevow resource, i.e., you can define
26 docFactory, locateChild, renderHTTP, and so on.
27
28 To use it, you have to define a service with the resdir-relative path
29 to the module in the customPage attribute and probably a nullCore. You
30 also have to allow the custom renderer (but you may have other renderers,
31 e.g., static).
32
33 If the custom page is for display in web browsers, define a
34 class method isBrowseable(cls, service) returning true. This is
35 for the generation of links like "use this service from your browser"
36 only; it does not change the service's behaviour with your renderer.
37
38 There should really be a bit more docs on this, but alas, there's
39 none as yet.
40 """
41 name = "custom"
42
49
50 @classmethod
54
56 mod = imp.load_module(*self.reloadInfo)
57 pageClass = mod.MainPage
58 self.service.customPageCode = (pageClass, self.reloadInfo)
59 return url.here.curdir()
60
63
66