[conduit/tracker: 148/179] Final round of PEBKAC fixing, and improve implementation of Property.__set__



commit 2841bb0780b2dbab1bec9f7ae06440726bfb03a7
Author: John Carr <john carr unrouted co uk>
Date:   Thu May 14 11:22:04 2009 +0100

    Final round of PEBKAC fixing, and improve implementation of Property.__set__
---
 conduit/modules/TrackerModule/TrackerModule.py  |    5 +++--
 conduit/modules/TrackerModule/tralchemy/core.py |    8 +++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/conduit/modules/TrackerModule/TrackerModule.py b/conduit/modules/TrackerModule/TrackerModule.py
index 5957a2f..6d383cd 100644
--- a/conduit/modules/TrackerModule/TrackerModule.py
+++ b/conduit/modules/TrackerModule/TrackerModule.py
@@ -12,6 +12,7 @@ from conduit.datatypes import Rid
 Utils.dataprovider_add_dir_to_path(__file__)
 import tralchemy
 from tralchemy.nco import PersonContact
+import vobject
 
 MODULES = {
     "TrackerContacts": { "type": "dataprovider" },
@@ -101,7 +102,7 @@ class TrackerContacts(DataProvider.TwoWay):
         c = Contact.Contact()
 
         if tracker.fullname:
-            c.vcard.add('fn').value = tracker.fullname
+            c.vcard.fn.value = tracker.fullname
 
         if tracker.nickname:
             c.vcard.add('nickname').value = tracker.nickname
@@ -109,7 +110,7 @@ class TrackerContacts(DataProvider.TwoWay):
         if tracker.namefamily or tracker.namegiven or tracker.nameadditional or tracker.namehonorificprefix or tracker.namehonorificsuffix:
             n = vobject.vcard.Name(family=tracker.namefamily, given=tracker.namegiven, additional=tracker.nameadditional,
                                    prefix=tracker.namehonorificprefix, suffix=tracker.namehonorificsuffix)
-            c.add('n').value = n
+            c.vcard.n.value = n
 
         return c
 
diff --git a/conduit/modules/TrackerModule/tralchemy/core.py b/conduit/modules/TrackerModule/tralchemy/core.py
index 4606f85..a5a7809 100644
--- a/conduit/modules/TrackerModule/tralchemy/core.py
+++ b/conduit/modules/TrackerModule/tralchemy/core.py
@@ -110,7 +110,13 @@ class Property(Resource, property):
     def __set__(self, instance, value):
         if instance is None:
             return
-        self.triples[self._type_] = value
+        if isinstance(value, Resource):
+            if value.uri.startswith("http://";):
+                instance.triples[self.uri] = "<%s>" % value.uri
+            else:
+                instance.triples[self.uri] = value.uri
+        else:
+            instance.triples[self.uri] = '"%s"' % value
 
     def __delete__(self, instance):
         pass



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