~yeliabmas/sloecode/bug-fix

« back to all changes in this revision

Viewing changes to sloecode/model/project.py

  • Committer: Thomi Richards
  • Date: 2012-05-02 16:20:55 UTC
  • mfrom: (156.1.1 license-compat)
  • Revision ID: thomi.richards@canonical.com-20120502162055-tkccaqjx2ffuqk09
merged code to fix GPL license compatibility, PEp8 and PEP257 fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Project model.
2
 
"""
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
#
 
3
# This program is free software: you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation, either version 3 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
# Copyright 2012 Sloecode Developers
 
17
 
 
18
"""Project model."""
3
19
 
4
20
import formencode
5
21
import re
17
33
 
18
34
    Projects have project names and descriptions. Will probably contain more
19
35
    in the future.
 
36
 
20
37
    """
21
38
    __tablename__ = "project"
22
39
 
31
48
 
32
49
 
33
50
class UniqueProject(formencode.FancyValidator):
34
 
    "A simple formencode validator that checks Project names are unique."
 
51
    """A simple formencode validator that checks Project names are unique."""
35
52
 
36
53
    project_regex = re.compile(r'^[a-z0-9][a-z0-9_.-]{2,23}$')
37
54
 
38
55
    def _to_python(self, value, state):
39
 
        """Validate form-data.
40
 
        """
 
56
        """Validate form-data."""
41
57
        value = value.strip()
42
58
        if len(Project.get(name=value)) > 0:
43
59
            raise formencode.Invalid(