comparison sat_pubsub/pgsql_storage.py @ 249:aaf5e34ff765

fixed getItems when there are not authorized_groups + fixed default value for StoreItem
author Goffi <goffi@goffi.org>
date Fri, 08 Jun 2012 18:34:45 +0200
parents 50f6ee966da8
children eb14b8d30cba
comparison
equal deleted inserted replaced
248:50f6ee966da8 249:aaf5e34ff765
66 from sat_pubsub import error, iidavoll 66 from sat_pubsub import error, iidavoll
67 67
68 NS_ITEM_CONFIG = "http://jabber.org/protocol/pubsub#item-config" 68 NS_ITEM_CONFIG = "http://jabber.org/protocol/pubsub#item-config"
69 OPT_ACCESS_MODEL = 'pubsub#access_model' 69 OPT_ACCESS_MODEL = 'pubsub#access_model'
70 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed' 70 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed'
71 VAL_DEFAULT = 'default'
72 VAL_OPEN = 'open' 71 VAL_OPEN = 'open'
73 VAL_ROSTER = 'roster' 72 VAL_ROSTER = 'roster'
73 VAL_DEFAULT = VAL_OPEN
74 74
75 class Storage: 75 class Storage:
76 76
77 implements(iidavoll.IStorage) 77 implements(iidavoll.IStorage)
78 78
606 else: 606 else:
607 query = ["""SELECT data FROM nodes 607 query = ["""SELECT data FROM nodes
608 INNER JOIN items USING (node_id) 608 INNER JOIN items USING (node_id)
609 LEFT JOIN item_groups_authorized USING (item_id) 609 LEFT JOIN item_groups_authorized USING (item_id)
610 WHERE node=%s AND 610 WHERE node=%s AND
611 (items.access_model='open' or 611 (items.access_model='open' """ +
612 (items.access_model='roster' and groupname in (%s)) 612 ("or (items.access_model='roster' and groupname in %s)" if authorized_groups else '') +
613 ) 613 """)
614 ORDER BY date DESC"""] 614 ORDER BY date DESC"""]
615 args = [self.nodeIdentifier, authorized_groups] 615 args = [self.nodeIdentifier]
616 if authorized_groups:
617 args.append(authorized_groups)
616 618
617 if maxItems: 619 if maxItems:
618 query.append("LIMIT %s") 620 query.append("LIMIT %s")
619 args.append(maxItems) 621 args.append(maxItems)
620 622