Pylons

Anonymous
Nov 10, 2009 2:19:02 AM

crud keyerror issue

Language: Python
Tags: pylons crud
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def editsection(self, section=None, projectslug=None):
        # get section content using a query, then htmlfill the editsection form. 
        # perhaps even show the current section image on top of form.
        id = request.params['id']
        section = Section()
        db = section.connect('projects')
        contain(db, Section)
        results = section.view('section/getsection', key=id)
        result = list(iter(results))
        mylist = []
        for row in range(len(result)):
            mylist.append(result[row]['value'])
        values = {
                'title':mylist[0][0],
                'body':mylist[0][1],
                'project':mylist[0][2]
                }
        c.projectlist = mylist[0][2]
        c.title = mylist[0][0]
        c.pagetitle = "Edit Section"
        c.imagename = mylist[0][3]
        c.imagelocation = mylist[0][4]
        c.id = mylist[0][5]
        return htmlfill.render(render('/admin/editsection.html'), values)

    @restrict('POST')
    @validate(schema=CreateSectionForm(), form='editsection')
    def savesection(self):
        # take edited section content and update it in couchdb.
        return self.form_result
        title = request.POST['title']
        body = request.POST['body']
        image = request.POST['image']
        return title, " ", body, " ", image

Download

Comments (0)

You must login before you can comment.

Powered by Pylons - Contact Administrators