Re: gmail plugin: display all contact data -- integrate patch?



Hi,

2011-01-16 13:28:35 Stefan Otte <stefan otte gmail com>:
>What is wrong with the current code and what is expected?
>The GoogleContact should be an ContactLeaf as mentioned in
>obj/contacts.py? And the slot mechanism should be used?
>Anything else?

I try to help with this stuff.

Grouping is a feature, that allow to group leaves from one or more
sources that have the same some attribute. For now we have only two
type of leaves: contacts (groped by name, email, jid) and hosts
(grouped by name or address).

For example, if you have the same contact in gmail, gajim, pingin etc,
leaves from appropriate sources will be grouped. One leaf will be
promoted to "main" leaf and other appear as its children.

Unique properties for each leaf are stored in "slots" - for example
"name", "email", "jid". Slots defined in "grouping_slots" are used
grouping. Type of group (contacts / host) is defined in source class.

We can provide new subclass of ContactLeaf for each source (for example
to provide other icon) or use one existing classes. But in actions we
should always use base class (ContactLeaf) and check that given leaf
have appropriate slot (i.e. "email" in actions related to sending
emails).

So, if you replace GoogleContact(EmailContact) with GoogleContact(Leaf)
this brake whole grouping for contacts from gmail (this leaves can't
(shouldn't) be grouped).

If you want provide provide some new attributes for contacts, I think
simplest and best method is create new class, something like that:

ATTRIBUTE_KEY = 'ATTRIBUTE_KEY'
VALUE_KEY = 'VALUE_KEY'

class ContactDetails (ContactLeaf):
	def __init__(self, name, attribute, value):
		slots = {ATTRIBUTE_KEY: attribute, NAME_KEY: name,
			VALUE_KEY: value}
		ContactLeaf.__init__(self, slots, value)

	def repr_key(self):
		return self.object[ATTRIBUTE_KEY]

	def get_description(self):
		return self.object[ATTRIBUTE_KEY]

	def get_text_representation(self):
		return self.object[VALUE_KEY]

And use this to keep additional information (yield this objects in
source). I check this for simple example and seems to work ok. Of
course this class may be extended or maybe there should be separate
class for phones, addresses etc.

I see that you read from google information about skype and jabber id -
for this you should use JabberContacts and skype.Contacts. This allow
to use this information in other plugins.

I hope this help...

Regards, 
Karol



Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]