Re: getting size of zope.schema.List from a view in bluebream

Adam GROSZER <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
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  -  [email protected]
> 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
_______________________________________________
Zope-Dev maillist  -  [email protected]
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 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.