[Zope-CVS] Re: CVS: Products/ZopeVersionControl - Repository.py:1.11

Casey Duncan casey at zope.com
Wed Feb 25 08:34:33 EST 2004


Just curious: Why not use a marker interface instead of a magic
attribute to flag non-versionableness?

-Casey

On Tue, 24 Feb 2004 13:32:54 -0500
Ken Manheimer <klm at zope.com> wrote:

> Update of /cvs-repository/Products/ZopeVersionControl
> In directory cvs.zope.org:/tmp/cvs-serv13474
> 
> Modified Files:
> 	Repository.py 
> Log Message:
> Make __non_versionable__ the canonical and sole attribute used for
> exempting an object from versioning.  Also, export a function named
> 'isAVersionableResource' for use in VersionSupport, so we use the
> exact same function there and in the Repository class.
> 
> This reconciliation will rectify the test i changed which expects
> __non_versionable__ to be the exemption.
> 
> 
> === Products/ZopeVersionControl/Repository.py 1.10 => 1.11 ===
> --- Products/ZopeVersionControl/Repository.py:1.10	Fri Jan 30 13:59:39 2004
> +++ Products/ZopeVersionControl/Repository.py	Tue Feb 24 13:32:54 2004
> @@ -30,6 +30,16 @@
>  from nonversioned import getNonVersionedData, restoreNonVersionedData
>  
>  
> +def isAVersionableResource(obj):
> +    """ True if an object is versionable.
> +
> +    To qualify, the object must be persistent (have its own db
> record), and+    must not have an true attribute named
> '__non_versionable__'."""+
> +    if getattr(obj, '__non_versionable__', 0):
> +        return 0
> +    return hasattr(obj, '_p_oid')
> +
>  class Repository(Implicit, Persistent):
>      """The repository implementation manages the actual data of
>      versions
>         and version histories. It does not handle user interface
>         issues."""
> @@ -95,9 +105,7 @@
>      def isAVersionableResource(self, obj):
>          # For now, an object must be persistent (have its own db
>          # record) in order to be considered a versionable resource.
> -        if not getattr(obj, '_versionable', 1):
> -            return 0
> -        return hasattr(obj, '_p_oid')
> +        return isAVersionableResource(obj)
>  
>      security.declarePublic('isUnderVersionControl')
>      def isUnderVersionControl(self, object):
> 
> 
> _______________________________________________
> Zope-CVS maillist  -  Zope-CVS at zope.org
> http://mail.zope.org/mailman/listinfo/zope-cvs
> 
> Zope CVS instructions: http://dev.zope.org/CVS
> 




More information about the Zope-CVS mailing list