Skip to content.

Etria Lists

 

[quills-dev] Entry description generated automatically

Tim Hicks tim at sitefusion.co.uk
Sun Dec 17 10:54:52 UTC 2006


Tim Hicks wrote:
> Andrey Fedoseev wrote:
>> Hi all.
>>
>> I made a small change to WeblogEntry.py and I'd like to discuss it
>> there. Changeset is:
>>
>> --- WeblogEntry.py      (revision 34053)
>> +++ WeblogEntry.py      (working copy)
>> @@ -160,4 +160,17 @@
>>          # first Y words.
>>          return self.Description()
>>
>> +    security.declareProtected(perms.View, 'Description')
>> +    def Description(self):
>> +       if self.description:
>> +           return self.description
>> +       transforms = getToolByName(self, "portal_transforms")
>> +       plain_data = transforms.convertToData("text/plain",
>> self.getText())
>> +
>> +       plain_data_words = plain_data.split()
>> +       if len(plain_data_words) < 50:
>> +           return plain_data
>> +       else:
>> +           return " ".join(plain_data_words[:50]) + " ..."
>> +
>>
>> If weblog entry doesn't have a description then description is generated
>> from entry's full text (I use first 50 words). It's useful for me as I
>> want all entries to have description but I'm too lazy to fill it
>> manually :)
>>
>> Plese, tell me what do you think of that.
> 
> This seems like a nice feature, and I'd be happy for it, or something
> like it, to go onto the trunk.  A couple of points:
> 
>   o I believe the correct method name for this is 'getExcerpt', rather
> than 'Description' (see IWeblogEntry).  As things stand,
> WeblogEntry.getExcerpt() currently just returns
> WeblogEntry.Description(), but I prefer the former spelling as it is
> clearer what it is.  See also <http://plone.org/products/quills/issues/60>.
> 
>   o Justin probably has opinions on this.  He has been talking about
> adding haystack/OTS
> (<http://bcsaller.blogspot.com/2006/06/haystack.html>/<http://libots.sourceforge.net/>)
> support for getExcerpt. libots looks unbelievably cool!  This would
> obviously be an optional extra, which suggests that this method should
> be pluggable.  That probably means that your patch would best be
> integrated as an implementation for an interface that gets adapted to in
> the standard implementation of WeblogEntry.getExcerpt().  So, something
> like:
> 
>   def getExcerpt(self):
>     return IWeblogEntrySummariser(self).getSummary()

Replying to myself...

There is also the issue with this approach surrounding how to handle the
existing 'desciption' (aka 'excerpt') AT field that needs to be
resolved.  I mean, the field probably should not get displayed in the
edit view when IWeblogEntrySummariser.getSummary() is just going to
ignore it.


Tim


More information about the quills-dev mailing list