I get:

$ python web2py.py -S welcome
Version 2.4.1-alpha.2+timestamp.2013.02.26.11.40.15
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
WARNING:web2py:import IPython error; use default python shell
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> db.define_table('test',
...     Field('t1'),
...     Field('t2'),
...     )
<Table test (id,t1,t2)>
>>> db.test.c12 = Field.Virtual (lambda r: r.t1+r.t2)
>>> 

On Tuesday, 26 February 2013 14:43:15 UTC-6, mweissen wrote:
>
> Sorry, no - same message.
> I have taken the last version from trunk one hour ago.
>
> Ticket ID 
>
> 127.0.0.1.2013-02-26.21-39-35.e1477239-8991-4217-810f-9e320daf692c
> <type 'exceptions.AttributeError'> 'FieldVirtual' object has no attribute 
> 'type' Version  web2py™ (2, 4, 1, 'alpha.2', datetime.datetime(2013, 2, 
> 25, 23, 19, 14))  Python Python 2.7.3: D:\Python27\python.exe (prefix: 
> D:\Python27)  Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
>
> Traceback (most recent call last):
>   File "D:\web2py\gluon\restricted.py", line 212, in restricted
>
>
>     exec ccode in environment
>   File "D:/web2py/applications/calctest/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/calctest/controllers/default.py>, 
> line 88, in <module>
>
>
>   File "D:\web2py\gluon\globals.py", line 193, in <lambda>
>
>
>     self._caller = lambda f: f()
>
>
>   File "D:/web2py/applications/calctest/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/calctest/controllers/default.py>, 
> line 16, in t
>
>
>     db.test.c12,
>   File "D:\web2py\gluon\dal.py", line 9754, in select
>
>
>     return adapter.select(self.query,fields,attributes)
>
>
>   File "D:\web2py\gluon\dal.py", line 2218, in select
>
>
>     return super(SQLiteAdapter, self).select(query, fields, attributes)
>
>
>   File "D:\web2py\gluon\dal.py", line 1665, in select
>
>
>     sql = self._select(query, fields, attributes)
>
>
>   File "D:\web2py\gluon\dal.py", line 1520, in _select
>
>
>     sql_f = ', '.join(map(geoexpand, fields))
>
>
>   File "D:\web2py\gluon\dal.py", line 1517, in geoexpand
>
>
>     if isinstance(field.type,str) and field.type.startswith('geometry'):
>
> AttributeError: 'FieldVirtual' object has no attribute 'type'
>
>
>
>
> 2013/2/26 Massimo Di Pierro <[email protected] <javascript:>>
>
>> This helped me a lot. I included these defaults in web2py so that you 
>> should need to do it yourself. Can you please check if 
>>
>> db.test.c12 = Field.Virtual (lambda r: r.t1+r.t2)
>>
>> now works as expected?
>>
>> On Tuesday, 26 February 2013 05:28:59 UTC-6, Donatas Burba wrote:
>>>
>>> I have a workaround for this issue. Just a little helper function in 
>>> modules:
>>>
>>> def virtual_field(db, table_name, field_name, field_type, compute=lambda 
>>> row: None, label='', represent=None):
>>>     db[table_name][field_name] = Field.Virtual(compute)
>>>     db[table_name][field_name].**type = field_type
>>>     db[table_name][field_name].**label = label
>>>     db[table_name][field_name].**represent = represent
>>>     db[table_name][field_name].**formatter = lambda value: value
>>>     db[table_name][field_name].**comment = None
>>>     db[table_name][field_name].**readable = True
>>>     db[table_name][field_name].**writable = False
>>>     db[table_name][field_name].**requires = None
>>>     db[table_name][field_name].**widget = None
>>>     db[table_name][field_name].**name = field_name
>>>     db[table_name][field_name].**tablename = table_name
>>>     db[table_name][field_name].**filter_out = None
>>>
>>> Because I very often need such virtual fields (to show complex computed 
>>> result from several fields or even tables), this really helps me.
>>>
>>  -- 
>>   
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to