Commits

Donald Stufft  committed 0fd0fd8

Include the last serial in a header on the simple pages

  • Participants
  • Parent commits 25291b4

Comments (0)

Files changed (2)

         safe_execute(cursor, 'select max(id) from journals j')
         return cursor.fetchone()[0]
 
+    def last_serial_for_package(self, package):
+        cursor = self.get_cursor()
+        safe_execute(cursor, """
+            SELECT id FROM journals WHERE name = %s ORDER BY id DESC LIMIT 1
+        """, (package,))
+        return cursor.fetchone()[0]
+
     def changed_packages(self, since):
         "Fetch list of names of packages changed 'since'"
         assert isinstance(since, int)
         path = path[:-1]
         if '/' not in path:
             html = self.simple_body(path)
+            serial = self.store.last_serial_for_package(path)
             self.handler.send_response(200, 'OK')
             if accept_encoding == 'gzip':
                 stream = cStringIO.StringIO()
             self.handler.set_content_type('text/html; charset=utf-8')
             self.handler.send_header('Content-Length', str(len(html)))
             self.handler.send_header("Surrogate-Key", "simple pkg~%s" % safe_name(path).lower())
+            self.handler.send_header("X-PYPI-LAST-SERIAL", str(serial))
             self.handler.end_headers()
             self.wfile.write(html)
             return
         if '/' in path:
             raise NotFound, path
         html = self.simple_body(path)
+        serial = self.store.last_serial_for_package(path)
         if not self.privkey:
             self.privkey = DSA.load_key(os.path.join(self.config.key_dir, 'privkey'))
         md = EVP.MessageDigest('sha1')
         self.handler.send_response(200, 'OK')
         self.handler.set_content_type('application/octet-stream')
         self.handler.send_header("Surrogate-Key", "simple pkg~%s" % safe_name(path).lower())
+        self.handler.send_header("X-PYPI-LAST-SERIAL", str(serial))
         self.handler.end_headers()
         self.wfile.write(sig)