[Zope3-Users] Access to request in content object and object path in doctests

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Thu Jan 25 03:18:22 EST 2007


> <InterfaceClass zope.traversing.interfaces.IPhysicallyLocatable>)
>
> Ehm...? Ideas?
OK, I forgot about:
setup.setUpTraversal()

Now it works with:

>>> from zope.app.folder import rootFolder 
>>> from zope.traversing.api import getPath
>>> root = rootFolder()
>>> root['test_content'] = DBCrudContent()
>>> test_content = root['test_content']
>>> getPath(root['test_content'])
/test_content

but unfortuantelly when my object is trying to get
path to itself like:

class DBCrudContent():
    def myfunction(self):
        getPath(self)

    >>> test_content.myfunction()

I get error:

File "dbcrudbase.txt", line 86, in dbcrudbase.txt
Failed example:
    test_content.myfunction()
Exception raised:
    Traceback (most recent call last):
      File
"/home/downloads/Zope/Zope-3.3.0/build/lib.linux-i686-2.4/zope/testing/doctest.py",
line 1256, in __run
        compileflags, 1) in test.globs
      File "<doctest dbcrudbase.txt[17]>", line 1, in ?
        test_content.myfunction()
      File "<doctest dbcrudbase.txt[7]>", line 18, in myfunction
        getPath(self)
      File
"/home/downloads/Zope/Zope-3.3.0/build/lib.linux-i686-2.4/zope/traversing/api.py",
line 62, in getPath
        return IPhysicallyLocatable(obj).getPath()
      File
"/home/downloads/Zope/Zope-3.3.0/build/lib.linux-i686-2.4/zope/location/traversing.py",
line 154, in getPath
        raise TypeError("Not enough context to determine location root")
    TypeError: Not enough context to determine location root

-- 
Maciej Wisniowski


More information about the Zope3-users mailing list