commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8831 - in trunk/gnue-forms/src: . uidrivers/html


From: jan
Subject: [gnue] r8831 - in trunk/gnue-forms/src: . uidrivers/html
Date: Tue, 17 Oct 2006 17:42:00 -0500 (CDT)

Author: jan
Date: 2006-10-17 17:41:57 -0500 (Tue, 17 Oct 2006)
New Revision: 8831

Added:
   trunk/gnue-forms/src/uidrivers/html/GFServer.py
   trunk/gnue-forms/src/uidrivers/html/UISplashScreen.py
Modified:
   trunk/gnue-forms/src/GFClient.py
   trunk/gnue-forms/src/GFConfig.py
   trunk/gnue-forms/src/uidrivers/html/__init__.py
Log:
Create a basic server adapter for GNUe Forms HTML UI driver

Modified: trunk/gnue-forms/src/GFClient.py
===================================================================
--- trunk/gnue-forms/src/GFClient.py    2006-10-17 21:26:22 UTC (rev 8830)
+++ trunk/gnue-forms/src/GFClient.py    2006-10-17 22:41:57 UTC (rev 8831)
@@ -147,6 +147,11 @@
         else:
           raise StartupError, u_("Unable to load UI driver: %s") % err
 
+    # start webserver for HTML UI driver
+    if hasattr(self._ui,"start_server"):
+       self._ui.start_server()
+       return
+   
     # -------------------------------------------------------------------------
     # Get the user supplied parameters
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFConfig.py
===================================================================
--- trunk/gnue-forms/src/GFConfig.py    2006-10-17 21:26:22 UTC (rev 8830)
+++ trunk/gnue-forms/src/GFConfig.py    2006-10-17 22:41:57 UTC (rev 8831)
@@ -35,7 +35,7 @@
     'Description': 'The default user interface driver to use if not specified '
                  + 'on the command line.',
     'Typecast'   : GTypecast.text,
-    'Options'    : ['curses','wx','gtk2','qt','win32'],
+    'Options'    : ['curses','wx','wx26','gtk2','qt3','html','win32'],
     'Default'    : 'wx' },
 
   { 'Name'       : 'AllowNumericFormulas',

Added: trunk/gnue-forms/src/uidrivers/html/GFServer.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/GFServer.py     2006-10-17 21:26:22 UTC 
(rev 8830)
+++ trunk/gnue-forms/src/uidrivers/html/GFServer.py     2006-10-17 22:41:57 UTC 
(rev 8831)
@@ -0,0 +1,134 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2000-2006 Free Software Foundation
+#
+# FILE:
+# uidrivers/html/GFServer.py
+#
+# DESCRIPTION:
+#
+# NOTES:
+#
+
+from gnue.common.utils import http
+from BaseHTTPServer import HTTPServer
+
+from UISplashScreen import SplashScreen
+
+# =============================================================================
+# GNUe Forms HTML UI driver Request handler
+# =============================================================================
+
+class GFServer:
+
+
+  def __init__(self):
+    self.splash = SplashScreen()    
+
+  def serve(self):
+    print '\nGNUe Forms HTML UI driver is loaded.'
+    print '\n-- please point your browser to http://127.0.0.1:8000 --'
+    server = HTTPServer(('',8000), GFRequestHandler)
+    server.GFServer = self
+    server.serve_forever()
+
+# =============================================================================
+# GNUe Forms HTML UI driver Request handler
+# =============================================================================
+
+class GFRequestHandler(http.HTTPRequestHandler):
+
+  """
+  Handle  requests sent via HTTP connections.
+
+  @cvar protocol_version: Set to 'HTTP/1.1' so we do have persistent
+    connections.
+  """
+
+  # Make sure to support persistent connections
+  protocol_version = "HTTP/1.1"
+
+
+  # ---------------------------------------------------------------------------
+  # log all requests at debug level 9
+  # ---------------------------------------------------------------------------
+
+  def log_request (self, code = '-', size = '-'):
+    """
+    Log all requests at debug level 9.
+    """
+
+    assert gDebug (9, '"%s" %s %s' % (self.requestline, code, size))
+     
+
+  # ---------------------------------------------------------------------------
+  # Process a GET request
+  # ---------------------------------------------------------------------------
+
+  def do_GET (self):
+    """
+    ....
+    """
+    if self.path=="/":   
+      response = self.server.GFServer.splash.getHTML()
+      self.push_content(response)
+    elif self.path=="/splashscreen.png":
+      response = self.server.GFServer.splash.getPicture()
+      self.push_content(response,"image/png")
+    else:
+      self.send_response(404)
+      self.connection.shutdown (1)   
+      print self.path
+      
+    # If a shutdown of the connection is requested do so, although we assume to
+    # have a persistent connection.
+    if self.close_connection:
+      self.connection.shutdown (1)    
+      
+  def push_content(self, response, content_type="text/html"):
+    self.send_response (200, flush = False)
+    self.send_header ("Content-type", content_type, flush = False)
+    self.send_header ("Content-length", str (len (response)), flush = False)
+    self.end_headers (flush = False)
+
+    # Add the response to the send-queue and finally flush everything to the
+    # socket.
+    self.write (response, flush = True)
+
+
+
+  def send_head(self):
+    self.send_response(200)
+    self.send_header("Content-Type", "text/html")
+    self.end_headers()
+
+    self.wfile.write('''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Strict//EN" 
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<body bgcolor="#EFEFEF" style="font-size: 18px; font-family: courier"
+<form method="POST" action="http://127.0.0.1:8000";>
+</form></body></html>''')
+   
+    #elif fs.has_key('requestEXIT'):
+    #  
_htmlApp.uidriver._form._instance.dispatchEvent(events.Event('requestEXIT',_form=_htmlApp.uidriver._form))
+
+    
+def start_server():
+    GFServer().serve()
+    
\ No newline at end of file

Added: trunk/gnue-forms/src/uidrivers/html/UISplashScreen.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/UISplashScreen.py       2006-10-17 
21:26:22 UTC (rev 8830)
+++ trunk/gnue-forms/src/uidrivers/html/UISplashScreen.py       2006-10-17 
22:41:57 UTC (rev 8831)
@@ -0,0 +1,66 @@
+# GNU Enterprise Forms - HTML UI Driver - Splash Screen
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: UISplashScreen.py 8150 2006-02-06 13:57:33Z johannes $
+
+import os.path
+
+from gnue.common.apps import GConfig
+from gnue.forms import VERSION
+
+# =============================================================================
+# Implementation of a splash screen
+# =============================================================================
+
+class SplashScreen:
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self):
+
+    iDir    = GConfig.getInstalledBase ('forms_images', 'common_images')
+    picture = gConfigForms ('splashScreenPNG')
+    if not os.path.isabs (picture):
+      self.picture = os.path.join (iDir, picture)   
+      
+  def getPicture(self):
+    file = open(self.picture,"rb")
+    data = ""
+    for line in file:
+      data+=line
+    return data
+    
+  def getHTML(self):
+    html = """<HTML><HEAD>
+    </HEAD>
+    <BODY>
+    <CENTER>
+    <IMAGE SRC="splashscreen.png"><BR>
+    Version: %s
+    </CENTER>
+    <H1 ALIGN="CENTER"> Please wait while GNUe-Forms is loading ...</H1>
+    </BODY>    
+    </HTML>    
+    """ % (VERSION)
+    
+    return html

Modified: trunk/gnue-forms/src/uidrivers/html/__init__.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/__init__.py     2006-10-17 21:26:22 UTC 
(rev 8830)
+++ trunk/gnue-forms/src/uidrivers/html/__init__.py     2006-10-17 22:41:57 UTC 
(rev 8831)
@@ -1,2 +1,3 @@
 from UIdriver import GFUserInterface
 from UILoginHandler import *
+from GFServer import start_server





reply via email to

[Prev in Thread] Current Thread [Next in Thread]