Fixzes in models
This commit is contained in:
parent
3c643f4a04
commit
3ad7d911b1
6 changed files with 29 additions and 14 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
import json
|
try:
|
||||||
|
import ujson as json
|
||||||
|
except:
|
||||||
|
import json
|
||||||
|
|
||||||
import fcntl
|
import fcntl
|
||||||
import errno
|
import errno
|
||||||
import time
|
import time
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
@ -138,7 +139,8 @@ class SqlClass:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
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:
|
||||||
|
|
|
||||||
|
|
@ -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,10 +46,14 @@ class DateTimeField(PhangoField):
|
||||||
def show_formatted(self, value):
|
def show_formatted(self, value):
|
||||||
|
|
||||||
# Convert to paramecio value
|
# Convert to paramecio value
|
||||||
value=str(value)
|
if value!=None:
|
||||||
value=value.replace('-', '').replace(':', '').replace(' ', '')
|
value=str(value)
|
||||||
|
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):
|
||||||
|
|
||||||
|
|
@ -57,4 +61,4 @@ class DateTimeField(PhangoField):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return 'DATETIME NOT NULL'
|
return 'DATETIME NULL'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
from paramecio.cromosoma.webmodel import WebModel, PhangoField
|
from paramecio.cromosoma.webmodel import WebModel, PhangoField
|
||||||
import json
|
|
||||||
|
try:
|
||||||
|
import ujson as json
|
||||||
|
except:
|
||||||
|
import json
|
||||||
|
|
||||||
class DictField(PhangoField):
|
class DictField(PhangoField):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue