server/sources/native.py
changeset 10095 200bd6a601dc
parent 10086 98bc2ca1a816
child 10125 bc6461a7d2da
equal deleted inserted replaced
10094:954765f57fb6 10095:200bd6a601dc
   444     def shutdown(self):
   444     def shutdown(self):
   445         self.eid_generator.close()
   445         self.eid_generator.close()
   446 
   446 
   447     # XXX deprecates [un]map_attribute?
   447     # XXX deprecates [un]map_attribute?
   448     def map_attribute(self, etype, attr, cb, sourcedb=True):
   448     def map_attribute(self, etype, attr, cb, sourcedb=True):
   449         self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = (cb, sourcedb)
   449         self._rql_sqlgen.attr_map[u'%s.%s' % (etype, attr)] = (cb, sourcedb)
   450 
   450 
   451     def unmap_attribute(self, etype, attr):
   451     def unmap_attribute(self, etype, attr):
   452         self._rql_sqlgen.attr_map.pop('%s.%s' % (etype, attr), None)
   452         self._rql_sqlgen.attr_map.pop(u'%s.%s' % (etype, attr), None)
   453 
   453 
   454     def set_storage(self, etype, attr, storage):
   454     def set_storage(self, etype, attr, storage):
   455         storage_dict = self._storages.setdefault(etype, {})
   455         storage_dict = self._storages.setdefault(etype, {})
   456         storage_dict[attr] = storage
   456         storage_dict[attr] = storage
   457         self.map_attribute(etype, attr,
   457         self.map_attribute(etype, attr,
   892         assert cnx.cnxset is not None
   892         assert cnx.cnxset is not None
   893         # begin by inserting eid/type/source/extid into the entities table
   893         # begin by inserting eid/type/source/extid into the entities table
   894         if extid is not None:
   894         if extid is not None:
   895             assert isinstance(extid, str)
   895             assert isinstance(extid, str)
   896             extid = b64encode(extid)
   896             extid = b64encode(extid)
   897         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
   897         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid and unicode(extid),
   898                  'asource': source.uri}
   898                  'asource': unicode(source.uri)}
   899         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   899         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   900         # insert core relations: is, is_instance_of and cw_source
   900         # insert core relations: is, is_instance_of and cw_source
   901         try:
   901         try:
   902             self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   902             self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   903                                          (entity.eid, eschema_eid(cnx, entity.e_schema)))
   903                                          (entity.eid, eschema_eid(cnx, entity.e_schema)))
  1471         """set the instance'schema"""
  1471         """set the instance'schema"""
  1472         pass
  1472         pass
  1473 
  1473 
  1474 class LoginPasswordAuthentifier(BaseAuthentifier):
  1474 class LoginPasswordAuthentifier(BaseAuthentifier):
  1475     passwd_rql = 'Any P WHERE X is CWUser, X login %(login)s, X upassword P'
  1475     passwd_rql = 'Any P WHERE X is CWUser, X login %(login)s, X upassword P'
  1476     auth_rql = ('Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s, '
  1476     auth_rql = (u'Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s, '
  1477                 'X cw_source S, S name "system"')
  1477                 'X cw_source S, S name "system"')
  1478     _sols = ({'X': 'CWUser', 'P': 'Password', 'S': 'CWSource'},)
  1478     _sols = ({'X': 'CWUser', 'P': 'Password', 'S': 'CWSource'},)
  1479 
  1479 
  1480     def set_schema(self, schema):
  1480     def set_schema(self, schema):
  1481         """set the instance'schema"""
  1481         """set the instance'schema"""