Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory Class Reference
Inheritance diagram for ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory:
Inheritance graph
[legend]
Collaboration diagram for ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def manage_edit
def __getitem__
def objectIds
def objectValues
def objectItems
def getId
def addLogEntry
def getLogEntries
def getLabels
def labelVersion
def createBranch
def createVersion
def hasVersionId
def isLatestVersion
def getLatestVersion
def findBranchId
def getVersionById
def getVersionByLabel
def getVersionByDate
def getVersionIds

Public Attributes

 id

Static Public Attributes

tuple security = AccessControl.ClassSecurityInfo()
string meta_type = 'Version History'
tuple manage_options
string icon = 'misc_/ZopeVersionControl/VersionHistory.gif'
tuple manage_main = DTMLFile('dtml/VersionHistoryManageMain', globals())
 manage = manage_main
tuple manage_properties_form

Detailed Description

The ZopeVersionHistory build on the core VersionHistory class to 
   provide the Zope management interface and other product trappings.

Definition at line 24 of file ZopeVersionHistory.py.


Member Function Documentation

Definition at line 66 of file ZopeVersionHistory.py.

00066 
00067     def __getitem__(self, name):
00068         activity = self._branches.get(name)
00069         if activity is not None:
00070             return activity.__of__(self)
00071         raise KeyError, name

Here is the caller graph for this function:

def ZopeVersionControl.VersionHistory.VersionHistory.addLogEntry (   self,
  version_id,
  action,
  path = None,
  message = '' 
) [inherited]
Add a new log entry associated with this version history.

Definition at line 51 of file VersionHistory.py.

00051 
00052     def addLogEntry(self, version_id, action, path=None, message=''):
00053         """Add a new log entry associated with this version history."""
00054         entry = LogEntry(version_id, action, path, message)
00055         self._eventLog.addEntry(entry)

def ZopeVersionControl.VersionHistory.VersionHistory.createBranch (   self,
  branch_id,
  version_id 
) [inherited]
Create a new branch associated with the given branch_id. The
   new branch is rooted at the version named by version_id.

Definition at line 84 of file VersionHistory.py.

00084 
00085     def createBranch(self, branch_id, version_id):
00086         """Create a new branch associated with the given branch_id. The
00087            new branch is rooted at the version named by version_id."""
00088         if self._branches.has_key(branch_id):
00089             raise VersionControlError(
00090                 'Activity already exists: %s' % branch_id
00091                 )
00092         branch = BranchInfo(branch_id, version_id)
00093         self._branches[branch_id] = branch
00094         return branch

Here is the caller graph for this function:

def ZopeVersionControl.VersionHistory.VersionHistory.createVersion (   self,
  object,
  branch_id 
) [inherited]
Create a new version in the line of descent named by the given
   branch_id, returning the newly created version object.

Definition at line 96 of file VersionHistory.py.

00096 
00097     def createVersion(self, object, branch_id):
00098         """Create a new version in the line of descent named by the given
00099            branch_id, returning the newly created version object."""
00100         branch = self._branches.get(branch_id)
00101         if branch is None:
00102             branch = self.createBranch(branch_id, None)
00103         if branch.name != 'mainline':
00104             version_id = '%s.%d' % (branch.name, len(branch) + 1)
00105         else:
00106             version_id = '%d' % (len(branch) + 1)
00107         version = ZopeVersion(version_id, object)
00108 
00109         # Update the  predecessor, successor and branch relationships.
00110         # This is something of a hedge against the future. Versions will
00111         # always know enough to reconstruct their lineage without the help
00112         # of optimized data structures, which will make it easier to change
00113         # internals in the future if we need to.
00114         latest = branch.latest()
00115         if latest is not None:
00116             last = self._versions[latest]
00117             last.next = last.next + (version_id,)
00118             version.prev = latest
00119 
00120         # If the branch is not the mainline, store the branch name in the
00121         # version. Versions have 'mainline' as the default class attribute
00122         # which is the common case and saves a minor bit of storage space.
00123         if branch.name != 'mainline':
00124             version.branch = branch.name
00125 
00126         branch.append(version)
00127         self._versions[version_id] = version
00128         # Call saveState() only after version has been linked into the
00129         # database, ensuring it goes into the correct database.
00130         version.saveState(object)
00131         return version.__of__(self)

Here is the call graph for this function:

def ZopeVersionControl.VersionHistory.VersionHistory.findBranchId (   self,
  version_id 
) [inherited]
Given a version id, return the id of the branch of the version.
   Note that we cheat, since we can find this out from the id.

Definition at line 152 of file VersionHistory.py.

00152 
00153     def findBranchId(self, version_id):
00154         """Given a version id, return the id of the branch of the version.
00155            Note that we cheat, since we can find this out from the id."""
00156         parts = version_id.split('.')
00157         if len(parts) > 1:
00158             return parts[-2]
00159         return 'mainline'

Definition at line 47 of file VersionHistory.py.

00047 
00048     def getId(self):
00049         return self.id

Definition at line 62 of file VersionHistory.py.

00062 
00063     def getLabels(self):
00064         return self._labels.keys()

def ZopeVersionControl.VersionHistory.VersionHistory.getLatestVersion (   self,
  branch_id 
) [inherited]
Return the latest version object within the given branch, or
   None if the branch contains no versions.

Definition at line 144 of file VersionHistory.py.

00144 
00145     def getLatestVersion(self, branch_id):
00146         """Return the latest version object within the given branch, or
00147            None if the branch contains no versions."""
00148         branch = self._branches[branch_id]
00149         version = self._versions[branch.latest()]
00150         return version.__of__(self)

Return a sequence of the log entries for this version history.

Definition at line 57 of file VersionHistory.py.

00057 
00058     def getLogEntries(self):
00059         """Return a sequence of the log entries for this version history."""
00060         return self._eventLog.getEntries()

def ZopeVersionControl.VersionHistory.VersionHistory.getVersionByDate (   self,
  branch_id,
  timestamp 
) [inherited]
Return the last version committed in the given branch on or
   before the given time value. The timestamp should be a float
   (time.time format) value in UTC.

Definition at line 182 of file VersionHistory.py.

00182 
00183     def getVersionByDate(self, branch_id, timestamp):
00184         """Return the last version committed in the given branch on or
00185            before the given time value. The timestamp should be a float
00186            (time.time format) value in UTC."""
00187         branch = self._branches[branch_id]
00188         tvalue = int(timestamp / 60.0)
00189         while 1:
00190             # Try to find a version with a commit date <= the given time
00191             # using the timestamp index in the branch information.
00192             if branch.m_order:
00193                 try:
00194                     match = branch.m_date.maxKey(tvalue)
00195                     match = branch.m_order[branch.m_date[match]]
00196                     return self._versions[match].__of__(self)
00197                 except ValueError:
00198                     pass
00199 
00200             # If we've run out of lineage without finding a version with
00201             # a commit date <= the given timestamp, we return None. It is
00202             # up to the caller to decide what to do in this situation.
00203             if branch.root is None:
00204                 return None
00205             
00206             # If the branch has a root (a version in another branch), then
00207             # we check the root and do it again with the ancestor branch.
00208             rootver = self._versions[branch.root]
00209             if int(rootver.date_created / 60.0) < tvalue:
00210                 return rootver.__of__(self)
00211             branch = self._branches[rootver.branch]

def ZopeVersionControl.VersionHistory.VersionHistory.getVersionById (   self,
  version_id 
) [inherited]
Return the version object named by the given version id, or
   raise a VersionControlError if the version is not found.

Definition at line 161 of file VersionHistory.py.

00161 
00162     def getVersionById(self, version_id):
00163         """Return the version object named by the given version id, or
00164            raise a VersionControlError if the version is not found."""
00165         version = self._versions.get(version_id)
00166         if version is None:
00167             raise VersionControlError(
00168                 'Unknown version id: %s' % version_id
00169                 )
00170         return version.__of__(self)

Return the version associated with the given label, or None
   if no version matches the given label.

Definition at line 172 of file VersionHistory.py.

00172 
00173     def getVersionByLabel(self, label):
00174         """Return the version associated with the given label, or None
00175            if no version matches the given label."""
00176         version_id = self._labels.get(label)
00177         version = self._versions.get(version_id)
00178         if version is None:
00179             return None
00180         return version.__of__(self)

def ZopeVersionControl.VersionHistory.VersionHistory.getVersionIds (   self,
  branch_id = None 
) [inherited]
Return a sequence of version ids for the versions in this
   version history. If a branch_id is given, only version ids
   from that branch will be returned. Note that the sequence
   of ids returned does not include the id of the branch root.

Definition at line 213 of file VersionHistory.py.

00213 
00214     def getVersionIds(self, branch_id=None):
00215         """Return a sequence of version ids for the versions in this
00216            version history. If a branch_id is given, only version ids
00217            from that branch will be returned. Note that the sequence
00218            of ids returned does not include the id of the branch root."""
00219         if branch_id is not None:
00220             return self._branches[branch_id].versionIds()
00221         return self._versions.keys()
00222 
00223 InitializeClass(VersionHistory)
00224 

def ZopeVersionControl.VersionHistory.VersionHistory.hasVersionId (   self,
  version_id 
) [inherited]
Return true if history contains a version with the given id.

Definition at line 133 of file VersionHistory.py.

00133 
00134     def hasVersionId(self, version_id):
00135         """Return true if history contains a version with the given id."""
00136         return self._versions.has_key(version_id)

def ZopeVersionControl.VersionHistory.VersionHistory.isLatestVersion (   self,
  version_id,
  branch_id 
) [inherited]
Return true if version id is the latest in its branch.

Definition at line 138 of file VersionHistory.py.

00138 
00139     def isLatestVersion(self, version_id, branch_id):
00140         """Return true if version id is the latest in its branch."""
00141         branch = self._branches[branch_id]
00142         return version_id == branch.latest()

def ZopeVersionControl.VersionHistory.VersionHistory.labelVersion (   self,
  version_id,
  label,
  force = 0 
) [inherited]
Associate a particular version in a version history with the
   given label, removing any existing association with that label
   if force is true, or raising an error if force is false and
   an association with the given label already exists.

Definition at line 66 of file VersionHistory.py.

00066 
00067     def labelVersion(self, version_id, label, force=0):
00068         """Associate a particular version in a version history with the
00069            given label, removing any existing association with that label
00070            if force is true, or raising an error if force is false and
00071            an association with the given label already exists."""
00072         current = self._labels.get(label)
00073         if current is not None:
00074             if current == version_id:
00075                 return
00076             if not force:
00077                 raise VersionControlError(
00078                     'The label %s is already associated with a version.' % (
00079                      label
00080                     ))
00081             del self._labels[label]
00082         self._labels[label] = version_id

Change object properties.

Definition at line 58 of file ZopeVersionHistory.py.

00058 
00059     def manage_edit(self, REQUEST=None):
00060         """Change object properties."""
00061         if REQUEST is not None:
00062             message="Saved changes."
00063             return self.manage_properties_form(
00064                 self, REQUEST, manage_tabs_message=message
00065                 )

Here is the caller graph for this function:

Definition at line 73 of file ZopeVersionHistory.py.

00073 
00074     def objectIds(self, spec=None):
00075         return self._branches.keys()

Here is the caller graph for this function:

Definition at line 81 of file ZopeVersionHistory.py.

00081 
00082     def objectItems(self, spec=None):
00083         return self._branches.items()
00084 
00085 InitializeClass(ZopeVersionHistory)
00086 
00087 

Here is the caller graph for this function:

Definition at line 77 of file ZopeVersionHistory.py.

00077 
00078     def objectValues(self, spec=None):
00079         return self._branches.values()

Here is the caller graph for this function:


Member Data Documentation

string ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory.icon = 'misc_/ZopeVersionControl/VersionHistory.gif' [static]

Definition at line 43 of file ZopeVersionHistory.py.

Definition at line 42 of file VersionHistory.py.

Definition at line 48 of file ZopeVersionHistory.py.

tuple ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory.manage_main = DTMLFile('dtml/VersionHistoryManageMain', globals()) [static]

Definition at line 46 of file ZopeVersionHistory.py.

Initial value:
(
        ( {'label': 'Contents',    'action':'manage_main',
           'help': ('ZopeVersionControl', 'VersionHistory-Manage.stx')},
          {'label': 'Properties', 'action':'manage_properties_form',
           'help': ('ZopeVersionControl', 'VersionHistory-Properties.stx')},
        ) +
        AccessControl.Role.RoleManager.manage_options +
        OFS.SimpleItem.Item.manage_options
        )

Definition at line 33 of file ZopeVersionHistory.py.

Initial value:
DTMLFile(
        'dtml/VersionHistoryProperties', globals()
        )

Definition at line 53 of file ZopeVersionHistory.py.

Definition at line 31 of file ZopeVersionHistory.py.

tuple ZopeVersionControl.ZopeVersionHistory.ZopeVersionHistory.security = AccessControl.ClassSecurityInfo() [static]

Reimplemented from ZopeVersionControl.VersionHistory.VersionHistory.

Definition at line 28 of file ZopeVersionHistory.py.


The documentation for this class was generated from the following file: