Adding new text source type options in my application.

Posted by Unknown Selasa, 05 Juli 2005 0 komentar

Now that I have Textile support integrated into Zope 3 for my application, I decided to add support for different source types to said application. This didn't really require much on top of the previous work. First, I added a new field to the IPost interface and a new default class attribute to the Post implementation for the Post's "description_type". On the interface, I added the field as a Choice stemming from the "SourceTypes" vocabulary:



    description_type = zope.schema.Choice(
title=u"Description Format",
description=u"Type of the description text.",
default="textism.textile",
required=True,
vocabulary="SourceTypes",
)


Then I updated the 'renderDescription' method of the PostView class to get the description type from the adapted object and use that to get the renderer. Now the method looks like this:



    def renderDescription(self):
"""Renders the description from textile source."""
description = self.context.description
description_type = self.context.description_type
source = zapi.createObject(description_type, description)
view = zapi.getMultiAdapter((source, self.request))
return view.render()


After restarting the application, I now have this as my add-form:


Notice another one of those types - "Source Code". I created that type for my code snippet content, with a renderer that wraps up text in HTML 'pre' tags and quotes some common trouble entities (angle brackets, ampersands).

TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Adding new text source type options in my application.
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke http://apk-zipalign.blogspot.com/2005/07/adding-new-text-source-type-options-in.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of apk zipalign.