| |
@@ -56,6 +56,8 @@
|
| |
name (str): The widget name. It will not be displayed in the UI, but
|
| |
will appear in some URLs, so be careful to only use simple,
|
| |
URL-compatible characters.
|
| |
+ label (str): A humanized name for the widget, which will be shown in
|
| |
+ the UI.
|
| |
position (str): The position of the widget in the rendered page. It
|
| |
should be one of the following values: ``left``, ``right``, or
|
| |
``both``.
|
| |
@@ -70,12 +72,18 @@
|
| |
"""
|
| |
|
| |
name = None
|
| |
+ label = None
|
| |
position = None
|
| |
parameters = []
|
| |
views_module = None
|
| |
cached_functions_module = None
|
| |
|
| |
def __init__(self):
|
| |
+ if self.name is None:
|
| |
+ raise AttributeError('widgets must have a "name" attribute')
|
| |
+ if self.label is None:
|
| |
+ # Try to be smart-ish with the default label.
|
| |
+ self.label = self.name.replace("_", " ").replace(".", ": ").title()
|
| |
self._template_environment = None
|
| |
|
| |
def validate(self):
|
| |
@@ -84,8 +92,6 @@
|
| |
|
| |
Raises: AttributeError
|
| |
"""
|
| |
- if self.name is None:
|
| |
- raise AttributeError('widgets must have a "name" attribute')
|
| |
if not re.match('^[\w_.-]+$', self.name):
|
| |
raise AttributeError(
|
| |
'invalid widget name: %r. ' % self.name +
|
| |
This improves the "Add widget" dialog significantly.