[Zope-dev] getting size of zope.schema.List from a view in bluebream

Adam GROSZER agroszer.ll at gmail.com
Tue Aug 23 08:39:43 EDT 2011


Hello,

Well using removeSecurityProxy is not so nice.

If there's really a list in your property, then zope should give you 
zope.Public access:

_default_checkers = {
...
     list: NamesChecker(['__getitem__', '__getslice__', '__len__', 
'__iter__',
                         '__contains__', 'index', 'count', '__str__',
                         '__add__', '__radd__', ]),
...

Can you do:

           from zope.security.proxy import removeSecurityProxy

           li = removeSecurityProxy(self.context.list_field)
	  print type(li)

On Tue, 23 Aug 2011 17:43:22 +0530 you wrote:
>
> Hello Charlie,
>
> Thanks for the reply.
>
> On Tue, 2011-08-23 at 13:56 +0200, Charlie Clark wrote:
>> I think it's really difficult to work out what you are trying to do.
>> Please state your problem more clearly. Are you still using zope.form
>> or are you using z3c.form?
>
> I am still using zope.formlib. I guess I found the root of the problem.
> All the schema fields are security proxied I guess. Removing the
> security proxy from those fields before accessing the field's inbuilt
> methods solves the problem. So, my code now looks like this
>
>          from zope.security.proxy import removeSecurityProxy
>
>          sz = len(removeSecurityProxy(self.context.list_field))
>          ...
>
>          li = removeSecurityProxy(self.context.list_field)
>          res = li[offset:limit]
>
> I guess this is a cleaner approach.
>
> Regards
>
>
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at 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 )


-- 
Best regards,
  Adam GROSZER
--
Quote of the day:
The celestial order and the beauty of the universe compel me to admit 
that there is some excellent and eternal Being, Who deserves the respect 
and homage of men.
- Cicero


More information about the Zope-Dev mailing list