Ejemplo n.º 1
0
def _wrap_podcast_group(res):
    if res['doc']['doc_type'] == 'Podcast':
        return Podcast.wrap(res['doc'])
    else:
        pg = PodcastGroup.wrap(res['doc'])
        id = res['key']
        return pg.get_podcast_by_id(id)
Ejemplo n.º 2
0
def search_wrapper(result):
    doc = result['doc']
    if doc['doc_type'] == 'Podcast':
        p = Podcast.wrap(doc)
    elif doc['doc_type'] == 'PodcastGroup':
        p = PodcastGroup.wrap(doc)
    p._id = result['id']
    return p
Ejemplo n.º 3
0
Archivo: merge.py Proyecto: Mic92/mygpo
def podcast_url_wrapper(r):
    url = r['key']
    doc = r['doc']
    if doc['doc_type'] == 'Podcast':
        obj = Podcast.wrap(doc)
    elif doc['doc_type'] == 'PodcastGroup':
        obj = PodcastGroup.wrap(doc)

    return obj.get_podcast_by_url(url)
Ejemplo n.º 4
0
def _wrap_podcast_group_key1(res):
    obj = res['doc']
    if obj['doc_type'] == 'Podcast':
        return Podcast.wrap(obj)

    else:
        pid = res[u'key'][1]
        pg = PodcastGroup.wrap(obj)
        podcast = pg.get_podcast_by_id(pid)
        return podcast
Ejemplo n.º 5
0
Archivo: slugs.py Proyecto: Mic92/mygpo
    def _podcast_wrapper(r):
        from mygpo.core.models import Podcast, PodcastGroup

        doc = r["doc"]

        if doc["doc_type"] == "Podcast":
            return Podcast.wrap(doc)
        else:
            pid = r["key"][2]
            pg = PodcastGroup.wrap(doc)
            return pg.get_podcast_by_id(pid)
Ejemplo n.º 6
0
Archivo: slugs.py Proyecto: fk-lx/mygpo
    def _podcast_wrapper(r):
        from mygpo.core.models import Podcast, PodcastGroup

        doc = r['doc']

        if doc['doc_type'] == 'Podcast':
            return Podcast.wrap(doc)
        else:
            pid = r['key'][2]
            pg = PodcastGroup.wrap(doc)
            return pg.get_podcast_by_id(pid)
Ejemplo n.º 7
0
def _wrap_pg(doc):

    doc = doc['doc']

    if not doc:
        return None

    if doc['doc_type'] == 'Podcast':
        return Podcast.wrap(doc)

    elif doc['doc_type'] == 'PodcastGroup':
        return PodcastGroup.wrap(doc)

    else:
        logger.error('received unknown doc_type "%s"', doc['doc_type'])
Ejemplo n.º 8
0
def all_podcasts():
    from mygpo.db.couchdb.utils import multi_request_view
    res = multi_request_view(Podcast,'podcasts/by_id',
            wrap         = False,
            include_docs = True,
            stale        = 'update_after',
        )

    # TODO: this method is only used for maintenance purposes; should we
    #       really send 'incomplete_obj' signals here?

    for r in res:
        obj = r['doc']
        if obj['doc_type'] == 'Podcast':
            yield Podcast.wrap(obj)
        else:
            pid = r[u'key']
            pg = PodcastGroup.wrap(obj)
            podcast = pg.get_podcast_by_id(pid)
            yield podcast