comparison MoinMoin/items/__init__.py @ 38:1d8e9b1153d6

docstrings: convert epydoc fields to rst/sphinx fields
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 28 Feb 2011 04:34:17 +0100
parents 4cd8edde9e94
children d43c7fb728e0
comparison
equal deleted inserted replaced
37:74a543f57ce7 38:1d8e9b1153d6
462 def before_revision_commit(self, newrev, data): 462 def before_revision_commit(self, newrev, data):
463 """ 463 """
464 hook that can be used to add more meta data to a revision before 464 hook that can be used to add more meta data to a revision before
465 it is committed. 465 it is committed.
466 466
467 @param newrev: new (still uncommitted) revision - modify as wanted 467 :param newrev: new (still uncommitted) revision - modify as wanted
468 @param data: either str or open file (we can avoid having to read/seek 468 :param data: either str or open file (we can avoid having to read/seek
469 rev's data with this) 469 rev's data with this)
470 """ 470 """
471 remote_addr = request.remote_addr 471 remote_addr = request.remote_addr
472 if remote_addr: 472 if remote_addr:
473 newrev[ADDRESS] = unicode(remote_addr) 473 newrev[ADDRESS] = unicode(remote_addr)
728 728
729 def get_member(self, name): 729 def get_member(self, name):
730 """ 730 """
731 return a file-like object with the member file data 731 return a file-like object with the member file data
732 732
733 @param name: name of the data in the container file 733 :param name: name of the data in the container file
734 """ 734 """
735 self.rev.seek(0) 735 self.rev.seek(0)
736 tf = tarfile.open(fileobj=self.rev, mode='r') 736 tf = tarfile.open(fileobj=self.rev, mode='r')
737 return tf.extractfile(name) 737 return tf.extractfile(name)
738 738
740 """ 740 """
741 puts a new member file into a temporary tar container. 741 puts a new member file into a temporary tar container.
742 If all expected members have been put, it saves the tar container 742 If all expected members have been put, it saves the tar container
743 to a new item revision. 743 to a new item revision.
744 744
745 @param name: name of the data in the container file 745 :param name: name of the data in the container file
746 @param content: the data to store into the tar file (str or file-like) 746 :param content: the data to store into the tar file (str or file-like)
747 @param content_length: byte-length of content (for str, None can be given) 747 :param content_length: byte-length of content (for str, None can be given)
748 @param expected_members: set of expected member file names 748 :param expected_members: set of expected member file names
749 """ 749 """
750 if not name in expected_members: 750 if not name in expected_members:
751 raise StorageError("tried to add unexpected member %r to container item %r" % (name, self.name)) 751 raise StorageError("tried to add unexpected member %r to container item %r" % (name, self.name))
752 if isinstance(name, unicode): 752 if isinstance(name, unicode):
753 name = name.encode('utf-8') 753 name = name.encode('utf-8')
803 803
804 def get_member(self, name): 804 def get_member(self, name):
805 """ 805 """
806 return a file-like object with the member file data 806 return a file-like object with the member file data
807 807
808 @param name: name of the data in the zip file 808 :param name: name of the data in the zip file
809 """ 809 """
810 self.rev.seek(0) 810 self.rev.seek(0)
811 zf = zipfile.ZipFile(self.rev, mode='r') 811 zf = zipfile.ZipFile(self.rev, mode='r')
812 return zf.open(name, mode='r') 812 return zf.open(name, mode='r')
813 813