Hi guys, I'm working on a picture gallery using turbogears.
It works reasonably well so far, thanks to everyone who has done work on turbogears and its components. http://msarahan.homelinux.net:8080 (Might I suggest clicking the random button for testing) My issue is this: I have an edit option for each picture, so that if people care to, they can "tag" images with who or what is in the image. My methods for the edit and the edit_save are below: @turbogears.expose(html="gallerytest.templates.edit") def edit(self, alt_ID,search_terms): imagelist = [{ 'disk_loc':s.disk_loc, 'name':s.name, 'alt_ID':s.alt_ID } for s in Photoinfo.select(Photoinfo.q.alt_ID==alt_ID) ] for i in imagelist: diskloc=i['disk_loc'] name=i['name'] alt_ID=i['alt_ID'] textfile=os.path.join('/home/mikez0r/gallerytest/gallerytest',(os.path.splitext(diskloc)[0]+'.txt')) if os.path.exists(textfile)==True: f=open(textfile,'r+') else: f=open(textfile,'w') f.write('*,all') f.close() f=open(textfile,'r+') imageterms=f.read() return dict(imageterms=imageterms,search_terms=search_terms,name=name,alt_ID=alt_ID,disk_loc=diskloc) @turbogears.expose() def save_edits(self, alt_ID, imageterms, submit, search_terms, disk_loc): # some basic spam screening if find(imageterms,'.com')!=-1 or find(imageterms,'pen')!=-1 or find(imageterms,'via')!=-1 or find(imageterms,'.net')!=-1 or find(imageterms,'money')!=-1 or find(imageterms,'dollar')!=-1 or find(imageterms,'$')!=-1: pass else: hub.begin() record=Searchtable.byAlt_ID(alt_ID) record.imageterms = imageterms hub.commit() hub.end() filepath=('/home/mikez0r/gallerytest/gallerytest/'+os.path.splitext(disk_loc)[0]+'.txt') if os.path.exists(filepath)==True: f=open(filepath,'r+') f.write(imageterms) f.close() else: f=open(filepath,'w') f.write(imageterms) f.close() turbogears.flash("Changes saved! Search for your word(s) to test it.") raise cherrypy.HTTPRedirect(turbogears.url("/pics",search_terms=search_terms)) Edit is called with a std.url link that contains the alt_id of the picture to be edited and the search_terms as arguments, to pass the search_terms through to the save_edit method, which should then pass them back to the pics method. So the save_edit method should open up my pics method with the original search_terms passed to it, right? For some reason, I can't get the pics page to show anything when the search_terms are passed into the pics method with an HTTPRedirect. Currently, the only thing that works is form submission. I would prefer to be able to do this with <a href> links and the redirects, to avoid having so many buttons lying around. My entire controllers.py is at: http://msarahan.homelinux.net/tg/controllers.py.txt Also, since I am very new to python (1mo. or so, started when TG was announced on Slashdot) and all of the projects involved, I would appreciate it if you all would tell me if I am doing something entirely backwards and/or wonky. Thanks. Mike

