Back to index

plone3  3.1.7
PloneCompat.py
Go to the documentation of this file.
00001 """make some plone utilities available to raw CMF sites
00002 """
00003 
00004 import transaction
00005 import logging
00006 logger = logging.getLogger('Archetypes')
00007 
00008 try:
00009     from Products.CMFPlone.utils import IndexIterator
00010 except ImportError:
00011     class IndexIterator:
00012         __allow_access_to_unprotected_subobjects__ = 1
00013 
00014         def __init__(self, upper=100000, pos=0):
00015             self.upper=upper
00016             self.pos=pos
00017 
00018         def next(self):
00019             if self.pos <= self.upper:
00020                 self.pos += 1
00021                 return self.pos
00022             raise KeyError, 'Reached upper bounds'
00023 
00024 try:
00025     from Products.CMFPlone.utils import transaction_note
00026 except ImportError:
00027     def transaction_note(note):
00028         """ Write human legible note """
00029         T=transaction.get()
00030         if (len(T.description)+len(note))>=65535:
00031             logger.warning('Transaction note too large omitting %s' % str(note))
00032         else:
00033             T.note(str(note))