Commits

Jason R. Coombs  committed a75681d

Fixed two issues with the new code causing failing tests.

  • Participants
  • Parent commits bc6e77e
  • Branches registering-parts

Comments (0)

Files changed (2)

File openpack/basepack.py

 	"A mixin class for packages and parts; both support relationships."
 	def relate(self, part, id=None):
 		"""Relate this package component to the supplied part."""
-		name = part.name.lstrip(self.base).lstrip('/')
+		assert part.name.startswith(self.base)
+		name = part.name[len(self.base):].lstrip('/')
 		rel = Relationship(self, name, part.rel_type, id=id)
 		self.relationships.add(rel)
 		return rel
 		part = cls(self, name)
 		part.load(data)
 		self[name] = part
+		return part
 
 	def __repr__(self):
 		return "Package-%s" % id(self)

File openpack/zippack.py

 					continue
 				target_path = to_zip_name(pname)
 				data = "".join(self._get_matching_segments(zf, target_path))
-				self._load_part(rel.type, pname, data)
-				ropen(self[pname])
+				new_part = self._load_part(rel.type, pname, data)
+				if new_part: ropen(new_part)
 		ropen(self)
 		zf.close()