def parent(self): """Obj to call :meth:`Request.link` or :meth:`Request.view` on parent. Get an object that represents the parent app that this app is mounted inside. You can call ``link`` and ``view`` on it. """ return generic.linkmaker(self, self.mounted.parent, lookup=self.lookup)
def child(self, app, **variables): """Obj to call :meth:`Request.link` or :meth:`Request.view` on child. Get an object that represents the application mounted in this app. You can call ``link`` and ``view`` on it. """ return generic.linkmaker(self, self.mounted.child(app, **variables), lookup=self.lookup)
def view(self, obj, default=None, **predicates): """Call view for model instance. This does not render the view, but calls the appropriate view function and returns its result. :param obj: the model instance to call the view on. :param default: default value if view is not found. :param predicates: extra predicates to modify view lookup, such as ``name`` and ``request_method``. The default ``name`` is empty, so the default view is looked up, and the default ``request_method`` is ``GET``. If you introduce your own predicates you can specify your own default. """ return generic.linkmaker(self, self.mounted, lookup=self.lookup).view(obj, default, **predicates)
def link(self, obj, name="", default=None): """Create a link (URL) to a view on a model instance. If no link can be constructed for the model instance, a :exc:``morepath.LinkError`` is raised. ``None`` is treated specially: if ``None`` is passed in the default value is returned. :param obj: the model instance to link to, or ``None``. :param name: the name of the view to link to. If omitted, the the default view is looked up. :param default: if ``None`` is passed in, the default value is returned. By default this is ``None``. """ return generic.linkmaker(self, self.mounted, lookup=self.lookup).link(obj, name, default)
def child(self, app, **variables): return generic.linkmaker(self.request, self.mounted.child(app, **variables), lookup=self.mounted.lookup)
def parent(self): return generic.linkmaker(self.request, self.mounted.parent, lookup=self.mounted.lookup)