HowTo: Make an Image/File a DataSkin ???
Hello .. sorry I bother you again with my ZPatterns related Questions .. I just try it once again ;-) I have a Folder w/Customizer in that I want to store Objects of type Image or File (CMFDefault.Image to be correct) in it. The inline doku of CMFDefault.File/Image says the following: ---------------------------------------------------------- class File(OFS.Image.File , PortalContent , DefaultDublinCoreImpl ): """ A Portal-managed File """ # The order of base classes is very significant in this case. # Image.File does not store it's id in it's 'id' attribute. # Rather, it has an 'id' method which returns the contents of the # instnace's __name__ attribute. Inheriting in the other order # obscures this method, resulting in much pulling of hair and # gnashing of teeth and fraying of nerves. Don't do it. # # Really. # # Note that if you use getId() to retrieve an object's ID, you will avoid # this problem altogether. getId is the new way, accessing .id is # deprecated. ---------------------------------------------------------- this is fairly true. I needed to make the DataSkin the "first" subclass of File to ensure the datamanager-machinery will work (not_found v_dm) for example: class File(DataSkin , OFS.Image.File , PortalContent , DefaultDublinCoreImpl ): this basically works fine except when I rename this object the different behaviour of Dataskin (stores its id in self.id) and Image/File (stores its id in self.__name__ and recommends the use of ob.getId() to get the id). Has anyone used a Image/File/ExtFile class for combining it with ZPatterns.DataSkin and perhaps give me a hint ?? thanks Ulrich Eck net-labs
Hi Ulrich, Hmm.. can you just call DataSkin.__init__(self, id) in the File's constructor? -steve Ulrich Eck wrote:
Hello .. sorry I bother you again with my ZPatterns related Questions ..
I just try it once again ;-)
I have a Folder w/Customizer in that I want to store Objects of type Image or File (CMFDefault.Image to be correct) in it.
The inline doku of CMFDefault.File/Image says the following:
---------------------------------------------------------- class File(OFS.Image.File , PortalContent , DefaultDublinCoreImpl ): """ A Portal-managed File """
# The order of base classes is very significant in this case. # Image.File does not store it's id in it's 'id' attribute. # Rather, it has an 'id' method which returns the contents of the # instnace's __name__ attribute. Inheriting in the other order # obscures this method, resulting in much pulling of hair and # gnashing of teeth and fraying of nerves. Don't do it. # # Really. # # Note that if you use getId() to retrieve an object's ID, you will avoid # this problem altogether. getId is the new way, accessing .id is # deprecated.
----------------------------------------------------------
this is fairly true. I needed to make the DataSkin the "first" subclass of File to ensure the datamanager-machinery will work (not_found v_dm)
for example: class File(DataSkin , OFS.Image.File , PortalContent , DefaultDublinCoreImpl ):
this basically works fine except when I rename this object the different behaviour of Dataskin (stores its id in self.id) and Image/File (stores its id in self.__name__ and recommends the use of ob.getId() to get the id).
Has anyone used a Image/File/ExtFile class for combining it with ZPatterns.DataSkin and perhaps give me a hint ??
thanks
Ulrich Eck net-labs
_______________________________________________ ZPatterns mailing list ZPatterns@eby-sarna.com http://www.eby-sarna.com/mailman/listinfo/zpatterns
Steve Spicklemire wrote:
Hi Ulrich,
Hmm.. can you just call DataSkin.__init__(self, id) in the File's constructor?
You might need to do it like this: DataSkin.inheritedAttribute('__init__')(self, id) -- Steve Alexander
You might need to do it like this:
DataSkin.inheritedAttribute('__init__')(self, id)
can you give me a hint what this actually does or where it comes from (ExtensionClass.Base or Persistence...)? when do I need to use this and how is it compareable to DataSkin.__init__(self,id) or DataSkin.__init__.im_func(self,id) ?? I have tried the above and it didn't work in this case .. now I have the DataSkin Method the first that a PortalImage is subclassed from and needed to overlay _setId() to coop with Image.__name and DataSkin.id .. it works .. but I have no idea what drawbacks this could have. thanks for your help .. I nearly got it .. cu Ulrich Eck
At 08:03 AM 7/11/01 +0100, Steve Alexander wrote:
Steve Spicklemire wrote:
Hi Ulrich, Hmm.. can you just call DataSkin.__init__(self, id) in the File's constructor?
You might need to do it like this:
DataSkin.inheritedAttribute('__init__')(self, id)
Actually, I'm not sure you need to do anything special at all. If you use the File DataSkin in a Folder w/Customizer Support, you shouldn't need to do anything special, because in that mode the 'id' attribute is never used by ZPatterns. If you need to use these File DataSkins in a Rack, though, you'll need to include a SkinScript that says:: WITH SELF COMPUTE id=getId() Racks still use the "id" attribute directly, I'm afraid. Your '__init__' method will still need to accept an 'id' parameter, also, and you'd need to set the __name__ attribute instead of id. Ugh. Anyway, I will take a look at Rack and see if it can be made to use the 'getId()' and 'setId()' methods. Of course, you can also subclass Rack and replace the '_getClientID(client)' method with one that uses 'getId()', but it might be that I could do this safely in the base Rack class. The SkinScript examples should also probably be changed to use 'getId()' instead of 'id' so that people don't use them as a justification for continuing to indulge in deprecated behavior. :)
participants (4)
-
Phillip J. Eby -
Steve Alexander -
Steve Spicklemire -
Ulrich Eck