Exemple #1
0
 def new(cls,user,dis,content,f='M',ip='127.0.0.1',user_agent='Firefox'):
     key_name = Counter.get_max('comment').value
     while Comment.get_by_key_name(key_name):
         key_name = Counter.get_max('comment').value
     
     comment = Comment(key_name =key_name,user=user,dis = dis ,content=content,f=f,ip=ip,user_agent=user_agent)
     comment.put()
     return comment
Exemple #2
0
 def add(cls,tag,slug,title,content,user,**kwargs):
     tag_key = tag.key().name()
     slug = filter_url(slug) or Counter.get_max(":%s:" % tag_key).value
     key_name = "%s:%s" % (tag_key,slug)
     while Discussion.is_exist(key_name):
         slug = Counter.get_max(":%s:" % tag.key().name()).value
         key_name = "%s:%s" % (tag_key,slug)
         
     dis = Discussion(key_name = key_name,tag = tag,slug = slug,title=title,content=content,user=user,**kwargs)
     dis.put()
     return dis
Exemple #3
0
 def put(self):
     if not self.is_saved():
         self.name_lower = self.name.lower()
         self.email = self.email.lower()
         self.email_md5 = get_md5(self.email)
         self.user_id = Counter.get_max("user").value
         self.role.extend(['M','G'])
     super(User,self).put()
Exemple #4
0
    def new(cls,name,mime,bf,user):
        key_name = Counter.get_max("gs").value
        img = images.Image(bf)
        
        gsfile = GSFile(key_name=key_name,name =name,mime=mime,size =len(bf),user=user,cname = settings.cname)
        gsfile.width = img.width
        gsfile.heigth= img.height
        gsfile.small_pic=key_name

        if img.height > 800: #need resize
            img.resize(width=800)
            #img.im_feeling_lucky()
            save_image_to_gs('s/'+key_name,img.execute_transforms(output_encoding=images.PNG))
            gsfile.small_pic='s/'+key_name
        if save_image_to_gs(key_name,bf,gsfile.mime):
            gsfile.put()