示例#1
0
文件: photo.py 项目: kruser/zualoo
def uploadByteArray(byteArray):
    """ 
	Allows the upload of a PNG encoded as a ByteArray from Flash for 
	authenticated users. (This is used to upload cropped images from Flash.)
	"""
    user = users.get_current_user()

    # Does a photo entry exist for this user?
    photo = Photo.all().filter("user ="******"Cropped bytearray"
    photo.fileSize = len(byteArray)
    photo.fileType = "PNG"
    photo.authToken = ""
    photo.put()

    userProfile = UserProfile.all().filter("user = ", user).get()

    userProfile.hasPhoto = True
    userProfile.photo = photo
    userProfile.put()
示例#2
0
文件: photo.py 项目: kruser/zualoo
	def post(self):
		authToken = self.request.get('authToken')
		
		photo = Photo.all().filter("authToken = ", authToken).get()

		#if photo == None:
		#	photo = Photo()
		#	photo.user = user

		if photo:
			logging.info("Storing photo...")
			photo.ip = self.request.remote_addr
		
			image = self.request.get('upload')

			photo.fileBlob = db.Blob(image)	
			photo.put()
			
			# Until the user crops the photo, set their hasPhoto to false 
			# so that uncropped photos don't show up in the stream.
			userProfile = UserProfile.all().filter("user = "******"Error: No such photo.")
			# Unauthorized	
			self.error(401)
示例#3
0
文件: user.py 项目: kruser/zualoo
def login(base_url, login_return_url):
		
	user = users.get_current_user()

	# The user value object (VO) contains login and logout URLs.
	# (With /gateway stripped out so that it returns to the SWF). 
	
	urls = getUrls(base_url, login_return_url)
	
	user_vo = {
		'login': urls['login'],
		'logout': urls['logout'],
		'auth': False
	}
	
	if user:
		# Add the user object to the user VO.
		user_vo['user'] = user
		user_vo['auth'] = True
		
		# Get the user's profile from the database
		profile = UserProfile.all().filter('user ='******'profile'] = {
			'name': profile.name,
			'url': profile.url,
			'description': profile.description,
			'key': str(profile.key())
		}

	return user_vo
示例#4
0
文件: user.py 项目: kruser/zualoo
def getRecentUsersWithPhotos():
	
	# Profiles with photos created in the last 12 hours.
	# last12Hours = datetime.utcnow()-timedelta(hours=12)
	# .filter('modifiedAt > ', last12Hours)
	userProfileQuery = UserProfile.all().filter('hasPhoto = ', True).order('-modifiedAt')
	
	# Get the last 10.
	results = userProfileQuery.fetch(10)
	
	# Make an array of the results (PyAMF is currently choking on result sets from the
	# DataStore)
	resultsArray = [];	
	for result in results:
		resultsArray.append({'name': result.name, 'url': result.url, 'description': result.description, 'photo': amf3.ByteArray(result.photo.fileBlob)})

	# An ArrayCollection is even better :) 
	resultsArrayCollection = flex.ArrayCollection(resultsArray)

	return resultsArrayCollection