[Zapp-cvs-commit] ZApp ZApp_Application.py,1.34,1.35 ZApp_Base.py,1.22,1.23 ZApp_CMFBase.py,1.43,1.4
Brought to you by:
sspickle
|
From: Steve S. <ssp...@us...> - 2004-03-30 17:18:07
|
Update of /cvsroot/zapp/ZApp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10277 Modified Files: ZApp_Application.py ZApp_Base.py ZApp_CMFBase.py ZApp_MiscData.py ZApp_Specialist.py __init__.py Log Message: fixin' bugs. Index: ZApp_Base.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_Base.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ZApp_Base.py 6 Nov 2003 18:20:13 -0000 1.22 --- ZApp_Base.py 30 Mar 2004 17:06:26 -0000 1.23 *************** *** 9,14 **** --- 9,17 ---- undefined_zdb = [] + ZAPP_DEBUG=os.environ.get('ZAPP_DEBUG',undefined_zdb) + FULL_REPR=os.environ.get('ZAPP_REPR_FULL',undefined_zdb) + from OFS import SimpleItem from OFS.PropertyManager import PropertyManager *************** *** 23,26 **** --- 26,30 ---- _marker = [] + unbreak=0 if ZAPP_DEBUG: *************** *** 31,42 **** def __new__get_attr__(self, name, _v_dm_=_v_dm_): c = self._v_attrCache has = c.has_key d = self.__dict__ ! id = d.get('id','No id') t = self.__class__.__name__ if not has(name): ! ZApp_LOG("In getattr -> cache failed %s(%s) looking for %s" % (id, t, name)) else: v = c.get(name,'No Value') --- 35,50 ---- def __new__get_attr__(self, name, _v_dm_=_v_dm_): + + global unbreak # let's only break once.. + c = self._v_attrCache has = c.has_key d = self.__dict__ ! id = d.get('id',_marker) ! t = self.__class__.__name__ if not has(name): ! ZApp_LOG("In getattr -> cache failed %s(%s) looking for %s" % (`id`, t, name)) else: v = c.get(name,'No Value') *************** *** 188,193 **** def __repr__(self): ! return ('<ZApp_BaseObject meta_type=%s %s>' % (self.meta_type, self.propDisplay())) ! def get_argument_dictionary(self, props=None, REQUEST=None, kw=None): --- 196,203 ---- def __repr__(self): ! if FULL_REPR is not undefined_zdb: ! return ('<ZApp_BaseObject meta_type=%s %s>' % (self.meta_type, self.propDisplay())) ! else: ! return ('<ZApp_BaseObject meta_type=%s at 0x%x>' % (self.meta_type, id(self))) def get_argument_dictionary(self, props=None, REQUEST=None, kw=None): Index: ZApp_Application.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_Application.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ZApp_Application.py 28 Mar 2004 22:14:47 -0000 1.34 --- ZApp_Application.py 30 Mar 2004 17:06:25 -0000 1.35 *************** *** 517,525 **** --- 517,529 ---- resultList.append("Not allowed to run this lever.. safe levers only.. ") continue + spec = spec.__of__(leverMethod) + if leverName=='skinScriptLever': rackList = spec.rackList else: rackList = [spec.defaultRack] + + resultList.append("Found racks: " + `rackList`) for rack in rackList: *************** *** 535,538 **** --- 539,544 ---- f.seek(0) resultList.append("Ahh!!!" + f.read()) + else: + resultList.append("*** Can't find leverMethod: '%s' ***** " % leverName) else: resultList.append(" can't find any specialists there.. ") Index: ZApp_Specialist.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_Specialist.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** ZApp_Specialist.py 21 Mar 2004 13:08:18 -0000 1.39 --- ZApp_Specialist.py 30 Mar 2004 17:06:26 -0000 1.40 *************** *** 612,618 **** if not itemID: ! import pdb ! pdb.set_trace() ! raise RuntimeError, ("Can't be! got null id in %s.chachedSelectItemResult()" % self.id) queryResult = self._fromCache(itemID) --- 612,616 ---- if not itemID: ! return None queryResult = self._fromCache(itemID) Index: ZApp_MiscData.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_MiscData.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ZApp_MiscData.py 19 Mar 2004 15:53:32 -0000 1.27 --- ZApp_MiscData.py 30 Mar 2004 17:06:26 -0000 1.28 *************** *** 182,196 **** def getMiscDataSpecialist(self): ! mds = self.findApplication().getSpecialist('MiscData') if not mds: try: # acquisition failed... try CMF skin, if we're in context.. # ! mds = self.getApplication().getSpecialist('MiscData') except AttributeError: pass return mds - def getMiscData(self, Manager=None, dataType='', createIfNone=0): """ --- 182,197 ---- def getMiscDataSpecialist(self): ! app = self.findApplication() ! mdID = app.MiscDataSpecialist ! mds = getattr(app, mdID) if not mds: try: # acquisition failed... try CMF skin, if we're in context.. # ! mds = self.getApplication().getSpecialist(mdID) except AttributeError: pass return mds def getMiscData(self, Manager=None, dataType='', createIfNone=0): """ Index: ZApp_CMFBase.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ZApp_CMFBase.py 29 Mar 2004 13:58:34 -0000 1.43 --- ZApp_CMFBase.py 30 Mar 2004 17:06:26 -0000 1.44 *************** *** 48,51 **** --- 48,53 ---- from DateTime import DateTime + cmfbase_unbreak=0 + import tempfile *************** *** 99,107 **** --- 101,120 ---- def calcPathID(self): + + global cmfbase_unbreak try: if self.id.find(',') != -1: result = self.id else: + if 0: # not cmfbase_unbreak: + cmfbase_unbreak=1 + + import pdb + pdb.set_trace() + app = self.findApplication() + cmfSpec = getattr(app,app.CMFDataSpecialist,'') + if cmfSpec and cmfSpec.getId() == self.aq_parent.getId(): + return 'IMPOSSIBLE_PATH_ID' objPath = ','.join(self.getPhysicalPath()) portal_object = app.zapp_portal_object *************** *** 355,369 **** if it's an image, create our preferred media type to handle it. """ - if typ.startswith('image') or typ.startswith('application'): - self.invokeFactory( self.preferredMediaType, name ) - obj = aq_base( self._getOb( name ) ) - self._delObject( name ) - return obj ! class ZApp_CMF_FSObject( ZApp_CMFBase ): meta_type = 'ZApp CMF FSObject' isPrincipiaFolderish = 0 isAnObjectManager = 0 __dav_collection__ = 0 --- 368,395 ---- if it's an image, create our preferred media type to handle it. """ ! pf = getattr(self, 'ZApp_putFactory', None) ! if not pf: ! if typ.startswith('image') or typ.startswith('application'): ! self.invokeFactory( self.preferredMediaType, name ) ! obj = aq_base( self._getOb( name ) ) ! #self._delObject( name ) ! return obj ! else: ! return pf(name, typ, body) ! ! extendProperties(ZApp_CMF_FSFolder, props) + class ZApp_CMF_FSObject( ZApp_CMFBase ): + """ + There is an attribute check for ZApp_PUT_filter during a 'PUT' so that a custom filter can + be invoked before data is stored. + """ + meta_type = 'ZApp CMF FSObject' isPrincipiaFolderish = 0 isAnObjectManager = 0 + isPortalContent = 1 + __dav_collection__ = 0 *************** *** 385,388 **** --- 411,417 ---- def objectValues(self, spec=None): + """ + Don't behave like a container. + """ return () *************** *** 456,459 **** --- 485,491 ---- if file: fileObj.manage_upload(file) + self.content_type = fileObj.content_type + self.setFormat(self.content_type) + self.size = fileObj.get_size() return oldID, newID, newTitle *************** *** 478,485 **** else: fileObj = self.fs_object ! if fileObj: fileObj.PUT( REQUEST, RESPONSE) self.content_type = fileObj.content_type self.size = fileObj.get_size() --- 510,522 ---- else: fileObj = self.fs_object ! if fileObj: + hook_method = getattr(self, 'ZApp_PUT_Filter', None) + if hook_method: + hook_method(REQUEST, RESPONSE) + fileObj.PUT( REQUEST, RESPONSE) self.content_type = fileObj.content_type + self.setFormat(self.content_type) self.size = fileObj.get_size() *************** *** 600,603 **** --- 637,641 ---- self.height = fileObj.height self.size = fileObj.get_size() + self.setFormat(self.content_type) return oldID, newID, newTitle *************** *** 615,620 **** else: fileObj = self.fs_object ! if fileObj: fileObj.PUT( REQUEST, RESPONSE) self.content_type = fileObj.content_type --- 653,662 ---- else: fileObj = self.fs_object ! if fileObj: + hook_method = getattr(self, 'ZApp_PUT_Filter', None) + if hook_method: + hook_method(REQUEST, RESPONSE) + fileObj.PUT( REQUEST, RESPONSE) self.content_type = fileObj.content_type *************** *** 622,625 **** --- 664,668 ---- self.height = fileObj.height self.size = fileObj.get_size() + self.setFormat(self.content_type) *************** *** 628,632 **** class ZApp_CMF_ZODBImage( ZApp_CMFBase, Image): ! meta_type = 'ZApp CMF Image' zapp_cmf_type = 1 isPrincipiaFolderish = 0 --- 671,675 ---- class ZApp_CMF_ZODBImage( ZApp_CMFBase, Image): ! meta_type = 'ZApp CMF ZODB Image' zapp_cmf_type = 1 isPrincipiaFolderish = 0 *************** *** 667,670 **** --- 710,743 ---- self.ZAppRecursionLock_clear() + def edit(self, precondition='', file=''): + """ Update and reindex. """ + return Image.edit(self, precondition=precondition, file=file) + + def index_html(self, REQUEST=None, RESPONSE=None): + """ + use Image version... + """ + return Image.index_html(self, REQUEST, RESPONSE) + + def PUT(self, REQUEST, RESPONSE): + """Handle HTTP PUT requests""" + + import pdb + pdb.set_trace() + + hook_method = getattr(self, 'ZApp_PUT_Filter', None) + if hook_method: + hook_method(REQUEST, RESPONSE) + + return Image.PUT(self, REQUEST, RESPONSE) + + __str__ = Image.__str__ + __len__ = Image.__len__ + manage_FTPget = Image.index_html + get_size = Image.get_size + getContentType = Image.getContentType + + extendProperties(ZApp_CMF_ZODBImage, []) + from DateTime import DateTime *************** *** 719,722 **** --- 792,832 ---- ), }, + {'id': 'ZApp CMF ZODB Image', + 'title':'', + 'meta_type' : ZApp_CMF_ZODBImage.meta_type, + 'product': 'ZApp', + 'description':'Image Content type based on ZApp objects using ZODB for storage', + 'icon':'image_icon.gif', + 'factory': 'addZAppCMFZODBImage', + 'immediate_view': 'image_edit_form', + 'actions': ({'id': 'view', + 'name': 'View', + 'action': 'image_view', + 'permissions': (CMFCorePermissions.View,), + }, + {'id': 'edit', + 'name': 'Edit', + 'action': 'image_edit_form', + 'permissions': (CMFCorePermissions.ModifyPortalContent,), + }, + { 'id' : 'metadata' + , 'name' : 'Metadata' + , 'action': 'string:${object_url}/metadata_edit_form' + , 'permissions' : (CMFCorePermissions.ModifyPortalContent,), + }, + { 'id' : 'xml' + , 'name' : 'XML' + , 'action': 'string:${object_url}/zapp_cmf_xml_form' + , 'permissions' : (CMFCorePermissions.ManagePortal,) + , 'visible' : 1, + }, + { 'id' : 'relations' + , 'name' : 'Relationships' + , 'action': 'string:${object_url}/zapp_cmf_view_relations' + , 'permissions' : (CMFCorePermissions.ManagePortal,) + , 'visible' : 1, + }, + ), + }, {'id': 'ZApp CMF ImageFolder', 'title':'', *************** *** 823,833 **** 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: --- 933,946 ---- 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 not existingObject: + proxyObj = dm.newItem( checkID ) if existingObject: *************** *** 843,847 **** self._setObject(id, o) initCMFObjectMetadata(o) - o.change() if klass not in [ZApp_CMFBase, ZApp_CMF_FSObject, ZApp_CMF_FSImage, ZApp_CMF_FSFolder, ZApp_CMF_ZODBImage]: --- 956,959 ---- *************** *** 854,858 **** return addZAppCMFObject(self, id, title, klass, useExisting) ! def addZAppCMFImage(self, id, title='', klass=ZApp_CMF_ZODBImage, useExisting=1): """ add a CMF_ZODBImage object.. pass in the right class... --- 966,970 ---- return addZAppCMFObject(self, id, title, klass, useExisting) ! def addZAppCMFZODBImage(self, id, title='', klass=ZApp_CMF_ZODBImage, useExisting=1): """ add a CMF_ZODBImage object.. pass in the right class... Index: __init__.py =================================================================== RCS file: /cvsroot/zapp/ZApp/__init__.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** __init__.py 28 Mar 2004 22:14:47 -0000 1.25 --- __init__.py 30 Mar 2004 17:06:26 -0000 1.26 *************** *** 55,58 **** --- 55,59 ---- context.registerBaseClass(ZApp_CMFBase.ZApp_CMFBase) context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSImage) + context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_ZODBImage) context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSFolder) *************** *** 61,65 **** content_types = (ZApp_CMFBase.ZApp_CMFBase, ZApp_CMFBase.ZApp_CMF_FSImage, ZApp_CMFBase.ZApp_CMF_ZODBImage, ZApp_CMFBase.ZApp_CMF_FSFolder), permission = AddPortalContent, ! extra_constructors = (ZApp_CMFBase.addZAppCMFObject, ZApp_CMFBase.addZAppCMFFSImage, ZApp_CMFBase.addZAppCMFImage, ZApp_CMFBase.addZAppCMFFSFolder), fti=ZApp_CMFBase.factory_type_information, ).initialize(context) --- 62,66 ---- content_types = (ZApp_CMFBase.ZApp_CMFBase, ZApp_CMFBase.ZApp_CMF_FSImage, ZApp_CMFBase.ZApp_CMF_ZODBImage, ZApp_CMFBase.ZApp_CMF_FSFolder), permission = AddPortalContent, ! extra_constructors = (ZApp_CMFBase.addZAppCMFObject, ZApp_CMFBase.addZAppCMFFSImage, ZApp_CMFBase.addZAppCMFZODBImage, ZApp_CMFBase.addZAppCMFFSFolder), fti=ZApp_CMFBase.factory_type_information, ).initialize(context) |