Skip to content.

Etria Lists

 

[quills-dev] Entry description generated automatically

Andrey Fedoseev andrey.fedoseev at gmail.com
Sun Dec 17 08:58:36 UTC 2006


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.

-- 
Regards!
Andrey Fedoseev <andrey.fedoseev at gmail.com>



More information about the quills-dev mailing list