Source code for page.collection

from onegov.core.orm.abstract import AdjacencyListCollection
from onegov.page.model import Page


[docs] class PageCollection(AdjacencyListCollection[Page]): """ Manages a hierarchy of pages. Use it like this: from onegov.page import PageCollection pages = PageCollection(session) """
[docs] __listclass__ = Page
[docs] def copy(self, page: Page, parent: Page | None) -> Page: """ Takes the given page and copies it to a given parent. The parent may be the same as the given page or another. If there's a conflict with existing children, the name is adjusted using :meth:`get_unique_child_name`. """ return self.add( parent=parent, title=page.title, type=page.type, meta=page.meta, content=page.content )