MCPcopy Create free account
hub / github.com/PageBot/PageBot / Template

Class Template

Lib/pagebot/elements/template.py:21–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19from pagebot.elements.page import Page
20
21class Template(Page):
22
23 def __repr__(self):
24 return '<Template>'
25
26 def _get_parent(self):
27 """Answers the parent of the element, if it exists, by weakref
28 reference. Answer None of there is not parent defined or if the parent
29 not longer exists."""
30 if self._parent is not None:
31 return self._parent()
32 return None
33
34 def _set_parent(self, parent):
35 """Set the parent of the template. Don&#x27;t call self.appendParent here,
36 as we don&#x27;t want the parent to add self to the page/element list. Just
37 a simple reference, to connect to styles, etc."""
38 if parent is not None:
39 parent = weakref.ref(parent)
40 self._parent = parent
41 parent = property(_get_parent, _set_parent)
42
43 def draw(self, origin, view):
44 raise ValueError('Templates cannot draw themselves in a view. Apply the template to a page first.')
45
46
47if __name__ == '__main__':

Callers 3

initializeTemplatesMethod · 0.90
newTemplateFunction · 0.90
makeTemplateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected