コード例 #1
0
ファイル: adding.py プロジェクト: goschtl/zope
    def action(self, type_name='', id=''):
        if not type_name:
            raise UserError("You must select the type of object to add.")

        if type_name.startswith('@@'):
            type_name = type_name[2:]

        if '/' in type_name:
            view_name  = type_name.split('/', 1)[0]
        else:
            view_name = type_name

        if zapi.queryView(self, view_name, self.request) is not None:
            url = "%s/%s=%s" % (
                zapi.getMultiAdapter((self, self.request), name=u"absolute_url"),
                type_name, id)
            self.request.response.redirect(url)
            return

        if not self.contentName:
            self.contentName = id

        factory = zapi.getUtility(IFactory, type_name)
        content = factory()

        notify(ObjectCreatedEvent(content))
        self.add(content)
        self.request.response.redirect(self.nextURL())
コード例 #2
0
ファイル: adding.py プロジェクト: bendavis78/zope
    def action(self, type_name='', id=''):
        if not type_name:
            raise UserError("You must select the type of object to add.")

        if type_name.startswith('@@'):
            type_name = type_name[2:]

        if '/' in type_name:
            view_name = type_name.split('/', 1)[0]
        else:
            view_name = type_name

        if zapi.queryView(self, view_name, self.request) is not None:
            url = "%s/%s=%s" % (zapi.getView(self, "absolute_url",
                                             self.request), type_name, id)
            self.request.response.redirect(url)
            return

        if not self.contentName:
            self.contentName = id

        factory = zapi.getUtility(IFactory, type_name)
        content = factory()

        notify(ObjectCreatedEvent(content))
        self.add(content)
        self.request.response.redirect(self.nextURL())
コード例 #3
0
ファイル: adding.py プロジェクト: bendavis78/zope
    def publishTraverse(self, request, name):
        """See zope.app.container.interfaces.IAdding"""
        if '=' in name:
            view_name, content_name = name.split("=", 1)
            self.contentName = content_name

            if view_name.startswith('@@'):
                view_name = view_name[2:]
            return zapi.getView(self, view_name, request)

        if name.startswith('@@'):
            view_name = name[2:]
        else:
            view_name = name

        view = zapi.queryView(self, view_name, request)
        if view is not None:
            return view

        factory = zapi.queryUtility(IFactory, name)
        if factory is None:
            return super(BasicAdding, self).publishTraverse(request, name)

        return factory
コード例 #4
0
ファイル: adding.py プロジェクト: goschtl/zope
    def publishTraverse(self, request, name):
        """See zope.app.container.interfaces.IAdding"""
        if '=' in name:
            view_name, content_name = name.split("=", 1)
            self.contentName = content_name

            if view_name.startswith('@@'):
                view_name = view_name[2:]
            return zapi.getMultiAdapter((self, request), name=view_name)

        if name.startswith('@@'):
            view_name = name[2:]
        else:
            view_name = name

        view = zapi.queryView(self, view_name, request)
        if view is not None:
            return view

        factory = zapi.queryUtility(IFactory, name)
        if factory is None:
            return super(BasicAdding, self).publishTraverse(request, name)

        return factory