Bugs in new Security Stuff :P (part 2)
Okay, next up, if it's a security error, it should throw a security error! :( Squishdot Posting's can have file attachments. class Posting(Persistent, Implicit,RoleManager): ... # protected by 'View' permission def attachment(self): file=self.file return file and (file,) or None ... These are stored as attributes in a totally un-security aware class: class Squishfile(Acquirer,Persistent): def file_name(self): return self._name ... posting_html is a DTML method and, in 2.2, fails is this bit (which used to work! ;-): <dtml-if attachment> <dtml-in attachment> <A HREF="./<dtml-var file_name url_quote>"> <IMG SRC="<dtml-var SCRIPT_NAME >/<dtml-var icon>" HEIGHT="16 WIDTH="16" BORDER="0" ALT="Click to download attachment"></A> <A HREF="./<dtml-var file_name url_quote>"><dtml-var file_name></A> <dtml-var file_kbytes>KB (<dtml-var file_bytes> bytes)<BR> </dtml-in attachment><BR> </dtml-if attachment> However, the error is rather strange: Error Type: KeyError Error Value: file_name (traceback in PS) This, believe it or not, is actually a security error, since I can make it go away by mixing RoleManager into Squishfile and adding __allow_access_to_unprotected_subobjects__=1 to the class. Why do I get this, which I presume is due to file_name not being available in the stacked namespaces, rather than a security dialog box? confusedly, Chris PS: The above code works fine in the management interface, without any changes to Squishfile, which was the subejct fo my previous post.
Here it is: Error Type: KeyError Error Value: file_name Traceback (innermost last): File E:\Zope\227194~1.0\lib\python\ZPublisher\Publish.py, line 222, in publish_module File E:\Zope\227194~1.0\lib\python\ZPublisher\Publish.py, line 187, in publish File E:\Zope\227194~1.0\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: RoleManager) File E:\Zope\227194~1.0\lib\python\ZPublisher\Publish.py, line 171, in publish File E:\Zope\227194~1.0\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: index_html) File E:\Zope\227194~1.0\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: index_html) File E:\Zope\2.2.0\lib\python\Products\Squishdot\Squishdot.py, line 1388, in index_html (Object: RoleManager) File E:\Zope\227194~1.0\lib\python\OFS\DTMLMethod.py, line 167, in __call__ (Object: posting_html) File E:\Zope\227194~1.0\lib\python\DocumentTemplate\DT_String.py, line 502, in __call__ (Object: posting_html) File E:\Zope\227194~1.0\lib\python\DocumentTemplate\DT_In.py, line 691, in renderwob (Object: attachment) File E:\Zope\227194~1.0\lib\python\DocumentTemplate\DT_Var.py, line 276, in render (Object: file_name) KeyError: (see above)
participants (1)
-
Chris Withers