Beispiel #1
0
tracer = flaf_tracer.Tracer('WordMapAction')

form = cgi.FieldStorage()
bookIdsString = form.getvalue('bookIds')
bookIds = map(int, bookIdsString.split(',')) if bookIdsString else None
listId = form.getvalue('listId')

conn = flaf_db.newConn()
dbDao = flaf_db.DbDao(conn)
cursor = conn.cursor()

if listId is not None:
  listDao = list_dao.ListDao(conn)
  bookIds = listDao.getBooksInList(listId)

util.dieIfNone(bookIds, 'No book ids specified.')


# tracer.log('Looking for [%s] in book %s' % (word, bookId))

data = {
  'bookIds': bookIds,
  'allBooks': dbDao.getAllBooks(),
  'uncommonShared': dbDao.getUncommonShared(bookIds),
  'commonUnsharedMap': dbDao.getCommonUnshared(bookIds, 7)
}

tracer.log('got data')

# Package the contexts into a single data object
# to pass down to the client
Beispiel #2
0
    help='Label of the list to use.', dest="label")

args = parser.parse_args()
listDao = list_dao.ListDao(flaf_db.newConn())

if args.action == 'create':
  label = util.requireFlag(args, 'label')

  util.dieIfNotNone(listDao.getListId(label),
     'Cannot create list [%s], list already exists.' % label)


  listDao.createList(label)

if args.action == 'delete':
  label = util.requireFlag(args, 'label')
  listId = listDao.getListId(label)
  util.dieIfNone(listId, 'Cannot delete list [%s], list does not exist.' % label)
  listDao.deleteList(label)

if args.action == 'add':
  label = util.requireFlag(args, 'label')
  bookIds = util.requireFlag(args, 'bookIds').split(',')

  listId = listDao.getListId(label)
  util.dieIfNone(listId, 'Cannot add to list [%s], list does not exist.' % label)

  listDao.addBookIds(listId, bookIds)