[conduit/tracker] Create a PostalAddress object from the 'ADR' part of a vcard



commit 1bdf6cf8c4eaa9456c121815b6bbf61c22d78dfe
Author: John Carr <john carr unrouted co uk>
Date:   Mon Jun 15 05:37:06 2009 +0100

    Create a PostalAddress object from the 'ADR' part of a vcard

 conduit/modules/TrackerModule/TrackerModule.py  |   17 +++++++++++++++++
 conduit/modules/TrackerModule/tralchemy/core.py |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/conduit/modules/TrackerModule/TrackerModule.py b/conduit/modules/TrackerModule/TrackerModule.py
index d9a3298..6d7fe7a 100644
--- a/conduit/modules/TrackerModule/TrackerModule.py
+++ b/conduit/modules/TrackerModule/TrackerModule.py
@@ -86,6 +86,23 @@ class TrackerContacts(DataProvider.TwoWay):
                 c.nameadditional = x.additional
                 c.namehonorificprefix = x.prefix
                 c.namehonorificsuffix = x.suffix
+            elif k == "adr":
+                x = v[0].value
+                adr = nco.PostalAddress.create(commit=False)
+                if x.box:
+                    adr.pobox = x.box
+                if x.extended:
+                    adr.extendedaddress = x.extended
+                if x.street:
+                    adr.streetaddress = x.street
+                if x.city:
+                    adr.locality = x.city
+                if x.code:
+                    adr.postalcode = x.code
+                if x.country:
+                    adr.country = x.country
+                adr.commit()
+                c.haspostaladdress = adr
             elif k == "version":
                 pass
             elif k == "org":
diff --git a/conduit/modules/TrackerModule/tralchemy/core.py b/conduit/modules/TrackerModule/tralchemy/core.py
index 38fafa8..6019c3a 100644
--- a/conduit/modules/TrackerModule/tralchemy/core.py
+++ b/conduit/modules/TrackerModule/tralchemy/core.py
@@ -85,6 +85,7 @@ class Resource(object):
         for k, v in self.triples.iteritems():
             query += " ; %s %s" % (k, v)
         query += " . }"
+        print query
         tracker.SparqlUpdate(query)
         self.triples = {}
 



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