--- a/server/session.py Mon Mar 09 12:12:53 2009 +0100
+++ b/server/session.py Tue Mar 10 11:35:52 2009 +0100
@@ -10,10 +10,8 @@
import threading
from time import time
from types import NoneType
-from decimal import Decimal
-from mx.DateTime import DateTimeType, DateTimeDeltaType
-from rql.nodes import VariableRef, Function
+from rql.nodes import VariableRef, Function, ETYPE_PYOBJ_MAP, etype_from_pyobj
from yams import BASE_TYPES
from cubicweb import RequestSessionMixIn, Binary
@@ -21,26 +19,7 @@
from cubicweb.utils import make_uid
from cubicweb.server.rqlrewrite import RQLRewriter
-_ETYPE_PYOBJ_MAP = { bool: 'Boolean',
- int: 'Int',
- long: 'Int',
- float: 'Float',
- Decimal: 'Decimal',
- unicode: 'String',
- NoneType: None,
- Binary: 'Bytes',
- DateTimeType: 'Datetime',
- DateTimeDeltaType: 'Interval',
- }
-
-def etype_from_pyobj(value):
- """guess yams type from python value"""
- # note:
- # * Password is not selectable so no problem)
- # * use type(value) and not value.__class__ since mx instances have no
- # __class__ attribute
- # * XXX Date, Time
- return _ETYPE_PYOBJ_MAP[type(value)]
+ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
def is_final(rqlst, variable, args):
# try to find if this is a final var or not