Exemplo n.º 1
0
 def __init_itemlist__(self):
     base_list.__init_itemlist__(self)
     if self.is_a_searchresult():
         search_query = self._request_args.get('q', '')
         for f in fstools.filelist(config.database_folder, '*.json'):
             t = tags(f)
             if t.matches(search_query):
                 c = get_class_for_item(t.get_rel_path())
                 if c:
                     item = c(t.get_rel_path(), self._request_args)
                     if item.exists():
                         if type(item) not in [itemlist, cached_itemlist]:
                             if self._create_cache or item.user_may_view():
                                 self._len += 1
                                 self._itemlist.append(item)
                         else:
                             if item.len() > 0:
                                 self._len += 1
                                 self._itemlist.append(item)
     else:
         if self.exists():
             for entry in os.listdir(self.raw_path()):
                 c = get_class_for_item(os.path.join(self._rel_path, entry))
                 if c:
                     item = c(os.path.join(self._rel_path, entry), request_args=self._request_args, parent=self, create_cache=self._create_cache)
                     if item.exists():
                         if type(item) not in [itemlist, cached_itemlist]:
                             if self._create_cache or item.user_may_view():
                                 self._len += 1
                                 self._itemlist.append(item)
                         else:
                             if item.len() > 0:
                                 self._len += 1
                                 self._itemlist.append(item)
         #
         self.sort()
Exemplo n.º 2
0
 def delete(self):
     base_item_props.delete(self)
     for folder in [config.citem_folder]:
         for filename in fstools.filelist(folder, self.uid() + '*'):
             os.remove(filename)
     os.remove(self.prop_item_path())