Beispiel #1
0
 def GET(self,provider):
   if provider!="sina":
      return u"todo"
   client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
   url = client.get_authorize_url()
   content=u'<h1>功能测试中</h1><p>请联系我们开通您的微博登录功能.</p><a href="%s">继续</a>'%url
   return render.info(content=content)
Beispiel #2
0
 def POST(self):
          picurl=web.input().get("check")
          name=web.input().get("name")
          _tags=web.input().get("tags")
          source=web.input().get("source")                 
          if _tags:
            tags=[x for x in  _tags.split(",")]
          else:
            tags=[]
          user=User.objects(id=Auth.uid()).first()     
          creatorID=user.ID     
          intro=web.input().get("intro")
          price=web.input().get("price")
          link=web.input().get("source")
          store=web.input().get("store")
          #store=get_store(link).decode("utf-8")
          price=web.input().get("price")
          buyinfo=Buy_info(link=link,store=store,price=price)
          pic=urllib2.urlopen(picurl).read()
          ID=Node.objects.count()+1
          open(str(ID)+".jpg","wb").write(pic)
          u = UpYun(BUCKETNAME,USER,PASSWORD)
          data = open(str(ID)+".jpg",'rb')
          u.setContentMD5(md5file(data))
          a = u.writeFile('/o'+str(ID)+'.jpg',data)
          if not a:
              return "get picture erro"
          #cut_item_picture(STATIC_FILE,ID,str(ID)+".jpg")  
          node=Node(creatorID=creatorID,ID=ID,name=name,des=intro,picurl=picurl,tags=tags,buy_info=[buyinfo])
          node.picinfo=101    #a out sidelink
          node.save()
          share=Share_items(ID=Share_items.objects.count()+1,creatorID=user.ID,itemID=ID,flag=1,content="")
          share.save()
          content=u'''<h1>发布成功</h1><p>你可以<a href="/item/%s/">去看看</a>或者
          <a href="%s">回到刚才的逛的</a>'''%(str(ID),source)
          return render.info(content=content)
          return web.seeother("/item/"+str(ID)+"/")