commit-gnue
[Top][All Lists]
Advanced

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

r5338 - in trunk: gnue-appserver/samples gnue-common/src/datasources/dri


From: reinhard
Subject: r5338 - in trunk: gnue-appserver/samples gnue-common/src/datasources/drivers/DBSIG2 gnue-forms/src
Date: Wed, 17 Mar 2004 16:25:17 -0600 (CST)

Author: reinhard
Date: 2004-03-17 16:25:16 -0600 (Wed, 17 Mar 2004)
New Revision: 5338

Modified:
   trunk/gnue-appserver/samples/sample.gfd
   trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
   trunk/gnue-forms/src/GFDisplayHandler.py
   trunk/gnue-forms/src/GFParser.py
Log:
Fixed Date and Datetime masks.


Modified: trunk/gnue-appserver/samples/sample.gfd
===================================================================
--- trunk/gnue-appserver/samples/sample.gfd     2004-03-17 21:41:57 UTC (rev 
5337)
+++ trunk/gnue-appserver/samples/sample.gfd     2004-03-17 22:25:16 UTC (rev 
5338)
@@ -76,11 +76,14 @@
       <entry name="entWeight" Char:height="1" Char:width="10" Char:x="14"
              Char:y="7" block="blkPerson" field="inpWeight"/>
       <entry name="entBorn" Char:height="1" Char:width="25" Char:x="14"
-             Char:y="8" block="blkPerson" field="inpBorn"/>
+             Char:y="8" block="blkPerson" field="inpBorn" displaymask="%x"
+             inputmask="%x"/>
       <entry name="entMeetTime" Char:height="1" Char:width="25" Char:x="14"
-             Char:y="9" block="blkPerson" field="inpMeetTime"/>
+             Char:y="9" block="blkPerson" field="inpMeetTime" displaymask="%X"
+             inputmask="%X"/>
       <entry name="entLastMeeting" Char:height="1" Char:width="25" Char:x="14"
-             Char:y="10" block="blkPerson" field="inpLastMeeting"/>
+             Char:y="10" block="blkPerson" field="inpLastMeeting"
+             displaymask="%x %X" inputmask="%x %X"/>
       <entry name="entHuman" Char:height="1" Char:width="2" Char:x="14"
              Char:y="11" block="blkPerson" field="inpHuman" style="checkbox"/>
       <button name="Call" Char:height="1" Char:width="25" Char:x="14"

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2004-03-17 21:41:57 UTC (rev 5337)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py      
2004-03-17 22:25:16 UTC (rev 5338)
@@ -38,6 +38,7 @@
 from gnue.common.apps import GDebug
 import string
 import types
+import mx.DateTime
 
 from ResultSet import ResultSet
 
@@ -54,6 +55,7 @@
   # The date/time format used in insert/select statements
   # (based on format used for time.strftime())
   _dateTimeFormat = "'%c'"
+  _timeFormat = "'%X'"
 
   # If a DB driver supports a unique identifier for rows,
   # list it here.  _primaryIdField is the field name (lower case)
@@ -116,10 +118,12 @@
 
 
   def _toSqlString(self, value):
-    try:
-      return value.strftime(self._dateTimeFormat)
-    except AttributeError:
-
+    if isinstance (value, mx.DateTime.DateTimeType):
+      if (value.year, value.month, value.day) == (1, 1, 1):
+        return value.strftime (self._timeFormat)
+      else:
+        return value.strftime (self._dateTimeFormat)
+    else:
       if value == None:
         return "NULL"
 

Modified: trunk/gnue-forms/src/GFDisplayHandler.py
===================================================================
--- trunk/gnue-forms/src/GFDisplayHandler.py    2004-03-17 21:41:57 UTC (rev 
5337)
+++ trunk/gnue-forms/src/GFDisplayHandler.py    2004-03-17 22:25:16 UTC (rev 
5338)
@@ -1,4 +1,4 @@
-#
+
 # This file is part of GNU Enterprise.
 #
 # GNU Enterprise is free software; you can redistribute it
@@ -41,7 +41,7 @@
   Image = None
 
 try:
-  from mx.DateTime import DateTime
+  from mx.DateTime import DateTime, strptime
 except ImportError:
   print """
    This GNUe tool requires mxDateTime to be installed
@@ -647,6 +647,8 @@
 ##    FieldDisplayHandler.__init__(self, entry, eventHandler,
 ##            DateMask.DateMask(displayMask, inputMask, displayMask))
     FieldDisplayHandler.__init__(self, entry, eventHandler, None)
+    self.__displayMask = displayMask
+    self.__inputMask = inputMask
 
 
   def setValue(self, value):
@@ -656,9 +658,15 @@
   # TODO: Replace with format mask
   def _buildDisplayHelper(self, value, editing):
     if editing:
-      format = "%m/%d/%Y"
+      if self.__inputMask:
+        format = self.__inputMask
+      else:
+        format = "%m/%d/%Y"
     else:
-      format = "%m/%d/%y"
+      if self.__displayMask:
+        format = self.__displayMask
+      else:
+        format = "%m/%d/%y"
 
 ##    print "format=%s, value=%s, type=%s" % (format, value, type(value))
     if value in (None,""):
@@ -676,6 +684,12 @@
       return 1
 
     # TODO: Replace with format mask
+    if self.__inputMask:
+      try:
+        self.value = strptime (self.work, self.__inputMask)
+      except:
+        return 0
+      return 1
     try:
       value = string.replace(string.replace(self.work,'.','/'),'-','/')
 

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2004-03-17 21:41:57 UTC (rev 5337)
+++ trunk/gnue-forms/src/GFParser.py    2004-03-17 22:25:16 UTC (rev 5338)
@@ -327,18 +327,6 @@
                'Default': 'text',
                'Description': 'The type of data the entry widget will accept. '
                               'Possible values are {text}, {number}, {date}.'},
-            'formatmask': {
-               'Typecast': GTypecast.text,
-               'Label': _('Format Mask'),
-               'Description': 'TODO' },
-            'inputmask': {
-               'Typecast': GTypecast.text,
-               'Label': _('Input Mask'),
-               'Description': 'TODO' },
-            'displaymask': {
-               'Label': _('Display Mask'),
-               'Typecast': GTypecast.text,
-               'Description': 'TODO' },
             'value': {
                'Typecast': GTypecast.text,
                'Description': 'TODO' },
@@ -503,7 +491,19 @@
                               'use {dropdown} you are required to use both the 
'
                               '{fk_source}, {fk_key}, and {fk_description} '
                               'attributes. The {label} style implies the '
-                              '{readonly} attribute.'  } },
+                              '{readonly} attribute.'  },
+            'formatmask': {
+               'Typecast': GTypecast.text,
+               'Label': _('Format Mask'),
+               'Description': 'TODO' },
+            'inputmask': {
+               'Typecast': GTypecast.text,
+               'Label': _('Input Mask'),
+               'Description': 'TODO' },
+            'displaymask': {
+               'Label': _('Display Mask'),
+               'Typecast': GTypecast.text,
+               'Description': 'TODO' } },
 ##            'x': {
 ##               'Required': True,
 ##               'Typecast': GTypecast.whole,





reply via email to

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