Toggle line numbers
1 ### namespace high level --------------------------------------------
2
3 class CompositeNamespace:
4 """ Namespace supporting mounting other namespaces within it -
5 either at the root of it or below some name
6 API: dict like, see Namespace
7 """
8 def __init__(self, nstab):
9 self.nstab = nstab
10
11 ...
12
13 class LayeredNamespace:
14 """ Layers of item namespaces, visible is the topmost item
15 API: dict like, see Namespace
16 """
17 def __init__(self, *layers):
18 self.layers = layers
19
20 ...
21
22
23 ### namespace medium level ------------------------------------------
24
25 class Namespace:
26 """ A single item namespace
27 API: dict like
28 """
29 def __init__(self, storage):
30 self.storage = storage
31
32 def __contains__(self, name):
33 return self.has_item(name)
34
35 def has_item(self, name, include_deleted=False):
36 """ check if namespace has an item <name>
37
38 (we can use "if itemname in namespace")
39 """
40 return self.storage.has_item(name, include_deleted)
41
42 def __getitem__(self, name):
43 """ get item from namespace """
44 return StorageItem(self.storage, name)
45
46 def __setitem__(self, name, item):
47 """ put item into namespace """
48 ???
49
50 def __delitem__(self, name):
51 """ nuke item from namespace """
52 self.storage.nuke_item(name)
53
54 def __len__(self):
55 """ return item count in namespace """
56
57 def __str__(self):
58 """ for debugging """
59 def __unicode__(self):
60 """ for debugging """
61
62 def iteritems/iterkeys/itervalues(self):
63 ...
64
65
66 ### item high level -------------------------------------------------
67
68 class Item:
69 """ proxy to the following mimetype specific *Item classes,
70 gets ProtectedItem and dynamically offers appropriate interface for
71 the mimetype that item has
72 """
73
74 class BinaryItem:
75 """ have stuff here we need for all item types,
76 like:
77 .url
78 .link_to
79 .delete
80 .nuke
81 .rename
82 """
83
84 class TextItem(BinaryItem):
85 """ as BinaryItem, but with special stuff for text/* """
86
87 class WikiItem(TextItem):
88 """ as TextItem, but with special stuff for text/moin-wiki """
89
90 class ImageItem(BinaryItem):
91 """ as BinaryItem, but with special stuff for image/* """
92
93
94 ### item medium level -----------------------------------------------
95
96 class ProtectedItem(StorageItem):
97 """ same as StorageItem, but raises AccessDenied exception when accessing
98 data with insufficient user rights
99 """
100 def __init__(self, storage, name, user, revisioning=True):
101 ...
102
103 def may(self, right):
104 """ check permissions without trying to do something """
105
106 class StorageItem:
107 """ a revisioned, generic StorageItem """
108 def __init__(self, storage, name, revisioning=True):
109 """ create Item <name> instance """
110 self.storage = storage
111 self.name = name
112 self.revisioning = revisioning
113
114 def exists(self, include_deleted=False):
115 # redundant with similar function from Namespace
116 return self.storage.has_item(self.name, include_deleted)
117
118 current = property(...) # lazy load current Revision
119
120 revisions = property(...) # lazy load older Revision dict
121 # dict revno -> Revision
122 # add_revision ==:
123 # next_rev = current.meta['rev'] + 1
124 # revisions[next_rev] = newrev
125 # del_revision == del revisions[rev]
126 # list_revisions == revisions.keys()
127 # has_revision == rev in revisions
128
129 class Revision:
130 """ a single, specific revision of an Item
131 API: properties, lazy load
132 """
133 def __init__(self, rev):
134 """ create a revision <rev> """
135 self.rev = rev # this is also in the MetaData
136
137 meta = property() # MetaDataComponent
138 data = property() # same as content['data']
139 content = property() # dict name -> DataComponent obj or None (if deleted)
140
141
142 class MetaDataComponent:
143 """ represent meta data component (a Revision has 1 MetaDataComponent)
144 API: dict-like
145 """
146
147
148 class DataComponent:
149 """ represent a single data component (a Revision can have 0..n DataComponents -
150 if it has no DataComponent called 'data', it is considered as a deleted Revision,
151 TwikiDraw Items have multiple DataComponents)
152 API: file-like as well as comfortable properties
153 """
154
155
156 ### item / namespace low level storage ------------------------------
157 ...