getting size of zope.schema.List from a view in bluebream
Joshua Immanuel <[email protected]>
| Newsgroups | gmane.comp.web.zope.bluebream,gmane.comp.web.zope.devel |
|---|---|
| Organization | HiPro IT Solutions Private Limited |
| Message-ID | <1314085584.2450.47.camel@jimman> |
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
signature.asc
(application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEABECAAYFAk5TWscACgkQWw85XwuSFMIHKgCgun5xwEuXm4grg/fEttmCHk81 7q8An32smQeXHl2/1CxJpQ95rqxrA6zW =JpNE -----END PGP SIGNATURE-----