root/ShortMessage/trunk/ShortMessage.py

Revision 127 (checked in by fenix, 3 years ago)

add docstrings to all classes and functions

Line 
1 # Author: Melnychuk Taras
2 # Contact: fenix@quintagroup.com
3 # Date: $Date: 2005-11-23 12:57:23 +0200 (Thu, 23 Nov 2005) $
4 # Copyright: quintagroup.com
5
6 """ShortMessage is Archetypes-based content type. It has Workflow that sends Short message upon object publishing.
7    This module defines the following classes:
8
9     - `ShortMessage`, a ShortMessage type that allows you to create your own short message
10    Methods:
11     - `ShortMessage.setDefaultSender`: sets none to Sender field if policy is free and enforceOriginator in other case"""
12
13 __docformat__ = 'restructuredtext'
14
15 from Products.CMFCore.utils import getToolByName
16 from Products.Archetypes.public import *
17
18 from validators import MaxSmValidator
19 from config import *
20
21 schema = BaseSchema+Schema((
22                     ComputedField('title',
23                                   accessor = 'Title',
24                                   expression = "context.getBody()[:25]+'...'",
25                                   widget=ComputedWidget(
26                                   visible={'edit':'invisible',
27                                            'view':'invisible'}, ),
28                                            ),
29                     StringField('sender',
30                                 required=1,
31                                 default_method = 'setDefaultSender',
32                                 widget = StringWidget(
33                                 condition = "python: object.portal_smsCommunicator.getProperty('policy') == 'free'"
34                                                       )
35                                  ),
36                     StringField('recipient',
37                                  required=1,
38                                  widget = LinesWidget(
39                                           rows = 1,
40                                           label="recipient"),
41                                            ),
42                      TextField('body',
43                                 searchable = 1,
44                                 validators=MaxSmValidator(),
45                                 widget = TextAreaWidget(
46                                          description = "Enter your text message.",
47                                          label = "Body text")
48                                            ),
49                            ))
50
51 class ShortMessage(BaseContent):
52     """ShortMessage type allows you to create your own short message"""
53     schema = schema
54     archetype_name=ARCHETYPE_NAME
55
56     def setDefaultSender(self):
57         """ sets none to Sender field if policy is free and enforceOriginator in other case"""
58         communicator = getToolByName(self, 'portal_smsCommunicator')
59         policy = communicator.getProperty('policy')
60         if policy == 'free':
61             return None
62         else:
63             return communicator.getProperty('mtMessageOriginator')
64
65 registerType(ShortMessage)
Note: See TracBrowser for help on using the browser.