Re: improving 'BaseObject._renameAfterCreation'

"Martin Aspeli" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
On Tue, 03 Jan 2006 16:26:00 -0000, Raphael Ritz  
<[email protected]>

> in BaseObject._renameAfterCreation it is currently
> hard coded that the candidate value for the new id
> is coming from the title (by simply calling
>
>      title = self.Title()
>
> and working with that value further on.
>
> Now I would like to be able to extend that such that
> custom content types can optionally override this
> behavior, e.g., by checking for a certain method
> that people can provide to influence renaming.
>
> Something like
>
>     title = shasattr(self, '_at_RenameFrom')
>             and self._at_RenameFrom()
>             or self.Title()
>
> should do it.
>
> Any objections? Any better approaches to providing the
> desired behavior? Any better names for the new method?

-0.5 on more magic hooks in AT (until we have an events system or such,  
yeah, I know, heard it before). I found that simply overriding  
_renameAfterCreation() works well, and normally I need a bit more logic  
than just the Title() attribute anyway, so copying and modifying the  
BaseObject version is necessary. For example, I use this for sequentially  
numbering ids in Poi (and it's much better than a custom generateUniqueId,  
because it's factory-safe)


Martin

-- 
(muted)



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.