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

2011-08-23 Thread Joshua Immanuel
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
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 )


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

2011-08-23 Thread Adam GROSZER
Hello,

You forgot to paste interfaces.IMyObject definition.

On Tue, 23 Aug 2011 13:16:24 +0530 you wrote:

 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.




 ___
 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 )


-- 
Best regards,
  Adam GROSZER
--
Quote of the day:
Two men please God: who serves Him with all his heart because he knows 
Him; who seeks Him with all his heart because he knows Him not.
- Nikita Ivanovich Panin
___
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 )


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

2011-08-23 Thread Joshua Immanuel
Hello all,
On Tue, 2011-08-23 at 13:16 +0530, Joshua Immanuel wrote:
 def getListSize(self):
 return len(self.list_field)
 
 This solves my issue. 

This solves just the '__len__' issue. But if do the slice operation like
this

self.context.list_field[offset:limit]

I get the following error

ForbiddenAttribute: ('__getslice__',[...])

I guess my approach is flawed. Implementing all the functionality (like
the one I did for length) that a list provides is a overkill. So, please
guide me in this regard.

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


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 )


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

2011-08-23 Thread Charlie Clark
Am 23.08.2011, 13:34 Uhr, schrieb Joshua Immanuel j...@hipro.co.in:

 This solves just the '__len__' issue. But if do the slice operation like
 this
self.context.list_field[offset:limit]
 I get the following error
ForbiddenAttribute: ('__getslice__',[...])
 I guess my approach is flawed. Implementing all the functionality (like
 the one I did for length) that a list provides is a overkill. So, please
 guide me in this regard.

Joshua,

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?

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting  Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
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 )


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

2011-08-23 Thread Joshua Immanuel
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
-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in


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 )


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

2011-08-23 Thread Adam GROSZER
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@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
___
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 )


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

2011-08-23 Thread Joshua Immanuel
Hello Adam,

Thanks for the reply.

On Tue, 2011-08-23 at 14:39 +0200, Adam GROSZER wrote:
 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) 

As I am using the persistent List in the implementation of IMyObject,
the output of the above is

class 'persistent.list.PersistentList'

So, How can I access its inbuilt methods without removing the security
proxy. Please guide me.

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


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 )


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

2011-08-23 Thread Joshua Immanuel
Hello Adam,

On Tue, 2011-08-23 at 15:13 +0200, Adam GROSZER wrote:
 class class=persistent.list.PersistentList
 allow attributes=__getitem__ __getslice__ __len__ __iter__
__contains__ index count data /
 /class
 
 Should do it. (but beware I did not test!)
 
 That is in zope.app.security/_protections.zcml
 
 Might be that you'd need to include that package. 

Yes. Including that file in zcml solved the issue.

include package=zope.app.security file=_protections.zcml /

Apart from the PersistentList and PersistentDict I see many other BTree
related allow attributes configurations. I guess these configurations
are not available in any other place and including this
'_protections.zcml' is safe.

Thanks for the tip.

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


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 )


[Zope-dev] zope-tests - FAILED: 32, OK: 29, UNKNOWN: 3

2011-08-23 Thread Zope tests summarizer
This is the summary for test reports received on the 
zope-tests list between 2011-08-22 00:00:00 UTC and 2011-08-23 00:00:00 UTC:

See the footnotes for test reports of unsuccessful builds.

An up-to date view of the builders is also available in our 
buildbot documentation: 
http://docs.zope.org/zopetoolkit/process/buildbots.html#the-nightly-builds

Reports received


   Bluebream / Python2.4.6 64bit linux
   Bluebream / Python2.5.5 64bit linux
   Bluebream / Python2.6.5 64bit linux
[1]FAILED (failures=6, errors=9) : Zope-trunk Python-2.6.6 : Linux
[2]FAILED (failures=7, errors=9) : Zope-trunk-alltests Python-2.6.6 : Linux
[3]UNKNOWN : winbot / ZODB_dev py_270_win32
   ZTK 1.0 / Python2.4.6 Linux 64bit
   ZTK 1.0 / Python2.5.5 Linux 64bit
   ZTK 1.0 / Python2.6.5 Linux 64bit
[4]ZTK 1.0dev / Python2.4.6 Linux 64bit
[5]ZTK 1.0dev / Python2.5.5 Linux 64bit
[6]ZTK 1.0dev / Python2.6.5 Linux 64bit
   Zope 3.4 KGS / Python2.4.6 64bit linux
   Zope 3.4 KGS / Python2.5.5 64bit linux
   Zope 3.4 Known Good Set / py2.4-32bit-linux
   Zope 3.4 Known Good Set / py2.4-64bit-linux
   Zope 3.4 Known Good Set / py2.5-32bit-linux
   Zope 3.4 Known Good Set / py2.5-64bit-linux
   Zope-2.10 Python-2.4.6 : Linux
   Zope-2.11 Python-2.4.6 : Linux
   Zope-2.12 Python-2.6.6 : Linux
   Zope-2.12-alltests Python-2.6.6 : Linux
   Zope-2.13 Python-2.6.6 : Linux
   Zope-2.13-alltests Python-2.6.6 : Linux
   winbot / ZODB_dev py_254_win32
   winbot / ZODB_dev py_265_win32
   winbot / ZODB_dev py_265_win64
   winbot / ZODB_dev py_270_win64
[7]winbot / z3c.configurator_py_265_32
[8]winbot / z3c.contents_py_265_32
[9]winbot / z3c.formui_py_265_32
[10]   winbot / z3c.jsontree_py_265_32
[11]   winbot / z3c.layer.pagelet_py_265_32
[12]   winbot / z3c.pagelet_py_265_32
[13]   winbot / z3c.sampledata_py_265_32
[14]   winbot / z3c.tabular_py_265_32
[15]   winbot / z3c.template_py_265_32
[16]   winbot / zc.ngi_py_265_32
[17]   winbot / zc.resourcelibrary_py_265_32
[18]   winbot / zope.app.authentication_py_265_32
[19]   winbot / zope.app.component_py_265_32
[20]   winbot / zope.app.container_py_265_32
[21]   winbot / zope.app.form_py_265_32
[22]   winbot / zope.app.publisher_py_265_32
[23]   winbot / zope.app.testing_py_265_32
[24]   winbot / zope.contentprovider_py_265_32
[25]   winbot / zope.formlib_py_265_32
[26]   winbot / zope.pagetemplate_py_265_32
[27]   winbot / zope.pagetemplate_py_265_32
[28]   winbot / zope.pagetemplate_py_265_32
[29]   winbot / zope.viewlet_py_265_32
   winbot / ztk_10 py_254_win32
   winbot / ztk_10 py_265_win32
[30]   winbot / ztk_10 py_265_win64
   winbot / ztk_11 py_254_win32
   winbot / ztk_11 py_265_win32
   winbot / ztk_11 py_265_win64
   winbot / ztk_11 py_270_win32
   winbot / ztk_11 py_270_win64
[31]   winbot / ztk_dev py_254_win32
[32]   winbot / ztk_dev py_265_win32
[33]   winbot / ztk_dev py_265_win64
[34]   winbot / ztk_dev py_270_win32
[35]   winbot / ztk_dev py_270_win64

Non-OK results
--

[1]UNKNOWN FAILED (failures=6, errors=9) : Zope-trunk Python-2.6.6 : Linux
   https://mail.zope.org/pipermail/zope-tests/2011-August/048588.html


[2]UNKNOWN FAILED (failures=7, errors=9) : Zope-trunk-alltests Python-2.6.6 
: Linux
   https://mail.zope.org/pipermail/zope-tests/2011-August/048589.html


[3]UNKNOWN UNKNOWN : winbot / ZODB_dev py_270_win32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048547.html


[4]FAILED  ZTK 1.0dev / Python2.4.6 Linux 64bit
   https://mail.zope.org/pipermail/zope-tests/2011-August/048562.html


[5]FAILED  ZTK 1.0dev / Python2.5.5 Linux 64bit
   https://mail.zope.org/pipermail/zope-tests/2011-August/048564.html


[6]FAILED  ZTK 1.0dev / Python2.6.5 Linux 64bit
   https://mail.zope.org/pipermail/zope-tests/2011-August/048563.html


[7]FAILED  winbot / z3c.configurator_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048555.html


[8]FAILED  winbot / z3c.contents_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048569.html


[9]FAILED  winbot / z3c.formui_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048557.html


[10]   FAILED  winbot / z3c.jsontree_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048565.html


[11]   FAILED  winbot / z3c.layer.pagelet_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048566.html


[12]   FAILED  winbot / z3c.pagelet_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048578.html


[13]   FAILED  winbot / z3c.sampledata_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048571.html


[14]   FAILED  winbot / z3c.tabular_py_265_32
   https://mail.zope.org/pipermail/zope-tests/2011-August/048568.html


[15]   FAILED  winbot /