Trees | Indices | Help |
|
---|
|
1 """I define `GroupMixin`, a helper class to implement groups.""" 2 3 from itertools import chain 4 5 from advene.model.core.element import MEDIA, ANNOTATION, RELATION, LIST, \ 6 TAG, VIEW, QUERY, RESOURCE, IMPORT, \ 7 ElementCollection10 """I provide default implementation for all methods of the Group interface. 11 12 Note that at least __iter__ or all the iter_* methods must be implemented 13 by subclasses, for in this implementation, they depend on each other. 14 """ 15109 return GroupMedias(group.owner) 110 111 @property17 return chain(*( 18 self.iter_medias(), 19 self.iter_annotations(), 20 self.iter_relations(), 21 self.iter_lists(), 22 self.iter_tags(), 23 self.iter_views(), 24 self.iter_queries(), 25 self.iter_resources(), 26 self.iter_imports(), 27 ))28 33 38 43 48 53 58 63 68 73 74 77 80 83 86 89 92 95 98 101 102 @property104 class GroupMedias(ElementCollection): 105 __iter__ = group.iter_medias 106 __len__ = group.count_medias 107 def __contains__(self, e): 108 return getattr(e, "ADVENE_TYPE", None) == MEDIA and e in group113 class GroupAnnotations(ElementCollection): 114 __iter__ = group.iter_annotations 115 __len__ = group.count_annotations 116 def __contains__(self, e): 117 return getattr(e, "ADVENE_TYPE", None) == ANNOTATION \ 118 and e in group119 return GroupAnnotations(group.owner) 120 121 @property123 class GroupRelations(ElementCollection): 124 __iter__ = group.iter_relations 125 __len__ = group.count_relations 126 def __contains__(self, e): 127 return getattr(e, "ADVENE_TYPE", None) == RELATION \ 128 and e in group129 return GroupRelations(group.owner) 130 131 @property133 class GroupViews(ElementCollection): 134 __iter__ = group.iter_views 135 __len__ = group.count_views 136 def __contains__(self, e): 137 return getattr(e, "ADVENE_TYPE", None) == VIEW and e in group138 return GroupViews(group.owner) 139 140 @property142 class GroupResources(ElementCollection): 143 __iter__ = group.iter_resources 144 __len__ = group.count_resources 145 def __contains__(self, e): 146 return getattr(e, "ADVENE_TYPE", None) == RESOURCE \ 147 and e in group148 return GroupResources(group.owner) 149 150 @property 157 return GroupTags(group.owner) 158 159 @property161 class GroupLists(ElementCollection): 162 __iter__ = group.iter_lists 163 __len__ = group.count_lists 164 def __contains__(self, e): 165 return getattr(e, "ADVENE_TYPE", None) == LIST and e in group166 return GroupLists(group.owner) 167 168 @property170 class GroupQueries(ElementCollection): 171 __iter__ = group.iter_queries 172 __len__ = group.count_queries 173 def __contains__(self, e): 174 return getattr(e, "ADVENE_TYPE", None) == QUERY and e in group175 return GroupQueries(group.owner) 176 177 @property179 class GroupImports(ElementCollection): 180 __iter__ = group.iter_imports 181 __len__ = group.count_imports 182 def __contains__(self, e): 183 return getattr(e, "ADVENE_TYPE", None) == IMPORT and e in group184 return GroupImports(group.owner) 185
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 8 16:00:08 2009 | http://epydoc.sourceforge.net |