| @@ 118-132 (lines=15) @@ | ||
| 115 | context = context.__of__(self.context) |
|
| 116 | return context |
|
| 117 | ||
| 118 | def attr(self, name, default=None): |
|
| 119 | """Get the named attribute of the widget or the field |
|
| 120 | """ |
|
| 121 | value = getattr(self, name, _marker) |
|
| 122 | if value is _marker: |
|
| 123 | return default |
|
| 124 | if isinstance(value, six.string_types): |
|
| 125 | context = self.get_context() |
|
| 126 | if base_hasattr(context, value): |
|
| 127 | attr = getattr(context, value) |
|
| 128 | if callable(attr): |
|
| 129 | value = attr() |
|
| 130 | else: |
|
| 131 | value = attr |
|
| 132 | return value |
|
| 133 | ||
| 134 | def get_value(self): |
|
| 135 | """Extract the value from the request or get it from the field |
|
| @@ 109-123 (lines=15) @@ | ||
| 106 | context = context.__of__(self.context) |
|
| 107 | return context |
|
| 108 | ||
| 109 | def attr(self, name, default=None): |
|
| 110 | """Get the named attribute of the widget or the field |
|
| 111 | """ |
|
| 112 | value = getattr(self, name, _marker) |
|
| 113 | if value is _marker: |
|
| 114 | return default |
|
| 115 | if isinstance(value, six.string_types): |
|
| 116 | context = self.get_context() |
|
| 117 | if base_hasattr(context, value): |
|
| 118 | attr = getattr(context, value) |
|
| 119 | if callable(attr): |
|
| 120 | attr = attr() |
|
| 121 | if attr: |
|
| 122 | value = attr |
|
| 123 | return value |
|
| 124 | ||
| 125 | def get_value(self): |
|
| 126 | """Extract the value from the request or get it from the field |
|