From python-checkins at python.org Thu Feb 2 00:38:10 2012 From: python-checkins at python.org (richard) Date: Thu, 2 Feb 2012 00:38:10 +0100 (CET) Subject: [Pypi-checkins] r1008 - trunk/pypi/templates Message-ID: <3Tdgr21b2RzQ9R@mail.python.org> Author: richard Date: Thu Feb 2 00:38:09 2012 New Revision: 1008 Modified: trunk/pypi/templates/standard_template.pt Log: let's see if this helps Modified: trunk/pypi/templates/standard_template.pt ============================================================================== --- trunk/pypi/templates/standard_template.pt (original) +++ trunk/pypi/templates/standard_template.pt Thu Feb 2 00:38:09 2012 @@ -75,14 +75,16 @@
  • Python 3 packages
  • -
  • Tutorial
  • +
  • PyPI Tutorial
  • -
  • Get - help
  • -
  • Bug - reports
  • -
  • Comments
  • -
  • Developers
  • +
  • PyPI + support
  • +
  • PyPI + Bug reports
  • +
  • PyPI discussion
  • +
  • PyPI + Developer info
  • From python-checkins at python.org Thu Feb 2 02:44:21 2012 From: python-checkins at python.org (richard) Date: Thu, 2 Feb 2012 02:44:21 +0100 (CET) Subject: [Pypi-checkins] r1009 - trunk/pypi/templates Message-ID: <3Tdkdd343GzQQ8@mail.python.org> Author: richard Date: Thu Feb 2 02:44:21 2012 New Revision: 1009 Modified: trunk/pypi/templates/standard_template.pt Log: consistency Modified: trunk/pypi/templates/standard_template.pt ============================================================================== --- trunk/pypi/templates/standard_template.pt (original) +++ trunk/pypi/templates/standard_template.pt Thu Feb 2 02:44:21 2012 @@ -73,18 +73,18 @@ -
  • Python 3 packages
  • +
  • Python 3 Packages
  • PyPI Tutorial
  • PyPI - support
  • + Support
  • PyPI - Bug reports
  • -
  • PyPI discussion
  • + Bug Reports +
  • PyPI Discussion
  • PyPI - Developer info
  • + Developer Info From python-checkins at python.org Mon Feb 6 01:08:59 2012 From: python-checkins at python.org (richard) Date: Mon, 6 Feb 2012 01:08:59 +0100 (CET) Subject: [Pypi-checkins] r1010 - trunk/pypi Message-ID: <3Th8Kl2QL8zMJm@mail.python.org> Author: richard Date: Mon Feb 6 01:08:59 2012 New Revision: 1010 Modified: trunk/pypi/rpc.py trunk/pypi/store.py trunk/pypi/webui.py Log: add docs url to the XML-RPC meta-data Modified: trunk/pypi/rpc.py ============================================================================== --- trunk/pypi/rpc.py (original) +++ trunk/pypi/rpc.py Mon Feb 6 01:08:59 2012 @@ -113,6 +113,7 @@ info['package_url'] = 'http://pypi.python.org/pypi/%s' % package_name info['release_url'] = 'http://pypi.python.org/pypi/%s/%s' % (package_name, version) + info['docs_url'] = store.docs_url(package_name) return info package_data = release_data # "deprecated" Modified: trunk/pypi/store.py ============================================================================== --- trunk/pypi/store.py (original) +++ trunk/pypi/store.py Mon Feb 6 01:08:59 2012 @@ -536,8 +536,8 @@ _Package = FastResultRow('''name stable_version version author author_email maintainer maintainer_email home_page license summary description - description_html keywords platform requires_python download_url - _pypi_ordering! _pypi_hidden! cheesecake_installability_id! + description_html keywords platform requires_python download_url + _pypi_ordering! _pypi_hidden! cheesecake_installability_id! cheesecake_documentation_id! cheesecake_code_kwalitee_id! bugtrack_url!''') def get_package(self, name, version): ''' Retrieve info about the package from the database. @@ -549,7 +549,7 @@ author_email, maintainer, maintainer_email, home_page, license, summary, description, description_html, keywords, platform, requires_python, download_url, _pypi_ordering, - _pypi_hidden, + _pypi_hidden, cheesecake_installability_id, cheesecake_documentation_id, cheesecake_code_kwalitee_id, bugtrack_url @@ -731,7 +731,7 @@ ''' cursor = self.get_cursor() safe_execute(cursor, '''select specifier from release_dependencies where - name=%s and version=%s and kind=%s''', (name, version, + name=%s and version=%s and kind=%s''', (name, version, getattr(dependency, relationship))) return Result(None, cursor.fetchall(), self._Release_Relationships) @@ -749,7 +749,7 @@ safe_execute(cursor, '''select filename, downloads from release_files where name=%s and version=%s''', (name, version)) return cursor.fetchall() - + _Package_Roles = FastResultRow('role_name package_name') def get_user_packages(self, name): '''Fetch all packages and roles associated to user.''' @@ -757,7 +757,7 @@ safe_execute(cursor, '''select role_name, package_name from roles where user_name=%s''', (name,)) return Result(None, cursor.fetchall(), self._Package_Roles) - + _Package_Roles = FastResultRow('role_name user_name') def get_package_roles(self, name): ''' Fetch the list of Roles for the package. @@ -1488,7 +1488,7 @@ safe_execute(cursor, '''delete from cookies where name=%s''', (user,)) - # every other reference should either be cascading, + # every other reference should either be cascading, # or it's a bug to break it # delete user account itself @@ -1723,6 +1723,18 @@ self.username, self.userip)) + def docs_url(self, name): + '''Determine the local (packages.python.org) documentation URL, if any. + + Returns the URL or '' if there are no docs. + ''' + for sub in [[], ['html']]: + path = [self.config.database_docs_dir, + name.encode('utf8')] + sub + ['index.html'] + if os.path.exists(os.path.join(*path)): + return '/'.join(['http://packages.python.org', name] + sub) + return '' + def update_upload_times(self): cursor = self.get_cursor() safe_execute(cursor, @@ -1799,7 +1811,7 @@ safe_execute(cursor, 'delete from cookies where cookie=%s', (cookie,)) # CSRF Protection - + def get_token(self, username): '''Return csrf current token for user.''' cursor = self.get_cursor() @@ -1810,7 +1822,7 @@ if not token: return self.create_token(username) return token[0][0] - + def create_token(self, username): '''Create and return a new csrf token for user.''' alphanum = string.ascii_letters + string.digits @@ -1824,7 +1836,7 @@ # no cookie, make one cookie = ''.join(random.choice(alphanum) for i in range(10)) - # create random data + # create random data rand = [random.choice(alphanum) for i in range(12)] rand.append(str(int(time.time()))) rand.append(cookie) @@ -1837,7 +1849,7 @@ safe_execute(cursor, 'delete from csrf_tokens where name=%s', (username,)) sql = '''insert into csrf_tokens values(%s, %s, NOW()+interval \'15 minutes\')''' - safe_execute(cursor, sql, (username, rand)) + safe_execute(cursor, sql, (username, rand)) return rand @@ -1974,7 +1986,7 @@ safe_execute(cursor, '''insert into openid_whitelist( name, trust_root, created) values(%s,%s,%s)''', (username, trusted_root, now)) - + def check_openid_trustedroot(self, username, trusted_root): """Check trusted_root is in user's whitelist""" cursor = self.get_cursor() @@ -1985,7 +1997,7 @@ return True else: return False - + def log_keyrotate(self): cursor = self.get_cursor() date = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime()) Modified: trunk/pypi/webui.py ============================================================================== --- trunk/pypi/webui.py (original) +++ trunk/pypi/webui.py Mon Feb 6 01:08:59 2012 @@ -1424,12 +1424,7 @@ project_url = self.store.get_package_project_url(name, version) requires_external = self.store.get_package_requires_external(name, version) - docs = '' - for sub in [[], ['html']]: - path = [self.config.database_docs_dir, name.encode('utf8')] + sub + ['index.html'] - if os.path.exists(os.path.join(*path)): - docs = '/'.join(['http://packages.python.org', name] + sub) - + docs = self.store.docs_url(name) files = self.store.list_files(name, version) self.write_template('display.pt',