Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_abort_transaction_if_doomed(app):
with app.test_request_context():
db['answer'] = 42
transaction.doom()
with app.test_request_context():
assert 'answer' not in db
continue
tool._bootstrap()
tool.__class__ = getattr(erp5.portal_type, tool.portal_type)
if migrate:
portal.migrateToPortalTypeClass()
portal.portal_skins.changeSkin(None)
TransactionalResource(tpc_finish=lambda txn:
_bootstrapped.add(portal.id))
LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates')
else:
_bootstrapped.add(portal.id)
except:
# Required because the exception may be silently dropped by the caller.
transaction.doom()
LOG('ERP5Site', PANIC, "Automatic migration of type and"
" property sheet tool failed", error=sys.exc_info())
raise
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
try:
for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass):
klass.restoreGhostState()
# Clear accessor holders of ZODB Property Sheets and Portal Types
erp5.accessor_holder.clear()
erp5.accessor_holder.property_sheet.clear()
for name in erp5.accessor_holder.portal_type.__dict__.keys():
if name[0] != '_':
except AttributeError:
pass # no Activity Tool yet
if migrate:
portal.migrateToPortalTypeClass()
portal.portal_skins.changeSkin(None)
TransactionalResource(tpc_finish=lambda txn:
_bootstrapped.add(portal.id))
transaction.get().note('Site migrated')
LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates')
else:
_bootstrapped.add(portal.id)
except:
# Required because the exception may be silently dropped by the caller.
transaction.doom()
LOG('ERP5Site', PANIC, "Automatic migration of core tools failed",
error=True)
raise
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
try:
for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass):
# Zope Interface is implemented through __implements__,
# __implemented__ (both implementedBy instances) and __provides__
# (ClassProvides instance) attributes set on the class by
# zope.interface.declarations.implementedByFallback.
#
# However both implementedBy and ClassProvides instances keep a
# reference to the class itself, thus creating a circular references
# preventing erp5.* classes to be GC even when not being actually used
discussion_id, user_id, P_SYSADMIN):
role = R_ADMINISTRATOR
if 'user_csvfile' in request.POST:
try:
num_users = add_multiple_users_csv(
request, request.POST['user_csvfile'].file,
discussion_id, role,
request.POST.get('send_invite', False),
request.POST['email_subject'],
request.POST['text_email_message'],
request.POST['html_email_message'],
request.POST['sender_name'],
request.POST.get('resend_notloggedin', False))
except Exception as e:
error = repr(e)
transaction.doom()
else:
error = request.localizer.translate(_('No file given.'))
def allowed(role, permission):
if role == R_SYSADMIN:
return True
return (role, permission) in disc_perms_as_set
def has_local_role(user_id, role):
return (user_id, role) in local_roles_as_set
users = list(users)
users.sort(key=order_by_domain_and_name)
context = dict(
get_default_context(request),
vcs_tool = context.getVcsTool()
if do_extract:
vcs_tool.extractBT(context)
context.REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml; charset=utf-8')
root = vcs_tool.getModifiedTree(show_unmodified)
if not root:
return '''
'''
if REQUEST is not None: # XXX workaround to prevent zodb bloat (bt build)
# This script is mostly used by javascript, we can abort the transaction
import transaction
transaction.doom()
return vcs_tool.treeToXML(root)