[Zapp-cvs-commit] ZApp ZApp_CMFBase.py,1.24,1.25 __init__.py,1.19,1.20
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2004-01-16 09:55:41
|
Update of /cvsroot/zapp/ZApp
In directory sc8-pr-cvs1:/tmp/cvs-serv22109
Modified Files:
ZApp_CMFBase.py __init__.py
Log Message:
file system based image handling for Plone
Index: ZApp_CMFBase.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** ZApp_CMFBase.py 12 Jan 2004 14:25:16 -0000 1.24
--- ZApp_CMFBase.py 16 Jan 2004 09:55:34 -0000 1.25
***************
*** 14,18 ****
missing = []
! dbug_level = 100
lpcol = LeverPropertyCollection
--- 14,18 ----
missing = []
! dbug_level = 0
lpcol = LeverPropertyCollection
***************
*** 65,69 ****
class_default_for_copyable = 0 # make these guys default to 'not copyable'
! _custom_skin_scripts = ('WHEN OBJECT CHANGED STORE portal_type using self.change(cmf_portal_type=self.portal_type)',)
_primaryKeyStringSize=255 # allow for a pretty rediculous size...
--- 65,77 ----
class_default_for_copyable = 0 # make these guys default to 'not copyable'
! # we're converting our primaru key to an URL that points to filesystem
! # src="http://hecxs.spvi.net:9180/HECPlone/fSystem/HECPlone/HEC/Media/Foods/clay.jpg"
!
! _custom_skin_scripts = ('WHEN OBJECT CHANGED STORE portal_type using self.change(cmf_portal_type=self.portal_type)',
! "WITH SELF COMPUTE portal_object_id=_.getattr(self, 'zapp_portal_id')",
! "WITH SELF COMPUTE portal_object=_.getattr(self.findApplication(), self.portal_object_id)"
! "WITH SELF COMPUTE graphic_url=self.findApplication().absolute_url() + ( '/fSystem/%s/%s/%s' % (self.getPhysicalPath()[1], self.portal_object_id, self.cmfdataid[1:].replace(',','/')))",
! )
!
_primaryKeyStringSize=255 # allow for a pretty rediculous size...
***************
*** 300,339 ****
extendProperties(ZApp_CMFBase, props)
! def addZAppCMFObject(self, id, title='', klass=ZApp_CMFBase, useExisting=1):
!
! #
! # since we're a FreeRangeDataSkin.. we can get our data manager here..
! #
!
! existingObject = None
!
! if id.find(',') != -1:
! raise RuntimeError, "Sorry.. no ',' allowed in id!"
! if useExisting:
! dm = self.getDataManagerFor( klass, None )
!
! if dm != None:
! objPath = ','.join(self.getPhysicalPath()) + ',' + id
! portalPath = ','.join(self.portal_url.getPortalObject().getPhysicalPath()) + ','
! checkID = objPath[len(portalPath):]
! existingObject = dm.getItem(checkID)
! if existingObject:
! o = existingObject
! o.id = id
! o.title = title
! else:
! o = klass()
! o = o.__of__(self)
! o.id = id
! o.title = title
! self._setObject(id, o)
! initCMFObjectMetadata(o)
! o.change()
! if klass != ZApp_CMFBase:
! return o
from DateTime import DateTime
--- 308,323 ----
extendProperties(ZApp_CMFBase, props)
! class ZApp_CMF_FSObject( ZApp_CMFBase ):
! meta_type = 'ZApp CMF FSObject'
! _custom_skin_scripts = ("WITH SELF COMPUTE portal_object_id=_.getattr(self, 'zapp_portal_id')",
! "WITH SELF COMPUTE portal_object=_.getattr(self.findApplication(), self.portal_object_id)"
! "WITH SELF COMPUTE fs_object_url=self.findApplication().absolute_url() + ( '/fSystem/%s/%s/%s' % (self.getPhysicalPath()[1], self.portal_object_id, self.cmfdataid[1:].replace(',','/')))",
! )
! class ZApp_CMF_FSImage( ZApp_CMF_FSObject):
! meta_type = 'ZApp CMF FSImage'
from DateTime import DateTime
***************
*** 354,362 ****
{'id': 'ZApp CMF Image',
'title':'',
! 'meta_type' : 'ZApp CMF Image',
'product': 'ZApp',
'description':'Image Content type based on ZApp objects',
'icon':'image_icon.gif',
! 'factory': 'addZAppCMFObject',
'immediate_view': 'zapp_image_edit_form',
'actions': ({'id': 'view',
--- 338,346 ----
{'id': 'ZApp CMF Image',
'title':'',
! 'meta_type' : ZApp_CMF_FSImage.meta_type,
'product': 'ZApp',
'description':'Image Content type based on ZApp objects',
'icon':'image_icon.gif',
! 'factory': 'addZAppCMFImage',
'immediate_view': 'zapp_image_edit_form',
'actions': ({'id': 'view',
***************
*** 374,402 ****
),
},
- {'id': 'ZApp CMF File',
- 'title':'',
- 'meta_type' : 'ZApp CMF File',
- 'product': 'ZApp',
- 'description':'File Content type based on ZApp objects',
- 'icon':'file_icon.gif',
- 'factory': 'addZAppCMFObject',
- 'immediate_view': 'zapp_file_edit_form',
- 'actions': ({'id': 'view',
- 'name': 'View',
- 'action': 'zapp_file_view',
- 'permissions': (CMFCorePermissions.View,)},
- {'id': 'edit',
- 'name': 'Edit',
- 'action': 'zapp_file_edit_form',
- 'permissions': (CMFCorePermissions.ModifyPortalContent,)},
- { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (CMFCorePermissions.ModifyPortalContent,)},
- ),
- },
{'id': 'ZApp CMF Content',
'title':'',
! 'meta_type' : 'ZApp CMF Content',
'product': 'ZApp',
'description':'Content type based on ZApp objects',
--- 358,364 ----
),
},
{'id': 'ZApp CMF Content',
'title':'',
! 'meta_type' : ZApp_CMFBase.meta_type,
'product': 'ZApp',
'description':'Content type based on ZApp objects',
***************
*** 433,434 ****
--- 395,440 ----
+ def addZAppCMFObject(self, id, title='', klass=ZApp_CMFBase, useExisting=1):
+
+ #
+ # since we're a FreeRangeDataSkin.. we can get our data manager here..
+ #
+
+ existingObject = None
+
+ if id.find(',') != -1:
+ raise RuntimeError, "Sorry.. no ',' allowed in id!"
+
+ if useExisting:
+ dm = self.getDataManagerFor( klass, None )
+
+ if dm != None:
+ objPath = ','.join(self.getPhysicalPath()) + ',' + id
+ portalPath = ','.join(self.portal_url.getPortalObject().getPhysicalPath()) + ','
+ checkID = objPath[len(portalPath):]
+ existingObject = dm.getItem(checkID)
+
+ if existingObject:
+ o = existingObject
+ o.id = id
+ o.title = title
+ else:
+ o = klass()
+ o = o.__of__(self)
+ o.id = id
+ o.title = title
+
+ self._setObject(id, o)
+ initCMFObjectMetadata(o)
+ o.change()
+
+ if klass not in [ZApp_CMFBase, ZApp_CMF_FSObject, ZApp_CMF_FSImage]:
+ return o
+
+
+ def addZAppCMFImage(self, id, title='', klass=ZApp_CMF_FSImage, useExisting=1):
+ """
+ add a CMFImage object.. pass in the right class...
+ """
+
+ return addZAppCMFObject(self, id, title, klass, useExisting)
Index: __init__.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/__init__.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** __init__.py 4 Dec 2003 22:25:59 -0000 1.19
--- __init__.py 16 Jan 2004 09:55:34 -0000 1.20
***************
*** 52,61 ****
if do_cmf:
context.registerBaseClass(ZApp_CMFBase.ZApp_CMFBase)
utils.ContentInit(
! 'ZAppCMFContent',
! content_types = (ZApp_CMFBase.ZApp_CMFBase,),
permission = AddPortalContent,
! extra_constructors = (ZApp_CMFBase.addZAppCMFObject,),
fti=ZApp_CMFBase.factory_type_information,
).initialize(context)
--- 52,62 ----
if do_cmf:
context.registerBaseClass(ZApp_CMFBase.ZApp_CMFBase)
+ context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSImage)
utils.ContentInit(
! 'ZApp CMF Content',
! content_types = (ZApp_CMFBase.ZApp_CMFBase, ZApp_CMFBase.ZApp_CMF_FSImage),
permission = AddPortalContent,
! extra_constructors = (ZApp_CMFBase.addZAppCMFObject, ZApp_CMFBase.addZAppCMFImage),
fti=ZApp_CMFBase.factory_type_information,
).initialize(context)
|