1 ### -*- coding: utf-8 -*- #################################################### |
|
2 ############################################################################## |
|
3 # |
|
4 # Copyright (c) 2008-2010 Thierry Florac <tflorac AT ulthar.net> |
|
5 # All Rights Reserved. |
|
6 # |
|
7 # This software is subject to the provisions of the Zope Public License, |
|
8 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
9 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
10 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
11 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
12 # FOR A PARTICULAR PURPOSE. |
|
13 # |
|
14 ############################################################################## |
|
15 |
|
16 __docformat__ = "restructuredtext" |
|
17 |
|
18 # import standard packages |
|
19 |
|
20 # import Zope3 interfaces |
|
21 from zope.component.interfaces import IObjectEvent |
|
22 |
|
23 # import local interfaces |
|
24 |
|
25 # import Zope3 packages |
|
26 from zope.interface import Interface |
|
27 |
|
28 # import local packages |
|
29 |
|
30 |
|
31 class INewSiteManagerEvent(IObjectEvent): |
|
32 """Event interface for new site manager event""" |
|
33 |
|
34 |
|
35 # |
|
36 # Generic list interface |
|
37 # |
|
38 |
|
39 class IListInfo(Interface): |
|
40 """Custom interface used to handle list-like components""" |
|
41 |
|
42 def count(): |
|
43 """Get list items count""" |
|
44 |
|
45 def index(): |
|
46 """Get position of the given item""" |
|
47 |
|
48 def __contains__(): |
|
49 """Check if given value is int list""" |
|
50 |
|
51 def __getitem__(): |
|
52 """Return item at given position""" |
|
53 |
|
54 def __iter__(): |
|
55 """Iterator over list items""" |
|
56 |
|
57 |
|
58 class IListWriter(Interface): |
|
59 """Writer interface for list-like components""" |
|
60 |
|
61 def append(): |
|
62 """Append value to list""" |
|
63 |
|
64 def extend(): |
|
65 """Extend list with given items""" |
|
66 |
|
67 def insert(): |
|
68 """Insert item to given index""" |
|
69 |
|
70 def pop(): |
|
71 """Pop item from list and returns it""" |
|
72 |
|
73 def remove(): |
|
74 """Remove given item from list""" |
|
75 |
|
76 def reverse(): |
|
77 """Sort list in reverse order""" |
|
78 |
|
79 def sort(): |
|
80 """Sort list""" |
|
81 |
|
82 |
|
83 class IList(IListInfo, IListWriter): |
|
84 """Marker interface for list-like components""" |
|
85 |
|
86 |
|
87 # |
|
88 # Generic dict interface |
|
89 # |
|
90 |
|
91 class IDictInfo(Interface): |
|
92 """Custom interface used to handle dict-like components""" |
|
93 |
|
94 def keys(): |
|
95 """Get list of keys for the dict""" |
|
96 |
|
97 def has_key(key): |
|
98 """Check to know if dict includes the given key""" |
|
99 |
|
100 def get(key, default=None): |
|
101 """Get given key or default from dict""" |
|
102 |
|
103 def copy(): |
|
104 """Duplicate content of dict""" |
|
105 |
|
106 def __contains__(key): |
|
107 """Check if given key is in dict""" |
|
108 |
|
109 def __getitem__(key): |
|
110 """Get given key value from dict""" |
|
111 |
|
112 def __iter__(): |
|
113 """Iterator over dictionnary keys""" |
|
114 |
|
115 |
|
116 class IDictWriter(Interface): |
|
117 """Writer interface for dict-like components""" |
|
118 |
|
119 def clear(): |
|
120 """Clear dict""" |
|
121 |
|
122 def update(b): |
|
123 """Update dict with given values""" |
|
124 |
|
125 def setdefault(key, failobj=None): |
|
126 """Create value for given key if missing""" |
|
127 |
|
128 def pop(key, *args): |
|
129 """Remove and return given key from dict""" |
|
130 |
|
131 def popitem(): |
|
132 """Pop item from dict""" |
|
133 |
|
134 def __setitem__(key, value): |
|
135 """Update given key with given value""" |
|
136 |
|
137 def __delitem__(key): |
|
138 """Remove selected key from dict""" |
|
139 |
|
140 |
|
141 class IDict(IDictInfo, IDictWriter): |
|
142 """Marker interface for dict-like components""" |
|