message.py :  » Development » Lyntin » lyntin-4.2 » lyntin » ui » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » Lyntin 
Lyntin » lyntin 4.2 » lyntin » ui » message.py
#######################################################################
# This file is part of Lyntin.
# copyright (c) Free Software Foundation 2001-2007
#
# Lyntin is distributed under the GNU General Public License license.  See the
# file LICENSE for distribution details.
# $Id: message.py,v 1.3 2007/07/24 00:39:03 willhelm Exp $
#######################################################################
"""
Holds the ui's Message class.  This gets passed around Lyntin and
allows us to scope data going to the ui.
"""

""" The message type constants."""
ERROR = "ERROR: "
USERDATA = "USERDATA: "
MUDDATA = "MUDDATA: "
LTDATA = "LTDATA: "

""" Used for debugging purposes."""
MESSAGETYPES = {ERROR: "ERROR: ",
                USERDATA: "USERDATA: ",
                MUDDATA: "MUDDATA: ",
                LTDATA: "LTDATA: "}

class Message:
  """
  Encapsulates a message to be written to the user.
  """
  def __init__(self, data, messagetype=LTDATA, ses=None, **hints):
    """
    Initialize.

    @param data: the message string
    @type  data: string

    @param messagetype: the message type (use a constant defined in ui.ui)
    @type  messagetype: int

    @param ses: the session this message belongs to
    @type  ses: session.Session
    """
    self.session = ses
    self.data = data
    self.type = messagetype
    self.hints = hints

  def __repr__(self):
    """
    Represents the message (returns data + type).
    """
    return repr(self.session) + MESSAGETYPES[self.type] + repr(self.data)

  def __str__(self):
    """
    The string representation of the Message is the data
    itself.
    """
    return self.data


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.