~mvo/software-center/new-apps-icons

« back to all changes in this revision

Viewing changes to softwarecenter/db/database.py

  • Committer: Michael Vogt
  • Date: 2010-08-05 10:29:12 UTC
  • mfrom: (858.2.71 buy-something)
  • Revision ID: michael.vogt@ubuntu.com-20100805102912-0ol8f1qnr4ajx2l4
merged lp:~mvo/software-center/buy-something, currently needs to
be enabled via "--enable-buy" to make it work

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        gobject.GObject.__init__(self)
68
68
        self._db_pathname = pathname
69
69
        self._aptcache = cache
 
70
        self._additional_databases = []
 
71
 
70
72
        # the xapian values as read from /var/lib/apt-xapian-index/values
71
73
        self._axi_values = {}
72
74
        self._logger = logging.getLogger("softwarecenter.db")
73
75
 
74
 
    def open(self, pathname=None, use_axi=True):
 
76
    def open(self, pathname=None, use_axi=True, use_agent=True):
75
77
        " open the database "
76
78
        if pathname:
77
79
            self._db_pathname = pathname
85
87
                self.xapiandb.add_database(axi)
86
88
                self._axi_values = parse_axi_values_file()
87
89
            except:
88
 
                self._logger.exception("failed to add apt-xapian-index")
 
90
                self._logging.exception("failed to add apt-xapian-index")
 
91
        if use_agent:
 
92
            try:
 
93
                sca = xapian.Database(XAPIAN_BASE_PATH_SOFTWARE_CENTER_AGENT)
 
94
                self.xapiandb.add_database(sca)
 
95
            except Exception as e:
 
96
                logging.warn("failed to add sca db %s" % e)
 
97
        # additional dbs
 
98
        for db in self._additional_databases:
 
99
            self.xapiandb.add_database(db)
 
100
        # parser etc
89
101
        self.xapian_parser = xapian.QueryParser()
90
102
        self.xapian_parser.set_database(self.xapiandb)
91
103
        self.xapian_parser.add_boolean_prefix("pkg", "XP")
95
107
        self.xapian_parser.set_default_op(xapian.Query.OP_AND)
96
108
        self.emit("open", self._db_pathname)
97
109
 
 
110
    def add_database(self, database):
 
111
        self._additional_databases.append(database)
 
112
        self.xapiandb.add_database(database)
 
113
 
 
114
    def del_database(self, database):
 
115
        self._additional_databases.remove(database)
 
116
 
98
117
    def reopen(self):
99
118
        " reopen the database "
100
119
        self.open()