1. marchael
  2. moin-2.0


Thomas Waldmann  committed 9fe3154

get rid of storage level search_items method (uses deprecated code)

user module still needed that functionality (we have no whoosh indexing for
user items yet as they use item metadata not revision metadata/data).

fixed some comments/docstrings that referred to it

  • Participants
  • Parent commits 7a51d13
  • Branches pytest2

Comments (0)

Files changed (5)

File MoinMoin/storage/__init__.py

View file
     This class abstracts access to backends. If you want to write a specific
     backend, say a mercurial backend, you have to implement the methods below.
     A backend knows of its items and can perform several item related operations
-    such as search_items, get_item, create_item, etc.
+    such as get_item, create_item, etc.
     # If you need to write a backend it is sufficient
-    def search_items(self, searchterm):
-        """
-        Takes a MoinMoin search term and returns an iterator (maybe empty) over
-        matching item objects (NOT item names!).
-        :type searchterm: MoinMoin search term
-        :param searchterm: The term for which to search.
-        :rtype: iterator of item objects
-        """
-        # Very simple implementation because we have no indexing
-        # or anything like that. If you want to optimize this, override it.
-        for item in self.iteritems():
-            searchterm.prepare()
-            if searchterm.evaluate(item):
-                yield item
     def get_item(self, itemname):
         Returns item object or raises Exception if that item does not exist.

File MoinMoin/storage/_tests/test_backends.py

View file
     def test_has_item_that_doesnt_exist(self):
         assert not self.backend.has_item(u"i_do_not_exist")
-    def test_search_simple(self):
-        for name in [u"songlist", u"song lyric", u"odd_SONG_item"]:
-            self.create_rev_item_helper(name)
-        self.create_meta_item_helper(u"new_song_player")
-        query_string = u"song"
-        query = terms.Name(query_string, True)
-        for num, item in enumerate(self.backend.search_items(query)):
-            assert item.name.find(query_string) != -1
-        assert num == 2
-    def test_search_better(self):
-        self.create_rev_item_helper(u'abcde')
-        self.create_rev_item_helper(u'abcdef')
-        self.create_rev_item_helper(u'abcdefg')
-        self.create_rev_item_helper(u'abcdefgh')
-        def _test_search(term, expected):
-            found = list(self.backend.search_items(term))
-            assert len(found) == expected
-        # must be /part/ of the name
-        yield _test_search, terms.Name(u'AbCdEf', False), 3
-        yield _test_search, terms.Name(u'AbCdEf', True), 0
-        yield _test_search, terms.Name(u'abcdef', True), 3
-        yield _test_search, terms.NameRE(re.compile(u'abcde.*')), 4
-        yield _test_search, terms.NameFn(lambda n: n == u'abcdef'), 1
     def test_iteritems_1(self):
         for num in range(10, 20):
             self.create_rev_item_helper(u"item_" + str(num).zfill(2))

File MoinMoin/storage/backends/acl.py

View file
         # up on the real backend.
         return getattr(self.backend, attr)
-    def search_items(self, searchterm):
-        """
-        @see: Backend.search_items.__doc__
-        """
-        for item in self.backend.search_items(searchterm):
-            if self._may(item.name, READ):
-                # The item returned needs to be wrapped because otherwise the
-                # item's methods (like create_revision) wouldn't be wrapped.
-                wrapped_item = AclWrapperItem(item, self)
-                yield wrapped_item
     def get_item(self, itemname):
         @see: Backend.get_item.__doc__

File MoinMoin/storage/backends/sqla.py

View file
         * Data.read must be changed to operate on dynamically loaded chunks. I.e., the data._chunks must
           be set to lazy='dynamic', which will then be a query instead of a collection.
-        * Find a proper solution for methods that issue many SQL queries. Especially search_items is
-          difficult, as we cannot know what data will be needed in the subsequent processing of the items
-          returned, which will result in more queries being issued. Eager loading is only a partial solution.
+        * Find a proper solution for methods that issue many SQL queries.
         * MetaData should definitely NOT simply be stored as a dict in a PickleType Column. Store that properly,
           perhaps in (a) seperate table(s).
         * Find out why RC lists an item that was just written below Trash/ as well. (Likely a UI bug.)

File MoinMoin/user.py

View file
 def get_items_by_filter(key, value):
     """ Searches for an user with a given filter """
     from MoinMoin.storage.terms import ItemMetaDataMatch
-    items = get_user_backend().search_items(ItemMetaDataMatch(key, value))
-    return list(items)
+    backend = get_user_backend()
+    searchterm = ItemMetaDataMatch(key, value)
+    items = []
+    for item in backend.iteritems():
+        searchterm.prepare()
+        if searchterm.evaluate(item):
+            items.append(item)
+    return items
 def get_by_email_address(email_address):