Commit 050b2c57 authored by Aurel's avatar Aurel

fixup! merge into cmf_upgrade_versions

parent 4671bc8e
......@@ -52,6 +52,7 @@ from AccessControl.ZopeGuards import guarded_getattr, guarded_hasattr
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.utils import removeZODBPythonScript
from Products.ERP5Type import Permissions
from DateTime import DateTime
class PropertySheetTestCase(ERP5TypeTestCase):
"""Base test case class for property sheets tests.
......@@ -2479,7 +2480,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
folder = self.getOrganisationModule()
obj = folder.newContent(portal_type='Organisation')
self.assertIsInstance(portal.creation_date, DateTime)
self.assertLess(portal.creation_date, object.getCreationDate())
self.assertLess(portal.creation_date, obj.getCreationDate())
self.assertIsNone(folder.getCreationDate())
def test_copyWithoutModificationRight(self):
......
......@@ -34,6 +34,7 @@ import random
import tempfile
from xml.dom.minidom import getDOMImplementation
from App.config import getConfiguration
from Products.CMFCore.ActionsTool import ActionsTool
from Products.ERP5.Document.BusinessTemplate import \
BusinessTemplateMissingDependency
......
......@@ -34,7 +34,7 @@ from erp5.component.document.Document import Document, VALID_TEXT_FORMAT_LIST
from erp5.component.document.Document import VALID_IMAGE_FORMAT_LIST
from erp5.component.document.Document import ConversionError
from Products.ERP5Type.Base import Base, removeIContentishInterface
from Products.CMFDefault.File import File as CMFFile
from OFS.Image import File as OFS_File
from Products.ERP5Type.Utils import deprecated
def _unpackData(data):
......@@ -46,7 +46,7 @@ def _unpackData(data):
_MARKER = object()
class File(Document, CMFFile):
class File(Document, OFS_File):
"""
A File can contain raw data which can be uploaded and downloaded.
It is the root class of Image, OOoDocument (ERP5OOo product),
......@@ -110,8 +110,14 @@ class File(Document, CMFFile):
filename = kw.get('filename')
if filename:
self._setFilename(filename)
if self._isNotEmpty(file_object):
self._setFile(file_object, precondition=precondition)
if file_object is not None:
# XXX: Rather than doing nothing if empty, consider changing:
# - _update_image_info to clear metadata
# - interactions to do nothing (or else?)
file_object.seek(0, 2)
if file_object.tell():
file_object.seek(0)
self._setFile(file_object)
Base._edit(self, **kw)
security.declareProtected( Permissions.ModifyPortalContent, 'edit' )
......@@ -138,11 +144,15 @@ class File(Document, CMFFile):
return None
def _setFile(self, data, precondition=None):
if data is not None and self.hasData() and \
str(data.read()) == str(self.getData()):
# Same data as previous, no need to change it's content
if data is None:
return
if str(data.read()) == (self.hasData() and str(self.getData())):
# Same data as previous, no need to change its content
return
CMFFile._edit(self, precondition=precondition, file=data)
if data.tell():
data.seek(0)
self.manage_upload(data)
security.declareProtected(Permissions.ModifyPortalContent,'setFile')
def setFile(self, data, precondition=None):
......@@ -176,11 +186,16 @@ class File(Document, CMFFile):
return str(data)
# DAV Support
PUT = CMFFile.PUT
security.declareProtected(Permissions.ModifyPortalContent, 'PUT')
def PUT(self, REQUEST, RESPONSE):
"""from Products.CMFDefault.File"""
OFS_File.PUT(self, REQUEST, RESPONSE)
self.reindexObject()
security.declareProtected(Permissions.FTPAccess, 'manage_FTPstat',
'manage_FTPlist')
manage_FTPlist = CMFFile.manage_FTPlist
manage_FTPstat = CMFFile.manage_FTPstat
manage_FTPlist = OFS_File.manage_FTPlist
manage_FTPstat = OFS_File.manage_FTPstat
security.declareProtected(Permissions.AccessContentsInformation, 'getMimeTypeAndContent')
def getMimeTypeAndContent(self):
......
......@@ -6,13 +6,13 @@ utool = portal.portal_url
portal_url = utool()
param = '?ignore_layout:int=1' if int(portal.REQUEST.get('ignore_layout', 0)) else ''
if include_root:
result = [{
result = [{
'id' : 'root',
'title' : portal.title,
'url' : '%s/view%s' % (portal_url, param),
}]
else:
result = []
result = []
obj = portal
now = []
......@@ -23,7 +23,7 @@ for name in utool.getRelativeContentPath(context):
getattr(obj, "getCompactTranslatedTitle", lambda: None)() or
obj.getTitle() or obj.getId()
)
if name != 'talkback':
if name != 'talkback':
result.append( { 'id' : name
, 'title' : title
, 'url' : '%s/%s/view%s' % (portal_url, '/'.join(now), param)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment