server/session.py
branchtls-sprint
changeset 1016 26387b836099
parent 985 6a25c58a1c23
child 1132 96752791c2b6
equal deleted inserted replaced
1014:4792a1bb72a9 1016:26387b836099
     8 
     8 
     9 import sys
     9 import sys
    10 import threading
    10 import threading
    11 from time import time
    11 from time import time
    12 from types import NoneType
    12 from types import NoneType
    13 from decimal import Decimal
    13 
    14 
    14 from rql.nodes import VariableRef, Function, ETYPE_PYOBJ_MAP, etype_from_pyobj
    15 from mx.DateTime import DateTimeType, DateTimeDeltaType
       
    16 from rql.nodes import VariableRef, Function
       
    17 from yams import BASE_TYPES
    15 from yams import BASE_TYPES
    18 
    16 
    19 from cubicweb import RequestSessionMixIn, Binary
    17 from cubicweb import RequestSessionMixIn, Binary
    20 from cubicweb.dbapi import ConnectionProperties
    18 from cubicweb.dbapi import ConnectionProperties
    21 from cubicweb.utils import make_uid
    19 from cubicweb.utils import make_uid
    22 from cubicweb.server.rqlrewrite import RQLRewriter
    20 from cubicweb.server.rqlrewrite import RQLRewriter
    23 
    21 
    24 _ETYPE_PYOBJ_MAP = { bool: 'Boolean',
    22 ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
    25                      int: 'Int',
       
    26                      long: 'Int',
       
    27                      float: 'Float',
       
    28                      Decimal: 'Decimal',
       
    29                      unicode: 'String',
       
    30                      NoneType: None,
       
    31                      Binary: 'Bytes',
       
    32                      DateTimeType: 'Datetime',
       
    33                      DateTimeDeltaType: 'Interval',
       
    34                      }
       
    35 
       
    36 def etype_from_pyobj(value):
       
    37     """guess yams type from python value"""
       
    38     # note:
       
    39     # * Password is not selectable so no problem)
       
    40     # * use type(value) and not value.__class__ since mx instances have no
       
    41     #   __class__ attribute
       
    42     # * XXX Date, Time
       
    43     return _ETYPE_PYOBJ_MAP[type(value)]
       
    44 
    23 
    45 def is_final(rqlst, variable, args):
    24 def is_final(rqlst, variable, args):
    46     # try to find if this is a final var or not
    25     # try to find if this is a final var or not
    47     for select in rqlst.children:
    26     for select in rqlst.children:
    48         for sol in select.solutions:
    27         for sol in select.solutions: