projects
/
Plinn.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f7d6479
)
Bugfix : la connexion Solr peut se volatiliser plus vite que le hook de transaction…
zope-2.13-solr
author
Benoît Pin
<pin@cri.ensmp.fr>
Wed, 9 Jul 2014 08:16:16 +0000
(10:16 +0200)
committer
Benoît Pin
<pin@cri.ensmp.fr>
Wed, 9 Jul 2014 08:16:16 +0000
(10:16 +0200)
catalog.py
patch
|
blob
|
history
diff --git
a/catalog.py
b/catalog.py
index
05cbd59
..
0a457f8
100644
(file)
--- a/
catalog.py
+++ b/
catalog.py
@@
-22,17
+22,20
@@
_VOLATILE_SOLR_NAME = '_v_solrConnection'
class SolrTransactionHook :
''' commit solr couplé sur le commit de la ZODB '''
class SolrTransactionHook :
''' commit solr couplé sur le commit de la ZODB '''
- def __init__(self, context) :
+ def __init__(self, context
, con
) :
self.context = context
self.context = context
+ self.con = con
def __call__(self, status) :
def __call__(self, status) :
- con = getattr(self.context, _VOLATILE_SOLR_NAME)
if status :
if status :
- con.commit()
- con.close()
+
self.
con.commit()
+
self.
con.close()
else :
else :
- con.close()
- delattr(self.context, _VOLATILE_SOLR_NAME)
+ self.con.close()
+ try :
+ delattr(self.context, _VOLATILE_SOLR_NAME)
+ except AttributeError :
+ pass
class CatalogTool(BaseCatalogTool) :
meta_type = 'Plinn Catalog'
class CatalogTool(BaseCatalogTool) :
meta_type = 'Plinn Catalog'
@@
-54,7
+57,7
@@
class CatalogTool(BaseCatalogTool) :
con = SolrConnection(self.solr_url)
setattr(self, _VOLATILE_SOLR_NAME, con)
txn = transaction.get()
con = SolrConnection(self.solr_url)
setattr(self, _VOLATILE_SOLR_NAME, con)
txn = transaction.get()
- txn.addAfterCommitHook(SolrTransactionHook(self))
+ txn.addAfterCommitHook(SolrTransactionHook(self
, con
))
return getattr(self, _VOLATILE_SOLR_NAME)
security.declarePrivate('solrAdd')
return getattr(self, _VOLATILE_SOLR_NAME)
security.declarePrivate('solrAdd')