__init__.py :  » Development » SnapLogic » snaplogic » server » 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 » SnapLogic 
SnapLogic » snaplogic » server » __init__.py
# $SnapHashLicense:
# 
# SnapLogic - Open source data services
# 
# Copyright (C) 2008-2009, SnapLogic, Inc.  All rights reserved.
# 
# See http://www.snaplogic.org for more information about
# the SnapLogic project. 
# 
# This program is free software, distributed under the terms of
# the GNU General Public License Version 2. See the LEGAL file
# at the top of the source tree.
# 
# "SnapLogic" is a trademark of SnapLogic, Inc.
# 
# 
# $

# $Id: __init__.py 7729 2009-05-21 00:20:51Z dhiraj $ 
""" snaplogic.server package  """
log    = None
elog   = None
config = None
logger = None

public_uri = None
"""URI derived from the config file, which respresents the official address of the server."""

auth_realm = "SnapLogic"
"""The realm used for HTTP authentication. Is here rather than in auth package to avoid circular-import issues."""

cc_token_list = []
""" The list of CC tokens. The information is redundantly stored in a list for easy lookup."""

server_token = None
"""This server's token."""

local_host_ip_addresses = None
"""All the IP addresses configured on the local host."""

server_port = None
"""The server port that the server listens on."""
    
class RhResponse(object):
    """
    Response object for any RH handler functions.

    The Request Handler calls various handler functions (which may be
    located in different modules) to handle the actual requests. This
    object here is the response that is returned by those handler
    functions.

    An important aspect of the response is the error indicator, which
    is returned as a tuple. The error indicator consists of one of our
    own response codes (which are returned inside of an X-header), and
    an error message.
    
    Exposes:

        http_code
        data
        status
        options
        headers

    The 'headers' element may be used to specify additional response
    header lines. This is commonly used when a 401 error is returnd
    which requires the WWW-authenticate header.

    """

    def __init__(self, http_code, data=None, status=None, options=None):
        """
        Initialize the response object.

        @param http_code:   The HTTP response code.
        @type  http_code:   integer

        @param data:        The object that should be returned in the
                            response message body.
        @type  data:        string

        @param status:      A number indicating the Snapi status code.
                            If this is defined, a X-Snapi-status header
                            will be added to the response. If this is
                            an error, then it is advised to send a detailed
                            error message as the reponse body.
        @type  status:      integer

        @param options:     Options for the rendering (the RP modules).
                            has to be a dictionary specifying name value
                            pairs, which are interpreted (or ignored)
                            by the RPs any way they wish. An example of
                            the use of these options is an indication to
                            an HTML RP to render in fixed-width font.
        @type  options:     dict

        """
        self.http_code = http_code
        self.data      = data
        self.status    = status
        self.options   = options
        self.headers   = []
        if http_code == 401:
            self.headers.append( ( "WWW-Authenticate", "Basic realm=\"%s\"" % auth_realm ) )


    def __repr__(self):
        """
        The string representation of the RhResponse object.

        This is mosty useful for debugging.

        """
        s = "HTTP_CODE: %s\nDATA:      %s\nSTATUS:    %s\nOPTIONS:   %s" % (self.http_code, self.data, self.status, self.options)
        return s


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