Re: [Zope3-Users] Problem with z3c.form security when rendering error

2007-09-20 Thread Michael Kerrin
Hi Yuan,

I think I am having the same problem, as in all the errors look the same. I 
have just committed a fix for my problem so hopefully it is the same problem.

I did like you said added the widget to the interface and declared that all 
the widgets require the zope.Public permission to access the attribute.

Michael

On Thursday 20 September 2007 17:17:05 Yuan HOng wrote:
 HI, list:

 I am new to z3c.form. In my first AddForm, I encountered the following
 problem:

 When the form is submitted which contains some input error, like
 missing required fields, the rendering of the error message causes an
 system error. The traceback:

 ...
   File
 /usr/lib/python2.5/site-packages/zope.app.pagetemplate-3.4.0b1dev_r75616-p
y2.5.egg/zope/app/pagetemplate/engine.py, line 68, in __call__
 request=request)
   File
 /usr/lib/python2.5/site-packages/zope.traversing-3.5.0a1.dev_r78730-py2.5.
egg/zope/traversing/adapters.py, line 164, in traversePathElement
 return traversable.traverse(nm, further_path)
- __traceback_info__: (ErrorViewSnippet for RequiredMissing, 'widget')
   File
 /usr/lib/python2.5/site-packages/zope.traversing-3.5.0a1.dev_r78730-py2.5.
egg/zope/traversing/adapters.py, line 52, in traverse
 raise TraversalError(subject, name)
- __traceback_info__: (ErrorViewSnippet for RequiredMissing, 'widget',
 []) TraversalError: (ErrorViewSnippet for RequiredMissing, 'widget')

 After a little debugging, I was able to find that the chain leading to
 the error is as follows:

 1. div-form.pt in the z3c.formui package contains the following error
 presentation:

   li tal:repeat=error view/widgets/errors
 tal:block condition=error/widget
   span tal:replace=error/widget/label /:
 /tal:block
 span tal:replace=structure error/renderError Type/span
   /li

 error/widget is accessed here, with error being an ErrorViewSnippet object.

 2. The ErrorViewSnipped is created in field.py using:

   view = zope.component.getMultiAdapter(
   (error, self.request, widget, widget.field,
self.form, self.content), interfaces.IErrorViewSnippet)

 As in my application, self.content is a custom ISite folder, which is
 security proxied, the getMultiAdapter method returns a security
 proxied ErrorViewSnippet object.

 3. Access to ErrorViewSnippet is defined in z3c.form/configure.zcml as:

   adapter
   factory=.error.ErrorViewSnippet
   trusted=True
   permission=zope.Public
   /

 The IErrorViewSnippet interface contains only 3 attributes: error,
 update, render. Those are accessible to everyone. But there is no
 security declaration for the 'widget' attribute, so access to it is
 denied:

 (Pdb) snippet
 ErrorViewSnippet for RequiredMissing
 (Pdb) type(snippet)
 type 'zope.security._proxy._Proxy'
 (Pdb) from zope.security.proxy import getChecker
 (Pdb) getChecker(snippet).get_permissions
 {'update': Global(CheckerPublic,zope.security.checker), 'render':
 Global(CheckerPublic,zope.security.checker), 'error':
 Global(CheckerPublic,zope.security.checker)}
 (Pdb) from zope.security import canAccess
 (Pdb) canAccess(snippet, 'widget')
 *** ForbiddenAttribute: ('widget', ErrorViewSnippet for RequiredMissing)

 So it seems the default z3c.form security declaration only allows
 access to 'update', 'error' and 'render' attributes of an
 ErrorViewSnippet object. I tried to work this around the by adding the
 'widget' attribute to the IErrorViewSnippet interface and the system
 error is no longer raised. However, this time, another exception is
 raised saying the 'label' property of the widget is not accessible.

 How can I setup my security properly to use z3c.form smoothly?
 Shouldn't 'widget'  not be in IErrorViewSnippet since it is evidently
 externally used in the rendering template?

 Thanks for suggestions.


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: IContainer as IReadFile in WebDav

2007-02-19 Thread Michael Kerrin
Hi Alek,

Which webdav component are you using. zope.app.dav or zope.webdav?

On Monday 19 February 2007 12:12, Alek Kowalczyk wrote:
  adapter for=.interfaces.plot.IPlot
   provides=zope.filerepresentation.interfaces.IReadFile
   factory=.csv.PlotAsCsvFile permission=zope.Public /

 One small mistake (just here, in my real code it was OK).
 Of course the adapter provides IReadFile, no IReadDirectory).
 I still can't make this to get CSV files instead of folder on WebDAV.
WebDAV doesn't use a IReadFile adapter to access files. WebDAV is just an 
extension to HTTP so you must define the default view for your IPlot object 
to return your CSV file.

In order to tell Excel (I am going to assume this works with Excel but I know 
it works with OpenOffice and other WebDAV clients but I haven't tried it with 
Excel) that your IPlot objects are files - you need to override the 
DAV:resourcetype property and specify a None value for this property. The 
only other WebDAV properties that I think you may also need to change are the 
DAV:getcontenttype and DAV:getcontentlength to their respective values for 
the CSV file.

With zope.webdav it is as easy as writing a multi adapter from (IPlot, 
IHTTPRequest) - zope.webdav.coreproperties.IDAVResourceType to override the 
DAV:resourcetype propertry and for DAV:getcontenttype you write an adapter 
from (IPlot, IHTTPrequest) - zope.webdav.coreproperties.IDAVGetcontenttype.

Hope this helps
Michael

-- 
Michael Kerrin

55 Fitzwilliam Sq.,
Dublin 2.

Tel: 087 688 3894
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: Fwd: [Zope3-Users] SFTP , SSL

2006-06-23 Thread Michael Kerrin
Hi David,

On Thursday 22 June 2006 18:58, David Pratt wrote:
 Hi Michael. There is DAV module in twisted in web2. I have not played
 with this yet but it was on my to do list. Are you using this in this
 development?
I have briefly looked at it but no I am not using it. Zope needs manage all 
the WebDAV properties and communicating this data back to Twisted from Zope 
isn't a easy problem to solve. Also I think the WebDAV support in Zope should 
be independent of the actual server being used.

Michael

 Many thanks
 David

 Michael Kerrin wrote:
  I am currently have an ongoing side project to rewrite WebDAV support for
  zope, in order to get around some limitationsin the current
  implementation. This is nearly finsihed, and I will release it once I get
  the time.

-- 
Michael Kerrin

55 Fitzwilliam Sq.,
Dublin 2.

Tel: 087 688 3894
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users