[Zapp-cvs-commit] ZApp ZApp_Replicator.py,NONE,1.1 ZApp_CMFBase.py,1.21,1.22
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2004-01-05 22:27:13
|
Update of /cvsroot/zapp/ZApp
In directory sc8-pr-cvs1:/tmp/cvs-serv29488
Modified Files:
ZApp_CMFBase.py
Added Files:
ZApp_Replicator.py
Log Message:
add replication capability to ZApp objects
--- NEW FILE: ZApp_Replicator.py ---
#
# ZApp Replicator, a mixin class to enable sharing of data with another object type...
#
from ComputedAttribute import ComputedAttribute
class ZApp_Replicator:
"""
ZApp_Replicator is meant to be mixed in with a ZApp_Base subclass.
"""
class_default_for_replication_specialists = ()
def getReplicationManager(self):
"""
return the name of my replication manager
"""
return self.getMySpecialist().getId()
_v_rep_manager = ComputedAttribute( getReplicationManager )
def replicateSelf(self):
"""
a change or create event has occurred. Update other specialists with my info..
RuntimeError is raised if there is a serious problem..
"""
app = self.findApplication()
if not app:
app = self.getApplication() # try CMF skin method if we are not in app scope..
if not app:
return # punt... we can't replicate from here...
for spec_id in self.replication_specialists:
spec = app.getSpecialist( spec_id )
if spec:
myReps = spec.ZApp_getItems( objectID=self.id, manager=self._v_repManager, createIfNone=1)
if len(myReps) == 1:
myRep = myReps[0]
myRep.doUpdateRep( self )
else:
raise RuntimeError, "Too many reps?"
else:
raise RuntimeError, "Can't find specialist:" + spec_id
class ZApp_Replicatee:
def class_default_for_doUpdateRep( self, other ):
"""
dummy method. Replace with subclass, or skinscript.
"""
pass
Index: ZApp_CMFBase.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** ZApp_CMFBase.py 2 Jan 2004 22:07:01 -0000 1.21
--- ZApp_CMFBase.py 5 Jan 2004 22:27:10 -0000 1.22
***************
*** 12,15 ****
--- 12,16 ----
from ZApp_LOG import ZApp_LOG
+
missing = []
dbug_level = 0
***************
*** 39,42 ****
--- 40,44 ----
from Acquisition import ImplicitAcquisitionWrapper,aq_base
from ZApp_DublinCoreMixin import ZApp_DublinCoreMixin
+ from ZApp_Replicator import ZApp_Replicator
from DateTime import DateTime
***************
*** 44,48 ****
import tempfile
! class ZApp_CMFBase(FreeRangeDS, SkinnedFolder, ZApp_Base, ZApp_DublinCoreMixin, ZApp_MiscDataUser, ZApp_RelatedObject):
meta_type = 'ZApp CMF Content'
--- 46,50 ----
import tempfile
! class ZApp_CMFBase(FreeRangeDS, SkinnedFolder, ZApp_Base, ZApp_DublinCoreMixin, ZApp_MiscDataUser, ZApp_RelatedObject, ZApp_Replicator):
meta_type = 'ZApp CMF Content'
***************
*** 96,100 ****
result = objPath[len(portalPath)-1:]
except:
! raise
return result
--- 98,102 ----
result = objPath[len(portalPath)-1:]
except:
! result = getattr(self, self.getPrimaryKey(), "IMPOSSIBLE_PATH_ID")
return result
|