def post(self): genre_id = request.form["genre_id"] if request.files["icon"].filename != '': icon = request.files["icon"] hash_str, abs_save_file, save_file = upload_hash_file(icon, settings["pic_upload_dir"]) DB.app_genre.update({'genreId': int(genre_id)}, {'$set':{"icon_file": save_file}}, upsert=True) return redirect(url_for("admin_genre_list"))
def do_request(self): if request.method != 'POST': return self._view.render('app_topic_add', form=self._form) #上传文件 try: hash_str, abs_save_file, save_file= upload_hash_file(request.files['pic'], settings['pic_upload_dir'], ['png', 'jpg']) except Exception, ex: self._form.add_error('pic', str(ex))
def post(self): try: position = request.form["position"] ad_position = request.form["ad_position"] name = request.form["name"] link = request.form["link_url"] locations = request.form.getlist("locations") hash_str, abs_save_file, save_file = upload_hash_file( request.files["image_url"], settings["pic_upload_dir"] ) DB.other_ad.update({"position": position}, {"$push": {"data": { "url": save_file, "link_url": link, "ad_position": ad_position, "name": name, "hash": hash_str, "locations": locations }}}) except Exception, ex: status, message = 'error', str(ex) print message
self._form.add_validator(AppTopicEditValidator) self._form.set_value(self.topic_data) except FormException, ex: return self._view.error(str(ex)) self._view.assign('create_pic_url', create_pic_url) return self._view.render('app_topic_add', form=self._form, icon=self.icon) try: self._init_form() self._form.add_validator(AppTopicEditValidator) except FormException, ex: return self._view.error(str(ex)) #上传文件 try: hash_str, abs_save_file, save_file= upload_hash_file(request.files['pic'], settings['pic_upload_dir'], ['png', 'jpg']) except Exception, ex: #self._form.add_error('pic', str(ex)) hash_str, abs_save_file, save_file = None, None, None try: language = request.form.getlist('language') country = request.form.getlist('country') except: language, country = None, None if self._form.validate(): try: #入库 data = {} data['name'] = request.form['name']