def init_configuration_data(self): '''Default configuration, for when CKAN is first used out of the box. This state may be subsequently configured by the user.''' init_authz_configuration_data() if meta.Session.query(Revision).count() == 0: rev = Revision() rev.author = 'system' rev.message = u'Initialising the Repository' Session.add(rev) self.commit_and_remove()
def _get_revision(self, rev = None, pos = None): """ Get a revision record for given revision. Find the given rev revision record from the pos file position. If no rev is given, find the next revision record from the pos file position. If pos not given revision record is searched from the current file position. Args: rev (long): Revision number to get. Default to None. pos (long): File pointer in fs where rev will be searched. Return: tuple: With tuple containing 3 elements. All elements will 'None' if revision not found else index for the elements are as follows... 0) (long) First element is a file pointer to the begining of the revision. 1) (long) Size of the revision record. 2) (dict) revision record. """ fs = self._dump_fptr if pos is not None: fs.seek(pos) rrec = Revision() filepos = fs.tell() found_record = False found_pos = 0 # Revision record starts of with the "Revision-number:" and ends with # new line "\n". line = fs.readline() while line != "": s = line.split(":", 1) if (s[0] == self.REVISION_STR) and \ (rev is None or long(s[1]) == rev): # A revision is found or a requested revision is found. found_record = True found_pos = filepos if found_record == True: rrec.update(line, 0) if found_record == True and s[0] == '\n': found_record = False rrec.set_offset(found_pos) return rrec filepos = fs.tell() line = fs.readline() # Nothing to return. return None