conduit r1198 - in trunk: . conduit conduit/datatypes conduit/modules conduit/modules/NetworkModule test/python-tests



Author: jstowers
Date: Sat Jan 12 10:30:31 2008
New Revision: 1198
URL: http://svn.gnome.org/viewvc/conduit?rev=1198&view=rev

Log:
Misc fixes

Modified:
   trunk/ChangeLog
   trunk/conduit/Conduit.py
   trunk/conduit/datatypes/File.py
   trunk/conduit/modules/NetworkModule/Client.py
   trunk/conduit/modules/NetworkModule/XMLRPCUtils.py
   trunk/conduit/modules/TestModule.py
   trunk/test/python-tests/common.py

Modified: trunk/conduit/Conduit.py
==============================================================================
--- trunk/conduit/Conduit.py	(original)
+++ trunk/conduit/Conduit.py	Sat Jan 12 10:30:31 2008
@@ -128,7 +128,9 @@
                 log.warn("Only sinks, sources or twoway dataproviders may be added")
                 return False
 
-        dataprovider_wrapper.module.connect("change-detected", self._change_detected)
+        if dataprovider_wrapper.module != None:
+            dataprovider_wrapper.module.connect("change-detected", self._change_detected)
+
         self.emit("dataprovider-added", dataprovider_wrapper) 
         return True
 
@@ -242,6 +244,9 @@
                     dataprovider_wrapper=newDpw,
                     trySourceFirst=(x==0)
                     )
+        if newDpw.module != None:
+            newDpw.module.connect("change-detected", self._change_detected)
+        
         self.emit("dataprovider-changed", oldDpw, newDpw) 
 
     def refresh_dataprovider(self, dp, block=False):

Modified: trunk/conduit/datatypes/File.py
==============================================================================
--- trunk/conduit/datatypes/File.py	(original)
+++ trunk/conduit/datatypes/File.py	Sat Jan 12 10:30:31 2008
@@ -492,10 +492,15 @@
 
     def __getstate__(self):
         data = DataType.DataType.__getstate__(self)
-        data['uri'] = str(self.URI)
         data['basePath'] = self.basePath
         data['group'] = self.group
+        data['relpath'] = self.relpath
+        data['filename'] = self.get_filename()
+        data['filemtime'] = self.get_mtime()
+
+        #FIXME: Maybe we should tar this first...
         data['data'] = open(self.get_local_uri(), 'rb').read()
+
         return data
 
     def __setstate__(self, data):
@@ -503,10 +508,12 @@
         os.write(fd, data['data'])
         os.close(fd)
         
-        self.URI = gnomevfs.URI(data['uri'])
+        self.URI = gnomevfs.URI(name)
         self.basePath = data['basePath']
         self.group = data['group']
-        self._defer_rename(name)
+        self.relpath = data['relpath']
+        self._defer_rename(data['filename'])
+        self._defer_new_mtime(data['filemtime'])
 
         DataType.DataType.__setstate__(self, data)
 

Modified: trunk/conduit/modules/NetworkModule/Client.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Client.py	(original)
+++ trunk/conduit/modules/NetworkModule/Client.py	Sat Jan 12 10:30:31 2008
@@ -113,9 +113,9 @@
         params['url'] = dpUrl
         params['uid'] = uid
     
-        # Actually create a new object type based on XMLRPCUtils.ClientDataProvider
+        # Actually create a new object type based on XMLRPCUtils.DataProviderClient
         # but with the properties from the remote DataProvider
-        newdp = type(dpUrl, (XMLRPCUtils.ClientDataProvider, ), params)
+        newdp = type(dpUrl, (XMLRPCUtils.DataProviderClient, ), params)
 
         return newdp
 

Modified: trunk/conduit/modules/NetworkModule/XMLRPCUtils.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/XMLRPCUtils.py	(original)
+++ trunk/conduit/modules/NetworkModule/XMLRPCUtils.py	Sat Jan 12 10:30:31 2008
@@ -91,7 +91,7 @@
     def stop(self):
         self.closed = True
 
-class ClientDataProvider(DataProvider.TwoWay):
+class DataProviderClient(DataProvider.TwoWay):
     """
     Provides the Client portion of dataprovider proxying.
     """

Modified: trunk/conduit/modules/TestModule.py
==============================================================================
--- trunk/conduit/modules/TestModule.py	(original)
+++ trunk/conduit/modules/TestModule.py	Sat Jan 12 10:30:31 2008
@@ -3,6 +3,7 @@
 import datetime
 import thread
 import logging
+import time
 log = logging.getLogger("modules.Test")
 
 import conduit
@@ -14,10 +15,7 @@
 import conduit.Exceptions as Exceptions
 import conduit.Module as Module
 import conduit.Web as Web
-#from conduit.datatypes import Rid
-from conduit.datatypes import DataType, Text, Video, Audio
-
-import time
+from conduit.datatypes import Rid, DataType, Text, Video, Audio
 
 MODULES = {
     "TestSource" :              { "type": "dataprovider" },
@@ -45,13 +43,16 @@
 #"xy.." where x is an integer, and y is a string
 class TestDataType(DataType.DataType):
     _name_ = "test_type"
-    def __init__(self, xy, mtime=DEFAULT_MTIME, hash=DEFAULT_HASH):
+    def __init__(self, Integer, mtime=DEFAULT_MTIME, hash=DEFAULT_HASH):
         DataType.DataType.__init__(self)
-        self.Integer = int(xy[0])
+        self.Integer = int(Integer)
         self.myHash = hash
-        
+
+        #WARNING: Datatypes should not call these function from within
+        #their constructor - that is the dataproviders responsability. Consider
+        #this a special case for testing
+        self.set_UID(str(Integer))        
         self.set_open_URI("file:///home/")
-        self.set_UID(xy)
         self.set_mtime(mtime)
         
     def __str__(self):
@@ -252,7 +253,7 @@
         if self.count >= self.errorAfter:
             raise Exceptions.SyncronizeError("Error After:%s Count:%s" % (self.errorAfter, self.count))
         self.count += 1
-        newData = TestDataType(data.get_UID()+self._name_)
+        newData = TestDataType(data.get_UID())
         return newData.get_rid()
 
 class TestImageSink(Image.ImageSink):
@@ -270,7 +271,8 @@
 
     #ImageSink Methods
     def _upload_photo(self, uploadInfo):
-        return uploadInfo.name+uploadInfo.url+self._name_
+        LUID = "%s%s%s" % (uploadInfo.name,uploadInfo.url,self._name_)
+        return Rid(uid=LUID)
 
     def _get_photo_info(self, luid):
         return None
@@ -364,7 +366,7 @@
     def put(self, data, overwrite, LUID=None):
         log.debug("Put Video File: %s (stored at: %s)" % (data.get_UID(),data.get_local_uri()))
         DataProvider.DataSink.put(self, data, overwrite, LUID)
-        newData = TestDataType(data.get_UID()+self._name_)
+        newData = TestDataType(data.get_size())
         return newData.get_rid()
 
     def get_UID(self):
@@ -409,7 +411,7 @@
     def put(self, data, overwrite, LUID=None):
         log.debug("Put Audio File: %s (stored at: %s)" % (data.get_UID(),data.get_local_uri()))
         DataProvider.DataSink.put(self, data, overwrite, LUID)
-        newData = TestDataType(data.get_UID()+self._name_)
+        newData = TestDataType(data.get_size())
         return newData.get_rid()
 
     def get_UID(self):
@@ -467,7 +469,7 @@
 
     def put(self, data, overwrite, LUID=None):
         DataProvider.DataSink.put(self, data, overwrite, LUID)
-        newData = TestDataType(data.get_UID()+self._name_)
+        newData = TestDataType(data.get_UID())
         return newData.get_rid()
 
     def get_UID(self):
@@ -489,7 +491,7 @@
     def put(self, data, overwrite, LUID=None):
         log.debug("Putting file: %s" % data._get_text_uri())
         DataProvider.DataSink.put(self, data, overwrite, LUID)
-        newData = TestDataType(data.get_UID()+self._name_)
+        newData = TestDataType(data.get_size())
         return newData.get_rid()
 
     def get_UID(self):
@@ -598,7 +600,7 @@
     def put(self, data, overwrite, LUID=None):
         DataProvider.DataSink.put(self, data, overwrite, LUID)
         if not overwrite:
-            raise Exceptions.SynchronizeConflictError(conduit.datatypes.COMPARISON_UNKNOWN, data, TestDataType('0Conflict'))
+            raise Exceptions.SynchronizeConflictError(conduit.datatypes.COMPARISON_UNKNOWN, data, TestDataType('0'))
         newData = TestDataType(data.get_UID()+self._name_)
         return newData.get_rid()
 

Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py	(original)
+++ trunk/test/python-tests/common.py	Sat Jan 12 10:30:31 2008
@@ -297,7 +297,7 @@
             factory = self.model.dataproviderFactories[i]
             if str(factory).find("NetworkClientFactory") != -1:
                 newdp = factory.dataprovider_create("http://localhost:3400/";, conduit.uid, None)
-                ok("Created new ClientDataProvider", newdp != None)
+                ok("Created new DataProviderClient", newdp != None)
                 return self.wrap_dataprovider( newdp() )
 
     def configure(self, source={}, sink={}):



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