server/sources/pyrorql.py
changeset 8244 c7d89541e3c5
parent 7895 0a967180794b
child 8354 a9984ceebc26
equal deleted inserted replaced
8240:506ab2e8aeca 8244:c7d89541e3c5
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   365         # get cached cursor anyway
   365         # get cached cursor anyway
   366         cu = session.cnxset[self.uri]
   366         cu = session.cnxset[self.uri]
   367         if cu is None:
   367         if cu is None:
   368             # this is a ConnectionWrapper instance
   368             # this is a ConnectionWrapper instance
   369             msg = session._("can't connect to source %s, some data may be missing")
   369             msg = session._("can't connect to source %s, some data may be missing")
   370             session.set_shared_data('sources_error', msg % self.uri)
   370             session.set_shared_data('sources_error', msg % self.uri, txdata=True)
   371             return []
   371             return []
   372         translator = RQL2RQL(self)
   372         translator = RQL2RQL(self)
   373         try:
   373         try:
   374             rql = translator.generate(session, union, args)
   374             rql = translator.generate(session, union, args)
   375         except UnknownEid, ex:
   375         except UnknownEid, ex:
   381         try:
   381         try:
   382             rset = cu.execute(rql, args)
   382             rset = cu.execute(rql, args)
   383         except Exception, ex:
   383         except Exception, ex:
   384             self.exception(str(ex))
   384             self.exception(str(ex))
   385             msg = session._("error while querying source %s, some data may be missing")
   385             msg = session._("error while querying source %s, some data may be missing")
   386             session.set_shared_data('sources_error', msg % self.uri)
   386             session.set_shared_data('sources_error', msg % self.uri, txdata=True)
   387             return []
   387             return []
   388         descr = rset.description
   388         descr = rset.description
   389         if rset:
   389         if rset:
   390             needtranslation = []
   390             needtranslation = []
   391             rows = rset.rows
   391             rows = rset.rows