Fix some collecton validation

And add restrict_level helper method.
This commit is contained in:
Laurent Bachelier 2012-03-11 15:25:16 +01:00
commit 1430b40bc5
7 changed files with 11 additions and 13 deletions

View file

@ -64,8 +64,7 @@ class NovaBackend(BaseBackend, ICapRadio, ICapCollection):
def iter_resources(self, objs, split_path):
if Radio in objs:
if len(split_path) > 0:
raise CollectionNotFound(split_path)
self._restrict_level(split_path)
for id in self._RADIOS.iterkeys():
yield self.get_radio(id)

View file

@ -48,8 +48,7 @@ class OuiFMBackend(BaseBackend, ICapRadio, ICapCollection):
def iter_resources(self, objs, split_path):
if Radio in objs:
if len(split_path) > 0:
raise CollectionNotFound(split_path)
self._restrict_level(split_path)
for id in self._RADIOS.iterkeys():
yield self.get_radio(id)

View file

@ -112,7 +112,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
for _id in sorted(self._RADIOS.iterkeys()):
if not _id.startswith('fb'):
yield self.get_radio(_id)
yield Collection(['francebleu'], 'France Bleu')
yield Collection([u'francebleu'], u'France Bleu')
else:
raise CollectionNotFound(split_path)

View file

@ -96,17 +96,15 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
############# CapCollection ###################################################
def iter_resources(self, objs, split_path):
if Project in objs or Issue in objs:
self._restrict_level(split_path, 1)
if len(split_path) == 0:
return [Collection([project.id], project.name)
for project in self.iter_projects()]
if len(split_path) == 1:
elif len(split_path) == 1:
query = Query()
query.project = unicode(split_path[0])
return self.iter_issues(query)
raise CollectionNotFound(split_path)
def validate_collection(self, objs, collection):
if len(collection.split_path) == 0:
return