[web2py] How write subquery of LEFT JOIN using DAL?

2013-07-29 Thread Denis Rykov
Please help me to write the following SQL query using DAL:

SELECT indicator.*, v.date, v.value FROM indicator
LEFT JOIN (
SELECT value.value, _.indicator, date
FROM (SELECT indicator, min(client_date) AS "date" FROM value WHERE 
created_by = 1 GROUP BY indicator) _
LEFT JOIN value ON _.indicator = value.indicator and _.date = 
value.client_date
) v
ON indicator.id = v.indicator
WHERE indicator.checked = 'T'

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Add ondelete restriction

2013-05-20 Thread Denis Rykov
I have field defenition:

Field('company', 'reference company', notnull=True, label='Company')

and I want to add ondelete restriction:

Field('company', 'reference company', notnull=True, label='Company', 
ondelete='NO ACTION')

But web2py did not alter database.  Is it expected behavior?

P.S. I'm using PostgreSQL

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Save selected option after form submission

2013-05-20 Thread Denis Rykov
I've solved my problem by using 'value' instead '_value':

SELECT(admin_units, _name='admin_unit', value=request.get_vars.get(
'admin_unit', None))


On Tuesday, May 21, 2013 12:39:01 AM UTC+7, Niphlod wrote:
>
> then you must set the selected attribute of your default option to 
> "selected".
>
> e.g. 
>
> options = [OPTION(text, _value=value, _selected=True)]
>
> On Monday, May 20, 2013 7:05:11 PM UTC+2, Denis Rykov wrote:
>>
>> Thanks for response. But I build form manually, not from database table. 
>> What I have to do in this case?
>>
>> On Monday, May 20, 2013 1:52:06 PM UTC+7, Niphlod wrote:
>>>
>>> when you receive the form value, it's probably inside a 
>>> form.vars.name_of_the_field .
>>>
>>> save it somewhere (database, session, cache, etc) and use 
>>>
>>> db.tablename.name_of_the_field.default = your previously saved value
>>>
>>>
>>>
>>>
>>>
>>> On Monday, May 20, 2013 6:04:27 AM UTC+2, Denis Rykov wrote:
>>>>
>>>> I have SELECT item in my form. How I can save state of this item after 
>>>> form submission?
>>>> It looks like I should use selected attribute, but I can't find any 
>>>> examples how I can do it with web2py.
>>>>
>>>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Save selected option after form submission

2013-05-20 Thread Denis Rykov
Thanks for response. But I build form manually, not from database table. 
What I have to do in this case?

On Monday, May 20, 2013 1:52:06 PM UTC+7, Niphlod wrote:
>
> when you receive the form value, it's probably inside a 
> form.vars.name_of_the_field .
>
> save it somewhere (database, session, cache, etc) and use 
>
> db.tablename.name_of_the_field.default = your previously saved value
>
>
>
>
>
> On Monday, May 20, 2013 6:04:27 AM UTC+2, Denis Rykov wrote:
>>
>> I have SELECT item in my form. How I can save state of this item after 
>> form submission?
>> It looks like I should use selected attribute, but I can't find any 
>> examples how I can do it with web2py.
>>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Save selected option after form submission

2013-05-19 Thread Denis Rykov
I have SELECT item in my form. How I can save state of this item after form 
submission?
It looks like I should use selected attribute, but I can't find any 
examples how I can do it with web2py.

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Install web2py in virtualenv

2013-04-19 Thread Denis Rykov
Trying to install web2py in virtualenv on Ubuntu but when I run "w2p_run" I 
get an error "RuntimeError: Cannot determine web2py version".

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] unique and notnull options not applies to foreign key field

2012-09-04 Thread Denis Rykov
I would like make one to one tables relation. For example:

db.define_table('contract',
Field('num', unique=True, notnull=True'),
...

db.define_table('student',
Field('contract', db.contract, unique=True, notnull=True, 
label='Договор'),

But unique and notnull options doesnt reflects in database.

In generally, how I can make one to one relation? I've tried the following 
approach:

db.student.contract.requires = IS_NOT_IN_DB(db, 'student.contract')
db.student.contract.requires = IS_IN_DB(db, db.contract.id, '%(num)s')

but the first requirements (IS_NOT_IN_DB) doesn't work.


-- 





[web2py] required option in Field

2012-09-04 Thread Denis Rykov
I use the following Field definition:

Field('admin_unit', required=True, label='Region'),

But when I create new row through smartgrid interface and leave this field 
empty - validation error not appears and record creates in database. If see 
table in database you can see that 'admin_unit' field contains empty string 
(''). Is it correct? It looks like required options doesn't work properly.

--