Some activity registry fixes. Thanks cjb.

This commit is contained in:
Tomeu Vizoso 2007-06-13 11:50:05 +02:00
parent ceff7d71a2
commit b320ea36cf
4 changed files with 13 additions and 6 deletions

View File

@ -20,7 +20,7 @@ import sys
import os import os
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from sugar.activity import ActivityRegistry from sugar import activity
from sugar import env from sugar import env
# Setup the environment so that we run inside the Sugar shell # Setup the environment so that we run inside the Sugar shell
@ -51,8 +51,7 @@ def print_help(self):
activity_info = None activity_info = None
if len(sys.argv) > 1: if len(sys.argv) > 1:
registry = ActivityRegistry() activities = activity.get_registry().find_activity(sys.argv[1])
activities = registry.find_activity(sys.argv[1])
if len(activities) > 0: if len(activities) > 0:
activity_info = activities[0] activity_info = activities[0]

View File

@ -36,4 +36,6 @@ class. This class allows for querying the ID of the root
window, requesting sharing across the network, and basic window, requesting sharing across the network, and basic
"what type of application are you" queries. "what type of application are you" queries.
""" """
from sugar.activity.registry import ActivityRegistry
from sugar.activity.registry import get_registry
from sugar.activity.registry import ActivityInfo

View File

@ -58,7 +58,10 @@ class ActivityRegistry(object):
info_list = self._registry.GetActivitiesForType(mime_type) info_list = self._registry.GetActivitiesForType(mime_type)
return self._convert_info_list(info_list) return self._convert_info_list(info_list)
_registry = ActivityRegistry() _registry = None
def get_registry(): def get_registry():
global _registry
if not _registry:
_registry = ActivityRegistry()
return _registry return _registry

View File

@ -49,7 +49,10 @@ class ObjectTypeRegistry(object):
type_dict = self._registry.GetTypeForMIME(mime_type) type_dict = self._registry.GetTypeForMIME(mime_type)
return _object_type_from_dict(type_dict) return _object_type_from_dict(type_dict)
_registry = ObjectTypeRegistry() _registry = None
def get_registry(): def get_registry():
global _registry
if not _registry:
_registry = ObjectTypeRegistry()
return _registry return _registry