3
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
9
from canonical.lp import initZopeless
10
from canonical.database import postgresql
11
from canonical.database.sqlbase import cursor
12
from lp.registry.model.person import Person
13
from lp.registry.model.teammembership import TeamParticipation
16
person_handle = sys.argv[1]
21
if "@" in person_handle:
22
person = Person.selectOne("EmailAddress.person = Person.id AND "
23
"emailaddress.email = %s" % person_handle)
25
person = Person.selectOneBy(name=person_handle)
27
person = Person.selectOneBy(id=person_handle)
30
print "Person %s not found" % person_handle
36
references = list(postgresql.listReferences(cur, 'person', 'id'))
38
print ("Listing references for %s (ID %s, preferred email %s):\n" %
39
(person.name, person.id,
40
person.preferredemail and person.preferredemail.email))
41
for src_tab, src_col, ref_tab, ref_col, updact, delact in references:
42
if (src_tab, src_col) in skip:
44
query = "SELECT id FROM %s WHERE %s=%s" % (src_tab, src_col, person.id)
48
if src_tab.lower() == 'teamparticipation':
49
tp = TeamParticipation.selectOneBy(
50
personID=person.id, teamID=person.id)
52
# Every person has a teamparticipation entry for itself,
53
# and we already know this. No need to output it, then.
55
print ("\tColumn %s of table %s with id %s points to this "
56
"person." % (src_col, src_tab, row[0]))