Created
January 25, 2009 08:59
-
-
Save Surgo/51738 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from appengine_django import models | |
from google.appengine.ext import db | |
from google.appengine.ext.db import polymodel | |
class Timeline(polymodel.PolyModel): | |
""" | |
Usage:: | |
user = users.get_current_user() | |
message = 'test' | |
timeline = Timeline(author = user, message = message) | |
timeline.save() | |
""" | |
author = db.UserProperty() | |
message = db.StringProperty(_('message'), required=True) | |
photo = db.IntegerProperty() | |
class ImageTimeline(Timeline): | |
# image | |
data = db.BlobProperty(required=True) | |
format = db.StringProperty(required=True) | |
@classmethod | |
def class_name(cls): | |
return 'Photo' | |
from google.appengine.api import users, images | |
from django.core.files.uploadedfile import SimpleUploadedFile as UploadedFile | |
file = request.FILES['image'] | |
format = file.content_type | |
data = images.Image(file.read())._image_data | |
author = users.get_current_user() | |
image = ImageTimeline(author = author, message = 'test', data = data, format = format) | |
image.put() | |
# get photos | |
imagetimelines = Timeline.all().filter('class =', 'Photo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment