| 19 | from pagebot.elements.page import Page |
| 20 | |
| 21 | class 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't call self.appendParent here, |
| 36 | as we don'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 | |
| 47 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected