comparison MoinMoin/storage/middleware/indexing.py @ 1918:f0b346ac6338

added return_rev param to store_revision() to avoid returning a revision object without need
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Jan 2013 23:36:37 +0100
parents 4a054063fbb0
children 2bd864ed640e 5281fec759b1
comparison
equal deleted inserted replaced
1917:16ea00a08d51 1918:f0b346ac6338
862 userid=None, 862 userid=None,
863 wikiname=None, 863 wikiname=None,
864 contenttype_current=None, 864 contenttype_current=None,
865 contenttype_guessed=None, 865 contenttype_guessed=None,
866 acl_parent=None, 866 acl_parent=None,
867 return_rev=False,
867 ): 868 ):
868 """ 869 """
869 Store a revision into the backend, write metadata and data to it. 870 Store a revision into the backend, write metadata and data to it.
870 871
871 Usually this will be a new revision, either of an existing item or 872 Usually this will be a new revision, either of an existing item or
873 revisions. 874 revisions.
874 875
875 :type meta: dict 876 :type meta: dict
876 :type data: open file (file must be closed by caller) 877 :type data: open file (file must be closed by caller)
877 :param overwrite: if True, allow overwriting of existing revs. 878 :param overwrite: if True, allow overwriting of existing revs.
878 :returns: a Revision instance of the just created revision 879 :param return_rev: if True, return a Revision instance of the just created revision
880 :returns: a Revision instance or None
879 """ 881 """
880 if remote_addr is None: 882 if remote_addr is None:
881 try: 883 try:
882 # if we get here outside a request, this won't work: 884 # if we get here outside a request, this won't work:
883 remote_addr = unicode(request.remote_addr) 885 remote_addr = unicode(request.remote_addr)
935 revid = backend.store(meta, data) 937 revid = backend.store(meta, data)
936 meta[REVID] = revid 938 meta[REVID] = revid
937 self.indexer.index_revision(meta, content) 939 self.indexer.index_revision(meta, content)
938 if not overwrite: 940 if not overwrite:
939 self._current = self.indexer._document(revid=revid) 941 self._current = self.indexer._document(revid=revid)
940 return Revision(self, revid) 942 if return_rev:
943 return Revision(self, revid)
941 944
942 def store_all_revisions(self, meta, data): 945 def store_all_revisions(self, meta, data):
943 """ 946 """
944 Store over all revisions of this item. 947 Store over all revisions of this item.
945 """ 948 """