commit-gnue
[Top][All Lists]
Advanced

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

gnue/common/src GDateTime.py FormatMasks/BaseMa...


From: Jason Cater
Subject: gnue/common/src GDateTime.py FormatMasks/BaseMa...
Date: Tue, 01 Jan 2002 13:31:35 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/01 13:31:35

Modified files:
        common/src     : GDateTime.py 
        common/src/FormatMasks: BaseMask.py DateMask.py 
        common/src/commdrivers: GCommBase.py 
        common/src/commdrivers/_helpers: AsyncSocketServer.py 
        common/src/commdrivers/xmlrpc: ServerAdapter.py 

Log message:
        syncing machines

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GDateTime.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/FormatMasks/BaseMask.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/FormatMasks/DateMask.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/GCommBase.py.diff?cvsroot=OldCVS&tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: gnue/common/src/FormatMasks/BaseMask.py
diff -c gnue/common/src/FormatMasks/BaseMask.py:1.6 
gnue/common/src/FormatMasks/BaseMask.py:1.7
*** gnue/common/src/FormatMasks/BaseMask.py:1.6 Wed Oct 17 18:26:53 2001
--- gnue/common/src/FormatMasks/BaseMask.py     Tue Jan  1 13:31:35 2002
***************
*** 1,9 ****
  #
  # 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 
--- 1,9 ----
  #
  # 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 
***************
*** 32,44 ****
  
  # This is a class for a mask literal element
  class Literal:
!   def __init__(self, literal): 
      self.literal = literal
  
!   def getFormattedValue(self, value): 
      return self.literal
  
!   def isValidEntry(self, value): 
      return value == self.literal
  
  class BaseMask:
--- 32,44 ----
  
  # This is a class for a mask literal element
  class Literal:
!   def __init__(self, literal):
      self.literal = literal
  
!   def getFormattedValue(self, value):
      return self.literal
  
!   def isValidEntry(self, value):
      return value == self.literal
  
  class BaseMask:
***************
*** 59,64 ****
--- 59,79 ----
      if outputMask2 != None:
        self.output2Handlers = self.parseMask(outputMask2)
  
+     self.reset()
+ 
+ 
+   def reset(self):
+ 
+     self.index = 0
+     self.cursor = 0
+     self.display = ""
+     self.input = ""
+     self.inputMaskPos = []
+     self.inputMaskLen = []
+     for i in range(len(self.inputHandlers)):
+       self.inputMaskPos.append(0)
+       self.inputMaskLen.append(0)
+ 
  
    # Take a mask string and break it into its elements and map it to handlers
    def parseMask(self, mask):
***************
*** 87,93 ****
          isLiteral = 0
          maskHandler.append(self.literalClass(ch))
        elif self.maskMappings.has_key(ch):
!         maskHandler.append(self.maskMappings[ch]())
        else:
          raise InvalidCharInMask, 'Unexpected character "%s" in %s mask.' \
              % (ch, self.basetype)
--- 102,108 ----
          isLiteral = 0
          maskHandler.append(self.literalClass(ch))
        elif self.maskMappings.has_key(ch):
!         maskHandler.append(self.maskMappings[ch])
        else:
          raise InvalidCharInMask, 'Unexpected character "%s" in %s mask.' \
              % (ch, self.basetype)
***************
*** 101,188 ****
    def getFormattedInput(self):
      pass
  
-   def processEdit (self, str, pos=0, replaces=0):
-     pass
- 
- # This is a base class for mask elements
- class MaskSection:
-   def __init__(self):
-     self.minLength = 0
-     self.maxLength = 0
- 
-     self.intersperse = 0
-     self.intersperseString = ","
-     self.intersperseRepeat = 1
- 
- 
-   def getFormattedValue(self):
-     return self.value
- 
-   def isValidEntry(self, value):
-     return 0
- 
- 
  
! 
! class MaskInputInstance: 
!   def __init__(self, handler):
!     self.handler = handler
!     self.index = 0
!     self.cursor = 0
!     self.display = "" 
!     self.input = ""
!     self.inputMaskPos = []
!     self.inputMaskLen = []
!     for i in range(len(self.handler.inputHandlers)):
!       self.inputMaskPos.append(0)
!       self.inputMaskLen.append(0)
! 
!   def setText(self, text): 
      self.input = text
      self.display = text
      self.cursor = 0
      self.index = 0
  
!   def isValid(self): 
      return 1
  
!   def addText(self, text, pos, replaces): 
      pass
  
!   def deleteText(self, text, pos, characters): 
      pass
  
!   def cursorToIndex(self, val): 
      return val
  
  
!   def indexToCursor(self, val): 
      return val
  
  
!   def moveCursor(self, relative): 
  
      # Direction will be either 1 or -1.
      direction = relative = 0 or int(relative/abs(relative))
  
      self.cursor = self.cursor + relative
  
!     if self.cursor <= 0: 
!       self.cursor = 0 
        self.direction = 1
      elif self.cursor >= len(self.display):
        self.cursor = len(self.display)
        self.direction = -1
  
      section = 0
!     while section < len(self.handler.inputMaskPos) and \
!           self.handler.inputMaskPos[section] < pos:
        section += 1
  
!     if section == len(self.handler.inputMaskPos): 
        self.cursor = len(self.display)
  
!     elif isinstance(self.handler.inputMaskPos[section], Literal):
        self.moveCursor(self, direction)
  
      self.index = self.indexToCursor(self.cursor)
--- 116,168 ----
    def getFormattedInput(self):
      pass
  
  
!   def setText(self, text):
      self.input = text
      self.display = text
      self.cursor = 0
      self.index = 0
  
!   def isValid(self):
      return 1
  
!   def addText(self, text, pos, replaces):
      pass
  
!   def deleteText(self, text, pos, characters):
      pass
  
!   def cursorToIndex(self, val):
      return val
  
  
!   def indexToCursor(self, val):
      return val
  
  
!   def moveCursor(self, relative):
  
      # Direction will be either 1 or -1.
      direction = relative = 0 or int(relative/abs(relative))
  
      self.cursor = self.cursor + relative
  
!     if self.cursor <= 0:
!       self.cursor = 0
        self.direction = 1
      elif self.cursor >= len(self.display):
        self.cursor = len(self.display)
        self.direction = -1
  
      section = 0
!     while section < len(self.inputMaskPos) and \
!           self.inputMaskPos[section] < pos:
        section += 1
  
!     if section == len(self.inputMaskPos):
        self.cursor = len(self.display)
  
!     elif isinstance(self.inputMaskPos[section], Literal):
        self.moveCursor(self, direction)
  
      self.index = self.indexToCursor(self.cursor)
***************
*** 201,220 ****
      GDebug.printMesg(15,"inputMaskPos=%s" % self.inputMaskPos)
  
      section = 0
!     while section < len(self.handler.inputMaskPos) and \
!           self.handler.inputMaskPos[section] < pos:
        section += 1
      i = pos
      while i < len(nv):
!       if not self.handler.inputHandlers[section]\
!            .isValidEntry(nv[self.handler.inputMaskPos[section]:i+1]):
!         if i == self.handler.inputMaskPos[section] and \
!            not isinstance(self.handler.inputHandlers[section],Literal):
!           self.handler.inputMaskLen[section] = i - 
self.handler.inputMaskPos[section]
            return nv
          else:
!           self.handler.inputMaskLen[section] = i - 
self.handler.inputMaskPos[section]
!           if section == len(self.handler.inputHandlers) - 1:
              if i != len(nv)-1:
                return nv
            else:
--- 181,200 ----
      GDebug.printMesg(15,"inputMaskPos=%s" % self.inputMaskPos)
  
      section = 0
!     while section < len(self.inputMaskPos) and \
!           self.inputMaskPos[section] < pos:
        section += 1
      i = pos
      while i < len(nv):
!       if not self.inputHandlers[section]\
!            .isValidEntry(nv[self.inputMaskPos[section]:i+1]):
!         if i == self.inputMaskPos[section] and \
!            not isinstance(self.inputHandlers[section],Literal):
!           self.inputMaskLen[section] = i - self.inputMaskPos[section]
            return nv
          else:
!           self.inputMaskLen[section] = i - self.inputMaskPos[section]
!           if section == len(self.inputHandlers) - 1:
              if i != len(nv)-1:
                return nv
            else:
***************
*** 224,237 ****
        else:
          i += 1
  
!     self.handler.inputMaskLen[section] = i - 
self.handler.inputMaskPos[section]
  
!     for i in range(section+1, len(self.handler.inputHandlers)):
!       self.handler.inputMaskLen[i] = 0
  
      GDebug.printMesg(15,"<< %s" % nv)
      return nv
  
  
  
  
--- 204,236 ----
        else:
          i += 1
  
!     self.inputMaskLen[section] = i - self.inputMaskPos[section]
  
!     for i in range(section+1, len(self.inputHandlers)):
!       self.inputMaskLen[i] = 0
  
      GDebug.printMesg(15,"<< %s" % nv)
      return nv
  
+ 
+ 
+ # This is a base class for mask elements
+ class MaskSection:
+ 
+   def __init__(self):
+     self.minLength = 0
+     self.maxLength = 0
+ 
+     self.intersperse = 0
+     self.intersperseString = ","
+     self.intersperseRepeat = 1
+ 
+ 
+   def getFormattedValue(self):
+     return self.value
+ 
+   def isValidEntry(self, value):
+     return 0
  
  
  
Index: gnue/common/src/FormatMasks/DateMask.py
diff -c gnue/common/src/FormatMasks/DateMask.py:1.10 
gnue/common/src/FormatMasks/DateMask.py:1.11
*** gnue/common/src/FormatMasks/DateMask.py:1.10        Wed Oct 17 18:26:53 2001
--- gnue/common/src/FormatMasks/DateMask.py     Tue Jan  1 13:31:35 2002
***************
*** 44,57 ****
  #
  #     Predefined literals:  "/-.:, "
  #
! # Example: 
  #
  #  m/d/y              01/01/2001
  #  m/y                        01/2001
  #  h:i p              12:29 pm
  #
  
! from BaseMask import BaseMask, MaskSection, Literal, MaskInputInstance
  from gnue.common import GDebug
  from gnue.common.GDateTime import GDateTime, InvalidDate
  from FormatExceptions import *
--- 44,57 ----
  #
  #     Predefined literals:  "/-.:, "
  #
! # Example:
  #
  #  m/d/y              01/01/2001
  #  m/y                        01/2001
  #  h:i p              12:29 pm
  #
  
! from BaseMask import BaseMask, MaskSection, Literal
  from gnue.common import GDebug
  from gnue.common.GDateTime import GDateTime, InvalidDate
  from FormatExceptions import *
***************
*** 69,74 ****
--- 69,75 ----
  weekdayAbbrevNames = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
  
  
+ 
  predefinedDateLiterals = "-./: ,"
  
  
***************
*** 91,112 ****
      self.defaultmask = "m/d/y"
  
      self.maskMappings = {
!       'a': _aSection,       'A': _ASection,
!       'b': _bSection,       'B': _BSection,
!       'c': _cSection,       'd': _dSection,
!       'D': _DSection,
!       'h': _hSection,       'H': _HSection,
!       'g': _gSection,       'G': _GSection,
!       'j': _jSection,       'J': _JSection,
!       'm': _mSection,       'M': _mSection,
!       'i': _iSection,       'I': _ISection,
!       'p': _pSection,       'P': _PSection,
!       's': _sSection,       'S': _SSection,
!       'u': _uSection,       'U': _USection,
!       'v': _vSection,       'V': _VSection,
!       'w': _wSection,
!       'x': _xSection,       'X': _XSection,
!       'y': _ySection,       'Y': _YSection }
  
      BaseMask.__init__(self, outputMask, inputMask, outputMask2)
  
--- 92,113 ----
      self.defaultmask = "m/d/y"
  
      self.maskMappings = {
!       'a': _aSection(),       'A': _ASection(),
!       'b': _bSection(),       'B': _BSection(),
!       'c': _cSection(),       'd': _dSection(),
!       'D': _DSection(),
!       'h': _hSection(),       'H': _HSection(),
!       'g': _gSection(),       'G': _GSection(),
!       'j': _jSection(),       'J': _JSection(),
!       'm': _mSection(),       'M': _mSection(),
!       'i': _iSection(),       'I': _ISection(),
!       'p': _pSection(),       'P': _PSection(),
!       's': _sSection(),       'S': _SSection(),
!       'u': _uSection(),       'U': _USection(),
!       'v': _vSection(),       'V': _VSection(),
!       'w': _wSection(),
!       'x': _xSection(),       'X': _XSection(),
!       'y': _ySection(),       'Y': _YSection() }
  
      BaseMask.__init__(self, outputMask, inputMask, outputMask2)
  
***************
*** 114,124 ****
      self.entry = ""
  
  
-   def createInputHandler(self, value): 
-     instance = MaskInputInstance(self)
-     instance.setText(value)
-     return instance
- 
    def getFormattedOutput(self, value, secondary=0):
      rv = ""
      val = self._buildDate(value, 1)
--- 115,120 ----
***************
*** 141,155 ****
      rv = ""
      val = self._buildDate(value, 0)
  
      print val
  
-     self.lastInputPos = 0
  
      for i in range(len(self.inputHandlers)):
!       if self.inputMaskLen[i]: 
          self.lastInputPos = i + self.inputMaskLen[i] - 1
!       if (i < len(self.inputMaskLen) - 1) and not self.inputMaskLen[i+1]:
!         rv += val[self.inputMaskLen]
        if self.inputMaskLen[i] or isinstance(self.inputHandlers[i],Literal):
          rv += self.inputHandlers[i].getFormattedValue(val)
        elif len(padding):
--- 137,156 ----
      rv = ""
      val = self._buildDate(value, 0)
  
+     self.lastInputPos = 0
+ 
+     print
+     print value
+     print self.inputMaskLen
+     print self.inputMaskPos
      print val
  
  
      for i in range(len(self.inputHandlers)):
!       if self.inputMaskLen[i]:
          self.lastInputPos = i + self.inputMaskLen[i] - 1
!       if (i < len(self.inputMaskLen) - 1):# and not self.inputMaskLen[i+1]:
!         rv += 
value[self.inputMaskPos[i]:self.inputMaskPos[i]+self.inputMaskLen[i]]
        if self.inputMaskLen[i] or isinstance(self.inputHandlers[i],Literal):
          rv += self.inputHandlers[i].getFormattedValue(val)
        elif len(padding):
***************
*** 162,186 ****
      date = GDateTime()
  
      for i in range(len(self.inputHandlers)):
!       if self.inputMaskLen[i] or isinstance(self.inputHandlers[i],Literal):
!         self.inputHandlers[i].addSelfToDate(
!             value[ self.inputMaskPos[i]: \
                     self.inputMaskPos[i] + self.inputMaskLen[i]], date )
!       elif mustValidate: 
!         raise InvalidEntry, "Invalid Entry"
  
      return date
  
  
  
! class _baseDateSection (MaskSection): 
!   def __init__(self): 
      pass
  
    def isValidEntry(self, value):
      return 0
  
!   def addSelfToDate(self, value, date): 
      pass
  
  
--- 163,189 ----
      date = GDateTime()
  
      for i in range(len(self.inputHandlers)):
!       if (self.inputMaskLen[i] or isinstance(self.inputHandlers[i],Literal)):
! #        if self.inputHandlers[i].isValidEntry(value[ self.inputMaskPos[i]: \
! #                   self.inputMaskPos[i] + self.inputMaskLen[i]]):
!           self.inputHandlers[i].addSelfToDate(
!               value[ self.inputMaskPos[i]: \
                     self.inputMaskPos[i] + self.inputMaskLen[i]], date )
! #        else:
! #          raise InvalidEntry, "Invalid Entry"
  
      return date
  
  
  
! class _baseDateSection (MaskSection):
!   def __init__(self):
      pass
  
    def isValidEntry(self, value):
      return 0
  
!   def addSelfToDate(self, value, date):
      pass
  
  
***************
*** 227,233 ****
  
  
  class _cSection(_baseDateSection): 
!   def __init__(self): 
      _baseDateSection.__init__(self)
      self.minLength = 1
      self.maxLength = 2
--- 230,236 ----
  
  
  class _cSection(_baseDateSection): 
!   def __init__(self):
      _baseDateSection.__init__(self)
      self.minLength = 1
      self.maxLength = 2
***************
*** 239,270 ****
    def isValidEntry(self, value):
      return 0
  
!   def addSelfToDate(self, value, date): 
      pass
  
  
! class _dSection(_baseDateSection): 
!   def __init__(self): 
      _baseDateSection.__init__(self)
      self.minLength = 1
      self.maxLength = 2
  
!   def getFormattedValue(self, date): 
      return "%02i" % date.day
  
    def isValidEntry(self, value):
!     try: 
        v = int(value)
        return (v >= 0 and v <= 31) or (v == 0 and len(value) == 1)
!     except ValueError: 
        return 0
  
!   def addSelfToDate(self, value, date): 
      date.day = int(value or 1)
  
  
! class _DSection(_dSection): 
!   def getFormattedValue(self, date): 
      return "%i" % date.day
  
  
--- 242,273 ----
    def isValidEntry(self, value):
      return 0
  
!   def addSelfToDate(self, value, date):
      pass
  
  
! class _dSection(_baseDateSection):
!   def __init__(self):
      _baseDateSection.__init__(self)
      self.minLength = 1
      self.maxLength = 2
  
!   def getFormattedValue(self, date):
      return "%02i" % date.day
  
    def isValidEntry(self, value):
!     try:
        v = int(value)
        return (v >= 0 and v <= 31) or (v == 0 and len(value) == 1)
!     except ValueError:
        return 0
  
!   def addSelfToDate(self, value, date):
      date.day = int(value or 1)
  
  
! class _DSection(_dSection):
!   def getFormattedValue(self, date):
      return "%i" % date.day
  
  
Index: gnue/common/src/GDateTime.py
diff -c gnue/common/src/GDateTime.py:1.3 gnue/common/src/GDateTime.py:1.4
*** gnue/common/src/GDateTime.py:1.3    Mon Jul 16 23:00:08 2001
--- gnue/common/src/GDateTime.py        Tue Jan  1 13:31:34 2002
***************
*** 27,48 ****
  #
  
  
! def isLeapYear(year): 
    return divmod(year,400)[1] == 0 or \
        (divmod(year,4)[1] == 0 and divmod(year,100)[1] != 0)
  
! class InvalidDate(StandardError): 
    pass
  
! class GDateTime: 
!   def __init__(self): 
!     self.month = 1
!     self.day = 1
      self.year = 0
      self.hour = 0
      self.minute = 0
      self.second = 0
  
    def getDayOfWeek(self):
      # from the Calendar FAQ (http://www.pauahtun.org/CalendarFAQ/)
      # 0 = Sunday
--- 27,52 ----
  #
  
  
! def isLeapYear(year):
    return divmod(year,400)[1] == 0 or \
        (divmod(year,4)[1] == 0 and divmod(year,100)[1] != 0)
  
! class InvalidDate(StandardError):
    pass
  
! class GDateTime:
!   def __init__(self):
!     self.month = 0
!     self.day = 0
      self.year = 0
      self.hour = 0
      self.minute = 0
      self.second = 0
  
+   def __repr__(self):
+     return "%04d/%02d/%02d %02d:%02d:%02d" % \
+       (self.year, self.month, self.day, self.hour, self.minute, self.second)
+ 
    def getDayOfWeek(self):
      # from the Calendar FAQ (http://www.pauahtun.org/CalendarFAQ/)
      # 0 = Sunday
***************
*** 52,58 ****
      return divmod(self.day + y + int(y/4) - int(y/100) + int(y/400) + 
(31*m)/12,7)[1]
  
  
!   def validate(self): 
      if not (\
          self.month >= 1 and self.month <= 12 and \
          self.year >= 0 and \
--- 56,62 ----
      return divmod(self.day + y + int(y/4) - int(y/100) + int(y/400) + 
(31*m)/12,7)[1]
  
  
!   def validate(self):
      if not (\
          self.month >= 1 and self.month <= 12 and \
          self.year >= 0 and \
Index: gnue/common/src/commdrivers/GCommBase.py
diff -c gnue/common/src/commdrivers/GCommBase.py:1.13 
gnue/common/src/commdrivers/GCommBase.py:1.14
*** gnue/common/src/commdrivers/GCommBase.py:1.13       Thu Dec 20 18:27:27 2001
--- gnue/common/src/commdrivers/GCommBase.py    Tue Jan  1 13:31:35 2002
***************
*** 66,72 ****
      self._bindings = bindings
      self._rpcdef = rpcdef
  
!   def serve(self): 
  
    def runService(self, method, data):
      pass
--- 66,73 ----
      self._bindings = bindings
      self._rpcdef = rpcdef
  
!   def serve(self):
!     pass
  
    def runService(self, method, data):
      pass
Index: gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py
diff -c gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.5 
gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.6
*** gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.5       Thu Dec 
20 18:27:27 2001
--- gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py   Tue Jan  1 
13:31:35 2002
***************
*** 44,52 ****
    def __init__(self, bindings, params):
      GCommBase.Server.__init__(self, bindings, params)
  
!     # TODO: This should probably allow you to
!     # TODO: connect to both a Unix-style socket
!     # TODO: file and to a TCP/IP socket.
  
      try:
        self._socketfile = params['socket']
--- 44,52 ----
    def __init__(self, bindings, params):
      GCommBase.Server.__init__(self, bindings, params)
  
!     # TODO: This should probably allow you to connect
!     # TODO: to both a Unix-style socket file and to a
!     # TODO: TCP/IP socket simultaneously.
  
      try:
        self._socketfile = params['socket']
***************
*** 71,82 ****
--- 71,96 ----
      asyncore.loop()
  
  
+   # Called by the child socket listener to set
+   def setChannelHandler(self, handler):
+     self._dispatcher.setChannelHandler(handler)
+ 
  
  class AsyncHTTPServer(AsyncSocketServer):
    pass
  
  
  
+ #
+ #
+ #
+ class AsyncChannel(asynchat.async_chat):
+   def __init__(self, root, addr):
+     self.root = root
+     self.addr = addr
+     asynchat.async_chat.__init__ (self, conn)
+ 
+ 
  
  
  ##############################################################################
***************
*** 94,103 ****
  #
  class _AsyncDispatcher(asyncore.dispatcher):
  
    def handle_accept (self):
      conn, addr = self.accept()
!     _AsyncChannel (self.root, conn, addr)
  
  
  #
  # Bind to a port and dispatch events
--- 108,125 ----
  #
  class _AsyncDispatcher(asyncore.dispatcher):
  
+   def __init__(self, root, address):
+     self.listen (128)
+     self.root = root
+     self._channel = AsyncChannel
+ 
+ 
    def handle_accept (self):
      conn, addr = self.accept()
!     self._channel (self.root, conn, addr)
  
+   def setChannelHandler(self, handler):
+     self._channel = handler
  
  #
  # Bind to a port and dispatch events
***************
*** 105,115 ****
  class _AsyncInetDispatcher(_AsyncDispatcher):
  
    def __init__ (self, root, address):
      self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
      self.set_reuse_addr()
      self.bind (address)
-     self.listen (128)
-     self.root = root
  
  
  #
--- 127,136 ----
  class _AsyncInetDispatcher(_AsyncDispatcher):
  
    def __init__ (self, root, address):
+     _AsyncDispatcher.__init__(self, root, address)
      self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
      self.set_reuse_addr()
      self.bind (address)
  
  
  #
***************
*** 124,136 ****
      self.listen (128)
      self.root = root
  
- 
- #
- #
- #
- class _AsyncChannel(asynchat.async_chat):
-   def __init__(self, root, addr):
-     self.root = root
-     self.addr = addr
-     asynchat.async_chat.__init__ (self, conn)
  
--- 145,148 ----
Index: gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.6 
gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.7
*** gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.6     Thu Dec 20 
18:27:27 2001
--- gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py Tue Jan  1 13:31:35 2002
***************
*** 26,32 ****
  #
  # NOTES:
  # Requires xmlrpclib from http://www.pythonware.com/products/xmlrpc/
! # or Python 2.2
  #
  # Server Parameters:
  #
--- 26,32 ----
  #
  # NOTES:
  # Requires xmlrpclib from http://www.pythonware.com/products/xmlrpc/
! # or Python 2.2+
  #
  # Server Parameters:
  #
***************
*** 270,276 ****
    #
    # Handle the HTTP POST command
    #
!   # This method based largely on the
    # sample code in xmlrpcserver.
    #
    def do_POST(self):
--- 270,276 ----
    #
    # Handle the HTTP POST command
    #
!   # This method is based largely on the
    # sample code in xmlrpcserver.
    #
    def do_POST(self):
***************
*** 288,294 ****
          # report exception back to server
          GDebug.printMesg(1,
              'Unexpected Exception in XML-RPC code: %s:%s' % \
!                       (sys.exc_type, sys.exc_value)
          response = xmlrpclib.dumps(
             xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)))
        else:
--- 288,294 ----
          # report exception back to server
          GDebug.printMesg(1,
              'Unexpected Exception in XML-RPC code: %s:%s' % \
!                       (sys.exc_type, sys.exc_value))
          response = xmlrpclib.dumps(
             xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)))
        else:



reply via email to

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