Commit 48212534 by Julien Muchembled

Drop support for Zope 2.8

Checked following occurrences in comments:
- "Python 2.[456]"
- "Zope 2.[891]"
- "BBB"
- "BACK"

Checked uses of:
- email, hashlib, numpy & tarfile (modules)
- ImportError
- string.Template
- suppress_events (parameter of _setObject)

Excluded:
- some forked modules (MailTemplates, PortalTransforms...)
- some i18n compatibility code
1 parent 7c9313f0
Showing 130 changed files with 291 additions and 1273 deletions
......@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Ticket import Ticket
from Products.ERP5.mixin.encrypted_password import EncryptedPasswordMixin
from Products.CMFCore.utils import getToolByName
try:
from Products import PluggableAuthService
from Products.ERP5Security.ERP5UserManager import ERP5UserManager
......
402
\ No newline at end of file
403
\ No newline at end of file
......@@ -28,7 +28,7 @@
from PIL import ImageFont, Image, ImageDraw, ImageFilter
from random import randrange, uniform
from string import zfill
from md5 import md5
from hashlib import md5
from tempfile import NamedTemporaryFile
import sys, os
import commands
......
......@@ -37,8 +37,8 @@ from zLOG import LOG
import transaction
import random
import email
from email.Header import decode_header, make_header
from email.Utils import parseaddr
from email.header import decode_header, make_header
from email.utils import parseaddr
class TestEGovMixin(SecurityTestCase):
"""Usefull methods for eGov Unit Tests."""
......
756
\ No newline at end of file
757
\ No newline at end of file
......@@ -53,16 +53,10 @@ def getActionTitleListFromAllActionProvider(portal):
from StringIO import StringIO
try:
from TAL.HTMLTALParser import HTMLTALParser
from TAL.TALParser import TALParser
from TAL.TALGenerator import TALGenerator
from TAL.DummyEngine import name_match
except ImportError:
from zope.tal.htmltalparser import HTMLTALParser
from zope.tal.talparser import TALParser
from zope.tal.talgenerator import TALGenerator
from zope.tal.dummyengine import name_match
from zope.tal.htmltalparser import HTMLTALParser
from zope.tal.talparser import TALParser
from zope.tal.talgenerator import TALGenerator
from zope.tal.dummyengine import name_match
def findStaticTranslationText(page_template, func_name_list):
def iterate(node, target_name, function):
if type(node) is list:
......@@ -131,12 +125,8 @@ def findStaticTranslationText(page_template, func_name_list):
#
# Utility class for findStaticTranslationText
#
try:
from TAL.TALInterpreter import TALInterpreter
from TAL.DummyEngine import DummyEngine
except ImportError:
from zope.tal.talinterpreter import TALInterpreter
from zope.tal.dummyengine import DummyEngine
from zope.tal.talinterpreter import TALInterpreter
from zope.tal.dummyengine import DummyEngine
class MyDummyEngine(DummyEngine):
def evaluate(self, expression):
......
......@@ -56,11 +56,7 @@ trust_dict=dict((x, request[x]) for x in (\n
\n
context.getVcsTool().acceptSSLServer(trust_dict, True)\n
\n
try:\n
traverseName = request.traverseName\n
except AttributeError: # BBB: Zope2.8\n
return request.traverse(\'%s/%s\' % (context.getPath(), caller))(**dict(caller_kw))\n
return traverseName(context, caller)(**caller_kw)\n
return request.traverseName(context, caller)(**caller_kw)\n
</string> </value>
</item>
<item>
......
......@@ -52,12 +52,7 @@
<key> <string>_body</string> </key>
<value> <string>context.getVcsTool().setLogin(auth, user, password)\n
\n
request = context.REQUEST\n
try:\n
traverseName = request.traverseName\n
except AttributeError: # BBB: Zope2.8\n
return request.traverse(\'%s/%s\' % (context.getPath(), caller))(**dict(caller_kw))\n
return traverseName(context, caller)(**caller_kw)\n
return context.REQUEST.traverseName(context, caller)(**caller_kw)\n
</string> </value>
</item>
<item>
......
662
\ No newline at end of file
663
\ No newline at end of file
import feedparser, md5, urllib2, socket
import feedparser, urllib2, socket
from hashlib import md5
def getRssDataAsDict(self, url, username=None, password=None):
result = {}
translate = self.Base_translateString
......@@ -46,7 +47,7 @@ def getRssDataAsDict(self, url, username=None, password=None):
entry_dict['title'] = entry['title']
entry_dict['link'] = entry['link']
entry_dict['other_links'] = [x['href'] for x in entry['links']]
entry_dict['md5'] = md5.new(entry['link']).hexdigest()
entry_dict['md5'] = md5(entry['link']).hexdigest()
entry_dict['content'] = entry.get('summary', '')
entry_dict['date'] = entry.get('updated', None)
entry_dict['img'] = [x['href'] for x in entry.get('enclosures', [])]
......
730
\ No newline at end of file
731
\ No newline at end of file
......@@ -28,6 +28,7 @@
##############################################################################
from AccessControl import ClassSecurityInfo
from AccessControl.AuthEncoding import pw_encrypt, pw_validate
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
......@@ -38,17 +39,6 @@ try:
except ImportError:
PluggableAuthService = None
try:
from AccessControl.AuthEncoding import pw_encrypt
except ImportError:
pw_encrypt = lambda pw:pw
try:
from AccessControl.AuthEncoding import pw_validate
except ImportError:
pw_validate = lambda reference, attempt: reference == attempt
#class Person(Node, XMLObject):
class PsjPerson(XMLObject):
"""
......
936
\ No newline at end of file
937
\ No newline at end of file
......@@ -27,7 +27,7 @@
##############################################################################
import cPickle, sys
from hashlib import sha1 as sha_new
from hashlib import sha1
from DateTime import DateTime
from zLOG import LOG, WARNING, ERROR
from ZODB.POSException import ConflictError
......@@ -261,7 +261,7 @@ class Queue:
# is true in Python. This is important, because dtml-if assumes that an empty
# string is false, so we must use a non-empty string for this.
return 'none'
return sha_new(repr(order_validation_item_list)).hexdigest()
return sha1(repr(order_validation_item_list)).hexdigest()
def getMessageList(self, activity_tool, processing_node=None,**kw):
return []
......
......@@ -421,12 +421,8 @@ class SQLBase:
# should they be just made available again ?
if uid_to_duplicate_uid_list_dict is not None:
make_available_uid_list += uid_to_duplicate_uid_list_dict.get(uid, ())
# BACK: Only exceptions can be classes in Python 2.6.
# Once we drop support for Python 2.4,
# please, remove the "type(m.exc_type) is type(ConflictError)" check
# and leave only the "issubclass(m.exc_type, ConflictError)" check.
if type(m.exc_type) is type(ConflictError) and \
m.conflict_retry and issubclass(m.exc_type, ConflictError):
if (m.exc_type and # m.exc_type may be None
m.conflict_retry and issubclass(m.exc_type, ConflictError)):
delay_uid_list.append(uid)
else:
max_retry = m.max_retry
......
......@@ -78,10 +78,7 @@ except ImportError:
def getTimerService(self):
pass
try:
from traceback import format_list, extract_stack
except ImportError:
format_list = extract_stack = None
from traceback import format_list, extract_stack
# minimal IP:Port regexp
NODE_RE = re.compile('^\d+\.\d+\.\d+\.\d+:\d+$')
......@@ -356,11 +353,6 @@ Exception: %s %s
self.user_name, path, self.method_id, self.args, self.kw,
call_traceback, self.exc_type, self.exc_value, self.traceback)
if isinstance(mail_text, unicode):
# __traceback_info__ can turn the tracebacks into unicode strings, but
# MailHost.send (in Zope 2.8) will not be able to parse headers if the
# mail_text is passed as a unicode.
mail_text = mail_text.encode('utf8')
try:
activity_tool.MailHost.send( mail_text )
except (socket.error, MailHostError), message:
......
......@@ -32,14 +32,8 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
import transaction
try:
from transaction import get as get_transaction
except ImportError:
pass
class TestCMFCategory(ERP5TypeTestCase):
# Different variables used for this test
......@@ -368,13 +362,13 @@ class TestCMFCategory(ERP5TypeTestCase):
p2 = self.getPersonModule()._getOb(self.id2)
o1 = self.getOrganisationModule()._getOb(self.id1)
p1.setGenderValue(o1)
get_transaction().commit()
transaction.commit()
self.tic() # This is required
self.assertEqual(p1.getGenderValue(),o1)
self.assertEqual(o1.getGenderRelatedValueList(),[p1])
p2.setGenderValue(o1) # reindex implicit
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(len(o1.getGenderRelatedValueList()),2)
......@@ -386,12 +380,12 @@ class TestCMFCategory(ERP5TypeTestCase):
p1 = self.getPersonModule()._getOb(self.id1)
p1.setRegion('europe/west/france')
get_transaction().commit()
transaction.commit()
self.tic()
west = self.portal.portal_categories.resolveCategory('region/europe/west')
west.setId("ouest")
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(west,
......@@ -406,14 +400,14 @@ class TestCMFCategory(ERP5TypeTestCase):
p1 = self.getPersonModule()._getOb(self.id1)
p1.setRegion('europe/west/france')
get_transaction().commit()
transaction.commit()
self.tic()
europe = self.portal.portal_categories.resolveCategory('region/europe')
west = europe.west
cb_data = europe.manage_cutObjects(['west'])
self.portal.portal_categories.region.manage_pasteObjects(cb_data)
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(west,
......@@ -428,14 +422,14 @@ class TestCMFCategory(ERP5TypeTestCase):
p1 = self.getPersonModule()._getOb(self.id1)
p1.setRegion('europe/west/france')
get_transaction().commit()
transaction.commit()
self.tic()
europe = self.portal.portal_categories.resolveCategory('region/europe')
west = europe.west
cb_data = europe.manage_copyObjects(['west'])
self.portal.portal_categories.region.manage_pasteObjects(cb_data)
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(west,
......@@ -524,7 +518,7 @@ class TestCMFCategory(ERP5TypeTestCase):
pc = self.getCategoriesTool()
bc = pc.newContent(portal_type='Base Category', id='related_value_test')
self.failUnless(bc is not None)
get_transaction().commit()
transaction.commit()
self.tic()
# A newly created base category should be referred to only by itself
value_list = pc.getRelatedValueList(bc)
......@@ -532,7 +526,7 @@ class TestCMFCategory(ERP5TypeTestCase):
c = bc.newContent(portal_type='Category', id='1')
self.failUnless(c is not None)
get_transaction().commit()
transaction.commit()
self.tic()
value_list = pc.getRelatedValueList(bc)
# Now the base category should be referred to by itself and this sub category
......@@ -546,7 +540,7 @@ class TestCMFCategory(ERP5TypeTestCase):
org = self.portal.organisation_module.newContent(
id='organisation_test',
destination='person_module/person_test')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(person.getDefaultDestinationRelated(),
'organisation_module/organisation_test' )
......@@ -561,7 +555,7 @@ class TestCMFCategory(ERP5TypeTestCase):
obj = self.getOrganisationModule().newContent(
portal_type = 'Organisation')
obj.setCategoryList(['test_base_cat/test_cat'])
get_transaction().commit()
transaction.commit()
self.tic()
self.assert_(obj in [x.getObject() for x in test.getCategoryMemberValueList()])
......@@ -594,7 +588,7 @@ class TestCMFCategory(ERP5TypeTestCase):
organisation = self.getOrganisationModule().newContent(
portal_type='Organisation', region='west/france')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals([x.getObject() for x in
......@@ -938,7 +932,7 @@ class TestCMFCategory(ERP5TypeTestCase):
bc = self.portal.portal_categories.newContent(
portal_type='Base Category',
id='first_id')
get_transaction().commit()
transaction.commit()
self.tic()
bc.setId('new_id')
self.assertEquals('new_id', bc.getId())
......@@ -953,7 +947,7 @@ class TestCMFCategory(ERP5TypeTestCase):
self.assertNotEquals(line, None)
cell = line.newContent(id='baz', portal_type='Sale Order Cell')
self.assertNotEquals(cell, None)
get_transaction().commit()
transaction.commit()
self.tic()
for relative_url, value in (
......@@ -983,7 +977,7 @@ class TestCMFCategory(ERP5TypeTestCase):
#First remove Base Category
self.portal.portal_categories.manage_delObjects(['region'])
obj = self.portal.person_module.newContent(portal_type='Person')
get_transaction().commit()
transaction.commit()
try:
#Setters
self.assertRaises(AttributeError, getattr, obj, 'setRegion')
......@@ -999,7 +993,7 @@ class TestCMFCategory(ERP5TypeTestCase):
finally:
#add Base Category
self.portal.portal_categories.newContent(id='region', portal_type='Base Category')
get_transaction().commit()
transaction.commit()
#check Method exists after base_category creation
#Setters
self.assertTrue(getattr(obj, 'setRegion') is not None)
......
......@@ -26,10 +26,7 @@
#
##############################################################################
try:
from numpy import shape, array
except ImportError:
from Numeric import shape, array
from numpy import shape, array
MODEL_HEAD = """
/* The number of samples. */
......
......@@ -27,7 +27,7 @@
#
##############################################################################
import fnmatch, gc, glob, imp, os, re, shutil, sys, time
import fnmatch, gc, glob, imp, os, re, shutil, sys, time, tarfile
from Shared.DC.ZRDB import Aqueduct
from Shared.DC.ZRDB.Connection import Connection as RDBConnection
from Products.ERP5Type.DiffUtils import DiffFile
......@@ -80,7 +80,6 @@ from gzip import GzipFile
from lxml.etree import parse
from xml.sax.saxutils import escape
from Products.CMFCore.Expression import Expression
from Products.ERP5Type import tarfile
from urllib import quote, unquote
from difflib import unified_diff
import posixpath
......@@ -2737,22 +2736,15 @@ class ActionTemplateItem(ObjectTemplateItem):
return obj._exportOldAction(action)
def _getPortalToolActionCopy(self, obj, context, value):
try:
from Products.CMFCore.interfaces import IActionProvider
except ImportError:
# BACK:
# we still don't load ZCML on tests on 2.8, but on 2.8 actions from other
# tools are not redirected to portal_actions
pass
else:
if not IActionProvider.providedBy(obj):
# look for the action in portal_actions, instead of the original object
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Redirected action export',
'Attempted to retrieve action %r from %r which is no longer an '
'IActionProvided. Retrieving action from portal_actions instead' %
(value, obj.getId()))
obj = context.getPortalObject().portal_actions
from Products.CMFCore.interfaces import IActionProvider
if not IActionProvider.providedBy(obj):
# look for the action in portal_actions, instead of the original object
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Redirected action export',
'Attempted to retrieve action %r from %r which is no longer an '
'IActionProvided. Retrieving action from portal_actions instead' %
(value, obj.getId()))
obj = context.getPortalObject().portal_actions
id_id = 'id'
for action in obj.listActions():
if getattr(action, id_id, None) == value:
......@@ -2815,23 +2807,16 @@ class ActionTemplateItem(ObjectTemplateItem):
# Following code is for actions outside Types Tool.
# It will be removed when they are also converted to ERP5 actions.
try:
from Products.CMFCore.interfaces import IActionProvider
except ImportError:
# BACK:
# we still don't load ZCML on tests on 2.8, but on 2.8 we don't
# need to redirect actions to portal_actions.
pass
else:
if not IActionProvider.providedBy(container):
# some tools stopped being ActionProviders in CMF 2.x. Drop the
# action into portal_actions.
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Redirected action import',
'Attempted to store action %r in %r which is no longer an '
'IActionProvided. Storing action on portal_actions instead' %
(id, path))
container = p.portal_actions
from Products.CMFCore.interfaces import IActionProvider
if not IActionProvider.providedBy(container):
# some tools stopped being ActionProviders in CMF 2.x. Drop the
# action into portal_actions.
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Redirected action import',
'Attempted to store action %r in %r which is no longer an '
'IActionProvided. Storing action on portal_actions instead' %
(id, path))
container = p.portal_actions
obj, action = container, obj
action_list = obj.listActions()
for index in range(len(action_list)):
......
......@@ -53,8 +53,8 @@ except ImportError:
"""
from email import message_from_string
from email.Header import decode_header, HeaderParseError
from email.Utils import parsedate_tz, mktime_tz
from email.header import decode_header, HeaderParseError
from email.utils import parsedate_tz, mktime_tz
DEFAULT_TEXT_FORMAT = 'text/html'
COMMASPACE = ', '
......
......@@ -35,12 +35,11 @@ from Products.ERP5Type.Core.Predicate import Predicate
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.mixin.equivalence_tester import EquivalenceTesterMixin
# On Python 2.4, this dictionary doesn't include ROUND_05UP
ROUNDING_OPTION_DICT = dict((name, value)
for name, value in decimal.__dict__.items()
if name.startswith('ROUND_'))
# On Python >= 2.6, we could compute a value based on sys.float_info.epsilon
# XXX: We could compute a value based on sys.float_info.epsilon
DEFAULT_PRECISION = 1e-12
class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
......@@ -173,9 +172,7 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
value=relative_tolerance_max))
def _round(self, value):
# on Python 2.4, looking up 'ROUND_05UP' will return ROUND_DOWN here
rounding_option = ROUNDING_OPTION_DICT.get(self.getDecimalRoundingOption(),
decimal.ROUND_DOWN)
rounding_option = ROUNDING_OPTION_DICT[self.getDecimalRoundingOption()]
exponent = decimal.Decimal(self.getDecimalExponent())
# In Python 2.7, the str() below will no longer be necessary
result = decimal.Decimal(str(value)).quantize(exponent,
......
......@@ -28,7 +28,7 @@
##############################################################################
import StringIO
from hashlib import md5 as md5_new
from hashlib import md5
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type import Permissions, PropertySheet
......@@ -431,7 +431,7 @@ class PDFTypeInformation(ERP5TypeInformation):
generateParsedScribus = CachingMethod(generateParsedScribus,
('PDFTypeInformation_generateParsedScribus',
md5_new(scribus_form.getData()).digest()),
md5(scribus_form.getData()).digest()),
cache_factory='dms_cache_factory')
return generateParsedScribus()
......@@ -544,7 +544,7 @@ class PDFTypeInformation(ERP5TypeInformation):
return form
#generateERP5Form = CachingMethod(generateERP5Form,
# ('PDFTypeInformation_generateERP5Form',
# md5_new(self.getDefaultScribusFormValue().getData()).digest()),
# md5(self.getDefaultScribusFormValue().getData()).digest()),
# cache_factory='dms_cache_factory')
return generateERP5Form().__of__(self)
......@@ -594,7 +594,7 @@ class PDFTypeInformation(ERP5TypeInformation):
generateERP5FormCSS = CachingMethod(generateERP5FormCSS,
('PDFTypeInformation_generateERP5FormCSS',
md5_new(self.getDefaultScribusFormValue().getData()).digest()),
md5(self.getDefaultScribusFormValue().getData()).digest()),
cache_factory='dms_cache_factory')
self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/css')
return generateERP5FormCSS()
......
......@@ -38,14 +38,11 @@ from Products.ERP5Type.WebDAVSupport import TextContent
import re
from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST
import cStringIO
from string import Template
# Mixin Import
from Products.ERP5.mixin.cached_convertable import CachedConvertableMixin
from Products.ERP5.mixin.base_convertable import BaseConvertableFileMixin
try:
from string import Template
except ImportError:
from Products.ERP5Type.patches.string import Template
from Products.ERP5Type.Utils import guessEncodingFromText
from lxml import html as etree_html
......
......@@ -187,7 +187,6 @@ class ReferCheckerBeforeTraverseHook:
'request : "%s"' % http_url)
response.unauthorized()
import ZODB
class _site(threading.local):
"""Class for getting and setting the site in the thread global namespace
......@@ -198,15 +197,13 @@ class _site(threading.local):
self = threading.local.__new__(cls)
return self.__get, self.__set
def __get(self, REQUEST=None,
# XXX Compatibility code (ZODB >= 3.9 has no __version__ anymore)
__opened='_opened'[getattr(ZODB, '__version__', '3.9') >= '3.9':]):
def __get(self, REQUEST=None):
"""Returns the currently processed site, optionally wrapped in a request
"""
while True:
app, site_id = self.site[-1]
app = app()
if getattr(app._p_jar, __opened):
if app._p_jar.opened:
if REQUEST is None:
return getattr(app, site_id)
return getattr(app.__of__(RequestContainer(REQUEST=REQUEST)), site_id)
......@@ -346,8 +343,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
return self
def manage_beforeDelete(self, item, container):
# On Zope 2.8, skin is setup during Acquisition (in the .__of__() method).
# On Zope 2.12, skin is setup during __before_publishing_traverse__, which
# skin is setup during __before_publishing_traverse__, which
# doesn't happen when the object is being deleted from the management
# interface, but we need it to be set for portal_activities when we're
# being deleted.
......@@ -1864,17 +1860,11 @@ class ERP5Generator(PortalGenerator):
# Remove unused default actions
def removeActionsFromTool(tool, remove_list):
try:
from Products.CMFCore.interfaces import IActionProvider
if not IActionProvider.providedBy(tool):
# On CMF 2.x, some tools (portal_membership)
# are no longer action providers
return
except ImportError:
# BACK: Currently ERP5 tests don't load ZCML which is needed by the
# above import on CMF 1.5. This "try" should be removed when ERP5 tests
# start loading ZCML.
pass
from Products.CMFCore.interfaces import IActionProvider
if not IActionProvider.providedBy(tool):
# On CMF 2.x, some tools (portal_membership)
# are no longer action providers
return
action_id_list = [i.id for i in tool.listActions()]
remove_index_list = []
for i in remove_list:
......@@ -1911,26 +1901,14 @@ class ERP5Generator(PortalGenerator):
"""Semi-manually create DirectoryViews since CMFDefault 2.X no longer
registers the "skins" directory, only its subdirectories, making it
unusable with Products.CMFCore.DirectoryView.addDirectoryViews."""
from Products.CMFCore.DirectoryView import createDirectoryView
try:
from Products.CMFCore.DirectoryView import _generateKey
def generateKey(package, subdir):
return _generateKey(package.__name__, subdir)
except ImportError:
# Means we're still on CMF 1.x, were they generate the DirectoryView
# key using minimalpath
# ( see Products.CMFCore.DirectoryView.addDirectoryViews() )
from Products.CMFCore.DirectoryView import minimalpath
def generateKey(package, subdir):
package_path = os.path.dirname(package.__file__)
return minimalpath(os.path.join(package_path, subdir))
from Products.CMFCore.DirectoryView import createDirectoryView, _generateKey
import Products.CMFDefault
ps = p.portal_skins
# get the layer directories actually present
for cmfdefault_skin_layer in self.CMFDEFAULT_FOLDER_LIST:
reg_key = generateKey(Products.CMFDefault,
'skins/' + cmfdefault_skin_layer)
reg_key = _generateKey(Products.CMFDefault.__name__,
'skins/' + cmfdefault_skin_layer)
createDirectoryView(ps, reg_key)
def setupDefaultSkins(self, p):
......
......@@ -6,16 +6,9 @@ import csv
from Products.CMFCore.utils import expandpath
from zLOG import LOG
from App.config import getConfiguration
try:
from App.config import getConfiguration
except ImportError:
getConfiguration = None
if getConfiguration is None:
data_dir = '/var/lib/zope/data'
else:
data_dir = getConfiguration().instancehome + '/data'
data_dir = os.path.join(getConfiguration().instancehome, 'data')
fs_skin_spec = ('ERP5 Filesystem Formulator Form',
'ERP5 Filesystem PDF Template',
......
......@@ -4,13 +4,8 @@
# have to be patched with a manage_FTPget wich contains
# a section <dtml-comment></dtml-comment>
#instance_home = getConfiguration().instancehome
# Zope 2.6.x does not have App.Config
try:
from App.config import getConfiguration
except ImportError:
getConfiguration = None
import os
from App.config import getConfiguration
fs_skin_ids = ('fs_erp5_core', 'fs_erp5_trade', 'fs_erp5_accounting', 'fs_erp5_crm')
fs_skin_spec = ('ERP5 Filesystem Formulator Form',
......@@ -19,10 +14,7 @@ fs_skin_spec = ('ERP5 Filesystem Formulator Form',
'Filesystem Page Template',
'Filesystem Script (Python)',
'Filesystem Z SQL Method')
if getConfiguration is None:
fs_skin_dir = '/var/lib/zope/Products'
else:
fs_skin_dir = getConfiguration().instancehome + '/Products'
fs_skin_dir = os.path.join(getConfiguration().instancehome, 'Products')
zodb_skin_ids = ('erp5_core', 'erp5_trade', 'erp5_accounting', 'erp5_crm')
zodb_skin_spec = ('ERP5 Form', 'ERP5 PDF Template', 'Page Template', 'Script', 'Script (Python)','Z SQL Method')
......
......@@ -19,6 +19,7 @@ import urllib2, os, dircache, urllib
from StringIO import StringIO
from urllib2 import FileHandler, url2pathname, addinfourl, URLError
import mimetypes, mimetools
from email.utils import formatdate
class DirectoryFileHandler(FileHandler):
"""
......@@ -37,13 +38,12 @@ class DirectoryFileHandler(FileHandler):
# not entirely sure what the rules are here
def open_local_file(self, req):
import email.Utils
host = req.get_host()
file = req.get_selector()
localfile = url2pathname(file)
stats = os.stat(localfile)
size = stats.st_size
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
modified = formatdate(stats.st_mtime, usegmt=True)
mtype = mimetypes.guess_type(file)[0]
headers = mimetools.Message(StringIO(
'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
......
......@@ -31,6 +31,7 @@ import os
import sys
import tempfile
import json
import tarfile
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass, DTMLFile
from Products.ERP5Type.Tool.BaseTool import BaseTool
......@@ -42,7 +43,6 @@ from Products.ERP5Type.Utils import _setSuperSecurityManager
from App.config import getConfiguration
from AccessControl import Unauthorized
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type import tarfile
from cgi import escape
import logging
......
......@@ -35,13 +35,13 @@ from AccessControl import ModuleSecurityInfo
from Products.ERP5 import _dtmldir
from mimetypes import guess_type
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Header import make_header
from email import Encoders
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.audio import MIMEAudio
from email.mime.image import MIMEImage
from email.header import make_header
from email import encoders
class ConversionError(Exception): pass
class MimeTypeException(Exception): pass
......@@ -168,7 +168,7 @@ def buildEmailMessage(from_url, to_url, msg=None,
# encode non-plaintext attachment in base64
part = MIMEBase(major, minor)
part.set_payload(attachment['content'])
Encoders.encode_base64(part)
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment',
filename=attachment_name)
......
......@@ -36,7 +36,7 @@ from Products.ERP5Type import Permissions
from Products.ERP5 import _dtmldir
from zLOG import LOG, INFO
import time, random
from hashlib import md5 as md5_new
from hashlib import md5
from DateTime import DateTime
from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Globals import PersistentMapping
......@@ -214,9 +214,7 @@ class PasswordTool(BaseTool):
# if we can't get a network address, just imagine one
a = random.random()*100000000000000000L
data = ' '.join((str(t), str(r), str(a), str(args)))
data = md5_new(data).hexdigest()
return data
return md5(data).hexdigest()
def resetPassword(self, reset_key=None, REQUEST=None):
"""
......
......@@ -39,10 +39,7 @@ from Products.ERP5 import _dtmldir
from zLOG import LOG, PROBLEM
from Products.ERP5.Capacity.GLPK import solve
try:
from numpy import zeros, resize
except ImportError:
from Numeric import zeros, resize
from numpy import zeros, resize
from DateTime import DateTime
from Products.ERP5 import DeliverySolver
......
......@@ -33,6 +33,7 @@ from App.config import getConfiguration
import os
import shutil
import sys
import tarfile
from Acquisition import Implicit, Explicit
from AccessControl import ClassSecurityInfo
......@@ -40,7 +41,7 @@ from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping
from Products.ERP5Type.DiffUtils import DiffFile
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions, tarfile
from Products.ERP5Type import Permissions
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency
from Acquisition import aq_base
from tempfile import mkstemp, mkdtemp
......
......@@ -116,18 +116,13 @@ class TrashTool(BaseTool):
try:
backup = connection.importFile(copy)
backup.isIndexable = ConstantGetter('isIndexable', value=False)
try:
# the isIndexable setting above avoids the recursion of
# manage_afterAdd on
# Products.ERP5Type.CopySupport.CopySupport.manage_afterAdd()
# but not on event subscribers, so we need to suppress_events,
# otherwise subobjects will be reindexed
backup_object_container._setObject(object_id, backup,
suppress_events=True)
except TypeError:
# BACK: On Zope 2.8. _setObject does not accept "suppress_events"
# remove when we drop support
backup_object_container._setObject(object_id, backup)
# the isIndexable setting above avoids the recursion of
# manage_afterAdd on
# Products.ERP5Type.CopySupport.CopySupport.manage_afterAdd()
# but not on event subscribers, so we need to suppress_events,
# otherwise subobjects will be reindexed
backup_object_container._setObject(object_id, backup,
suppress_events=True)
except (AttributeError, ImportError):