def save(self, req): distro_id = self.distro.distro_id indexname = self.indexname updated = simplejson.loads(req.body or '{}') entries = updated['entries'] if self.pypi.index_manager.has_index(distro_id, indexname): self.pypi.index_manager.remove_index(distro_id, indexname) for x in entries: target_name, opt, target_version = utils.parse_req_parts(x) if opt not in ('==', '='): raise ValueError('Bad req option "%s" for "%s"' % (str(opt), x)) target_distro_id = utils.make_distro_id(target_name) self.pypi.index_manager.add_index_item(distro_id, indexname, target_distro_id, target_version) return http.ok([], simplejson.dumps({'entries': entries}))
def put(self, req): distro_id = self.distro.distro_id updated = simplejson.loads(req.body or '{}') altered = [] for indexdict in updated['indexes']: indexname = indexdict['indexname'] altered.append(indexname) entries = indexdict['entries'] self.pypi.index_manager.remove_index(distro_id, indexname) for x in entries: target_name, opt, target_version = utils.parse_req_parts(x) if opt not in ('==', '='): raise ValueError('Bad req option "%s" for "%s"' % (str(opt), x)) target_distro_id = utils.make_distro_id(target_name) self.pypi.index_manager.add_index_item(distro_id, indexname, target_distro_id, target_version) return http.ok([], simplejson.dumps({'indexes': altered}))