92 |
92 |
93 class NativeSQLSource(SQLAdapterMixIn, AbstractSource): |
93 class NativeSQLSource(SQLAdapterMixIn, AbstractSource): |
94 """adapter for source using the native cubicweb schema (see below) |
94 """adapter for source using the native cubicweb schema (see below) |
95 """ |
95 """ |
96 sqlgen_class = SQLGenerator |
96 sqlgen_class = SQLGenerator |
97 # need default value on class since migration doesn't call init method |
|
98 has_deleted_entitites_table = True |
|
99 |
97 |
100 passwd_rql = "Any P WHERE X is CWUser, X login %(login)s, X upassword P" |
98 passwd_rql = "Any P WHERE X is CWUser, X login %(login)s, X upassword P" |
101 auth_rql = "Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s" |
99 auth_rql = "Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s" |
102 _sols = ({'X': 'CWUser', 'P': 'Password'},) |
100 _sols = ({'X': 'CWUser', 'P': 'Password'},) |
103 |
101 |
222 finally: |
220 finally: |
223 self.open_pool_connections() |
221 self.open_pool_connections() |
224 |
222 |
225 def init(self): |
223 def init(self): |
226 self.init_creating() |
224 self.init_creating() |
227 pool = self.repo._get_pool() |
|
228 pool.pool_set() |
|
229 # XXX cubicweb < 2.42 compat |
|
230 if 'deleted_entities' in self.dbhelper.list_tables(pool['system']): |
|
231 self.has_deleted_entitites_table = True |
|
232 else: |
|
233 self.has_deleted_entitites_table = False |
|
234 pool.pool_reset() |
|
235 self.repo._free_pool(pool) |
|
236 |
225 |
237 def map_attribute(self, etype, attr, cb): |
226 def map_attribute(self, etype, attr, cb): |
238 self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb |
227 self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb |
239 |
228 |
240 # ISource interface ####################################################### |
229 # ISource interface ####################################################### |
545 """delete system information on deletion of an entity by transfering |
534 """delete system information on deletion of an entity by transfering |
546 record from the entities table to the deleted_entities table |
535 record from the entities table to the deleted_entities table |
547 """ |
536 """ |
548 attrs = {'eid': eid} |
537 attrs = {'eid': eid} |
549 session.system_sql(self.sqlgen.delete('entities', attrs), attrs) |
538 session.system_sql(self.sqlgen.delete('entities', attrs), attrs) |
550 if self.has_deleted_entitites_table: |
539 if extid is not None: |
551 if extid is not None: |
540 assert isinstance(extid, str), type(extid) |
552 assert isinstance(extid, str), type(extid) |
541 extid = b64encode(extid) |
553 extid = b64encode(extid) |
542 attrs = {'type': etype, 'eid': eid, 'extid': extid, |
554 attrs = {'type': etype, 'eid': eid, 'extid': extid, |
543 'source': uri, 'dtime': datetime.now()} |
555 'source': uri, 'dtime': datetime.now()} |
544 session.system_sql(self.sqlgen.insert('deleted_entities', attrs), attrs) |
556 session.system_sql(self.sqlgen.insert('deleted_entities', attrs), attrs) |
|
557 |
545 |
558 def fti_unindex_entity(self, session, eid): |
546 def fti_unindex_entity(self, session, eid): |
559 """remove text content for entity with the given eid from the full text |
547 """remove text content for entity with the given eid from the full text |
560 index |
548 index |
561 """ |
549 """ |