示例#1
0
文件: request.py 项目: io41/morepath
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
文件: request.py 项目: io41/morepath
 def child(self, app, **variables):
     return generic.linkmaker(self.request,
                              self.mounted.child(app, **variables),
                              lookup=self.mounted.lookup)
示例#6
0
文件: request.py 项目: io41/morepath
 def parent(self):
     return generic.linkmaker(self.request, self.mounted.parent,
                              lookup=self.mounted.lookup)