comparison idavoll/pgsql_backend.py @ 98:b9c449f4c167

Removed debugging junk
author Ralph Meijer <ralphm@ik.nu>
date Wed, 24 Nov 2004 20:08:28 +0000
parents 3ad74552bbc7
children 8d8946e67fcb
comparison
equal deleted inserted replaced
97:cf918d581da5 98:b9c449f4c167
175 175
176 if not cursor.fetchone(): 176 if not cursor.fetchone():
177 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", 177 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
178 (owner.full().encode('utf8'))) 178 (owner.full().encode('utf8')))
179 179
180 try: 180 cursor.execute("""INSERT INTO affiliations
181 cursor.execute("""INSERT INTO affiliations 181 (node_id, entity_id, affiliation)
182 (node_id, entity_id, affiliation) 182 SELECT n.id, e.id, 'owner' FROM
183 SELECT n.id, e.id, 'owner' FROM 183 (SELECT id FROM nodes WHERE node=%s) AS n
184 (SELECT id FROM nodes WHERE node=%s) AS n 184 CROSS JOIN
185 CROSS JOIN 185 (SELECT id FROM entities WHERE jid=%s) AS e""",
186 (SELECT id FROM entities WHERE jid=%s) AS e""", 186 (node_id.encode('utf8'),
187 (node_id.encode('utf8'), 187 owner.full().encode('utf8')))
188 owner.full().encode('utf8')))
189 except Exception, e:
190 print e
191 188
192 return None 189 return None
193 190
194 def get_affiliations(self, entity): 191 def get_affiliations(self, entity):
195 return self.dbpool.runQuery("""SELECT node, affiliation FROM entities 192 return self.dbpool.runQuery("""SELECT node, affiliation FROM entities
274 def _get_items(self, cursor, node_id, max_items): 271 def _get_items(self, cursor, node_id, max_items):
275 self._check_node_exists(cursor, node_id) 272 self._check_node_exists(cursor, node_id)
276 query = """SELECT data FROM nodes JOIN items ON 273 query = """SELECT data FROM nodes JOIN items ON
277 (nodes.id=items.node_id) 274 (nodes.id=items.node_id)
278 WHERE node=%s ORDER BY date DESC""" 275 WHERE node=%s ORDER BY date DESC"""
279 try: 276 if max_items:
280 if max_items: 277 cursor.execute(query + " LIMIT %s",
281 cursor.execute(query + " LIMIT %s", 278 (node_id.encode('utf8'),
282 (node_id.encode('utf8'), 279 max_items))
283 max_items)) 280 else:
284 else: 281 cursor.execute(query, (node_id.encode('utf8')))
285 cursor.execute(query, (node_id.encode('utf8')))
286 except Exception, e:
287 print e
288 282
289 result = cursor.fetchall() 283 result = cursor.fetchall()
290 return [r[0] for r in result] 284 return [r[0] for r in result]
291 285
292 def remove_items(self, node_id, item_ids): 286 def remove_items(self, node_id, item_ids):