32 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent |
32 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent |
33 |
33 |
34 # import packages |
34 # import packages |
35 from persistent import Persistent |
35 from persistent import Persistent |
36 from persistent.dict import PersistentDict |
36 from persistent.dict import PersistentDict |
37 from pyams_utils.property import DocFieldProperty |
|
38 from pyams_utils.registry import query_utility |
37 from pyams_utils.registry import query_utility |
39 from pyams_utils.request import check_request, get_request_data, set_request_data |
38 from pyams_utils.request import check_request, get_request_data, set_request_data |
40 from pyams_utils.vocabulary import vocabulary_config |
39 from pyams_utils.vocabulary import vocabulary_config |
41 from pyramid.events import subscriber |
40 from pyramid.events import subscriber |
42 from zope.componentvocabulary.vocabulary import UtilityVocabulary |
41 from zope.componentvocabulary.vocabulary import UtilityVocabulary |
43 from zope.container.contained import Contained |
42 from zope.container.contained import Contained |
44 from zope.interface import implementer |
43 from zope.interface import implementer |
|
44 from zope.schema.fieldproperty import FieldProperty |
45 from zope.sqlalchemy.datamanager import _SESSION_STATE, STATUS_READONLY, STATUS_ACTIVE, \ |
45 from zope.sqlalchemy.datamanager import _SESSION_STATE, STATUS_READONLY, STATUS_ACTIVE, \ |
46 ZopeTransactionExtension, join_transaction |
46 ZopeTransactionExtension, join_transaction |
47 |
47 |
48 |
48 |
49 CONNECTIONS_TIMESTAMP = {} |
49 CONNECTIONS_TIMESTAMP = {} |
104 |
104 |
105 @implementer(IAlchemyEngineUtility, IOptionalUtility) |
105 @implementer(IAlchemyEngineUtility, IOptionalUtility) |
106 class AlchemyEngineUtility(object): |
106 class AlchemyEngineUtility(object): |
107 """SQLAlchemy engine utility""" |
107 """SQLAlchemy engine utility""" |
108 |
108 |
109 name = DocFieldProperty(IAlchemyEngineUtility['name']) |
109 name = FieldProperty(IAlchemyEngineUtility['name']) |
110 dsn = DocFieldProperty(IAlchemyEngineUtility['dsn']) |
110 dsn = FieldProperty(IAlchemyEngineUtility['dsn']) |
111 echo = DocFieldProperty(IAlchemyEngineUtility['echo']) |
111 echo = FieldProperty(IAlchemyEngineUtility['echo']) |
112 use_pool = DocFieldProperty(IAlchemyEngineUtility['use_pool']) |
112 use_pool = FieldProperty(IAlchemyEngineUtility['use_pool']) |
113 pool_size = DocFieldProperty(IAlchemyEngineUtility['pool_size']) |
113 pool_size = FieldProperty(IAlchemyEngineUtility['pool_size']) |
114 pool_recycle = DocFieldProperty(IAlchemyEngineUtility['pool_recycle']) |
114 pool_recycle = FieldProperty(IAlchemyEngineUtility['pool_recycle']) |
115 echo_pool = DocFieldProperty(IAlchemyEngineUtility['echo_pool']) |
115 echo_pool = FieldProperty(IAlchemyEngineUtility['echo_pool']) |
116 encoding = DocFieldProperty(IAlchemyEngineUtility['encoding']) |
116 encoding = FieldProperty(IAlchemyEngineUtility['encoding']) |
117 convert_unicode = DocFieldProperty(IAlchemyEngineUtility['convert_unicode']) |
117 convert_unicode = FieldProperty(IAlchemyEngineUtility['convert_unicode']) |
118 |
118 |
119 def __init__(self, name='', dsn='', echo=False, use_pool=True, pool_size=25, pool_recycle=-1, echo_pool=False, |
119 def __init__(self, name='', dsn='', echo=False, use_pool=True, pool_size=25, pool_recycle=-1, echo_pool=False, |
120 encoding='utf-8', convert_unicode=False, **kwargs): |
120 encoding='utf-8', convert_unicode=False, **kwargs): |
121 self.name = name |
121 self.name = name |
122 self.dsn = dsn |
122 self.dsn = dsn |