monologista /

# vim: fileencoding=utf8

import string
import random

from google.appengine.ext import db
from google.appengine.api import users

LETTERS_AND_DIGITS = string.letters + string.digits


class Account(db.Model):
  >>> users.User()
  >>> account = Account(key_name='spam')
  user = db.UserProperty(required=True)
  account_id = db.StringProperty(required=True)
  access_key_id = db.StringProperty(default=self.generate_random_string(20))
  secret_access_key = db.StringProperty(default=self.generate_random_string(20))
  timeline = db.ListProperty(db.Key)
  followings = db.ListProperty(db.Key)
  image = db.BlobProperty(required=False)
  created = db.DateTimeProperty(auto_now_add=True)

  def followers(self):
    >>> for i in account.followers: Account.get_by_key(i)
    return Account.all().filter('followings =', self.key())

  def generate_random_string(self, length):
    return ''.join([random.choice(LETTERS_AND_DIGITS) for i in range(length)])

class Tag(db.Model):
  name = db.StringProperty()
  created = db.DateTimeProperty(auto_now_add=True)

  def statuses(self):
    return Status.all().filter('tags =', self.key())

class Status(db.Model):
  >>> account
  >>> status = Status(parent=account)
  >>> status.account = account
  >>> status.text = 'spam'
  >>> status.put()
  account = db.ReferenceProperty(Account)
  text = db.StringProperty(required=True)
  created = db.DateTimeProperty(auto_now_add=True)
  replies = db.LinkProperty(db.Key)
  tags = db.LinkProperty(db.Key)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.