-
Notifications
You must be signed in to change notification settings - Fork 13
/
models.py
38 lines (31 loc) · 1.1 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#coding:utf-8
import re,logging,os
from google.appengine.ext import db
from google.appengine.api import memcache
class Images(db.Model):
name = db.StringProperty()
mime = db.StringProperty()
size = db.IntegerProperty()
created_at = db.DateTimeProperty(auto_now_add=True)
description = db.TextProperty()
width = db.IntegerProperty()
height = db.IntegerProperty()
filetype=db.StringProperty()
bf = db.BlobProperty() #binary file
def put(self):
super(Images,self).put()
def delete(self):
key=str(self.key().id())+"image"
memcache.delete(key)
super(Images,self).delete()
@property
def id(self):
return str(self.key().id())
@property
def imgurl(self):
return "http://%s/image/%s/" %(os.environ['HTTP_HOST'],self.key().id())
@property
def showurl(self):
return "http://%s/show/%s/" %(os.environ['HTTP_HOST'],self.key().id())
class Counter(db.Model):
count = db.IntegerProperty(required=True, default=0)