Ticket #459: sugar.patch

File sugar.patch, 2.3 KB (added by alsroot, 14 years ago)

new version

  • src/jarabe/model/bundleregistry.py

    diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
    index 57db287..d23d5cb 100644
    a b  
    11# Copyright (C) 2006-2007 Red Hat, Inc.
     2# Copyright (C) 2009 Aleksey Lim
    23#
    34# This program is free software; you can redistribute it and/or modify
    45# it under the terms of the GNU General Public License as published by
    import gio 
    2425import cjson
    2526
    2627from sugar.bundle.activitybundle import ActivityBundle
     28from sugar.bundle.contentbundle import ContentBundle
    2729from sugar.bundle.bundle import MalformedBundleException, \
    2830    AlreadyInstalledException, RegistrationException
    2931from sugar import env
    class BundleRegistry(gobject.GObject): 
    305307        open(path, 'w').write(cjson.encode(favorites_data))
    306308
    307309    def is_installed(self, bundle):
     310        # TODO treat ContentBundle in special way
     311        # needs rethinking while fixing ContentBundle support
     312        if isinstance(bundle, ContentBundle):
     313            return bundle.is_installed()
     314
    308315        for installed_bundle in self._bundles:
    309316            if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \
    310317                    bundle.get_activity_version() == \
    class BundleRegistry(gobject.GObject): 
    328335        install_dir = env.get_user_activities_path()
    329336        install_path = bundle.install(install_dir)
    330337       
    331         if not self.add_bundle(install_path):
     338        # TODO treat ContentBundle in special way
     339        # needs rethinking while fixing ContentBundle support
     340        if isinstance(bundle, ContentBundle):
     341            pass
     342        elif not self.add_bundle(install_path):
    332343            raise RegistrationException
    333344
    334345    def uninstall(self, bundle, force=False):       
     346        # TODO treat ContentBundle in special way
     347        # needs rethinking while fixing ContentBundle support
     348        if isinstance(bundle, ContentBundle):
     349            if bundle.is_installed():
     350                bundle.uninstall()
     351            else:
     352                logging.warning('Not uninstalling, bundle is not installed')
     353            return
     354
    335355        act = self.get_bundle(bundle.get_bundle_id())
    336356        if not force and \
    337357                act.get_activity_version() != bundle.get_activity_version():