Hello all,
        While trying to get the length of zope.schema.List field in a view
(like this: len(self.context.list_field) I get the following error

        ForbiddenAttribute: ('__len__', [])
        
Even though my zcml configuration for that class is defined as below

  <class class=".app.MyObject">

    <require
        permission="zope.Public"
        interface=".interfaces.IMyObject"
        />

    <require
        permission="zope.Public"
        set_schema=".interfaces.IMyObject"
        />
  </class>

I still get the above error. To circumvent this issue, I added a method
in the interface like say 'getListSize()' which has the following
implementation

        class MyObject(persistent.Persistent):
            implements(IMyObject)
        
            name = u''
            list_field = PersistentList()
            ...
        
            def getListSize(self):
                return len(self.list_field)
        
This solves my issue. However, I am curious to know whether is this the
only solution available to the above issue. Am I going in the right
direction?

Please guide me.

-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to