Fixzes in models

This commit is contained in:
Antonio de la Rosa 2021-03-22 00:09:30 +01:00
parent 3c643f4a04
commit 3ad7d911b1
6 changed files with 29 additions and 14 deletions

View file

@ -151,10 +151,10 @@ def obtain_timestamp(timeform, local=False, tz=''):
t=arrow.arrow.Arrow(y, m, d, h, mi, s).to(tz) t=arrow.arrow.Arrow(y, m, d, h, mi, s).to(tz)
timestamp=t.timestamp timestamp=t.timestamp()
else: else:
timestamp=arrow.arrow.Arrow(y, m, d, h, mi, s).timestamp timestamp=arrow.arrow.Arrow(y, m, d, h, mi, s).timestamp()
return timestamp return timestamp
@ -425,7 +425,7 @@ class TimeClass:
if checkdatetime(y, m, d, h, mi, s): if checkdatetime(y, m, d, h, mi, s):
timestamp=arrow.arrow.Arrow(y, m, d, h, mi, s).timestamp timestamp=arrow.arrow.Arrow(y, m, d, h, mi, s).timestamp()
return timestamp return timestamp

View file

@ -18,7 +18,11 @@ except:
from itsdangerous import JSONWebSignatureSerializer from itsdangerous import JSONWebSignatureSerializer
from bottle import request, response from bottle import request, response
import os import os
try:
import ujson as json
except:
import json import json
import fcntl import fcntl
import errno import errno
import time import time

View file

@ -29,6 +29,7 @@ class SqlClass:
self.connected=False self.connected=False
self.pool_recycle=3600 self.pool_recycle=3600
self.connect() self.connect()
self.last_query=''
def connect(self): def connect(self):
@ -139,6 +140,7 @@ class SqlClass:
cursor.execute(sql_query, arguments) cursor.execute(sql_query, arguments)
self.conn.commit() self.conn.commit()
self.last_query=cursor._last_executed
return cursor return cursor
except: except:

View file

@ -24,13 +24,13 @@ class DateTimeField(PhangoField):
self.error=True self.error=True
self.txt_error=self.error_default self.txt_error=self.error_default
return '' return None
if value==False: if value==False:
self.error=True self.error=True
self.txt_error=self.error_default self.txt_error=self.error_default
return '' return None
else: else:
""" """
@ -46,15 +46,19 @@ class DateTimeField(PhangoField):
def show_formatted(self, value): def show_formatted(self, value):
# Convert to paramecio value # Convert to paramecio value
if value!=None:
value=str(value) value=str(value)
value=value.replace('-', '').replace(':', '').replace(' ', '') value=value.replace('-', '').replace(':', '').replace(' ', '')
return datetime.format_date(value) return datetime.format_date(value)
else:
return ''
def get_type_sql(self): def get_type_sql(self):
"""Method for return the sql code for this type """Method for return the sql code for this type
""" """
return 'DATETIME NOT NULL' return 'DATETIME NULL'

View file

@ -1,4 +1,8 @@
from paramecio.cromosoma.webmodel import WebModel, PhangoField from paramecio.cromosoma.webmodel import WebModel, PhangoField
try:
import ujson as json
except:
import json import json
class DictField(PhangoField): class DictField(PhangoField):

View file

@ -471,7 +471,8 @@ class WebModel:
except: except:
self.query_error='Cannot insert the new row' self.query_error='Cannot insert the new row'
print(sys.exc_info()[0]) print(sys.exc_info()[0])
return False raise
#return False
c=len(values) c=len(values)