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)
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
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)
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
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)
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)
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'])
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