Commit 8338a9da authored by Rafael Monnerat's avatar Rafael Monnerat

ERP5/Extensions: Remove unused Extension untouched for years

See merge request nexedi/erp5!1244
parents 714520cf cf879a85
from Products.ERP5Type.Globals import get_request
import time
from zLOG import LOG
CACHE_DURATION = 600
cached_template = {}
expires_date = {}
def getCachedPageTemplate(self, id=None, REQUEST=None):
global cached_template
global expires_date
if id is not None:
# Get the user id and request
if not REQUEST:
REQUEST = get_request()
user_id = self.portal_membership.getAuthenticatedMember().getIdOrUserName()
key = (user_id, id)
# lookup the cache for time
now = time.time()
# if cache exists and time is OK, return cache
expires = expires_date.get(key, now)
if expires > now:
LOG('CACHED:',0, str(id))
return cached_template[key]
# else recompute cache
method = getattr(self, id, None)
if method is not None:
cached_template[key] = method(REQUEST=REQUEST)
expires_date[key] = now + CACHE_DURATION
return cached_template[key]
else:
return ''
def _checkPermission(folder):
msg=''
if hasattr(folder, 'objectValues'):
for child in folder.objectValues():
msg += _checkPermission(child)
if hasattr(folder, 'valid_roles'):
valid_role_list = folder.valid_roles()
manager_index = list(valid_role_list).index('Manager')
permission_list = folder.permission_settings()
for permission in permission_list:
if permission['acquire'] == '':
for role in permission['roles']:
name = role['name']
pos = name.find('r')
index = int(name[pos+1:])
if manager_index == index:
if role['checked'] == '':
msg += '%s: %s does not contain Manager\n' % (folder.getUrl(), permission['name'])
break
return msg
def ERP5Site_checkAllPermissions(self):
portal = self.portal_url.getPortalObject()
return _checkPermission(portal)
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
#
# This program as such is not intended to be used by end users. End
# users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the Zope Public License (ZPL) Version 2.0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
##############################################################################
from Acquisition import aq_base
def filterReindexAll(object=None,request=None,**kw):
return 1
def testAfterReindexAll(object=None,request=None,**kw):
result = []
try:
result.append((object.getRelativeUrl(), 'portal_type',1,object.getPortalType()))
except:
message = 'Could not find the portal type'
if hasattr(object,'getRelativeUrl'):
result.append((object.getRelativeUrl(), 'testAfterReindexAll',101,message))
elif hasattr(object,'id'):
result.append((object.id, 'testAfterReindexAll',101,message))
else:
result.append(('Object with no id', 'testAfterReindexAll',101,message))
return result
def methodReindexAll(object,REQUEST=None,**kw):
result = []
try:
object.portal_catalog.catalog_object(object,None)
#object.reindexObject()
except:
message = 'Object could not be catalogued'
if hasattr(object,'getRelativeUrl'):
result.append((object.getRelativeUrl(), 'methodReindexAll',101,message))
elif hasattr(object,'id'):
result.append((object.id, 'methodReindexAll',101,message))
else:
result.append(('Object with no id', 'methodReindexAll',101,message))
return result
def reindexAll(object=None,REQUEST=None,**kw):
"""
Folder needs to be updated in order to take into account
changes of classes and in particular meta_type
"""
result = []
container = object
obase = aq_base(container)
# Call recursiveApply only if this is an ERP5 Folder
if hasattr(obase,'recursiveApply'):
result += container.recursiveApply(filter=filterReindexAll, method=methodReindexAll,
test_after=testAfterReindexAll,REQUEST=REQUEST)
# or if this is a folder, do it on contained objects
elif hasattr(obase,'objectValues'):
for object in container.objectValues():
result += reindexAll(object=object, REQUEST=REQUEST, **kw)
# else reindex
else:
result += methodReindexAll(object = container, REQUEST=REQUEST, **kw)
return result
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