~yeliabmas/sloecode/wiki-merge-proposal

« back to all changes in this revision

Viewing changes to sloecode/model/template.py

  • Committer: Sam Bailey
  • Date: 2012-09-12 10:08:05 UTC
  • Revision ID: yeliabmas@gmail.com-20120912100805-355zr9m17ex47jl5
Reverted un-needed PEP8 changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import re
21
21
 
22
22
from sqlalchemy import Column
23
 
from sqlalchemy.types import Integer, Text
 
23
from sqlalchemy.types import Integer, String, Text
 
24
#from sqlalchemy.orm import relationship, synonym
24
25
 
25
26
from sloecode.model.meta import Base, QueryMixin
26
27
 
27
 
 
28
28
def get_template_names():
29
 
    """Returns a list containing the names of all of the templates."""
30
29
    templates = Template.get()
31
30
    template_names = []
32
31
    for template in templates:
33
32
        template_names.append(template.name)
34
33
    return template_names
35
34
 
36
 
 
37
35
class Template(Base, QueryMixin):
38
36
    """ A model for a page template in sloecode."""
39
37
    __tablename__ = "template"
40
38
 
41
39
    id = Column(Integer, primary_key=True)
42
40
    name = Column(Text, unique=True)
43
 
 
 
41
    
44
42
    description = Column(Text)
45
43
    save_location = Column(Text)
46
44
    content = Column(Text)
50
48
    """A simple formencode validator that checks Project names are unique."""
51
49
 
52
50
    template_regex = re.compile(r'^[a-z0-9][a-z0-9_.-]{2,23}$')
53
 
 
 
51
    
54
52
    def _to_python(self, value, state):
55
53
        """Validate form-data."""
56
54
        value = value.strip()
69
67
    filter_extra_fields = True
70
68
 
71
69
    name = UniqueTemplate(not_empty=True)
72
 
    old_name = formencode.validators.String(not_empty=False)
73
 
    description = formencode.validators.String(not_empty=False)
 
70
    old_name = formencode.validators.String(not_empty=False)  
 
71
    description = formencode.validators.String(not_empty=False)   
74
72
    save_location = formencode.validators.String(not_empty=True)
75
73
    content = formencode.validators.String(not_empty=False)
 
74
    
 
 
b'\\ No newline at end of file'