24 |
24 |
25 |
25 |
26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
27 from __future__ import print_function |
27 from __future__ import print_function |
28 import os |
28 import os |
29 import platform |
29 import platform as platform_module |
30 from zope.interface import implements |
30 from zope.interface import implements |
31 from nevow import appserver, inevow, tags, loaders, athena, url, rend |
31 from nevow import appserver, inevow, tags, loaders, athena, url, rend |
32 from nevow.page import renderer |
32 from nevow.page import renderer |
33 from formless import annotate |
33 from formless import annotate |
34 from formless import webform |
34 from formless import webform |
141 |
141 |
142 def addExtension(self, name, desc, fields, btnlabel, callback): |
142 def addExtension(self, name, desc, fields, btnlabel, callback): |
143 def _bind(ctx): |
143 def _bind(ctx): |
144 return annotate.MethodBinding( |
144 return annotate.MethodBinding( |
145 'action_' + name, |
145 'action_' + name, |
146 annotate.Method(arguments=[ |
146 annotate.Method( |
147 annotate.Argument(*field) |
147 arguments=[ |
148 for field in fields], |
148 annotate.Argument(*field) |
|
149 for field in fields], |
149 label=desc), |
150 label=desc), |
150 action=btnlabel) |
151 action=btnlabel) |
151 setattr(self, 'bind_' + name, _bind) |
152 setattr(self, 'bind_' + name, _bind) |
152 |
153 |
153 setattr(self, 'action_' + name, callback) |
154 setattr(self, 'action_' + name, callback) |
157 ConfigurableSettings = ConfigurableBindings() |
158 ConfigurableSettings = ConfigurableBindings() |
158 |
159 |
159 |
160 |
160 class ISettings(annotate.TypedInterface): |
161 class ISettings(annotate.TypedInterface): |
161 platform = annotate.String(label=_("Platform"), |
162 platform = annotate.String(label=_("Platform"), |
162 default=platform.system( |
163 default=platform_module.system() + |
163 ) + " " + platform.release(), |
164 " " + platform_module.release(), |
164 immutable=True) |
165 immutable=True) |
|
166 |
165 # TODO version ? |
167 # TODO version ? |
166 |
168 |
|
169 # pylint: disable=no-self-argument |
167 def sendLogMessage( |
170 def sendLogMessage( |
168 ctx=annotate.Context(), |
171 ctx=annotate.Context(), |
169 level=annotate.Choice(LogLevels, |
172 level=annotate.Choice(LogLevels, |
170 required=True, |
173 required=True, |
171 label=_("Log message level")), |
174 label=_("Log message level")), |
172 message=annotate.String(label=_("Message text"))): |
175 message=annotate.String(label=_("Message text"))): |
173 pass |
176 pass |
|
177 |
174 sendLogMessage = annotate.autocallable(sendLogMessage, |
178 sendLogMessage = annotate.autocallable(sendLogMessage, |
175 label=_( |
179 label=_( |
176 "Send a message to the log"), |
180 "Send a message to the log"), |
177 action=_("Send")) |
181 action=_("Send")) |
178 |
182 |