Skip to content

Commit

Permalink
Update so that we can view hte urls as part of the readable todo list.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitechie committed Sep 2, 2012
1 parent 3ac907f commit da95ba7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions bookie/views/api.py
Expand Up @@ -5,6 +5,7 @@
from pyramid.settings import asbool
from pyramid.view import view_config
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import contains_eager
from StringIO import StringIO

from bookie.lib.access import api_auth
Expand All @@ -18,6 +19,7 @@
from bookie.models import Bmark
from bookie.models import BmarkMgr
from bookie.models import DBSession
from bookie.models import Hashed
from bookie.models import NoResultFound
from bookie.models import Readable
from bookie.models import TagMgr
Expand Down Expand Up @@ -874,11 +876,21 @@ def invite_user(request):
def to_readable(request):
"""Get a list of urls, hash_ids we need to readable parse"""
url_list = Bmark.query.outerjoin(Readable, Readable.bid == Bmark.bid).\
filter(Readable.imported == None).all()
ret = {
'urls': [dict(h) for h in url_list]
join(Bmark.hashed).\
options(contains_eager(Bmark.hashed)).\
filter(Readable.imported == None).all()

def data(urls):
"""Yield out the results with the url in the data streamed."""
for url in urls:
d = dict(url)
d['url'] = url.hashed.url
yield d

return {
'urls': [u for u in data(url_list)]

}
return ret


@view_config(route_name="api_admin_accounts_inactive", renderer="json")
Expand Down

0 comments on commit da95ba7

Please sign in to comment.