def post(self): user_id = self.get_argument("uid", None) title = self.get_argument("title", "") link = self.get_argument("link", "") profile = self.get_argument("profile", True) tags = self.get_argument("tags", "").split(" ") description = self.get_argument("description", "") image_path = self.get_argument("Filedata.path", None) image_name = self.get_argument("Filedata.name", None) image_md5 = self.get_argument("Filedata.md5", None) image_size = self.get_argument("Filedata.size", None) categories = self.get_argument("categories", None) if not user_id: return user_id = int(user_id) if not image_path: return name, ext = os.path.splitext(image_name) response = upload_crop(image_path, ext) if not response["status"]: return source_path = response["source_path"].split("/upload/")[1] thumb_path = response["thumb_path"].split("/upload/")[1] middle_path = response["middle_path"].split("/upload/")[1] width = response["width"] height = response["height"] entry = self.entry_dal.template() entry["user_id"] = user_id entry["user"] = self.entry_dal.dbref("users", user_id) entry["title"] = title entry["link"] = link entry["profile"] = profile entry["tags"] = tags entry["description"] = description entry["source"] = source_path entry["thumb"] = thumb_path entry["middle"] = middle_path entry["height"] = height entry["width"] = width entry["md5"] = image_md5 entry["size"] = image_size if categories: entry["categories"] = [int(item.strip()) for item in categories.split(",") if item.strip()] if title: title = title.encode("utf-8", "ignore") keywords = [seg for seg in seg_txt_search(title) if len(seg) > 1] if len(tags) and tags[0]: keywords = keywords + tags entry["_keywords"] = keywords try: self.entry_dal.save(entry) self.user_dal.update_entries_count(user_id) except Exception, ex: Log.error(ex)
def crop(): import util image_path = "/home/meego/Desktop/dd" ext = ".jpg" response = util.upload_crop(image_path, ext) for param in response: print response[param]
def post(self): user_id = self.get_argument("uid", None) title = self.get_argument("title", "") link = self.get_argument("link", "") profile = self.get_argument("profile", True) tags = self.get_argument("tags", "").split(" ") description = self.get_argument("description", "") image_path = self.get_argument("Filedata.path", None) image_name = self.get_argument("Filedata.name", None) image_md5 = self.get_argument("Filedata.md5", None) image_size = self.get_argument("Filedata.size", None) categories = self.get_argument("categories", None) if not user_id: return user_id = int(user_id) if not image_path: return name, ext = os.path.splitext(image_name) response = upload_crop(image_path, ext) if not response["status"]: return source_path = response["source_path"].split("/upload/")[1] thumb_path = response["thumb_path"].split("/upload/")[1] middle_path = response["middle_path"].split("/upload/")[1] width = response["width"] height = response["height"] entry = self.entry_dal.template() entry["user_id"] = user_id entry["user"] = self.entry_dal.dbref("users", user_id) entry["title"] = title entry["link"] = link entry["profile"] = profile entry["tags"] = tags entry["description"] = description entry["source"] = source_path entry["thumb"] = thumb_path entry["middle"] = middle_path entry["height"] = height entry["width"] = width entry["md5"] = image_md5 entry["size"] = image_size if categories: entry["categories"] = [ int(item.strip()) for item in categories.split(",") if item.strip() ] if title: title = title.encode("utf-8", "ignore") keywords = [seg for seg in seg_txt_search(title) if len(seg) > 1] if len(tags) and tags[0]: keywords = keywords + tags entry["_keywords"] = keywords try: self.entry_dal.save(entry) self.user_dal.update_entries_count(user_id) except Exception, ex: Log.error(ex)