[editcontroller] fix bad method name: s/process_form_data/process_form_value
NOTE: this still doesn't work, relations are not processed properly
"""CubicWeb server connections pool : the repository has a limited number ofconnections pools, each of them dealing with a set of connections on each sourceused by the repository. A connections pools (`ConnectionsPool`) is anabstraction for a group of connection to each source.:organization: Logilab:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses"""__docformat__="restructuredtext en"importsysclassConnectionsPool(object):"""handle connections on a set of sources, at some point associated to a user session """def__init__(self,sources):# dictionnary of (source, connection), indexed by sources'uriself.source_cnxs={}forsourceinsources:self.source_cnxs[source.uri]=(source,source.get_connection())ifnot'system'inself.source_cnxs:self.source_cnxs['system']=self.source_cnxs[sources[0].uri]self._cursors={}def__getitem__(self,uri):"""subscription notation provide access to sources'cursors"""try:cursor=self._cursors[uri]exceptKeyError:cursor=self.source_cnxs[uri][1].cursor()ifcursorisnotNone:# None possible on sources without cursor support such as ldapself._cursors[uri]=cursorreturncursordefcommit(self):"""commit the current transaction for this user"""# FIXME: what happends if a commit fail# would need a two phases commit or like, but I don't know how to do# this using the db-api...forsource,cnxinself.source_cnxs.values():# let exception propagatescnx.commit()defrollback(self):"""rollback the current transaction for this user"""forsource,cnxinself.source_cnxs.values():# catch exceptions, rollback other sources anywaytry:cnx.rollback()except:source.critical('rollback error',exc_info=sys.exc_info())defclose(self,i_know_what_i_do=False):"""close all connections in the pool"""ifi_know_what_i_doisnotTrue:# unexpected closing safety beltraiseRuntimeError('pool shouldn\'t be closed')forcuinself._cursors.values():try:cu.close()except:continuefor_,cnxinself.source_cnxs.values():try:cnx.close()except:continue# internals ###############################################################defpool_set(self):"""pool is being set"""self.check_connections()defpool_reset(self):"""pool is being reseted"""forsource,cnxinself.source_cnxs.values():source.pool_reset(cnx)defsources(self):"""return the source objects handled by this pool"""# implementation details of flying insert requires the system source# firstyieldself.source_cnxs['system'][0]foruri,(source,cursor)inself.source_cnxs.items():ifuri=='system':continueyieldsource#return [source_cnx[0] for source_cnx in self.source_cnxs.values()]defsource(self,uid):"""return the source object with the given uri"""returnself.source_cnxs[uid][0]defconnection(self,uid):"""return the connection on the source object with the given uri"""returnself.source_cnxs[uid][1]defreconnect(self,source=None):"""reopen a connection for this source or all sources if none specified """ifsourceisNone:sources=self.sources()else:sources=(source,)forsourceinsources:source.info('trying to reconnect')self.source_cnxs[source.uri]=(source,source.get_connection())self._cursors.pop(source.uri,None)defcheck_connections(self):forsource,cnxinself.source_cnxs.itervalues():newcnx=source.check_connection(cnx)ifnewcnxisnotNone:self.reset_connection(source,newcnx)defreset_connection(self,source,cnx):self.source_cnxs[source.uri]=(source,cnx)self._cursors.pop(source.uri,None)fromcubicweb.server.hookimport(Operation,LateOperation,SingleOperation,SingleLastOperation)fromlogilab.common.deprecationimportclass_moved,class_renamedOperation=class_moved(Operation)PreCommitOperation=class_renamed('PreCommitOperation',Operation)LateOperation=class_moved(LateOperation)SingleOperation=class_moved(SingleOperation)SingleLastOperation=class_moved(SingleLastOperation)