def commitedit(context, req): s = DBSession() if not req.params.get("commit"): return HTTPFound(location = req.resource_url(get_root())) if req.params.get("new_article"): a = Article() s.add(a) else: a = context a.title = req.params.get("title", "") a.body = req.params.get("body", "") s.commit() return HTTPFound(location = req.resource_url(a))
def commitedit(album, req): if not req.params.get("commit"): return HTTPFound(location = req.resource_url(album)) s = DBSession() if req.params.get("new_album"): a = Album(parent_id = album.id) s.add(a) s.commit() else: a = album a.display_name = req.params.get("title") a.descr = req.params.get("description") a.hidden = bool(req.params.get("hide_album", 0)) a.sort_by = int(req.params.get("sort_by", 1)) new_thumb = req.params.get('album_thumbnail') print new_thumb, repr(new_thumb) if type(new_thumb) is types.InstanceType: old_preview = a.preview # add preview name = new_thumb.filename.lstrip(os.sep) preview = Photo(name, a.id, new_thumb.file.read()) new_thumb.file.close() preview.hidden = True s.add(preview) s.commit() a.preview_id = preview.id if old_preview: s.delete(old_preview) s.commit() return HTTPFound(location = req.resource_url(a))