def _sample_ecosystem(self): """ Creates an ecosystem of some sample work, pool, edition, and author objects that all know each other. """ # make some authors [bob], ignore = Contributor.lookup(self._db, u"Bitshifter, Bob") bob.family_name, bob.display_name = bob.default_names() [alice], ignore = Contributor.lookup(self._db, u"Adder, Alice") alice.family_name, alice.display_name = alice.default_names() edition_std_ebooks, pool_std_ebooks = self._edition(DataSource.STANDARD_EBOOKS, Identifier.URI, with_license_pool=True, with_open_access_download=True, authors=[]) edition_std_ebooks.title = u"The Standard Ebooks Title" edition_std_ebooks.subtitle = u"The Standard Ebooks Subtitle" edition_std_ebooks.add_contributor(alice, Contributor.AUTHOR_ROLE) edition_git, pool_git = self._edition(DataSource.PROJECT_GITENBERG, Identifier.GUTENBERG_ID, with_license_pool=True, with_open_access_download=True, authors=[]) edition_git.title = u"The GItenberg Title" edition_git.subtitle = u"The GItenberg Subtitle" edition_git.add_contributor(bob, Contributor.AUTHOR_ROLE) edition_git.add_contributor(alice, Contributor.AUTHOR_ROLE) edition_gut, pool_gut = self._edition(DataSource.GUTENBERG, Identifier.GUTENBERG_ID, with_license_pool=True, with_open_access_download=True, authors=[]) edition_gut.title = u"The GUtenberg Title" edition_gut.subtitle = u"The GUtenberg Subtitle" edition_gut.add_contributor(bob, Contributor.AUTHOR_ROLE) work = self._work(presentation_edition=edition_git) for p in pool_gut, pool_std_ebooks: work.license_pools.append(p) work.calculate_presentation() return (work, pool_std_ebooks, pool_git, pool_gut, edition_std_ebooks, edition_git, edition_gut, alice, bob)
def get(self): message = '''<h1>List of Contributors</h1> <p>This lists all Contributors currently in the distribution system as of %s.</p> <table class="sortable" border=\"1\">''' % datetime.datetime.utcnow().isoformat(' ') message += '<tr><th>Row</th><th>Contributor</th><th>Key</th></tr><br />\n' query = Contributor.gql("") dists = [] for record in query: s = '<td>%s</td><td>%s</td>\n' % (record.avname, record.avkey) if (s in dists) == False: dists += [s] for i in range(0,len(dists)): message += '<tr><td>%d</td>%s' % (i+1, dists[i]) message += "</table>" self.response.out.write((head % 'Contributor List') + message + end)