← Back to team overview

quickly-talk team mailing list archive

Re: Updating apps for precise

 

Hi Allison
 The patch was more of a concept than a complete solution. I've add a
better one but moving from gtk2 & desktopcouch to gtk3 & gsettings
requires some developer effort. However this student used our template
on 28 March and it sucks that it doesn't work in May. Luckily this
project does not use persistence so the desktopcouch calls can simply
be removed, hopefully this time the API should be preserved.



On 04/05/2012, Allison Randal <allison@xxxxxxxxxx> wrote:
> Excellent, thanks! I've applied that. I'm still getting a build error
> from __init__ from the User_dict class in
> opensinhalease_lib/preferences.py.
>
> You can find the exact version of the code I'm building at:
>
> https://code.launchpad.net/~allison/+junk/opensinhalease-precise
>
> Thanks for any thoughts,
> Allison
>
> On 05/03/2012 03:59 PM, tony byrne wrote:
>> Hi Allison
>>  I had a look at lp:~mpgallage/opensinhalease/quickly_trunk and it
>> tries to call desktopcouch
>>  which is unusable in Precise. I stubbed out the desktopcouch calls
>> and the app runs from the source code now. Patch attached.
>>
>> There is a porting wiki entry https://wiki.ubuntu.com/Quickly/GTK3
>> that considers
>> PyGObject to PyGI
>> GTK+ 2 to GTK+ 3
>> GConf to GSettings
>>
>> but old quickly apps need a desktopcouch to GSettings guide.
>>
>> On 03/05/2012, Allison Randal <allison@xxxxxxxxxx> wrote:
>>> We have Quickly apps submitted to the ARB that run just fine on Oneiric,
>>> but fail to build on Precise. This seems to be related to changes in the
>>> APIs for GTK (I've attached a build log for one).
>>>
>>> Is there a set of simple instructions we can give developers on how to
>>> update their Quickly apps from Oneiric to Precise?
>>>
>>> Thanks!
>>> Allison
>>>
>
=== modified file 'opensinhalease_lib/preferences.py'
--- opensinhalease_lib/preferences.py	2012-04-01 15:51:12 +0000
+++ opensinhalease_lib/preferences.py	2012-05-06 13:06:37 +0000
@@ -21,10 +21,10 @@
 
 """Provides a shared preferences dictionary"""
 
-from desktopcouch.records.server import CouchDatabase
-from desktopcouch.records.record import Record
-import gtk
-import gobject
+import logging
+
+_hint = ''' not supported
+if you need preferences persistence use gsettings'''
 
 class User_dict(dict):
     ''' a dictionary with extra methods:
@@ -32,85 +32,31 @@
     persistence: load, save and db_connect
     gobject signals: connect and emit.
     
-    Don't use this directly. Please use the preferences instance.'''
-    
+    Originally based on couchdb - not compatible with gtk3
+    This is a stub to allow old projects to run'''
+
     def __init__(self, *args, **kwds):
         dict.__init__(self, *args, **kwds)
-        # Set up couchdb.
-        self._db_name = "opensinhalease"
-        self._key = None
-        self._database = None
-        
-        self._record_type = (
-            "http://wiki.ubuntu.com/Quickly/RecordTypes/Opensinhalease/";
-            "Preferences")
-        
-        class Publisher(gtk.Invisible): # pylint: disable=R0904
-            '''set up signals in a separate class
-            
-            gtk.Invisible has 230 public methods'''
-            __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST,
-                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
-                 'loaded' : (gobject.SIGNAL_RUN_LAST,
-                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))}
-        
-        publisher = Publisher()
-        self.emit  = publisher.emit
-        self.connect  = publisher.connect
+
+    def emit(self, *args, **kwargs):
+        '''emit signal'''
+        logging.warn('emit' + _hint)
+
+    def connect(self, *args, **kwargs):
+        '''connect to signal'''
+        logging.warn('connect' + _hint)
 
     def db_connect(self):
-        '''connect to couchdb
-        
-        create if necessary'''
-        # logging.basicConfig will be called now
-        self._database = CouchDatabase(self._db_name, create=True)
+        '''connect to couchdb'''
+        logging.warn('db_connect' + _hint)
 
     def save(self):
         'save to couchdb'
-        self._database.update_fields(self._key, self)
+        logging.warn('save' + _hint)
 
- 
     def load(self):
         'load from couchdb'
-        self.update({"record_type": self._record_type})
-
-        results = self._database.get_records(
-            record_type=self._record_type, create_view=True)
-
-        if len(results.rows) == 0:
-            # No preferences have ever been saved
-            # save them before returning.
-            self._key = self._database.put_record(Record(self))
-        else:
-            self.update(results.rows[0].value)
-            del self['_rev']
-            self._key = results.rows[0].value["_id"]
-        self.emit('loaded', None)
-
-    def update(self, *args, **kwds):
-        ''' interface for dictionary
-        
-        send changed signal when appropriate '''
-        
-        # parse args
-        new_data = {}
-        new_data.update(*args, **kwds)
-
-        changed_keys = []
-        for key in new_data.keys():
-            if new_data.get(key) != dict.get(self, key):
-                changed_keys.append(key)
-        dict.update(self, new_data)
-        if changed_keys:
-            self.emit('changed', tuple(changed_keys))
-
-    def __setitem__(self, key, value):
-        ''' interface for dictionary
-        
-        send changed signal when appropriate '''
-        if value != dict.get(self, key):
-            dict.__setitem__(self, key, value)
-            self.emit('changed', (key,))
+        logging.warn('load' + _hint)
+
 
 preferences = User_dict()
-



References