def getter(contact): person = IBasicPerson(contact.__parent__, None) if person is None: return getattr(contact, attribute) if attribute == '__name__': return person.username return ''
def getBoundContact(context): person = IBasicPerson(removeSecurityProxy(context)) annotations = IAnnotations(person) contact = annotations.get(PERSON_CONTACT_KEY, None) if contact is None: contact = BoundContact() annotations[PERSON_CONTACT_KEY] = contact contact.__name__ = 'contact' contact.__parent__ = person dependable = IDependable(contact) dependable.addDependent("") notify(ObjectAddedEvent(contact, contact.__parent__, contact.__name__)) return contact
def format_person_contacts(self, person, major_progress=()): contacts = IContactable(person).contacts rows = [] for contact in contacts.all(): row = [] row.append(Text(person.username)) target_person = IBasicPerson(contact.__parent__, None) if target_person is None: row.append(Text(contact.__name__)) else: row.append(Text(target_person.username)) state = contacts.state(contact) for x, (date, meaning, code) in enumerate(state): row.append(Date(date)) row.append(Text(code)) rows.append(row) return rows
def contains(self, principal): user = IPerson(principal, None) person = self.context if not IBasicPerson.providedBy(person): return False return user in person.advisors
def _person(self): person = IBasicPerson(self.__parent__) return person