In article <4199B4D3.3070706@meteo.fr> you write:
Hello,
I try to use some functions of the mimetypes_registry class in a python file (ExFile.py) in a product for zope 2.7.2 and plone 2.0.4 call PloneExFile (to have ftp support)... But without success. How can I use this function ?
This is bug 1344: http://collector.zope.org/Zope/1344 Florent
If I do something like this :
/def PUT(self, REQUEST, RESPONSE): """ Handle HTTP / WebDAV / FTP PUT requests. """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) file=REQUEST["BODY"]
mime_type=self.mimetypes_registry.classify(file,filename=self.id).mimetypes[0]
nom = self.id dummyfile=DummyFileUpload(file,nom,mime_type) self.attachFile(file=dummyfile,REQUEST=REQUEST)
# Change attributes self.title = nom
# Reindex self.reindexObject() RESPONSE.setStatus(204) return RESPONSE
/I have got this error log :/
2004-11-16T08:47:46 ERROR(200) SiteError http://xxxxx:xx21/Zope/IGNet/Documentation/Exploitation/document.doc/PUT Traceback (most recent call last): File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\Publish.py", line 101, in publish request, bind=1) File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\mapply.py", line 88, in mapply if debug is not None: return debug(object,args,context) File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\Publish.py", line 39, in call_object result=apply(object,args) # Type s<cr> to step into published object. File "D:\Zope\Zope-2.7.2-0\lib\python\webdav\NullResource.py", line 126, in PUT ob.PUT(REQUEST, RESPONSE) File "E:\Zope-Instance\SG-IG\Products\PloneExFile\ExFile.py", line 220, in PUT
mime_type=self.mimetypes_registry.classify(file,filename=self.id).mimetypes[0] AttributeError: mimetypes_registry / I do something like this : / def PUT(self, REQUEST, RESPONSE): """ Handle HTTP / WebDAV / FTP PUT requests. """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) file = REQUEST["BODY"]
registry = getToolByName(self, 'mimetypes_registry')
name = self.id mime_type = "" name_temp = name.split(".") ext = name_temp[len(name_temp)-1]
mt=registry.list_mimetypes() for id in mt: mtbis=registry.lookup(id)[0] if ext in mtbis.extensions: mime_type= mtbis
dummyfile=DummyFileUpload(file,name,mime_type) self.attachFile(file=dummyfile,REQUEST=REQUEST)
# Change attributes self.title = name
# Reindex self.reindexObject() RESPONSE.setStatus(204) return RESPONSE/
I have got this error :
/2004-11-16T08:59:38 ERROR(200) SiteError http:////xxxxx:xx21///Zope/IGNet/Documentation/Exploitation/Document.doc/PUT Traceback (most recent call last): File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\Publish.py", line 101, in publish request, bind=1) File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\mapply.py", line 88, in mapply if debug is not None: return debug(object,args,context) File "D:\Zope\Zope-2.7.2-0\lib\python\ZPublisher\Publish.py", line 39, in call_object result=apply(object,args) # Type s<cr> to step into published object. File "D:\Zope\Zope-2.7.2-0\lib\python\webdav\NullResource.py", line 126, in PUT ob.PUT(REQUEST, RESPONSE) File "E:\Zope-Instance\SG-IG\Products\PloneExFile\ExFile.py", line 220, in PUT registry = getToolByName(self, 'mimetypes_registry') File "E:\Zope-Instance\SG-IG\Products\CMFCore\utils.py", line 75, in getToolByName raise AttributeError, name AttributeError: mimetypes_registry
/Thanks/ /Stephane Peillon
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D +33 1 40 33 71 59 http://nuxeo.com fg@nuxeo.com