Beispiel #1
0
 def test_book_update_via_service_put(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
        title = "test",
        ident = "1",
        author = "author",
        notes = "",
        image = "http://example.com/image.gif",
        url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     json = """{
         "ident": "1", 
         "title": "test update",
         "author": "author",
         "notes": "",
         "image": "http://example.com/image.gif",
         "url": "http://example.com"
     }"""
     response = self.app.put('/books/1', params=json, expect_errors=True)
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/1', expect_errors=True)
     self.assertEquals("200 OK", response.status)
     try:
         json = response.json
     except AttributeError:
         assert(False)
     self.assertEqual(json['ident'], "1")
     self.assertEqual(json['title'], "test update")
Beispiel #2
0
 def test_book_update_via_service_put(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     json = """{
         "ident": "1", 
         "title": "test update",
         "author": "author",
         "notes": "",
         "image": "http://example.com/image.gif",
         "url": "http://example.com"
     }"""
     response = self.app.put('/books/1', params=json, expect_errors=True)
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/1', expect_errors=True)
     self.assertEquals("200 OK", response.status)
     try:
         json = response.json
     except AttributeError:
         assert (False)
     self.assertEqual(json['ident'], "1")
     self.assertEqual(json['title'], "test update")
Beispiel #3
0
 def test_book_views_return_correct_mime_type(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/%s' % book.ident, expect_errors=True)
     self.assertEquals(response.content_type, "application/json")
Beispiel #4
0
 def test_sending_email(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     # TODO: needs assertion
     _email_new_book(book)
Beispiel #5
0
 def test_book_deletion(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     book.delete()
     self.assertEquals(0, Book.all().count())
Beispiel #6
0
 def test_book_deletion_via_service(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     response = self.app.delete('/books/%s' % book.ident,
                                expect_errors=True)
     self.assertEquals(0, Book.all().count())
Beispiel #7
0
 def test_response_contents_from_book(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/%s' % book.ident, expect_errors=True)
     response.mustcontain('"ident": "1"')
     response.mustcontain('"title": "test"')
Beispiel #8
0
 def test_book_deletion(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
        title = "test",
        ident = "1",
        author = "author",
        notes = "",
        image = "http://example.com/image.gif",
        url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     book.delete()
     self.assertEquals(0, Book.all().count())
Beispiel #9
0
 def test_book_addition_via_service_post(self):
     json = """{
         "ident": "1", 
         "title": "test",
         "author": "author",
         "notes": "",
         "image": "http://example.com/image.gif",
         "url": "http://example.com"
     }"""
     self.assertEquals(0, Book.all().count())
     response = self.app.post('/books', params=json, expect_errors=True)
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/1', expect_errors=True)
     self.assertEquals("200 OK", response.status)
Beispiel #10
0
 def test_book_deletion_via_service(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
        title = "test",
        ident = "1",
        author = "author",
        notes = "",
        image = "http://example.com/image.gif",
        url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     response = self.app.delete('/books/%s' % book.ident, expect_errors=True)
     self.assertEquals(0, Book.all().count())
Beispiel #11
0
 def test_sending_email(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
        title = "test",
        ident = "1",
        author = "author",
        notes = "",
        image = "http://example.com/image.gif",
        url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     # TODO: needs assertion
     _email_new_book(book)
Beispiel #12
0
 def test_book_addition_via_service_post(self):
     json = """{
         "ident": "1", 
         "title": "test",
         "author": "author",
         "notes": "",
         "image": "http://example.com/image.gif",
         "url": "http://example.com"
     }"""
     self.assertEquals(0, Book.all().count())
     response = self.app.post('/books', params=json, expect_errors=True)
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/1', expect_errors=True)
     self.assertEquals("200 OK", response.status)
Beispiel #13
0
 def test_books_views_return_correct_mime_type(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
         title = "test",
         ident = "1",
         author = "author",
         notes = "",
         image = "http://example.com/image.gif",
         url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/', expect_errors=True)
     self.assertEquals(response.content_type, "application/json")
Beispiel #14
0
 def test_response_from_book_is_json(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/%s' % book.ident, expect_errors=True)
     try:
         response.json
     except AttributeError:
         assert (False)
Beispiel #15
0
 def test_response_contents_from_books(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
         title = "test",
         ident = "1",
         author = "author",
         notes = "",
         image = "http://example.com/image.gif",
         url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/', expect_errors=True)
     response.mustcontain('"ident": "1"')
     response.mustcontain('"title": "test"')
Beispiel #16
0
 def get(self, book_slug = None):
   if not book_slug:
     books = Book.all().order("title")
     self.render_template(self.BOOKS_TEMPLATE,{'books': books})
   else:
     self.book = self.get_object_by_key_or_404(Book, book_slug)
     self._render_book()
Beispiel #17
0
 def DeleteClass(self, *args):
     from google.appengine.ext import db
     from models import Task, Class, Book, Chapter
     from google.appengine.api import users
     user = users.get_current_user()
     classname = args[0].replace('%20', ' ')
     #Deleting all Tasks for this Module
     q = Task.all().filter('user ==',user).filter('classname ==',classname)
     results = q.fetch(10)
     for result in results:
         result.delete()
     #Deleting all the Scripts and Chapters from this Module
     qq = Book.all().filter('user ==',user).filter('classname ==',classname)
     books = qq.fetch(10)
     for book in books:
         qqq = Chapter.all().filter('book ==', book.title).filter('user ==',user)
         for chapter in qqq:
             chapter.delete()
         book.delete()
     #Deleting the Module itself
     qqqq = Class.all().filter('user ==',user).filter('name ==',classname)
     results = qqqq.fetch(10)
     for result in results:
         result.delete()
     return self.RefreshClasses()
Beispiel #18
0
    def get(self, ident):
        "Show the JSON representation of the book"

        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)

        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
        except IndexError:
            # if we don't find a book then throw a Not Found error
            return self.error(404)

        # create the datastructure we will convert to JSON
        book_for_output = {
            "title": book.title,
            "ident": book.ident,
            "author": book.author,
            "image": book.image,
            "notes": book.notes,
            "url": book.url,
            "key": str(book.key())
        }
        # create the JSON object
        json = simplejson.dumps(book_for_output, sort_keys=False, indent=4)

        # serve the response with the correct content type
        self.response.headers['Content-Type'] = 'application/json'
        logging.info("Request for %s (%s)" % (book.title, book.ident))
        # write the json to the response
        self.response.out.write(json)
Beispiel #19
0
    def get(self, ident):
        "Show the JSON representation of the book"
        
        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)
        
        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
        except IndexError:
            # if we don't find a book then throw a Not Found error
            return self.error(404)
        
        # create the datastructure we will convert to JSON
        book_for_output = {
            "title": book.title,
            "ident": book.ident,
            "author": book.author,
            "image": book.image,
            "notes": book.notes,
            "url": book.url,
            "key": str(book.key())
        }
        # create the JSON object
        json = simplejson.dumps(book_for_output, sort_keys=False, indent=4)

        # serve the response with the correct content type
        self.response.headers['Content-Type'] = 'application/json'        
        logging.info("Request for %s (%s)" % (book.title, book.ident))
        # write the json to the response
        self.response.out.write(json)
Beispiel #20
0
    def delete(self, ident):
        "Delete the book from the datastore"
        
        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)
        
        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
        except IndexError:
            # if we don't find a book then throw a Not Found error
            return self.error(404)

        logging.info("Update request for %s (%s)" % (book.title, ident))
        try:
            # delete the book
            book.delete()
            # we'e updated so we need to clear the cache
            memcache.delete("ws_books")
        except:
            logging.error("Error occured deleting %s (%s)"
                % (book.title, ident))
            self.error(500)
Beispiel #21
0
 def get(self, book_slug = None):
   if not book_slug:
     books = Book.all()
     self.render_template(self.BOOKS_TEMPLATE,{'books': books})
   else:
     book = self.get_object_by_key_or_404(Book, book_slug)
     self.render_template(self.BOOK_TEMPLATE,{'book': book})
Beispiel #22
0
    def delete(self, ident):
        "Delete the book from the datastore"

        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)

        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
        except IndexError:
            # if we don't find a book then throw a Not Found error
            return self.error(404)

        logging.info("Update request for %s (%s)" % (book.title, ident))
        try:
            # delete the book
            book.delete()
            # we'e updated so we need to clear the cache
            memcache.delete("ws_books")
        except:
            logging.error("Error occured deleting %s (%s)" %
                          (book.title, ident))
            self.error(500)
Beispiel #23
0
 def test_response_from_books_is_json(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
         title = "test",
         ident = "1",
         author = "author",
         notes = "",
         image = "http://example.com/image.gif",
         url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/', expect_errors=True)
     try:
         response.json # simplejons
     except AttributeError:
         assert(False)
Beispiel #24
0
    def get(self):
        books = Book.all();
        template_values = {
            'books' : books,                
        }

        path = os.path.join(os.path.dirname(__file__)+"/templates", 'list.html')
        self.response.out.write(template.render(path, template_values))
Beispiel #25
0
def search(request):
    if 'q' in request.GET and request.GET['q']:
        q = request.GET['q']
        books = Book.all()
        return render_to_response('search_results.html',
        {'books': books, 'query': q})
    else:
        return HttpResponse('Please submit a search term.')
Beispiel #26
0
 def test_response_contents_json_from_books(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/', expect_errors=True)
     try:
         json = response.json  # simplejons
     except AttributeError:
         assert (False)
     self.assertEqual(len(json), 1)
     self.assertEqual(json[0]['ident'], "1")
     self.assertEqual(json[0]['title'], "test")
Beispiel #27
0
 def test_response_contents_json_from_book(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
         title = "test",
         ident = "1",
         author = "author",
         notes = "",
         image = "http://example.com/image.gif",
         url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     response = self.app.get('/books/%s' % book.ident, expect_errors=True)
     try:
         json = response.json
     except AttributeError:
         assert(False)
     self.assertEqual(json['ident'], "1")
     self.assertEqual(json['title'], "test")
Beispiel #28
0
 def test_books_with_content_returns_200(self):
     self.assertEquals(0, Book.all().count())
     book = Book(title="test",
                 ident="1",
                 author="author",
                 notes="",
                 image="http://example.com/image.gif",
                 url="http://example.com")
     book.put()
     response = self.app.get('/books', expect_errors=True)
     self.assertEquals("200 OK", response.status)
Beispiel #29
0
    def put(self, ident):
        "Update an existing book or create a new one"

        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)

        # get the JSON from the request
        json = self.request.body
        # convert the JSON to a Python object 
        representation = simplejson.loads(json)
        # set the properties
        title = representation['title']
        ident = representation['ident']
        author = representation['author']
        image = representation['image']
        notes = representation['notes']
        url = representation['url']
        
        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
            book.title = title
            book.ident = ident
            book.author = author
            book.image = image
            book.notes = notes
            book.url = url
        except IndexError:
            # if we don't find a book then create one
            book = Book(
                title = title,
                ident = ident,
                author = author,
                image = image,
                notes = notes,
                url = url
            )
        logging.info("Update request for %s (%s)" % (title, ident))
        # save the object to the datastore
        try:
            # save the object to the datastore
            book.put()
            # send an email about the new book
            _email_new_book(book)            
            # we'e updated so we need to clear the cache
            memcache.delete("ws_books")
        except:
            logging.error("Error occured creating/updating \
                book %s (%s) via PUT") % (title, ident)
            self.error(500)
Beispiel #30
0
 def RefreshClasses(self):
     from models import Class, Task, Book
     from datetime import date
     user = users.get_current_user()
     books = Book.all().filter('user ==',user)
     classes = Class.all().order("exam").filter('user ==',user).filter('exam >', date.today())
     template_values = {
                        'books' : books,
                        'classes': classes
                        }
     path = os.path.join(os.path.dirname(__file__), "templates", "listmoduls.html")
     code = template.render(path, template_values).decode('utf-8')
     return code
Beispiel #31
0
 def test_books_with_content_returns_200(self):  
     self.assertEquals(0, Book.all().count())
     book = Book(
         title = "test",
         ident = "1",
         author = "author",
         notes = "",
         image = "http://example.com/image.gif",
         url = "http://example.com"
     )    
     book.put()   
     response = self.app.get('/books', expect_errors=True)        
     self.assertEquals("200 OK", response.status)
Beispiel #32
0
    def put(self, ident):
        "Update an existing book or create a new one"

        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)

        # get the JSON from the request
        json = self.request.body
        # convert the JSON to a Python object
        representation = simplejson.loads(json)
        # set the properties
        title = representation['title']
        ident = representation['ident']
        author = representation['author']
        image = representation['image']
        notes = representation['notes']
        url = representation['url']

        try:
            # retrieve the book based on its ident value
            book = Book.all().filter('ident =', ident)[0]
            book.title = title
            book.ident = ident
            book.author = author
            book.image = image
            book.notes = notes
            book.url = url
        except IndexError:
            # if we don't find a book then create one
            book = Book(title=title,
                        ident=ident,
                        author=author,
                        image=image,
                        notes=notes,
                        url=url)
        logging.info("Update request for %s (%s)" % (title, ident))
        # save the object to the datastore
        try:
            # save the object to the datastore
            book.put()
            # send an email about the new book
            _email_new_book(book)
            # we'e updated so we need to clear the cache
            memcache.delete("ws_books")
        except:
            logging.error("Error occured creating/updating \
                book %s (%s) via PUT") % (title, ident)
            self.error(500)
Beispiel #33
0
 def DeleteBook(self, *args):
     from google.appengine.ext import db
     from models import Class, Book, Chapter
     from google.appengine.api import users
     user = users.get_current_user()
     classname = args[0].replace('%20', ' ')
     bookname = args[1].replace('%20', ' ')
     qq = Book.all().filter('user ==',user).filter('classname ==',classname).filter('title ==',bookname)
     books = qq.fetch(10)
     for book in books:
         qqq = Chapter.all().filter('book ==', book.title).filter('user ==',user)
         for chapter in qqq:
             chapter.delete()
         book.delete()
         break
     return self.RefreshClasses()
Beispiel #34
0
    def get(self):
        #imports
        from models import Class, Task, Book
        from datetime import date
        
        #get current User
        user = users.get_current_user()
        
        #Check if user wants to change the language
        cookie_django_language = self.request.get('language', '')
        if cookie_django_language:
            if cookie_django_language == 'unset':
                del self.request.COOKIES['django_language']
            else:
                self.request.COOKIES['django_language'] = cookie_django_language
            self.reset_language()

        if user:
            classes = Class.all().order("exam").filter('user ==',user).filter('exam >', date.today())
            logoutlink = users.create_logout_url(self.request.uri)
            books = Book.all().filter('user ==',user)
            inline = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate >', date.today())
            urgent = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate <=', date.today())
            template_values = {
                           'books' : books,
                           'title':'Task Management',
                           'user' : user.email(),
                           'tasks': inline,
                           'urgent': urgent,
                           'logout' : logoutlink,
                           'classes': classes
                           }
            path = os.path.join(os.path.dirname(__file__), 'templates', "index.html")
            self.response.out.write(template.render(path, template_values).decode('utf-8'))
        else:
            providers = []
            for p in openIdProviders:
                p_name = p.split('.')[0].lower()
                p_url = p.lower()
                providers.append([users.create_login_url(federated_identity=p_url), p_name])
            template_values = { 
                           'providers' : providers,
            }
            path = os.path.join(os.path.dirname(__file__), 'templates', "login.html")
            self.response.out.write(template.render(path, template_values).decode('utf-8'))
Beispiel #35
0
    def get(self):
        "Returns a list of books"
        # first check if we have the list of books in the cache

        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)

        json = memcache.get("ws_books")
        # if not then we need to create it
        if json is None:
            # get all books
            books = Book.all()
            books_for_output = []

            for book in books:
                # for each book create a data structure representation
                books_for_output.append({
                    "title": book.title,
                    "ident": book.ident,
                    "author": book.author,
                    "image": book.image,
                    "notes": book.notes,
                    "url": book.url,
                    "key": str(book.key())
                })
            # if we have no books then return not found
            if not books_for_output:
                return self.error(404)
            # convert the datastructure to json
            json = simplejson.dumps(books_for_output,
                                    sort_keys=False,
                                    indent=4)
            # store the json in the cache for a specified time
            memcache.add("ws_books", json, settings.CACHE_TIME)

        # serve the response with the correct content type
        self.response.headers['Content-Type'] = 'application/json'
        # write the json to the response
        logging.info('Request for book list')
        self.response.out.write(json)
Beispiel #36
0
    def get(self):
        "Returns a list of books"
        # first check if we have the list of books in the cache
        
        # check we have the correct authentication ket
        auth = self.request.get("auth")
        if auth != settings.AUTH:
            return self.error(401)
        
        json = memcache.get("ws_books")
        # if not then we need to create it
        if json is None:
            # get all books
            books = Book.all()
            books_for_output = []
                
            for book in books:
                # for each book create a data structure representation
                books_for_output.append({
                    "title": book.title,
                    "ident": book.ident,
                    "author": book.author,
                    "image": book.image,
                    "notes": book.notes,
                    "url": book.url,
                    "key": str(book.key())
                })
            # if we have no books then return not found
            if not books_for_output:
                return self.error(404)
            # convert the datastructure to json
            json = simplejson.dumps(books_for_output, sort_keys=False, indent=4)
            # store the json in the cache for a specified time
            memcache.add("ws_books", json, settings.CACHE_TIME)

        # serve the response with the correct content type
        self.response.headers['Content-Type'] = 'application/json'        
        # write the json to the response
        logging.info('Request for book list')
        self.response.out.write(json)
Beispiel #37
0
 def test_books_with_no_content_returns_404(self):  
     self.assertEquals(0, Book.all().count())
     response = self.app.get('/books', expect_errors=True)        
     self.assertEquals("404 Not Found", response.status)
Beispiel #38
0
async def get_books():
    return await Book_Pydantic.from_queryset(Book.all())
Beispiel #39
0
if __name__ == "__main__":
    import logging

    logging.basicConfig(level=logging.INFO)

    (id_, secret) = file('subledger.secret').read().strip().split()
    Organization.authenticate(id_, secret)

    org_id = 'ivMaXfSHBQ9hBq5igz5nU1'

    #o = Organization.from_id(org_id)
    #print o

    # Test if we can skip loading the Org first
    from base import Dummy

    o = Dummy()
    o._id = org_id
    #b = Book(a._id, 'XBT')
    #b.save()

    #b = Book.from_id(u'nFCZ2CIDfIkaY1f6b7bBG4', a._id)
    tmp = set()
    for b in Book.all(o, state='archived'):
        print b.description
        print b.is_active
    for b in Book.all(o, state='active'):
        print b.description
        print b.is_active
Beispiel #40
0
def get_book_titles():
    books = Book.all().order('title').fetch(MAX_FETCH_LIMIT)
    books_list = []
    for book in books:
        books_list.append(book.to_json_dict('title', 'is_starred', 'is_active', 'is_deleted', 'when_created'))
    return books_list
Beispiel #41
0
 def book_with_no_content_returns_404(self):
     self.assertEquals(0, Book.all().count())
     response = self.app.get('/books/1', expect_errors=True)
     self.assertEquals("404 Not Found", response.status)
if __name__ == "__main__":
    import logging

    logging.basicConfig(level=logging.INFO)

    (id_, secret) = file('subledger.secret').read().strip().split()
    Organization.authenticate(id_, secret)

    org_id = 'ivMaXfSHBQ9hBq5igz5nU1'

    #o = Organization.from_id(org_id)
    #print o

    # Test if we can skip loading the Org first
    from base import Dummy

    o = Dummy()
    o._id = org_id
    #b = Book(a._id, 'XBT')
    #b.save()

    #b = Book.from_id(u'nFCZ2CIDfIkaY1f6b7bBG4', a._id)
    tmp = set()
    for b in Book.all(o, state='archived'):
        print b.description
        print b.is_active
    for b in Book.all(o, state='active'):
        print b.description
        print b.is_active