예제 #1
0
    def traverseName(self, request, ob, name):
        nm = name # the name to look up the object with

        if name and name[:1] in '@+':
            # Process URI segment parameters.
            ns, nm = nsParse(name)
            if ns:
                try:
                    ob2 = namespaceLookup(ns, nm, ob, request)
                except TraversalError:
                    raise NotFound(ob, name)

                return self.proxy(ob2)

        if nm == '.':
            return ob

        if IPublishTraverse.providedBy(ob):
            ob2 = ob.publishTraverse(request, nm)
        else:
            # self is marker
            adapter = queryMultiAdapter((ob, request), IPublishTraverse,
                                        default=self)
            if adapter is not self:
                ob2 = adapter.publishTraverse(request, nm)
            else:
                raise NotFound(ob, name, request)

        return self.proxy(ob2)
예제 #2
0
    def traverseName(self, request, ob, name):
        nm = name  # the name to look up the object with

        if name and name[:1] in '@+':
            # Process URI segment parameters.
            ns, nm = nsParse(name)
            if ns:
                try:
                    ob2 = namespaceLookup(ns, nm, ob, request)
                except TraversalError:
                    raise NotFound(ob, name)

                return self.proxy(ob2)

        if nm == '.':
            return ob

        if IPublishTraverse.providedBy(ob):
            ob2 = ob.publishTraverse(request, nm)
        else:
            # self is marker
            adapter = queryMultiAdapter((ob, request), IPublishTraverse,
                                        default=self)
            if adapter is not self:
                ob2 = adapter.publishTraverse(request, nm)
            else:
                raise NotFound(ob, name, request)

        return self.proxy(ob2)
예제 #3
0
파일: BaseRequest.py 프로젝트: wlang42/Zope
    def traverseName(self, ob, name):
        if name and name[:1] in '@+':
            # Process URI segment parameters.
            ns, nm = nsParse(name)
            if ns:
                try:
                    ob2 = namespaceLookup(ns, nm, ob, self)
                except LocationError:
                    raise ztkNotFound(ob, name)

                if IAcquirer.providedBy(ob2):
                    ob2 = ob2.__of__(ob)
                return ob2

        if name == '.':
            return ob

        if IPublishTraverse.providedBy(ob):
            ob2 = ob.publishTraverse(self, name)
        else:
            adapter = queryMultiAdapter((ob, self), IPublishTraverse)
            if adapter is None:
                # Zope2 doesn't set up its own adapters in a lot of cases
                # so we will just use a default adapter.
                adapter = DefaultPublishTraverse(ob, self)

            ob2 = adapter.publishTraverse(self, name)

        return ob2
예제 #4
0
    def traverseName(self, ob, name):
        if name and name[:1] in '@+':
            # Process URI segment parameters.
            ns, nm = nsParse(name)
            if ns:
                try:
                    ob2 = namespaceLookup(ns, nm, ob, self)
                except LocationError:
                    raise ztkNotFound(ob, name)

                if IAcquirer.providedBy(ob2):
                    ob2 = ob2.__of__(ob)
                return ob2

        if name == '.':
            return ob

        if IPublishTraverse.providedBy(ob):
            ob2 = ob.publishTraverse(self, name)
        else:
            adapter = queryMultiAdapter((ob, self), IPublishTraverse)
            if adapter is None:
                ## Zope2 doesn't set up its own adapters in a lot of cases
                ## so we will just use a default adapter.
                adapter = DefaultPublishTraverse(ob, self)

            ob2 = adapter.publishTraverse(self, name)

        return ob2
예제 #5
0
    def traverseName(self, request, ob, name):
        bpth = getattr(object, '__before_publishing_traverse__', None)
        if bpth is not None:
            bpth(object, self)

        # mostly lifted from zope.app.publication.publicationtraverse
        lookup_name = name

        if name and name[:1] in '@+':
            # Process URI segment parameters.
            ns, lookup_name = nsParse(name)
            if ns:
                try:
                    subobject = namespaceLookup(ns, lookup_name, ob, request)
                except TraversalError:
                    raise NotFound(ob, name)

                return subobject

        if lookup_name == '.':
            return ob

        if IPublishTraverse.providedBy(ob):
            subobject = ob.publishTraverse(request, lookup_name)
        else:
            # self is marker
            adapter = queryMultiAdapter((ob, request),
                                        IPublishTraverse,
                                        default=self)
            if adapter is not self:
                subobject = adapter.publishTraverse(request, lookup_name)
            else:
                raise NotFound(ob, name, request)

        request['PARENTS'].append(subobject)
        return subobject
예제 #6
0
    def getAllowedViews(self):
        """
        This method will return a dict containing the view name as keys
        and filesystem full path to both page template files and python
        files, according if it is a BrowserView or a FSPageTemplate
        """

        pt = getToolByName(self.context, 'portal_types')
        portal_type = self.context.portal_type
        dvt = pt[portal_type]

        result  = {}
        # The following was taken from traverseName function from
        # ZPublisher/BaseRequest.py
        for view in dvt.view_methods:
            if view[:1] in '@+':
                # Process URI segment parameters.
                ns, nm = nsParse(view)
                if ns:
                    try:
                        ob = namespaceLookup(ns, nm, self.context, self.request)
                    except TraversalError:
                        result[view] = {}
                        continue

                    if IAcquirer.providedBy(ob):
                        ob = ob.__of__(self.context)

            else:
                if IPublishTraverse.providedBy(self.context):
                    ob = self.context.publishTraverse(self.request, view)
                else:
                    adapter = queryMultiAdapter((self.context, self.request),
                                                IPublishTraverse)
                    if adapter is None:
                        ## Zope2 doesn't set up its own adapters in a lot of cases
                        ## so we will just use a default adapter.
                        adapter = DefaultPublishTraverse(self.context, self.request)

                    ob = adapter.publishTraverse(self.request, view)


            if isinstance(ob, BrowserView):
                # Taken from five.customerize.browser
                klass = ob.__class__
                base = klass.__bases__[0]
                if base is BrowserView or base is object:
                    py_file = inspect.getsourcefile(klass)
                else:
                    py_file = inspect.getsourcefile(base)
                pt_file = ob.index.filename

                result[view] = {'py':py_file,
                                'pt':pt_file}

            elif isinstance(ob, FSPageTemplate):
                result[view] = {'pt':ob.getObjectFSPath()}

            else:
                result[view] = {}


        return result
예제 #7
0
    nm = name # the name to look up the object with
    if name and name[:1] in '@+':
        # Process URI segment parameters.
        ns, nm = nsParse(name)
        if ns:
            try:
                ob2 = namespaceLookup(ns, nm, ob, request)
            except (TraversalError, ValueError), e:
                raise NotFound(ob, name)

            return ProxyFactory(ob2)

    if nm == '.':
        return ob

    if IPublishTraverse.providedBy(ob):
        ob2 = ob.publishTraverse(request, nm)
    else:
        # self is marker
        adapter = component.queryMultiAdapter((ob, request), IPublishTraverse,
                                    default=self)
        if adapter is not self:
            if component.getUtility(ICaseInsensitiveConfiglet).isNonCaseInsensitive:
                try:
                    for key in removeSecurityProxy(ob).keys():
                        if key.lower() == name.lower():
                            nm = key
                except AttributeError:
                    pass
            ob2 = adapter.publishTraverse(request, nm)
        else: