Try using ``len(self.context)``. The container will report its size.
For a BTreeContainer, methods like ``values`` return OOBTreeItems, not
a regular Python list. That's where the error is happening. You can
get to the values of the OOBTreeItems object, but not its length. But
the container itself you should be able to access just fine.

The other option is to turn the result of values into a list or tuple::

    values = list(self.context.values())
    len(values)

But if you're just trying to get the number of items in the container,
``len(self.context)`` is the best pattern to use.

On 1/7/06, John Smith <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I have a containerish content object, subclassed from
> BTreeContainer.
>
> I have a view class which lists some of the contents.
>
> The view class receives a security proxied version of
> the content object but when I try
> len(self.context.values()) if get Forbidden Attribute
> : ('__len__', <OOBTreeItems object at ....> )
>
> I have tried altering the zcml content/require
> permissions but they are all set for "zope.View",
> including the IReadContainer interface.
>
> Is it to do with the fact that the object is
> subclassed from BTreeContainer?
>
> Any pointers gratefully received,
>
> Thanks,
>
> John
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with 
> voicemail http://uk.messenger.yahoo.com
> _______________________________________________
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to