incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [25/36] PEP8 cleanup
Date Fri, 10 Jan 2014 21:23:21 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index f59b5fd..e8d9a27 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -28,8 +28,10 @@ import ew.jinja2_ew as ew
 
 log = logging.getLogger(__name__)
 
+
 def onready(text):
-    return ew.JSScript('$(function () {%s});' % text);
+    return ew.JSScript('$(function () {%s});' % text)
+
 
 class LabelList(fev.UnicodeString):
 
@@ -46,10 +48,11 @@ class LabelList(fev.UnicodeString):
         value = super(LabelList, self)._from_python(value, state)
         return value
 
+
 class LabelEdit(ew.InputField):
-    template='jinja:allura:templates/widgets/label_edit.html'
+    template = 'jinja:allura:templates/widgets/label_edit.html'
     validator = LabelList(if_empty=[])
-    defaults=dict(
+    defaults = dict(
         ew.InputField.defaults,
         name=None,
         value=None,
@@ -90,9 +93,10 @@ class LabelEdit(ew.InputField):
             });
         ''' % dict(url=c.app.url))
 
+
 class ProjectUserSelect(ew.InputField):
-    template='jinja:allura:templates/widgets/project_user_select.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/project_user_select.html'
+    defaults = dict(
         ew.InputField.defaults,
         name=None,
         value=None,
@@ -102,13 +106,14 @@ class ProjectUserSelect(ew.InputField):
     def __init__(self, **kw):
         super(ProjectUserSelect, self).__init__(**kw)
         if not isinstance(self.value, list):
-            self.value=[self.value]
+            self.value = [self.value]
 
     def from_python(self, value, state=None):
         return value
 
     def resources(self):
-        for r in super(ProjectUserSelect, self).resources(): yield r
+        for r in super(ProjectUserSelect, self).resources():
+            yield r
         yield ew.CSSLink('css/autocomplete.css')
         yield onready('''
           $('input.project_user_select').autocomplete({
@@ -153,8 +158,8 @@ class ProjectUserCombo(ew.SingleSelectField):
 
 
 class NeighborhoodProjectSelect(ew.InputField):
-    template='jinja:allura:templates/widgets/neighborhood_project_select.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/neighborhood_project_select.html'
+    defaults = dict(
         ew.InputField.defaults,
         name=None,
         value=None,
@@ -164,14 +169,15 @@ class NeighborhoodProjectSelect(ew.InputField):
     def __init__(self, url, **kw):
         super(NeighborhoodProjectSelect, self).__init__(**kw)
         if not isinstance(self.value, list):
-            self.value=[self.value]
+            self.value = [self.value]
         self.url = url
 
     def from_python(self, value, state=None):
         return value
 
     def resources(self):
-        for r in super(NeighborhoodProjectSelect, self).resources(): yield r
+        for r in super(NeighborhoodProjectSelect, self).resources():
+            yield r
         yield ew.CSSLink('css/autocomplete.css')
         yield onready('''
           $('input.neighborhood-project-select').autocomplete({
@@ -190,22 +196,25 @@ class NeighborhoodProjectSelect(ew.InputField):
             minLength: 3
           });''' % self.url)
 
+
 class AttachmentList(ew_core.Widget):
-    template='jinja:allura:templates/widgets/attachment_list.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/attachment_list.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         attachments=None,
         edit_mode=None)
 
+
 class AttachmentAdd(ew_core.Widget):
-    template='jinja:allura:templates/widgets/attachment_add.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/attachment_add.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         action=None,
         name=None)
 
     def resources(self):
-        for r in super(AttachmentAdd, self).resources(): yield r
+        for r in super(AttachmentAdd, self).resources():
+            yield r
         yield onready('''
             $(".attachment_form_add_button").click(function (evt) {
                 $(this).hide();
@@ -214,12 +223,13 @@ class AttachmentAdd(ew_core.Widget):
             });
          ''')
 
+
 class SubmitButton(ew.SubmitButton):
-    attrs={'class':'ui-state-default ui-button ui-button-text'}
+    attrs = {'class': 'ui-state-default ui-button ui-button-text'}
 
 
 class Radio(ew.InputField):
-    template=ew_core.render.Snippet('''<input {% if value %} checked{% endif %} {{widget.j2_attrs({
+    template = ew_core.render.Snippet('''<input {% if value %} checked{% endif %} {{widget.j2_attrs({
         'id':id,
         'type':field_type,
         'name':rendered_name,
@@ -227,13 +237,13 @@ class Radio(ew.InputField):
         'readonly':readonly,
         'value':value},
         attrs)}}>''', 'jinja2')
-    defaults=dict(
+    defaults = dict(
         ew.InputField.defaults,
         field_type='radio')
 
 
 class AutoResizeTextarea(ew.TextArea):
-    defaults=dict(
+    defaults = dict(
         ew.TextArea.defaults,
         name=None,
         value=None,
@@ -245,10 +255,11 @@ class AutoResizeTextarea(ew.TextArea):
             $('textarea.auto_resize').focus(function(){$(this).autosize();});
         ''')
 
+
 class MarkdownEdit(AutoResizeTextarea):
-    template='jinja:allura:templates/widgets/markdown_edit.html'
+    template = 'jinja:allura:templates/widgets/markdown_edit.html'
     validator = fev.UnicodeString()
-    defaults=dict(
+    defaults = dict(
         AutoResizeTextarea.defaults,
         name=None,
         value=None,
@@ -258,15 +269,17 @@ class MarkdownEdit(AutoResizeTextarea):
         return value
 
     def resources(self):
-        for r in super(MarkdownEdit, self).resources(): yield r
+        for r in super(MarkdownEdit, self).resources():
+            yield r
         yield ew.JSLink('js/jquery.lightbox_me.js')
         yield ew.JSLink('js/jquery.textarea.js')
         yield ew.JSLink('js/sf_markitup.js')
         yield ew.CSSLink('css/markitup_sf.css')
 
+
 class PageList(ew_core.Widget):
-    template='jinja:allura:templates/widgets/page_list.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/page_list.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         name=None,
         limit=None,
@@ -277,12 +290,13 @@ class PageList(ew_core.Widget):
     def paginator(self, count, page, limit, zero_based_pages=True):
         page_offset = 1 if zero_based_pages else 0
         limit = 10 if limit is None else limit
+
         def page_url(page):
             params = request.GET.copy()
             params['page'] = page - page_offset
             return url(request.path, params)
         return paginate.Page(range(count), page + page_offset, int(limit),
-        url=page_url)
+                             url=page_url)
 
     def resources(self):
         yield ew.CSSLink('css/page_list.css')
@@ -290,14 +304,15 @@ class PageList(ew_core.Widget):
     @property
     def url_params(self, **kw):
         url_params = dict()
-        for k,v in request.params.iteritems():
-            if k not in ['limit','count','page']:
+        for k, v in request.params.iteritems():
+            if k not in ['limit', 'count', 'page']:
                 url_params[k] = v
         return url_params
 
+
 class PageSize(ew_core.Widget):
-    template='jinja:allura:templates/widgets/page_size.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/page_size.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         limit=None,
         name=None,
@@ -307,8 +322,8 @@ class PageSize(ew_core.Widget):
     @property
     def url_params(self, **kw):
         url_params = dict()
-        for k,v in request.params.iteritems():
-            if k not in ['limit','count','page']:
+        for k, v in request.params.iteritems():
+            if k not in ['limit', 'count', 'page']:
                 url_params[k] = v
         return url_params
 
@@ -317,15 +332,17 @@ class PageSize(ew_core.Widget):
             $('select.results_per_page').change(function () {
                 this.form.submit();});''')
 
+
 class FileChooser(ew.InputField):
-    template='jinja:allura:templates/widgets/file_chooser.html'
-    validator=fev.FieldStorageUploadConverter()
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/file_chooser.html'
+    validator = fev.FieldStorageUploadConverter()
+    defaults = dict(
         ew.InputField.defaults,
         name=None)
 
     def resources(self):
-        for r in super(FileChooser, self).resources(): yield r
+        for r in super(FileChooser, self).resources():
+            yield r
         yield ew.JSLink('js/jquery.file_chooser.js')
         yield onready('''
             var num_files = 0;
@@ -350,27 +367,30 @@ class FileChooser(ew.InputField):
                 $(holder).append(delete_link);
             });''')
 
+
 class JQueryMixin(object):
     js_widget_name = None
     js_plugin_file = None
     js_params = [
         'container_cls'
-        ]
-    defaults=dict(
-        container_cls = 'container')
+    ]
+    defaults = dict(
+        container_cls='container')
 
     def resources(self):
         for r in super(JQueryMixin, self).resources():
             yield r
-        if self.js_plugin_file is not None: yield self.js_plugin_file
+        if self.js_plugin_file is not None:
+            yield self.js_plugin_file
         opts = dict(
             (k, getattr(self, k))
-            for k in self.js_params )
+            for k in self.js_params)
         yield onready('''
 $(document).bind('clone', function () {
     $('.%s').%s(%s); });
 $(document).trigger('clone');
-            ''' % (self.container_cls, self.js_widget_name, json.dumps(opts)));
+            ''' % (self.container_cls, self.js_widget_name, json.dumps(opts)))
+
 
 class SortableRepeatedMixin(JQueryMixin):
     js_widget_name = 'SortableRepeatedField'
@@ -380,8 +400,8 @@ class SortableRepeatedMixin(JQueryMixin):
         'flist_cls',
         'stub_cls',
         'msg_cls',
-        ]
-    defaults=dict(
+    ]
+    defaults = dict(
         container_cls='sortable-repeated-field',
         field_cls='sortable-field',
         flist_cls='sortable-field-list',
@@ -390,64 +410,72 @@ class SortableRepeatedMixin(JQueryMixin):
         empty_msg='No fields have been defined',
         nonempty_msg='Drag and drop the fields to reorder',
         repetitions=0)
-    button =  ew.InputField(
+    button = ew.InputField(
         css_class='add', field_type='button', value='New Field')
 
+
 class SortableRepeatedField(SortableRepeatedMixin, ew.RepeatedField):
-    template='genshi:allura.templates.widgets.sortable_repeated_field'
-    defaults=dict(
+    template = 'genshi:allura.templates.widgets.sortable_repeated_field'
+    defaults = dict(
         ew.RepeatedField.defaults,
         **SortableRepeatedMixin.defaults)
 
+
 class SortableTable(SortableRepeatedMixin, ew.TableField):
-    template='genshi:allura.templates.widgets.sortable_table'
-    defaults=dict(
+    template = 'genshi:allura.templates.widgets.sortable_table'
+    defaults = dict(
         ew.TableField.defaults,
         **SortableRepeatedMixin.defaults)
 
+
 class StateField(JQueryMixin, ew.CompoundField):
-    template='genshi:allura.templates.widgets.state_field'
+    template = 'genshi:allura.templates.widgets.state_field'
     js_widget_name = 'StateField'
     js_plugin_file = ew.JSLink('js/state_field.js')
     js_params = JQueryMixin.js_params + [
         'selector_cls',
         'field_cls',
-        ]
-    defaults=dict(
+    ]
+    defaults = dict(
         ew.CompoundField.defaults,
-        js_params = js_params,
+        js_params=js_params,
         container_cls='state-field-container',
         selector_cls='state-field-selector',
         field_cls='state-field',
         show_label=False,
-        selector = None,
-        states = {},
-        )
+        selector=None,
+        states={},
+    )
 
     @property
     def fields(self):
         return [self.selector] + self.states.values()
 
+
 class DateField(JQueryMixin, ew.TextField):
     js_widget_name = 'datepicker'
     js_params = JQueryMixin.js_params
     container_cls = 'ui-date-field'
-    defaults=dict(
+    defaults = dict(
         ew.TextField.defaults,
-        container_cls = 'ui-date-field',
-        css_class = 'ui-date-field')
+        container_cls='ui-date-field',
+        css_class='ui-date-field')
 
     def resources(self):
-        for r in super(DateField, self).resources(): yield r
+        for r in super(DateField, self).resources():
+            yield r
         yield ew.CSSLink('css/jquery.ui.datepicker.css')
 
+
 class FieldCluster(ew.CompoundField):
-    template='genshi:allura.templates.widgets.field_cluster'
+    template = 'genshi:allura.templates.widgets.field_cluster'
+
 
 class AdminField(ew.InputField):
+
     '''Field with the correct layout/etc for an admin page'''
-    template='jinja:allura:templates/widgets/admin_field.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/admin_field.html'
+    defaults = dict(
         ew.InputField.defaults,
         field=None,
         css_class=None,
@@ -462,9 +490,10 @@ class AdminField(ew.InputField):
         for r in self.field.resources():
             yield r
 
+
 class Lightbox(ew_core.Widget):
-    template='jinja:allura:templates/widgets/lightbox.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/lightbox.html'
+    defaults = dict(
         name=None,
         trigger=None,
         content='',
@@ -487,10 +516,11 @@ class Lightbox(ew_core.Widget):
 
 
 class DisplayOnlyField(ew.HiddenField):
+
     '''
     Render a field as plain text, optionally with a hidden field to preserve the value.
     '''
-    template=ew.Snippet('''{{ (text or value or attrs.value)|e }}
+    template = ew.Snippet('''{{ (text or value or attrs.value)|e }}
         {%- if with_hidden_input is none and name or with_hidden_input -%}
         <input {{
             widget.j2_attrs({
@@ -500,9 +530,8 @@ class DisplayOnlyField(ew.HiddenField):
                 'class':css_class}, attrs)
         }}>
         {%- endif %}''', 'jinja2')
-    defaults=dict(
+    defaults = dict(
         ew.HiddenField.defaults,
         text=None,
         value=None,
         with_hidden_input=None)
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index e656fc0..de87746 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -38,28 +38,33 @@ from allura import model as M
 
 log = logging.getLogger(__name__)
 
-weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
+weekdays = ['Monday', 'Tuesday', 'Wednesday',
+            'Thursday', 'Friday', 'Saturday', 'Sunday']
+
 
 class _HTMLExplanation(ew.InputField):
-    template=ew.Snippet(
+    template = ew.Snippet(
         '''<label class="grid-4">&nbsp;</label>
            <div class="grid-14" style="margin:2px;">{{widget.text}}</div>
         ''',
         'jinja2')
 
+
 class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
+
     def _validate_shortname(self, shortname, neighborhood, state):
         if not h.re_project_name.match(shortname):
             raise forge_exc.ProjectShortnameInvalid(
-                    'Please use only letters, numbers, and dashes 3-15 characters long.',
-                    shortname, state)
+                'Please use only letters, numbers, and dashes 3-15 characters long.',
+                shortname, state)
 
     def _validate_allowed(self, shortname, neighborhood, state):
-        p = M.Project.query.get(shortname=shortname, neighborhood_id=neighborhood._id)
+        p = M.Project.query.get(
+            shortname=shortname, neighborhood_id=neighborhood._id)
         if p:
             raise forge_exc.ProjectConflict(
-                    'This project name is taken.',
-                    shortname, state)
+                'This project name is taken.',
+                shortname, state)
 
     def to_python(self, value, state=None, check_allowed=True, neighborhood=None):
         """
@@ -70,13 +75,15 @@ class NeighborhoodProjectShortNameValidator(fev.FancyValidator):
         otherwise disallowed.
         """
         if neighborhood is None:
-            neighborhood = M.Neighborhood.query.get(name=state.full_dict['neighborhood'])
+            neighborhood = M.Neighborhood.query.get(
+                name=state.full_dict['neighborhood'])
         value = h.really_unicode(value or '').encode('utf-8').lower()
         self._validate_shortname(value, neighborhood, state)
         if check_allowed:
             self._validate_allowed(value, neighborhood, state)
         return value
 
+
 class ForgeForm(ew.SimpleForm):
     antispam = False
     template = 'jinja:allura:templates/widgets/forge_form.html'
@@ -109,7 +116,8 @@ class ForgeForm(ew.SimpleForm):
         ctx = self.context_for(field)
         display = field.display(**ctx)
         if ctx['errors'] and field.show_errors and not ignore_errors:
-            display = "%s<div class='error'>%s</div>" % (display, ctx['errors'])
+            display = "%s<div class='error'>%s</div>" % (display,
+                                                         ctx['errors'])
         return h.html.literal(display)
 
     def display_field_by_idx(self, idx, ignore_errors=False):
@@ -120,10 +128,13 @@ class ForgeForm(ew.SimpleForm):
         ctx = self.context_for(field)
         display = field.display(**ctx)
         if ctx['errors'] and field.show_errors and not ignore_errors:
-            display = "%s<div class='error'>%s</div>" % (display, ctx['errors'])
+            display = "%s<div class='error'>%s</div>" % (display,
+                                                         ctx['errors'])
         return display
 
+
 class PasswordChangeBase(ForgeForm):
+
     class fields(ew_core.NameList):
         pw = ew.PasswordField(
             label='New Password',
@@ -139,7 +150,9 @@ class PasswordChangeBase(ForgeForm):
             raise formencode.Invalid('Passwords must match', value, state)
         return d
 
+
 class PasswordChangeForm(PasswordChangeBase):
+
     class fields(ew_core.NameList):
         oldpw = ew.PasswordField(
             label='Old Password',
@@ -151,11 +164,13 @@ class PasswordChangeForm(PasswordChangeBase):
             label='New Password (again)',
             validator=fev.UnicodeString(not_empty=True))
 
+
 class PersonalDataForm(ForgeForm):
+
     class fields(ew_core.NameList):
         sex = ew.SingleSelectField(
             label='Gender',
-            options=[ew.Option(py_value=v,label=v,selected=False)
+            options=[ew.Option(py_value=v, label=v, selected=False)
                      for v in ['Male', 'Female', 'Unknown', 'Other']],
             validator=formencode.All(
                 V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other']),
@@ -170,26 +185,26 @@ class PersonalDataForm(ForgeForm):
         country = ew.SingleSelectField(
             label='Country of residence',
             validator=V.MapValidator(country_names, not_empty=False),
-            options = [
+            options=[
                 ew.Option(
-                    py_value=" ", label=" -- Unknown -- ", selected=False)] +\
-                [ew.Option(py_value=c, label=n, selected=False)
-                 for c,n in sorted(country_names.items(),
-                                   key=lambda (k,v):v)],
-            attrs={'onchange':'selectTimezone(this.value)'})
+                    py_value=" ", label=" -- Unknown -- ", selected=False)] +
+            [ew.Option(py_value=c, label=n, selected=False)
+             for c, n in sorted(country_names.items(),
+                                key=lambda (k, v):v)],
+            attrs={'onchange': 'selectTimezone(this.value)'})
         city = ew.TextField(
             label='City of residence',
             attrs=dict(value=None),
             validator=fev.UnicodeString(not_empty=False))
-        timezone=ew.SingleSelectField(
+        timezone = ew.SingleSelectField(
             label='Timezone',
-            attrs={'id':'tz'},
+            attrs={'id': 'tz'},
             validator=V.OneOfValidator(common_timezones, not_empty=False),
             options=[
-                 ew.Option(
-                     py_value=" ",
-                     label=" -- Unknown -- ")] + \
-                 [ew.Option(py_value=n, label=n)
+                ew.Option(
+                    py_value=" ",
+                    label=" -- Unknown -- ")] +
+            [ew.Option(py_value=n, label=n)
                   for n in sorted(common_timezones)])
 
     def display(self, **kw):
@@ -237,11 +252,11 @@ class PersonalDataForm(ForgeForm):
         yield ew.JSScript('''
 var $allTimezones = $("#tz").clone();
 var $t = {};
-''' + \
-    reduce(_append, [
-        '$t["'+ el +'"] = ' + str([name.encode('utf-8')
-                                  for name in country_timezones[el]]) + ";\n"
-        for el in country_timezones]) + '''
+''' +
+                          reduce(_append, [
+                              '$t["' + el + '"] = ' + str([name.encode('utf-8')
+                                                           for name in country_timezones[el]]) + ";\n"
+                              for el in country_timezones]) + '''
 function selectTimezone($country){
      if($country == " "){
          $("#tz").replaceWith($allTimezones);
@@ -254,54 +269,58 @@ function selectTimezone($country){
      }
 }''')
 
+
 class AddTelNumberForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     class fields(ew_core.NameList):
         newnumber = ew.TextField(
             label='New telephone number',
-            attrs={'value':''},
+            attrs={'value': ''},
             validator=fev.UnicodeString(not_empty=True))
 
     def display(self, **kw):
-        initial_value = kw.get('initial_value','')
+        initial_value = kw.get('initial_value', '')
         self.fields['newnumber'].attrs['value'] = initial_value
         return super(ForgeForm, self).display(**kw)
 
+
 class AddWebsiteForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     class fields(ew_core.NameList):
         newwebsite = ew.TextField(
             label='New website url',
-            attrs={'value':''},
+            attrs={'value': ''},
             validator=fev.URL())
 
     def display(self, **kw):
-        initial_value = kw.get('initial_value','')
+        initial_value = kw.get('initial_value', '')
         self.fields['newwebsite'].attrs['value'] = initial_value
         return super(ForgeForm, self).display(**kw)
 
+
 class SkypeAccountForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     class fields(ew_core.NameList):
         skypeaccount = ew.TextField(
             label='Skype account',
-            attrs={'value':''},
+            attrs={'value': ''},
             validator=fev.UnicodeString(not_empty=False))
 
     def display(self, **kw):
-        initial_value = kw.get('initial_value','')
+        initial_value = kw.get('initial_value', '')
         self.fields['skypeaccount'].attrs['value'] = initial_value
         return super(ForgeForm, self).display(**kw)
 
+
 class RemoveTextValueForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
-        initial_value = kw.get('value','')
-        label = kw.get('label','')
+        initial_value = kw.get('value', '')
+        label = kw.get('label', '')
         description = kw.get('description')
 
         self.fields = [
@@ -312,11 +331,11 @@ class RemoveTextValueForm(ForgeForm):
                     ffw.DisplayOnlyField(
                         name='oldvalue',
                         label=initial_value,
-                        attrs={'value':initial_value},
+                        attrs={'value': initial_value},
                         show_errors=False),
                     ew.SubmitButton(
                         show_label=False,
-                        attrs={'value':'Remove'},
+                        attrs={'value': 'Remove'},
                         show_errors=False)])]
         if description:
             self.fields.append(
@@ -331,8 +350,9 @@ class RemoveTextValueForm(ForgeForm):
         d["oldvalue"] = kw.get('oldvalue', '')
         return d
 
+
 class AddSocialNetworkForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     @property
     def fields(self):
@@ -354,11 +374,11 @@ class AddSocialNetworkForm(ForgeForm):
 
 
 class RemoveSocialNetworkForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
-        account = kw.get('account','')
-        socialnetwork = kw.get('socialnetwork','')
+        account = kw.get('account', '')
+        socialnetwork = kw.get('socialnetwork', '')
 
         self.fields = [
             ew.RowField(
@@ -367,15 +387,15 @@ class RemoveSocialNetworkForm(ForgeForm):
                     ffw.DisplayOnlyField(
                         text='%s account' % socialnetwork,
                         name="socialnetwork",
-                        attrs={'value':socialnetwork},
+                        attrs={'value': socialnetwork},
                         show_errors=False),
                     ffw.DisplayOnlyField(
                         name="account",
-                        attrs={'value':account},
+                        attrs={'value': account},
                         show_errors=False),
                     ew.SubmitButton(
                         show_label=False,
-                        attrs={'value':'Remove'},
+                        attrs={'value': 'Remove'},
                         show_errors=False)])]
         return super(ForgeForm, self).display(**kw)
 
@@ -386,7 +406,9 @@ class RemoveSocialNetworkForm(ForgeForm):
         d["socialnetwork"] = kw.get('socialnetwork', '')
         return d
 
+
 class AddInactivePeriodForm(ForgeForm):
+
     class fields(ew_core.NameList):
         startdate = ew.TextField(
             label='Start date',
@@ -404,12 +426,13 @@ class AddInactivePeriodForm(ForgeForm):
         d = super(AddInactivePeriodForm, self).to_python(kw, state)
         if d['startdate'] > d['enddate']:
                 raise formencode.Invalid(
-                   'Invalid period: start date greater than end date.',
+                    'Invalid period: start date greater than end date.',
                     kw, state)
         return d
 
+
 class RemoveInactivePeriodForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
         startdate = kw.get('startdate')
@@ -422,25 +445,27 @@ class RemoveInactivePeriodForm(ForgeForm):
                 fields=[
                     ffw.DisplayOnlyField(
                         name='startdate',
-                        attrs={'value':startdate.strftime('%d/%m/%Y')},
+                        attrs={'value': startdate.strftime('%d/%m/%Y')},
                         show_errors=False),
                     ffw.DisplayOnlyField(
                         name='enddate',
-                        attrs={'value':enddate.strftime('%d/%m/%Y')},
+                        attrs={'value': enddate.strftime('%d/%m/%Y')},
                         show_errors=False),
                     ew.SubmitButton(
-                        attrs={'value':'Remove'},
+                        attrs={'value': 'Remove'},
                         show_errors=False)])]
         return super(ForgeForm, self).display(**kw)
 
     @ew_core.core.validator
     def to_python(self, kw, state):
         d = super(RemoveInactivePeriodForm, self).to_python(kw, state)
-        d['startdate'] = V.convertDate(kw.get('startdate',''))
-        d['enddate'] = V.convertDate(kw.get('enddate',''))
+        d['startdate'] = V.convertDate(kw.get('startdate', ''))
+        d['enddate'] = V.convertDate(kw.get('enddate', ''))
         return d
 
+
 class AddTimeSlotForm(ForgeForm):
+
     class fields(ew_core.NameList):
         weekday = ew.SingleSelectField(
             label='Weekday',
@@ -466,15 +491,16 @@ class AddTimeSlotForm(ForgeForm):
         if (d['starttime']['h'], d['starttime']['m']) > \
            (d['endtime']['h'], d['endtime']['m']):
                 raise formencode.Invalid(
-                   'Invalid period: start time greater than end time.',
+                    'Invalid period: start time greater than end time.',
                     kw, state)
         return d
 
+
 class RemoveTimeSlotForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
-        weekday = kw.get('weekday','')
+        weekday = kw.get('weekday', '')
         starttime = kw.get('starttime')
         endtime = kw.get('endtime')
 
@@ -485,32 +511,32 @@ class RemoveTimeSlotForm(ForgeForm):
                 fields=[
                     ffw.DisplayOnlyField(
                         name='weekday',
-                        attrs={'value':weekday},
+                        attrs={'value': weekday},
                         show_errors=False),
                     ffw.DisplayOnlyField(
                         name='starttime',
-                        attrs={'value':starttime.strftime('%H:%M')},
+                        attrs={'value': starttime.strftime('%H:%M')},
                         show_errors=False),
                     ffw.DisplayOnlyField(
                         name='endtime',
-                        attrs={'value':endtime.strftime('%H:%M')},
+                        attrs={'value': endtime.strftime('%H:%M')},
                         show_errors=False),
                     ew.SubmitButton(
                         show_errors=False,
-                        attrs={'value':'Remove'})])]
+                        attrs={'value': 'Remove'})])]
         return super(ForgeForm, self).display(**kw)
 
     @ew_core.core.validator
     def to_python(self, kw, state):
         d = super(RemoveTimeSlotForm, self).to_python(kw, state)
         d["weekday"] = kw.get('weekday', None)
-        d['starttime'] = V.convertTime(kw.get('starttime',''))
-        d['endtime'] = V.convertTime(kw.get('endtime',''))
+        d['starttime'] = V.convertTime(kw.get('starttime', ''))
+        d['endtime'] = V.convertTime(kw.get('endtime', ''))
         return d
 
 
 class RemoveTroveCategoryForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
         cat = kw.get('category')
@@ -525,11 +551,11 @@ class RemoveTroveCategoryForm(ForgeForm):
                         href="/categories/%s" % cat.shortname),
                     ew.SubmitButton(
                         show_errors=False,
-                        attrs={'value':'Remove'})],
+                        attrs={'value': 'Remove'})],
                 hidden_fields=[
                     ew.HiddenField(
                         name='categoryid',
-                        attrs={'value':cat.trove_cat_id})])]
+                        attrs={'value': cat.trove_cat_id})])]
         return super(ForgeForm, self).display(**kw)
 
     @ew_core.core.validator
@@ -540,19 +566,20 @@ class RemoveTroveCategoryForm(ForgeForm):
             d["categoryid"] = int(d['categoryid'])
         return d
 
+
 class AddTroveCategoryForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     class fields(ew_core.NameList):
         uppercategory_id = ew.HiddenField(
-            attrs={'value':''},
+            attrs={'value': ''},
             show_errors=False)
         categoryname = ew.TextField(
             label="Category name",
             validator=fev.UnicodeString(not_empty=True))
 
     def display(self, **kw):
-        upper_category = kw.get('uppercategory_id',0)
+        upper_category = kw.get('uppercategory_id', 0)
 
         self.fields['uppercategory_id'].attrs['value'] = upper_category
         return super(ForgeForm, self).display(**kw)
@@ -563,39 +590,41 @@ class AddTroveCategoryForm(ForgeForm):
         d["uppercategory_id"] = kw.get('uppercategory_id', 0)
         return d
 
+
 class AddUserSkillForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults)
+    defaults = dict(ForgeForm.defaults)
 
     class fields(ew_core.NameList):
-        selected_skill=ew.HiddenField(
-            attrs={'value':''},
+        selected_skill = ew.HiddenField(
+            attrs={'value': ''},
             show_errors=False,
             validator=fev.UnicodeString(not_empty=True))
-        level=ew.SingleSelectField(
+        level = ew.SingleSelectField(
             label="Level of knowledge",
             options=[
-                ew.Option(py_value="low",label="Low level"),
-                ew.Option(py_value="medium",label="Medium level"),
-                ew.Option(py_value="high",label="Advanced level")],
+                ew.Option(py_value="low", label="Low level"),
+                ew.Option(py_value="medium", label="Medium level"),
+                ew.Option(py_value="high", label="Advanced level")],
             validator=formencode.All(
-                V.OneOfValidator(['low','medium','high']),
+                V.OneOfValidator(['low', 'medium', 'high']),
                 fev.UnicodeString(not_empty=True)))
-        comment=ew.TextArea(
+        comment = ew.TextArea(
             label="Additional comments",
             validator=fev.UnicodeString(not_empty=False),
-            attrs={'rows':5,'cols':30})
+            attrs={'rows': 5, 'cols': 30})
 
     def display(self, **kw):
         category = kw.get('selected_skill')
 
-        self.fields["selected_skill"].attrs['value']=category
+        self.fields["selected_skill"].attrs['value'] = category
         return super(ForgeForm, self).display(**kw)
 
+
 class SelectSubCategoryForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text="Continue")
+    defaults = dict(ForgeForm.defaults, submit_text="Continue")
 
     class fields(ew_core.NameList):
-        selected_category=ew.SingleSelectField(
+        selected_category = ew.SingleSelectField(
             name="selected_category",
             label="Available categories",
             options=[])
@@ -603,17 +632,18 @@ class SelectSubCategoryForm(ForgeForm):
     def display(self, **kw):
         categories = kw.get('categories')
 
-        self.fields['selected_category'].options= \
-            [ew.Option(py_value=el.trove_cat_id,label=el.fullname)
+        self.fields['selected_category'].options = \
+            [ew.Option(py_value=el.trove_cat_id, label=el.fullname)
              for el in categories]
-        self.fields['selected_category'].validator= \
-            validator=formencode.All(
+        self.fields['selected_category'].validator = \
+            validator = formencode.All(
                 V.OneOfValidator(categories),
                 fev.UnicodeString(not_empty=True))
         return super(ForgeForm, self).display(**kw)
 
+
 class RemoveSkillForm(ForgeForm):
-    defaults=dict(ForgeForm.defaults, submit_text=None, show_errors=False)
+    defaults = dict(ForgeForm.defaults, submit_text=None, show_errors=False)
 
     def display(self, **kw):
         skill = kw.get('skill')
@@ -627,7 +657,7 @@ class RemoveSkillForm(ForgeForm):
                 hidden_fields=[
                     ew.HiddenField(
                         name="categoryid",
-                        attrs={'value':skill['skill'].trove_cat_id},
+                        attrs={'value': skill['skill'].trove_cat_id},
                         show_errors=False)
                 ],
                 fields=[
@@ -636,7 +666,7 @@ class RemoveSkillForm(ForgeForm):
                     ffw.DisplayOnlyField(text=comment),
                     ew.SubmitButton(
                         show_label=False,
-                        attrs={'value':'Remove'},
+                        attrs={'value': 'Remove'},
                         show_errors=False)])]
         return super(ForgeForm, self).display(**kw)
 
@@ -646,11 +676,15 @@ class RemoveSkillForm(ForgeForm):
         d["categoryid"] = kw.get('categoryid', None)
         return d
 
+
 class UploadKeyForm(ForgeForm):
+
     class fields(ew_core.NameList):
         key = ew.TextArea(label='SSH Public Key')
 
+
 class RegistrationForm(ForgeForm):
+
     class fields(ew_core.NameList):
         display_name = ew.TextField(
             label='Displayed Name',
@@ -675,15 +709,18 @@ class RegistrationForm(ForgeForm):
         d = super(RegistrationForm, self).to_python(value, state)
         value['username'] = username = value['username'].lower()
         if M.User.by_username(username):
-            raise formencode.Invalid('That username is already taken. Please choose another.',
-                                    value, state)
+            raise formencode.Invalid(
+                'That username is already taken. Please choose another.',
+                value, state)
         if d['pw'] != d['pw2']:
             raise formencode.Invalid('Passwords must match', value, state)
         return d
 
+
 class AdminForm(ForgeForm):
     template = 'jinja:allura:templates/widgets/admin_form.html'
 
+
 class NeighborhoodOverviewForm(ForgeForm):
     template = 'jinja:allura:templates/widgets/neighborhood_overview_form.html'
 
@@ -695,7 +732,7 @@ class NeighborhoodOverviewForm(ForgeForm):
         show_title = ew.Checkbox(label='')
         css = ffw.AutoResizeTextarea()
         project_template = ffw.AutoResizeTextarea(
-                validator=V.JsonValidator(if_empty=''))
+            validator=V.JsonValidator(if_empty=''))
         icon = ew.FileField()
         tracking_id = ew.TextField()
         project_list_url = ew.TextField(validator=fev.URL())
@@ -724,17 +761,18 @@ class NeighborhoodOverviewForm(ForgeForm):
                            '<td class="right"><div class="%(ctx_name)s-%(inp_name)s-inp"><table class="input_inner">'\
                            '<tr><td><input type="text" class="%(inp_type)s" name="%(ctx_name)s-%(inp_name)s" '\
                            'value="%(inp_value)s"></td><td>%(inp_additional)s</td></tr></table></div></td></tr>\n' % {'ctx_id': ctx['id'],
-                                                            'ctx_name': ctx['name'],
-                                                            'inp_name': inp['name'],
-                                                            'inp_value': inp['value'],
-                                                            'label': inp['label'],
-                                                            'inp_type': inp['type'],
-                                                            'def_checked': 'checked="checked"' if empty_val else '',
-                                                            'inp_additional': additional_inputs}
+                                                                                                                      'ctx_name': ctx['name'],
+                                                                                                                      'inp_name': inp['name'],
+                                                                                                                      'inp_value': inp['value'],
+                                                                                                                      'label': inp['label'],
+                                                                                                                      'inp_type': inp['type'],
+                                                                                                                      'def_checked': 'checked="checked"' if empty_val else '',
+                                                                                                                      'inp_additional': additional_inputs}
             display += '</table>'
 
             if ctx['errors'] and field.show_errors and not ignore_errors:
-                display = "%s<div class='error'>%s</div>" % (display, ctx['errors'])
+                display = "%s<div class='error'>%s</div>" % (display,
+                                                             ctx['errors'])
 
             return h.html.literal(display)
         else:
@@ -754,7 +792,8 @@ class NeighborhoodOverviewForm(ForgeForm):
         return d
 
     def resources(self):
-        for r in super(NeighborhoodOverviewForm, self).resources(): yield r
+        for r in super(NeighborhoodOverviewForm, self).resources():
+            yield r
         yield ew.CSSLink('css/colorPicker.css')
         yield ew.CSSLink('css/jqfontselector.css')
         yield ew.CSSScript('''
@@ -800,6 +839,7 @@ table.table_class select.add_opt {width: 5em; margin:0; padding: 0;}
             });
         ''')
 
+
 class NeighborhoodAddProjectForm(ForgeForm):
     template = 'jinja:allura:templates/widgets/neighborhood_add_project.html'
     antispam = True
@@ -812,16 +852,17 @@ class NeighborhoodAddProjectForm(ForgeForm):
     class fields(ew_core.NameList):
         project_description = ew.HiddenField(label='Public Description')
         neighborhood = ew.HiddenField(label='Neighborhood')
-        private_project = ew.Checkbox(label="", attrs={'class':'unlabeled'})
+        private_project = ew.Checkbox(label="", attrs={'class': 'unlabeled'})
         project_name = ew.InputField(label='Project Name', field_type='text',
-            validator=formencode.All(
-                fev.UnicodeString(not_empty=True, max=40),
-                V.MaxBytesValidator(max=40)))
+                                     validator=formencode.All(
+                                         fev.UnicodeString(
+                                             not_empty=True, max=40),
+                                         V.MaxBytesValidator(max=40)))
         project_unixname = ew.InputField(
             label='Short Name', field_type='text',
             validator=None)  # will be set in __init__
         tools = ew.CheckboxSet(name='tools', options=[
-            ## Required for Neighborhood functional tests to pass
+            # Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
 
@@ -830,16 +871,17 @@ class NeighborhoodAddProjectForm(ForgeForm):
         # get the shortname validator from the provider
         provider = plugin.ProjectRegistrationProvider.get()
         self.fields.project_unixname.validator = provider.shortname_validator
-        ## Dynamically generating CheckboxSet of installable tools
+        # Dynamically generating CheckboxSet of installable tools
         from allura.lib.widgets import forms
         self.fields.tools.options = [
-                forms.ew.Option(label=tool.tool_label, html_value=ep)
-                    for ep,tool in g.entry_points["tool"].iteritems()
-                    if tool.installable and tool.status == 'production'
-            ]
+            forms.ew.Option(label=tool.tool_label, html_value=ep)
+            for ep, tool in g.entry_points["tool"].iteritems()
+            if tool.installable and tool.status == 'production'
+        ]
 
     def resources(self):
-        for r in super(NeighborhoodAddProjectForm, self).resources(): yield r
+        for r in super(NeighborhoodAddProjectForm, self).resources():
+            yield r
         yield ew.CSSLink('css/add_project.css')
         neighborhood = g.antispam.enc('neighborhood')
         project_name = g.antispam.enc('project_name')
@@ -949,7 +991,7 @@ class MoveTicketForm(ForgeForm):
     class fields(ew_core.NameList):
         tracker = ew.SingleSelectField(
             label='Tracker mount point',
-            options = [])
+            options=[])
 
     def __init__(self, *args, **kwargs):
         trackers = kwargs.pop('trackers', [])
@@ -960,9 +1002,11 @@ class MoveTicketForm(ForgeForm):
 
 
 class CsrfForm(ew.SimpleForm):
+
     @property
     def hidden_fields(self):
         return [ew.HiddenField(name='_session_id')]
+
     def context_for(self, field):
         ctx = super(CsrfForm, self).context_for(field)
         if field.name == '_session_id':

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/macros.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/macros.py b/Allura/allura/lib/widgets/macros.py
index 5f93d2a..18268cb 100644
--- a/Allura/allura/lib/widgets/macros.py
+++ b/Allura/allura/lib/widgets/macros.py
@@ -17,48 +17,53 @@
 
 import ew
 
+
 class Include(ew.Widget):
-    template='jinja:allura:templates/widgets/include.html'
-    params=['artifact', 'attrs']
-    artifact=None
+    template = 'jinja:allura:templates/widgets/include.html'
+    params = ['artifact', 'attrs']
+    artifact = None
     attrs = {
-        'style':'width:270px;float:right;background-color:#ccc'
-        }
+        'style': 'width:270px;float:right;background-color:#ccc'
+    }
+
 
 class GittipButton(ew.Widget):
-    template='jinja:allura:templates/widgets/gittip_button.html'
-    params=['username']
-    project=None
+    template = 'jinja:allura:templates/widgets/gittip_button.html'
+    params = ['username']
+    project = None
 
 
 class DownloadButton(ew.Widget):
-    template='jinja:allura:templates/widgets/download_button.html'
-    params=['project']
-    project=None
+    template = 'jinja:allura:templates/widgets/download_button.html'
+    params = ['project']
+    project = None
 
     def resources(self):
         yield ew.jinja2_ew.JSScript('''
             $(function(){$(".download-button-%s").load("%s");
-        });''' % (self.project._id,self.project.best_download_url()))
+        });''' % (self.project._id, self.project.best_download_url()))
+
 
 class NeighborhoodFeeds(ew.Widget):
     template = 'jinja:allura:templates/macro/neighborhood_feeds.html'
-    params=['feeds']
+    params = ['feeds']
     feeds = None
 
+
 class BlogPosts(ew.Widget):
     template = 'jinja:allura:templates/macro/blog_posts.html'
     params = ['posts']
     posts = None
 
+
 class ProjectAdmins(ew.Widget):
     template = 'jinja:allura:templates/macro/project_admins.html'
     params = ['users']
     users = None
 
+
 class Members(ew.Widget):
     template = 'jinja:allura:templates/macro/members.html'
     params = ['users', 'over_limit']
     users = None
     over_limit = None
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/oauth_widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/oauth_widgets.py b/Allura/allura/lib/widgets/oauth_widgets.py
index 46b6520..6426beb 100644
--- a/Allura/allura/lib/widgets/oauth_widgets.py
+++ b/Allura/allura/lib/widgets/oauth_widgets.py
@@ -26,17 +26,21 @@ from allura import model as M
 from .form_fields import AutoResizeTextarea
 from .forms import ForgeForm
 
+
 class OAuthApplicationForm(ForgeForm):
-    submit_text='Register new application'
-    style='wide'
+    submit_text = 'Register new application'
+    style = 'wide'
+
     class fields(ew_core.NameList):
-        application_name =ew.TextField(label='Application Name',
-                                       validator=V.UniqueOAuthApplicationName())
-        application_description = AutoResizeTextarea(label='Application Description')
+        application_name = ew.TextField(label='Application Name',
+                                        validator=V.UniqueOAuthApplicationName())
+        application_description = AutoResizeTextarea(
+            label='Application Description')
+
 
 class OAuthRevocationForm(ForgeForm):
-    submit_text='Revoke Access'
+    submit_text = 'Revoke Access'
     fields = []
-    class fields(ew_core.NameList):
-        _id=ew.HiddenField()
 
+    class fields(ew_core.NameList):
+        _id = ew.HiddenField()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/project_list.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/project_list.py b/Allura/allura/lib/widgets/project_list.py
index a5a327f..343c1ba 100644
--- a/Allura/allura/lib/widgets/project_list.py
+++ b/Allura/allura/lib/widgets/project_list.py
@@ -23,9 +23,10 @@ from pylons import tmpl_context as c, app_globals as g
 from allura import model as M
 from allura.lib.security import Credentials
 
+
 class ProjectSummary(ew_core.Widget):
-    template='jinja:allura:templates/widgets/project_summary.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/project_summary.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         sitemap=None,
         icon=None,
@@ -42,7 +43,7 @@ class ProjectSummary(ew_core.Widget):
         response = super(ProjectSummary, self).prepare_context(context)
         value = response['value']
         if response['sitemap'] is None:
-            response['sitemap'] = [ s for s in value.sitemap() if s.url ]
+            response['sitemap'] = [s for s in value.sitemap() if s.url]
 
         if response['grid_view_tools'] != '':
             view_tools_list = response['grid_view_tools'].split(',')
@@ -55,7 +56,7 @@ class ProjectSummary(ew_core.Widget):
 
         if response['icon_url'] is None:
             if value.icon:
-                response['icon_url'] = value.url()+'icon'
+                response['icon_url'] = value.url() + 'icon'
         if response['accolades'] is None:
             response['accolades'] = value.accolades
 
@@ -102,9 +103,10 @@ class ProjectSummary(ew_core.Widget):
         });
         ''')
 
+
 class ProjectList(ew_core.Widget):
-    template='jinja:allura:templates/widgets/project_list_widget.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/project_list_widget.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         projects=[],
         project_summary=ProjectSummary(),
@@ -157,9 +159,10 @@ class ProjectList(ew_core.Widget):
         for r in self.project_summary.resources():
             yield r
 
+
 class ProjectScreenshots(ew_core.Widget):
-    template='jinja:allura:templates/widgets/project_screenshots.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/project_screenshots.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         project=None,
         edit=False)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/repo.py b/Allura/allura/lib/widgets/repo.py
index 31c32c1..cda4ebf 100644
--- a/Allura/allura/lib/widgets/repo.py
+++ b/Allura/allura/lib/widgets/repo.py
@@ -24,9 +24,10 @@ from allura import model as M
 from allura.lib.widgets import forms as ff
 from allura.lib.widgets import form_fields as ffw
 
+
 class SCMLogWidget(ew_core.Widget):
-    template='jinja:allura:templates/widgets/repo/log.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/repo/log.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         value=None,
         limit=None,
@@ -35,32 +36,35 @@ class SCMLogWidget(ew_core.Widget):
         show_paging=True)
 
     class fields(ew_core.NameList):
-        page_list=ffw.PageList()
-        page_size=ffw.PageSize()
+        page_list = ffw.PageList()
+        page_size = ffw.PageSize()
 
     def resources(self):
         for f in self.fields:
             for r in f.resources():
                 yield r
 
+
 class SCMRevisionWidget(ew_core.Widget):
-    template='jinja:allura:templates/widgets/repo/revision.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/repo/revision.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         value=None,
         prev=ew_core.NoDefault,
         next=ew_core.NoDefault)
 
+
 class SCMTreeWidget(ew_core.Widget):
-    template='jinja:allura:templates/widgets/repo/tree_widget.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/repo/tree_widget.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         tree=None,
         list=list)
 
+
 class SCMMergeRequestWidget(ff.ForgeForm):
-    source_branches=[]
-    target_branches=[]
+    source_branches = []
+    target_branches = []
 
     @property
     def fields(self):
@@ -74,28 +78,31 @@ class SCMMergeRequestWidget(ff.ForgeForm):
                 name='target_branch',
                 label='Target Branch',
                 options=self.target_branches),
-            ffw.AutoResizeTextarea(name='description') ]
+            ffw.AutoResizeTextarea(name='description')]
         return result
 
+
 class SCMMergeRequestFilterWidget(ff.ForgeForm):
-    defaults=dict(
+    defaults = dict(
         ff.ForgeForm.defaults,
         submit_text='Filter',
         method='GET')
 
     class fields(ew_core.NameList):
-        status=ew.MultiSelectField(options=M.MergeRequest.statuses)
+        status = ew.MultiSelectField(options=M.MergeRequest.statuses)
+
 
 class SCMMergeRequestDisposeWidget(ff.ForgeForm):
 
     class fields(ew_core.NameList):
-        status=ew.SingleSelectField(
+        status = ew.SingleSelectField(
             label='Change Status',
             options=M.MergeRequest.statuses)
 
+
 class SCMCommitBrowserWidget(ew_core.Widget):
-    template='jinja:allura:templates/widgets/repo/commit_browser.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/repo/commit_browser.html'
+    defaults = dict(
         ew_core.Widget.defaults,
     )
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index e553842..32014c4 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -21,9 +21,10 @@ import jinja2
 
 from allura.lib.widgets import form_fields as ffw
 
+
 class SearchResults(ew_core.Widget):
-    template='jinja:allura:templates/widgets/search_results.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/search_results.html'
+    defaults = dict(
         ew_core.Widget.defaults,
         results=None,
         limit=None,
@@ -32,8 +33,8 @@ class SearchResults(ew_core.Widget):
         search_error=None)
 
     class fields(ew_core.NameList):
-        page_list=ffw.PageList()
-        page_size=ffw.PageSize()
+        page_list = ffw.PageList()
+        page_size = ffw.PageSize()
 
     def resources(self):
         for f in self.fields:
@@ -43,7 +44,7 @@ class SearchResults(ew_core.Widget):
 
 
 class SearchHelp(ffw.Lightbox):
-    defaults=dict(
+    defaults = dict(
         ffw.Lightbox.defaults,
         name='search_help_modal',
         trigger='a.search_help_modal')
@@ -51,7 +52,8 @@ class SearchHelp(ffw.Lightbox):
     def __init__(self, comments=True, history=True):
         super(SearchHelp, self).__init__()
         # can't use g.jinja2_env since this widget gets imported too early :(
-        jinja2_env = jinja2.Environment(loader=jinja2.PackageLoader('allura', 'templates/widgets'))
+        jinja2_env = jinja2.Environment(
+            loader=jinja2.PackageLoader('allura', 'templates/widgets'))
         self.content = jinja2_env.get_template('search_help.html').render(dict(
             comments=comments,
             history=history,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/subscriptions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/subscriptions.py b/Allura/allura/lib/widgets/subscriptions.py
index 3f68d58..687178a 100644
--- a/Allura/allura/lib/widgets/subscriptions.py
+++ b/Allura/allura/lib/widgets/subscriptions.py
@@ -28,41 +28,53 @@ from allura import model as M
 from .form_fields import SubmitButton
 
 # Discussion forms
+
+
 class _SubscriptionTable(ew.TableField):
+
     class hidden_fields(ew_core.NameList):
         subscription_id = ew.HiddenField(validator=V.Ming(M.Mailbox))
         tool_id = ew.HiddenField()
         project_id = ew.HiddenField()
         topic = ew.HiddenField()
         artifact_index_id = ew.HiddenField()
+
     class fields(ew_core.NameList):
-        project_name = ffw.DisplayOnlyField(label='Project', show_label=True, with_hidden_input=False)
-        mount_point = ffw.DisplayOnlyField(label='App', show_label=True, with_hidden_input=False)
-        topic = ffw.DisplayOnlyField(label='Topic', show_label=True, with_hidden_input=False)
-        type = ffw.DisplayOnlyField(label='Type', show_label=True, with_hidden_input=False)
-        frequency = ffw.DisplayOnlyField(label='Frequency', show_label=True, with_hidden_input=False)
-        artifact_title = ew.LinkField(label='Artifact', show_label=True, plaintext_if_no_href=True)
+        project_name = ffw.DisplayOnlyField(
+            label='Project', show_label=True, with_hidden_input=False)
+        mount_point = ffw.DisplayOnlyField(
+            label='App', show_label=True, with_hidden_input=False)
+        topic = ffw.DisplayOnlyField(
+            label='Topic', show_label=True, with_hidden_input=False)
+        type = ffw.DisplayOnlyField(
+            label='Type', show_label=True, with_hidden_input=False)
+        frequency = ffw.DisplayOnlyField(
+            label='Frequency', show_label=True, with_hidden_input=False)
+        artifact_title = ew.LinkField(
+            label='Artifact', show_label=True, plaintext_if_no_href=True)
         # unsubscribe = SubmitButton()
         subscribed = ew.Checkbox(suppress_label=True)
 
+
 class SubscriptionForm(CsrfForm):
-    defaults=dict(
+    defaults = dict(
         ew.SimpleForm.defaults,
         submit_text='Save')
+
     class fields(ew_core.NameList):
-        subscriptions=_SubscriptionTable()
+        subscriptions = _SubscriptionTable()
         email_format = ew.SingleSelectField(
-                    name='email_format',
-                    label='Email Format',
-                    options=[
-                        ew.Option(py_value='plain', label='Plain Text'),
-                        ew.Option(py_value='html', label='HTML'),
-                        ew.Option(py_value='both', label='Combined')])
+            name='email_format',
+            label='Email Format',
+            options=[
+                ew.Option(py_value='plain', label='Plain Text'),
+                ew.Option(py_value='html', label='HTML'),
+                ew.Option(py_value='both', label='Combined')])
 
 
 class SubscribeForm(ew.SimpleForm):
-    template='jinja:allura:templates/widgets/subscribe.html'
-    defaults=dict(
+    template = 'jinja:allura:templates/widgets/subscribe.html'
+    defaults = dict(
         ew.SimpleForm.defaults,
         thing='tool',
         style='text',
@@ -70,9 +82,9 @@ class SubscribeForm(ew.SimpleForm):
         value=None)
 
     class fields(ew_core.NameList):
-        subscribe=SubmitButton()
-        unsubscribe=SubmitButton()
-        shortname=ew.HiddenField()
+        subscribe = SubmitButton()
+        unsubscribe = SubmitButton()
+        shortname = ew.HiddenField()
 
     def from_python(self, value, state):
         return value

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/widgets/user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/user_profile.py b/Allura/allura/lib/widgets/user_profile.py
index eb19e27..c2e32e3 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -17,7 +17,7 @@
 
 import ew as ew_core
 import ew.jinja2_ew as ew
-from formencode import  validators as fev
+from formencode import validators as fev
 from .forms import ForgeForm
 
 
@@ -25,7 +25,6 @@ class SendMessageForm(ForgeForm):
     template = 'jinja:allura.ext.user_profile:templates/send_message_form.html'
     submit_text = 'Send Message'
 
-
     class fields(ew_core.NameList):
         subject = ew.TextField(
             validator=fev.UnicodeString(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/lib/zarkov_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/zarkov_helpers.py b/Allura/allura/lib/zarkov_helpers.py
index 8cda182..15d0b96 100644
--- a/Allura/allura/lib/zarkov_helpers.py
+++ b/Allura/allura/lib/zarkov_helpers.py
@@ -24,6 +24,7 @@ except ImportError:
     zmq = None
 import bson
 
+
 class ZarkovClient(object):
 
     def __init__(self, addr):
@@ -36,6 +37,7 @@ class ZarkovClient(object):
             type=type, context=context, extra=extra)
         self._sock.send(bson.BSON.encode(obj))
 
+
 def zero_fill_zarkov_result(zarkov_data, period, start_date, end_date):
     """Return a new copy of zarkov_data (a dict returned from a zarkov
     query) with the timeseries data zero-filled for missing dates.
@@ -60,9 +62,10 @@ def zero_fill_zarkov_result(zarkov_data, period, start_date, end_date):
     for query in zarkov_data.iterkeys():
         for series in zarkov_data[query].iterkeys():
             d[query][series] = zero_fill_time_series(d[query][series],
-                                    period, start_date, end_date)
+                                                     period, start_date, end_date)
     return d
 
+
 def zero_fill_time_series(time_series, period, start_date, end_date):
     """Return a copy of time_series after adding [timestamp, 0] pairs for
     each missing timestamp in the given date range.
@@ -91,10 +94,10 @@ def zero_fill_time_series(time_series, period, start_date, end_date):
                 new_series[ts] = 0
             # next month
             if date.month == 12:
-                date = date.replace(year=date.year+1, month=1)
+                date = date.replace(year=date.year + 1, month=1)
             else:
-                date = date.replace(month=date.month+1)
-    else: # daily
+                date = date.replace(month=date.month + 1)
+    else:  # daily
         days = (end_date - start_date).days + 1
         periods = range(0, days)
         for dayoffset in periods:
@@ -104,6 +107,7 @@ def zero_fill_time_series(time_series, period, start_date, end_date):
                 new_series[ts] = 0
     return sorted([[k, v] for k, v in new_series.items()])
 
+
 def to_utc_timestamp(d):
     """Return UTC unix timestamp representation of d (datetime)."""
     # http://stackoverflow.com/questions/1077285/how-to-specify-time-zone-utc-when-converting-to-unix-time-python

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 40ccb5e..faeb1cb 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -47,6 +47,7 @@ log = logging.getLogger(__name__)
 
 
 class Artifact(MappedClass):
+
     """
     Base class for anything you want to keep track of.
 
@@ -60,10 +61,11 @@ class Artifact(MappedClass):
     """
     class __mongometa__:
         session = artifact_orm_session
-        name='artifact'
+        name = 'artifact'
         indexes = [
             ('app_config_id', 'labels'),
         ]
+
         def before_save(data):
             if not getattr(artifact_orm_session._get(), 'skip_mod_date', False):
                 data['mod_date'] = datetime.utcnow()
@@ -76,7 +78,8 @@ class Artifact(MappedClass):
     # Artifact base schema
     _id = FieldProperty(S.ObjectId)
     mod_date = FieldProperty(datetime, if_missing=datetime.utcnow)
-    app_config_id = ForeignIdProperty('AppConfig', if_missing=lambda:c.app.config._id)
+    app_config_id = ForeignIdProperty(
+        'AppConfig', if_missing=lambda: c.app.config._id)
     plugin_verson = FieldProperty(S.Deprecated)
     tool_version = FieldProperty(S.Deprecated)
     acl = FieldProperty(ACL)
@@ -90,7 +93,7 @@ class Artifact(MappedClass):
     # the source, original ID, and any other info needed to identify where
     # the artifact came from.  But if you only have one source, a str might do.
     import_id = FieldProperty(None, if_missing=None)
-    deleted=FieldProperty(bool, if_missing=False)
+    deleted = FieldProperty(bool, if_missing=False)
 
     def __json__(self):
         """Return a JSON-encodable :class:`dict` representation of this
@@ -103,7 +106,8 @@ class Artifact(MappedClass):
             labels=list(self.labels),
             related_artifacts=[a.url() for a in self.related_artifacts()],
             discussion_thread=self.discussion_thread.__json__(),
-            discussion_thread_url=h.absurl('/rest%s' % self.discussion_thread.url()),
+            discussion_thread_url=h.absurl('/rest%s' %
+                                           self.discussion_thread.url()),
         )
 
     def parent_security_context(self):
@@ -158,18 +162,20 @@ class Artifact(MappedClass):
 
         """
         q = ArtifactReference.query.find(dict(references=self.index_id()))
-        return [ aref._id for aref in q ]
+        return [aref._id for aref in q]
 
     def related_artifacts(self):
         """Return all Artifacts that are related to this one.
 
         """
         related_artifacts = []
-        for ref_id in self.refs+self.backrefs:
+        for ref_id in self.refs + self.backrefs:
             ref = ArtifactReference.query.get(_id=ref_id)
-            if ref is None: continue
+            if ref is None:
+                continue
             artifact = ref.artifact
-            if artifact is None: continue
+            if artifact is None:
+                continue
             artifact = artifact.primary()
             # don't link to artifacts in deleted tools
             if hasattr(artifact, 'app_config') and artifact.app_config is None:
@@ -178,7 +184,7 @@ class Artifact(MappedClass):
             # artifact type strings in platform code.
             if artifact.type_s == 'Commit' and not artifact.repo:
                 ac = AppConfig.query.get(
-                        _id=ref.artifact_reference['app_config_id'])
+                    _id=ref.artifact_reference['app_config_id'])
                 app = ac.project.app_instance(ac) if ac else None
                 if app:
                     artifact.set_context(app.repo)
@@ -196,7 +202,8 @@ class Artifact(MappedClass):
 
         """
         from allura.model import Mailbox
-        if user is None: user = c.user
+        if user is None:
+            user = c.user
         Mailbox.subscribe(
             user_id=user._id,
             project_id=self.app_config.project_id,
@@ -214,7 +221,8 @@ class Artifact(MappedClass):
 
         """
         from allura.model import Mailbox
-        if user is None: user = c.user
+        if user is None:
+            user = c.user
         Mailbox.unsubscribe(
             user_id=user._id,
             project_id=self.app_config.project_id,
@@ -237,7 +245,7 @@ class Artifact(MappedClass):
         :param app_config: :class:`allura.model.project.AppConfig` instance
 
         """
-        return cls.query.find({'labels':label, 'app_config_id': app_config._id})
+        return cls.query.find({'labels': label, 'app_config_id': app_config._id})
 
     def email_link(self, subject='artifact'):
         """Return a 'mailto' URL for this Artifact, with optional subject.
@@ -337,7 +345,7 @@ class Artifact(MappedClass):
         Subclasses must implement this.
 
         """
-        raise NotImplementedError, 'url' # pragma no cover
+        raise NotImplementedError, 'url'  # pragma no cover
 
     def shorthand_id(self):
         """How to refer to this artifact within the app instance context.
@@ -347,7 +355,7 @@ class Artifact(MappedClass):
         this should have a strong correlation to the URL.
 
         """
-        return str(self._id) # pragma no cover
+        return str(self._id)  # pragma no cover
 
     def link_text(self):
         """Return the link text to use when a shortlink to this artifact
@@ -394,7 +402,8 @@ class Artifact(MappedClass):
             file_info = [file_info]
         for attach in file_info:
             if hasattr(attach, 'file'):
-                self.attach(attach.filename, attach.file, content_type=attach.type)
+                self.attach(attach.filename, attach.file,
+                            content_type=attach.type)
 
     def attach(self, filename, fp, **kw):
         """Attach a file to this Artifact.
@@ -430,22 +439,23 @@ class Artifact(MappedClass):
 
 
 class Snapshot(Artifact):
+
     """A snapshot of an :class:`Artifact <allura.model.artifact.Artifact>`, used in :class:`VersionedArtifact <allura.model.artifact.VersionedArtifact>`"""
     class __mongometa__:
         session = artifact_orm_session
-        name='artifact_snapshot'
-        unique_indexes = [ ('artifact_class', 'artifact_id', 'version') ]
-        indexes = [ ('artifact_id', 'version') ]
+        name = 'artifact_snapshot'
+        unique_indexes = [('artifact_class', 'artifact_id', 'version')]
+        indexes = [('artifact_id', 'version')]
 
     _id = FieldProperty(S.ObjectId)
     artifact_id = FieldProperty(S.ObjectId)
     artifact_class = FieldProperty(str)
     version = FieldProperty(S.Int, if_missing=0)
     author = FieldProperty(dict(
-            id=S.ObjectId,
-            username=str,
-            display_name=str,
-            logged_ip=str))
+        id=S.ObjectId,
+        username=str,
+        display_name=str,
+        logged_ip=str))
     timestamp = FieldProperty(datetime)
     data = FieldProperty(None)
 
@@ -456,7 +466,7 @@ class Snapshot(Artifact):
             original_index = original.index()
             result.update(original_index)
             result['title'] = '%s (version %d)' % (
-                    h.get_first(original_index, 'title'), self.version)
+                h.get_first(original_index, 'title'), self.version)
         result.update(
             id=self.index_id(),
             version_i=self.version,
@@ -467,7 +477,7 @@ class Snapshot(Artifact):
         return result
 
     def original(self):
-        raise NotImplemented, 'original' # pragma no cover
+        raise NotImplemented, 'original'  # pragma no cover
 
     def shorthand_id(self):
         return '%s#%s' % (self.original().shorthand_id(), self.version)
@@ -482,14 +492,16 @@ class Snapshot(Artifact):
     def __getattr__(self, name):
         return getattr(self.data, name)
 
+
 class VersionedArtifact(Artifact):
+
     """
     An :class:`Artifact <allura.model.artifact.Artifact>` that has versions.
     Associated data like attachments and discussion thread are not versioned.
     """
     class __mongometa__:
         session = artifact_orm_session
-        name='versioned_artifact'
+        name = 'versioned_artifact'
         history_class = Snapshot
 
     version = FieldProperty(S.Int, if_missing=0)
@@ -498,7 +510,8 @@ class VersionedArtifact(Artifact):
         '''Save off a snapshot of the artifact and increment the version #'''
         self.version += 1
         try:
-            ip_address = request.headers.get('X_FORWARDED_FOR', request.remote_addr)
+            ip_address = request.headers.get(
+                'X_FORWARDED_FOR', request.remote_addr)
             ip_address = ip_address.split(',')[0].strip()
         except:
             ip_address = '0.0.0.0'
@@ -523,7 +536,7 @@ class VersionedArtifact(Artifact):
             if self.version > 1:
                 g.statsUpdater.modifiedArtifact(
                     self.type_s, self.mod_date, self.project, c.user)
-            else :
+            else:
                 g.statsUpdater.newArtifact(
                     self.type_s, self.mod_date, self.project, c.user)
         return ss
@@ -544,13 +557,14 @@ class VersionedArtifact(Artifact):
     def revert(self, version):
         ss = self.get_version(version)
         old_version = self.version
-        for k,v in ss.data.iteritems():
+        for k, v in ss.data.iteritems():
             setattr(self, k, v)
         self.version = old_version
 
     def history(self):
         HC = self.__mongometa__.history_class
-        q = HC.query.find(dict(artifact_id=self._id)).sort('version', pymongo.DESCENDING)
+        q = HC.query.find(dict(artifact_id=self._id)).sort(
+            'version', pymongo.DESCENDING)
         return q
 
     @property
@@ -569,6 +583,7 @@ class VersionedArtifact(Artifact):
 
 
 class Message(Artifact):
+
     """
     A message
 
@@ -579,17 +594,17 @@ class Message(Artifact):
 
     class __mongometa__:
         session = artifact_orm_session
-        name='message'
-    type_s='Generic Message'
-
-    _id=FieldProperty(str, if_missing=h.gen_message_id)
-    slug=FieldProperty(str, if_missing=h.nonce)
-    full_slug=FieldProperty(str, if_missing=None)
-    parent_id=FieldProperty(str)
-    app_id=FieldProperty(S.ObjectId, if_missing=lambda:c.app.config._id)
-    timestamp=FieldProperty(datetime, if_missing=datetime.utcnow)
-    author_id=FieldProperty(S.ObjectId, if_missing=lambda:c.user._id)
-    text=FieldProperty(str, if_missing='')
+        name = 'message'
+    type_s = 'Generic Message'
+
+    _id = FieldProperty(str, if_missing=h.gen_message_id)
+    slug = FieldProperty(str, if_missing=h.nonce)
+    full_slug = FieldProperty(str, if_missing=None)
+    parent_id = FieldProperty(str)
+    app_id = FieldProperty(S.ObjectId, if_missing=lambda: c.app.config._id)
+    timestamp = FieldProperty(datetime, if_missing=datetime.utcnow)
+    author_id = FieldProperty(S.ObjectId, if_missing=lambda: c.user._id)
+    text = FieldProperty(str, if_missing='')
 
     @classmethod
     def make_slugs(cls, parent=None, timestamp=None):
@@ -622,26 +637,32 @@ class Message(Artifact):
     def shorthand_id(self):
         return self.slug
 
+
 class AwardFile(File):
+
     class __mongometa__:
         session = main_orm_session
         name = 'award_file'
-    award_id=FieldProperty(S.ObjectId)
+    award_id = FieldProperty(S.ObjectId)
+
 
 class Award(Artifact):
+
     class __mongometa__:
         session = main_orm_session
-        name='award'
-        indexes = [ 'short' ]
+        name = 'award'
+        indexes = ['short']
     type_s = 'Generic Award'
 
     from .project import Neighborhood
-    _id=FieldProperty(S.ObjectId)
-    created_by_neighborhood_id = ForeignIdProperty(Neighborhood, if_missing=None)
-    created_by_neighborhood = RelationProperty(Neighborhood, via='created_by_neighborhood_id')
-    short=FieldProperty(str, if_missing=h.nonce)
-    timestamp=FieldProperty(datetime, if_missing=datetime.utcnow)
-    full=FieldProperty(str, if_missing='')
+    _id = FieldProperty(S.ObjectId)
+    created_by_neighborhood_id = ForeignIdProperty(
+        Neighborhood, if_missing=None)
+    created_by_neighborhood = RelationProperty(
+        Neighborhood, via='created_by_neighborhood_id')
+    short = FieldProperty(str, if_missing=h.nonce)
+    timestamp = FieldProperty(datetime, if_missing=datetime.utcnow)
+    full = FieldProperty(str, if_missing='')
 
     def index(self):
         result = Artifact.index(self)
@@ -667,22 +688,27 @@ class Award(Artifact):
     def shorthand_id(self):
         return self.short
 
+
 class AwardGrant(Artifact):
+
     "An :class:`Award <allura.model.artifact.Award>` can be bestowed upon a project by a neighborhood"
     class __mongometa__:
         session = main_orm_session
-        name='grant'
-        indexes = [ 'short' ]
+        name = 'grant'
+        indexes = ['short']
     type_s = 'Generic Award Grant'
 
-    _id=FieldProperty(S.ObjectId)
+    _id = FieldProperty(S.ObjectId)
     award_id = ForeignIdProperty(Award, if_missing=None)
     award = RelationProperty(Award, via='award_id')
-    granted_by_neighborhood_id = ForeignIdProperty('Neighborhood', if_missing=None)
-    granted_by_neighborhood = RelationProperty('Neighborhood', via='granted_by_neighborhood_id')
+    granted_by_neighborhood_id = ForeignIdProperty(
+        'Neighborhood', if_missing=None)
+    granted_by_neighborhood = RelationProperty(
+        'Neighborhood', via='granted_by_neighborhood_id')
     granted_to_project_id = ForeignIdProperty('Project', if_missing=None)
-    granted_to_project = RelationProperty('Project', via='granted_to_project_id')
-    timestamp=FieldProperty(datetime, if_missing=datetime.utcnow)
+    granted_to_project = RelationProperty(
+        'Project', via='granted_to_project_id')
+    timestamp = FieldProperty(datetime, if_missing=datetime.utcnow)
 
     def index(self):
         result = Artifact.index(self)
@@ -700,11 +726,11 @@ class AwardGrant(Artifact):
         return AwardFile.query.get(award_id=self.award_id)
 
     def url(self):
-        slug = str(self.granted_to_project.shortname).replace('/','_')
+        slug = str(self.granted_to_project.shortname).replace('/', '_')
         return h.urlquote(slug)
 
     def longurl(self):
-        slug = str(self.granted_to_project.shortname).replace('/','_')
+        slug = str(self.granted_to_project.shortname).replace('/', '_')
         slug = self.award.longurl() + '/' + slug
         return h.urlquote(slug)
 
@@ -714,7 +740,9 @@ class AwardGrant(Artifact):
         else:
             return None
 
+
 class Feed(MappedClass):
+
     """
     Used to generate rss/atom feeds.  This does not need to be extended;
     all feed items go into the same collection
@@ -730,7 +758,8 @@ class Feed(MappedClass):
             (('project_id', pymongo.ASCENDING),
              ('app_config_id', pymongo.ASCENDING),
              ('pubdate', pymongo.DESCENDING)),
-            'author_link',  # used in ext/user_profile/user_main.py for user feeds
+            # used in ext/user_profile/user_main.py for user feeds
+            'author_link',
         ]
 
     _id = FieldProperty(S.ObjectId)
@@ -738,18 +767,19 @@ class Feed(MappedClass):
     neighborhood_id = ForeignIdProperty('Neighborhood')
     project_id = ForeignIdProperty('Project')
     app_config_id = ForeignIdProperty('AppConfig')
-    tool_name=FieldProperty(str)
-    title=FieldProperty(str)
-    link=FieldProperty(str)
+    tool_name = FieldProperty(str)
+    title = FieldProperty(str)
+    link = FieldProperty(str)
     pubdate = FieldProperty(datetime, if_missing=datetime.utcnow)
     description = FieldProperty(str)
     description_cache = FieldProperty(MarkdownCache)
-    unique_id = FieldProperty(str, if_missing=lambda:h.nonce(40))
-    author_name = FieldProperty(str, if_missing=lambda:c.user.get_pref('display_name') if hasattr(c, 'user') else None)
-    author_link = FieldProperty(str, if_missing=lambda:c.user.url() if hasattr(c, 'user') else None)
+    unique_id = FieldProperty(str, if_missing=lambda: h.nonce(40))
+    author_name = FieldProperty(str, if_missing=lambda: c.user.get_pref(
+        'display_name') if hasattr(c, 'user') else None)
+    author_link = FieldProperty(
+        str, if_missing=lambda: c.user.url() if hasattr(c, 'user') else None)
     artifact_reference = FieldProperty(S.Deprecated)
 
-
     @classmethod
     def post(cls, artifact, title=None, description=None, author=None, author_link=None, author_name=None, pubdate=None, link=None, **kw):
         """
@@ -769,12 +799,14 @@ class Feed(MappedClass):
         if author_name is None:
             author_name = author.get_pref('display_name')
         if title is None:
-            title='%s modified by %s' % (h.get_first(idx, 'title'), author_name)
-        if description is None: description = title
+            title = '%s modified by %s' % (
+                h.get_first(idx, 'title'), author_name)
+        if description is None:
+            description = title
         if pubdate is None:
             pubdate = datetime.utcnow()
         if link is None:
-            link=artifact.url()
+            link = artifact.url()
         item = cls(
             ref_id=artifact.index_id(),
             neighborhood_id=artifact.app_config.project.neighborhood_id,
@@ -796,7 +828,8 @@ class Feed(MappedClass):
     def feed(cls, q, feed_type, title, link, description,
              since=None, until=None, offset=None, limit=None):
         "Produces webhelper.feedgenerator Feed"
-        d = dict(title=title, link=h.absurl(link), description=description, language=u'en')
+        d = dict(title=title, link=h.absurl(link),
+                 description=description, language=u'en')
         if feed_type == 'atom':
             feed = FG.Atom1Feed(**d)
         elif feed_type == 'rss':
@@ -809,9 +842,11 @@ class Feed(MappedClass):
             query['pubdate']['$lte'] = until
         cur = cls.query.find(query)
         cur = cur.sort('pubdate', pymongo.DESCENDING)
-        if limit is None: limit = 10
+        if limit is None:
+            limit = 10
         query = cur.limit(limit)
-        if offset is not None: query = cur.offset(offset)
+        if offset is not None:
+            query = cur.offset(offset)
         for r in cur:
             feed.add_item(title=r.title,
                           link=h.absurl(r.link.encode('utf-8')),
@@ -824,6 +859,7 @@ class Feed(MappedClass):
 
 
 class VotableArtifact(MappedClass):
+
     """Voting support for the Artifact. Use as a mixin."""
 
     class __mongometa__:
@@ -899,11 +935,13 @@ class VotableArtifact(MappedClass):
 
 
 class MovedArtifact(Artifact):
+
     class __mongometa__:
         session = artifact_orm_session
-        name='moved_artifact'
+        name = 'moved_artifact'
 
     _id = FieldProperty(S.ObjectId)
-    app_config_id = ForeignIdProperty('AppConfig', if_missing=lambda:c.app.config._id)
+    app_config_id = ForeignIdProperty(
+        'AppConfig', if_missing=lambda: c.app.config._id)
     app_config = RelationProperty('AppConfig')
     moved_to_url = FieldProperty(str, required=True, allow_none=False)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/model/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/attachments.py b/Allura/allura/model/attachments.py
index 5401359..568f5b0 100644
--- a/Allura/allura/model/attachments.py
+++ b/Allura/allura/model/attachments.py
@@ -24,21 +24,22 @@ from allura.lib import helpers as h
 from .session import project_orm_session
 from .filesystem import File
 
+
 class BaseAttachment(File):
     thumbnail_size = (255, 255)
-    ArtifactType=None
+    ArtifactType = None
 
     class __mongometa__:
         name = 'attachment'
         polymorphic_on = 'attachment_type'
-        polymorphic_identity=None
+        polymorphic_identity = None
         session = project_orm_session
-        indexes = [ 'artifact_id', 'app_config_id' ]
+        indexes = ['artifact_id', 'app_config_id']
 
-    artifact_id=FieldProperty(S.ObjectId)
-    app_config_id=FieldProperty(S.ObjectId)
-    type=FieldProperty(str)
-    attachment_type=FieldProperty(str)
+    artifact_id = FieldProperty(S.ObjectId)
+    app_config_id = FieldProperty(S.ObjectId)
+    type = FieldProperty(str)
+    attachment_type = FieldProperty(str)
 
     @property
     def artifact(self):
@@ -76,7 +77,9 @@ class BaseAttachment(File):
             return orig, thumbnail
         else:
             # No, generic attachment
-            fp.seek(0)  # stream may have been partially consumed in a failed save_image attempt
+            # stream may have been partially consumed in a failed save_image
+            # attempt
+            fp.seek(0)
             return cls.from_stream(
                 filename, fp, content_type=content_type,
                 **original_meta)


Mime
View raw message