[web2py] Re: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Simon Ashley


Failing any other replies, this is what we do:

   1. copy the file to the server (read then write; we get the files first 
   and store them natively, outside a db, for later batch processing ) 
   2. use ElementTree to parse the file to get a decent dict
   3. use the dict in a bulk_insert into the db file
   4. sqlform it to the view

 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Update on multiple tables with one form

2013-12-27 Thread Matheus Cardoso
I've tried the Anthony's idea and it worked, with one difference, though: 
the id could not be any value. It just worked putting the id with the same 
value of request.arg(0). I think that has some relation with the hidden 
input in custom forms where you have to put the id of the instance that are 
going to be updated. But it worked like a charm. :)

On Tuesday, January 29, 2013 6:24:53 AM UTC-3, AngeloC wrote:
>
> Hi guys,
>
> I'm looking for a clean way to make an update on mutiple tables with only 
> one form and cannot find anything clean/simple searching the mailing list.
>
> Tables could be related (in parent-child relation) or not related at all.
>
> I'm missing something or there is no easy way to do that?
>
> Thanks in advance!
>  
> -- 
> Profile: http://it.linkedin.com/in/compagnucciangelo 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: trying to add a submit button to SQLFORM but it does nothing

2013-12-27 Thread Tim Richardson
There is nothing wrong with the HTML generated by web2py. Browsers don't 
like it though, too many forms perhaps. Or nested forms.

On Tuesday, 24 December 2013 09:39:36 UTC+11, Tim Richardson wrote:
>
> def test_form():
> grid = SQLFORM.grid(db.person,
> links=[dict(header='field1',body=lambda row: INPUT
> (_type='text',value='123',_name='field1 %s ' % row.id))])
>
> grid_form = FORM(grid,INPUT(_type="submit",_name="testsubmit",_value=
> "testsubmit"))
>
> if grid_form.accepts(request,session):
> print "submit successful"   #never happens
>
> return dict(form=grid_form,simple_form=simple_form)
>
>
> In the grid_form, the submit button doesn't submit anything and 
> grid_form.accepts() is therefore never true.
> It works if I replace grid_form with a simple FORM (the example for FORM 
> in the book). 
>
> This is with trunk, on os x, python 2.7.6
>
> The HTML looks fine. I am using a simple view {{=form}}
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Brando
Simon, could you share your code or possibly provide a w2p app?  Thanks for 
the reply.



On Friday, December 27, 2013 3:29:51 AM UTC-8, Simon Ashley wrote:
>
> Failing any other replies, this is what we do:
>
>1. copy the file to the server (read then write; we get the files 
>first and store them natively, outside a db, for later batch processing ) 
>2. use ElementTree to parse the file to get a decent dict
>3. use the dict in a bulk_insert into the db file
>4. sqlform it to the view
>
>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Drop down not showing

2013-12-27 Thread Michel Hayek
Please any help guys?

-- 
 

*This e-mail is confidential and may also be privileged. If you are not the 
intended **recipient, please notify the sender immediately, delete it from 
your system and do **not copy, disseminate, distribute or disclose any 
information contained therein.*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] only last item on the dict is rendered.

2013-12-27 Thread Avi A
Hi,
I'm doing something like that:
if auth.user:
my_org = db(db.t_org_members.f_org_member == 
auth.user.id).select(db.t_org_members.f_org_rep)
if my_org:
for m in my_org:
my_org_members = db(db.t_org_members.f_org_rep == 
 m.f_org_rep).select(db.t_org_members.created_by)
for member in my_org_members:
org_member_data = db(db.auth_user.id == 
 member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
db.auth_user.email, 
db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )

The only problem is that :

while this renders three members as expected:
{{=my_org_members}}

This renders the last member's data only:

{{for member in org_member_data:}} 
{{=member}}
{{pass}}


Thanks.





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Jonathan Lundell
On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
> Hi,
> I'm doing something like that:
> if auth.user:
> my_org = db(db.t_org_members.f_org_member == 
> auth.user.id).select(db.t_org_members.f_org_rep)
> if my_org:
> for m in my_org:
> my_org_members = db(db.t_org_members.f_org_rep ==  
> m.f_org_rep).select(db.t_org_members.created_by)
> for member in my_org_members:
> org_member_data = db(db.auth_user.id ==  
> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
> 
> The only problem is that :
> 
> while this renders three members as expected:
> {{=my_org_members}}
> 
> This renders the last member's data only:
> 
> {{for member in org_member_data:}} 
> {{=member}}
> {{pass}}
> 
> 
> Thanks.
> 

org_member_data is set to a single member's data, so it ends up with the last 
one it was set to. 

Did you mean to write:

{{for member in my_org_members:}} 
{{=member}}
{{pass}}

... or perhaps collect org_member_data instances in a list?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
Thanks,
I wasn't wrong, this is what I need:

{{for member in org_member_data:}} 

what do you mean by:
"org_member_data is set to a single member's data, so it ends up with the 
last one it was set to. ?
or:
or perhaps collect org_member_data instances in a list?

i return it as a dict or as locals() and it still renders the last one only.
 

On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 9:53 AM, Avi A > wrote:
>
> Hi,
> I'm doing something like that:
> if auth.user:
> my_org = db(db.t_org_members.f_org_member == auth.user.id
> ).select(db.t_org_members.f_org_rep)
> if my_org:
> for m in my_org:
> my_org_members = db(db.t_org_members.f_org_rep == 
>  m.f_org_rep).select(db.t_org_members.created_by)
> for member in my_org_members:
> org_member_data = db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>
> The only problem is that :
>
> while this renders three members as expected:
> {{=my_org_members}}
>
> This renders the last member's data only:
>
> {{for member in org_member_data:}} 
> {{=member}}
> {{pass}}
>
>
> Thanks.
>
>
> org_member_data is set to a single member's data, so it ends up with the 
> last one it was set to. 
>
> Did you mean to write:
>
> {{for member in my_org_members:}} 
> {{=member}}
> {{pass}}
>
> ... or perhaps collect org_member_data instances in a list?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Jonathan Lundell
On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
> Thanks,
> I wasn't wrong, this is what I need:
>> {{for member in org_member_data:}} 
> what do you mean by:
> "org_member_data is set to a single member's data, so it ends up with the 
> last one it was set to. ?
> or:
> or perhaps collect org_member_data instances in a list?
> 
> i return it as a dict or as locals() and it still renders the last one only.

You assign org_member_data to the select of a single row at a time. Assigning 
it three times doesn't mean that it'll contain all three rows.

Another potential problem is that org_member_data is undefined if my_org is 
empty; it'd be prudent to initialize it to None (and check for that).

But I think what you really mean is something like:

org_member_data = []
...
for member in my_org_members:
org_member_data.append(db(db.auth_user.id ==  
member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
db.auth_user.email, 
db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name ))


>  
> 
> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>> Hi,
>> I'm doing something like that:
>> if auth.user:
>> my_org = db(db.t_org_members.f_org_member == 
>> auth.user.id).select(db.t_org_members.f_org_rep)
>> if my_org:
>> for m in my_org:
>> my_org_members = db(db.t_org_members.f_org_rep ==  
>> m.f_org_rep).select(db.t_org_members.created_by)
>> for member in my_org_members:
>> org_member_data = db(db.auth_user.id ==  
>> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>> db.auth_user.email, 
>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>> 
>> The only problem is that :
>> 
>> while this renders three members as expected:
>> {{=my_org_members}}
>> 
>> This renders the last member's data only:
>> 
>> {{for member in org_member_data:}} 
>> {{=member}}
>> {{pass}}
>> 
>> 
>> Thanks.
>> 
> 
> org_member_data is set to a single member's data, so it ends up with the last 
> one it was set to. 
> 
> Did you mean to write:
> 
> {{for member in my_org_members:}} 
> {{=member}}
> {{pass}}
> 
> ... or perhaps collect org_member_data instances in a list?
> 
> 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
Alright, I see what you mean. I'll give it a try. Thanks.

On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 10:23 AM, Avi A > 
> wrote:
>
> Thanks,
> I wasn't wrong, this is what I need:
>
> {{for member in org_member_data:}} 
>
> what do you mean by:
> "org_member_data is set to a single member's data, so it ends up with the 
> last one it was set to. ?
> or:
> or perhaps collect org_member_data instances in a list?
>
> i return it as a dict or as locals() and it still renders the last one 
> only.
>
>
> You assign org_member_data to the select of a single row at a time. 
> Assigning it three times doesn't mean that it'll contain all three rows.
>
> Another potential problem is that org_member_data is undefined if my_org 
> is empty; it'd be prudent to initialize it to None (and check for that).
>
> But I think what you really mean is something like:
>
> org_member_data = []
> ...
> for member in my_org_members:
> org_member_data.append(db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email,
>  db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
> ))
>
>
>  
>
> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>>
>> Hi,
>> I'm doing something like that:
>> if auth.user:
>> my_org = db(db.t_org_members.f_org_member == auth.user.id
>> ).select(db.t_org_members.f_org_rep)
>> if my_org:
>> for m in my_org:
>> my_org_members = db(db.t_org_members.f_org_rep == 
>>  m.f_org_rep).select(db.t_org_members.created_by)
>> for member in my_org_members:
>> org_member_data = db(db.auth_user.id == 
>>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>> db.auth_user.email, 
>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>>
>> The only problem is that :
>>
>> while this renders three members as expected:
>> {{=my_org_members}}
>>
>> This renders the last member's data only:
>>
>> {{for member in org_member_data:}} 
>> {{=member}}
>> {{pass}}
>>
>>
>> Thanks.
>>
>>
>> org_member_data is set to a single member's data, so it ends up with the 
>> last one it was set to. 
>>
>> Did you mean to write:
>>
>> {{for member in my_org_members:}} 
>> {{=member}}
>> {{pass}}
>>
>> ... or perhaps collect org_member_data instances in a list?
>>
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
for case my_org is empty i wrote:
if my_org:
not good enough? (if not empty?)


On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 10:23 AM, Avi A > 
> wrote:
>
> Thanks,
> I wasn't wrong, this is what I need:
>
> {{for member in org_member_data:}} 
>
> what do you mean by:
> "org_member_data is set to a single member's data, so it ends up with the 
> last one it was set to. ?
> or:
> or perhaps collect org_member_data instances in a list?
>
> i return it as a dict or as locals() and it still renders the last one 
> only.
>
>
> You assign org_member_data to the select of a single row at a time. 
> Assigning it three times doesn't mean that it'll contain all three rows.
>
> Another potential problem is that org_member_data is undefined if my_org 
> is empty; it'd be prudent to initialize it to None (and check for that).
>
> But I think what you really mean is something like:
>
> org_member_data = []
> ...
> for member in my_org_members:
> org_member_data.append(db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email,
>  db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
> ))
>
>
>  
>
> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>>
>> Hi,
>> I'm doing something like that:
>> if auth.user:
>> my_org = db(db.t_org_members.f_org_member == auth.user.id
>> ).select(db.t_org_members.f_org_rep)
>> if my_org:
>> for m in my_org:
>> my_org_members = db(db.t_org_members.f_org_rep == 
>>  m.f_org_rep).select(db.t_org_members.created_by)
>> for member in my_org_members:
>> org_member_data = db(db.auth_user.id == 
>>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>> db.auth_user.email, 
>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>>
>> The only problem is that :
>>
>> while this renders three members as expected:
>> {{=my_org_members}}
>>
>> This renders the last member's data only:
>>
>> {{for member in org_member_data:}} 
>> {{=member}}
>> {{pass}}
>>
>>
>> Thanks.
>>
>>
>> org_member_data is set to a single member's data, so it ends up with the 
>> last one it was set to. 
>>
>> Did you mean to write:
>>
>> {{for member in my_org_members:}} 
>> {{=member}}
>> {{pass}}
>>
>> ... or perhaps collect org_member_data instances in a list?
>>
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Jonathan Lundell
On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
> for case my_org is empty i wrote:
> if my_org:
> not good enough? (if not empty?)

If that happens, what does the view see?

> 
> 
> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
>> Thanks,
>> I wasn't wrong, this is what I need:
>>> {{for member in org_member_data:}} 
>> what do you mean by:
>> "org_member_data is set to a single member's data, so it ends up with the 
>> last one it was set to. ?
>> or:
>> or perhaps collect org_member_data instances in a list?
>> 
>> i return it as a dict or as locals() and it still renders the last one only.
> 
> You assign org_member_data to the select of a single row at a time. Assigning 
> it three times doesn't mean that it'll contain all three rows.
> 
> Another potential problem is that org_member_data is undefined if my_org is 
> empty; it'd be prudent to initialize it to None (and check for that).
> 
> But I think what you really mean is something like:
> 
> org_member_data = []
> ...
> for member in my_org_members:
> org_member_data.append(db(db.auth_user.id ==  
> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name ))
> 
> 
>>  
>> 
>> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>>> Hi,
>>> I'm doing something like that:
>>> if auth.user:
>>> my_org = db(db.t_org_members.f_org_member == 
>>> auth.user.id).select(db.t_org_members.f_org_rep)
>>> if my_org:
>>> for m in my_org:
>>> my_org_members = db(db.t_org_members.f_org_rep ==  
>>> m.f_org_rep).select(db.t_org_members.created_by)
>>> for member in my_org_members:
>>> org_member_data = db(db.auth_user.id ==  
>>> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>>> db.auth_user.email, 
>>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>>> 
>>> The only problem is that :
>>> 
>>> while this renders three members as expected:
>>> {{=my_org_members}}
>>> 
>>> This renders the last member's data only:
>>> 
>>> {{for member in org_member_data:}} 
>>> {{=member}}
>>> {{pass}}
>>> 
>>> 
>>> Thanks.
>>> 
>> 
>> org_member_data is set to a single member's data, so it ends up with the 
>> last one it was set to. 
>> 
>> Did you mean to write:
>> 
>> {{for member in my_org_members:}} 
>> {{=member}}
>> {{pass}}
>> 
>> ... or perhaps collect org_member_data instances in a list?
>> 
>> 
> 
> 
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
user logged in
the view:
if he is in a group:
till now he will see the group members' data and take some action later on.
else:
will sign up for a group.
after page refresh will see the group members' data.

(will have a different page for modifying subscription.)


On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 10:53 AM, Avi A > 
> wrote:
>
> for case my_org is empty i wrote:
> if my_org:
> not good enough? (if not empty?)
>
>
> If that happens, what does the view see?
>
>
>
> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
>>
>> Thanks,
>> I wasn't wrong, this is what I need:
>>
>> {{for member in org_member_data:}} 
>>
>> what do you mean by:
>> "org_member_data is set to a single member's data, so it ends up with 
>> the last one it was set to. ?
>> or:
>> or perhaps collect org_member_data instances in a list?
>>
>> i return it as a dict or as locals() and it still renders the last one 
>> only.
>>
>>
>> You assign org_member_data to the select of a single row at a time. 
>> Assigning it three times doesn't mean that it'll contain all three rows.
>>
>> Another potential problem is that org_member_data is undefined if my_org 
>> is empty; it'd be prudent to initialize it to None (and check for that).
>>
>> But I think what you really mean is something like:
>>
>> org_member_data = []
>> ...
>> for member in my_org_members:
>> org_member_data.append(db(db.auth_user.id == 
>>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>> db.auth_user.email,
>>  db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
>> ))
>>
>>
>>  
>>
>> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>>>
>>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>>>
>>> Hi,
>>> I'm doing something like that:
>>> if auth.user:
>>> my_org = db(db.t_org_members.f_org_member == auth.user.id
>>> ).select(db.t_org_members.f_org_rep)
>>> if my_org:
>>> for m in my_org:
>>> my_org_members = db(db.t_org_members.f_org_rep == 
>>>  m.f_org_rep).select(db.t_org_members.created_by)
>>> for member in my_org_members:
>>> org_member_data = db(db.auth_user.id == 
>>>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>>> db.auth_user.email, 
>>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name )
>>>
>>> The only problem is that :
>>>
>>> while this renders three members as expected:
>>> {{=my_org_members}}
>>>
>>> This renders the last member's data only:
>>>
>>> {{for member in org_member_data:}} 
>>> {{=member}}
>>> {{pass}}
>>>
>>>
>>> Thanks.
>>>
>>>
>>> org_member_data is set to a single member's data, so it ends up with the 
>>> last one it was set to. 
>>>
>>> Did you mean to write:
>>>
>>> {{for member in my_org_members:}} 
>>> {{=member}}
>>> {{pass}}
>>>
>>> ... or perhaps collect org_member_data instances in a list?
>>>
>>
>>
>>
>>
>>
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: building model at run-time?

2013-12-27 Thread Tim Richardson


You may not realise it perhaps, but when defining models for legacy tables, 
you don't need to define every field, just the ones you use. The amount of 
work required in constructing your models may not be as much as you think.
Read about lazy tables: these mean that the table definition is only 
executed when needed. 
For performance reasons it will be better to define models as documented, 
rather than construct them on the fly by querying meta data. That will be 
slow, and you'll lose the lazy table advantage.

 Technically, web2py's models are always "runtime" in that each request 
from a client causes the model to be built as part of constructing the 
response. This means you should be sensitive about what you do as part of 
each request: every page served means the models are rebuilt. Lazy tables 
delays or avoids a lot of this; your 'runtime' approach could be a 
substantial slowdown.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] Re: links in texts stoded in a database

2013-12-27 Thread Jonas Fredriksson
I tried ckeditor and I've got an editor in admin so I can insert links, so
far so good.
but the text is still rendered plain with html tags visible.

my function and db in db.py: (text field is the field I want to insert
links into)

def advanced_editor(field,text):
return TEXTAREA(_id = str(text).replace('.','_'), _name=field.text,
_class='text ckeditor', value=text , _cols=80)

db.define_table('blog',
Field('date','datetime',default=request.now),
Field('image','upload'),
Field('imageTitle','text',default="image text"),
Field('title','text',default='imager text here...'),
Field('text','text',default='blog text
here...',widget=advanced_editor),
Field('votes','integer',default=0),
Field('plus','integer',default=0),
Field('minus','integer',default=0))
#format = '%(title)s')


On Wed, Dec 25, 2013 at 2:53 AM, 黄祥  wrote:

> i think you can achieve it with put the rich text editor in your form input
> ref:
> https://groups.google.com/forum/#!topic/web2py/OoZ1EI8OOmw
>
> another way is with put the html code in your input text area form or
> either use markmin.
> the first is the easiest.
>
> best regards,
> stifan
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/yukzpnZe4GQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
Now I am able to get the list as you suggested with append.
But i don't know how to render it.
This is what I try in the view but it says that NameError: name 'auth_user' is 
not defined:

 {{for member in org_member_data:}}
{{=member[auth_user.email]}}
  {{pass}}



On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
>
> user logged in
> the view:
> if he is in a group:
> till now he will see the group members' data and take some action later on.
> else:
> will sign up for a group.
> after page refresh will see the group members' data.
>
> (will have a different page for modifying subscription.)
>
>
> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
>>
>> for case my_org is empty i wrote:
>> if my_org:
>> not good enough? (if not empty?)
>>
>>
>> If that happens, what does the view see?
>>
>>
>>
>> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>>>
>>> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
>>>
>>> Thanks,
>>> I wasn't wrong, this is what I need:
>>>
>>> {{for member in org_member_data:}} 
>>>
>>> what do you mean by:
>>> "org_member_data is set to a single member's data, so it ends up with 
>>> the last one it was set to. ?
>>> or:
>>> or perhaps collect org_member_data instances in a list?
>>>
>>> i return it as a dict or as locals() and it still renders the last one 
>>> only.
>>>
>>>
>>> You assign org_member_data to the select of a single row at a time. 
>>> Assigning it three times doesn't mean that it'll contain all three rows.
>>>
>>> Another potential problem is that org_member_data is undefined if my_org 
>>> is empty; it'd be prudent to initialize it to None (and check for that).
>>>
>>> But I think what you really mean is something like:
>>>
>>> org_member_data = []
>>> ...
>>> for member in my_org_members:
>>> org_member_data.append(db(db.auth_user.id == 
>>>  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>>> db.auth_user.email,
>>>  db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
>>> ))
>>>
>>>
>>>  
>>>
>>> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:

 On 27 Dec 2013, at 9:53 AM, Avi A  wrote:

 Hi,
 I'm doing something like that:
 if auth.user:
 my_org = db(db.t_org_members.f_org_member == auth.user.id
 ).select(db.t_org_members.f_org_rep)
 if my_org:
 for m in my_org:
 my_org_members = db(db.t_org_members.f_org_rep == 
  m.f_org_rep).select(db.t_org_members.created_by)
 for member in my_org_members:
 org_member_data = db(db.auth_user.id == 
  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
 db.auth_user.email, 
 db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
 )

 The only problem is that :

 while this renders three members as expected:
 {{=my_org_members}}

 This renders the last member's data only:

 {{for member in org_member_data:}} 
 {{=member}}
 {{pass}}


 Thanks.


 org_member_data is set to a single member's data, so it ends up with 
 the last one it was set to. 

 Did you mean to write:

 {{for member in my_org_members:}} 
 {{=member}}
 {{pass}}

 ... or perhaps collect org_member_data instances in a list?

>>>
>>>
>>>
>>>
>>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Jonathan Lundell
On 27 Dec 2013, at 2:20 PM, Avi A  wrote:
> Now I am able to get the list as you suggested with append.
> But i don't know how to render it.
> This is what I try in the view but it says that NameError: name 'auth_user' 
> is not defined:
>  {{for member in org_member_data:}}
> {{=member[auth_user.email]}}
>   {{pass}}

You want something like member.auth_user.email or maybe member.email. auth_user 
isn't a variable defined in your controller or view; it's an element of the row.

> 
> 
> On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
> user logged in
> the view:
> if he is in a group:
> till now he will see the group members' data and take some action later on.
> else:
> will sign up for a group.
> after page refresh will see the group members' data.
> 
> (will have a different page for modifying subscription.)
> 
> 
> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
> On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
>> for case my_org is empty i wrote:
>> if my_org:
>> not good enough? (if not empty?)
> 
> If that happens, what does the view see?
> 
>> 
>> 
>> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
>>> Thanks,
>>> I wasn't wrong, this is what I need:
 {{for member in org_member_data:}} 
>>> what do you mean by:
>>> "org_member_data is set to a single member's data, so it ends up with the 
>>> last one it was set to. ?
>>> or:
>>> or perhaps collect org_member_data instances in a list?
>>> 
>>> i return it as a dict or as locals() and it still renders the last one only.
>> 
>> You assign org_member_data to the select of a single row at a time. 
>> Assigning it three times doesn't mean that it'll contain all three rows.
>> 
>> Another potential problem is that org_member_data is undefined if my_org is 
>> empty; it'd be prudent to initialize it to None (and check for that).
>> 
>> But I think what you really mean is something like:
>> 
>> org_member_data = []
>> ...
>> for member in my_org_members:
>> org_member_data.append(db(db.auth_user.id ==  
>> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>> db.auth_user.email, 
>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name ))
>> 
>> 
>>>  
>>> 
>>> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
 Hi,
 I'm doing something like that:
 if auth.user:
 my_org = db(db.t_org_members.f_org_member == 
 auth.user.id).select(db.t_org_members.f_org_rep)
 if my_org:
 for m in my_org:
 my_org_members = db(db.t_org_members.f_org_rep ==  
 m.f_org_rep).select(db.t_org_members.created_by)
 for member in my_org_members:
 org_member_data = db(db.auth_user.id ==  
 member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
 db.auth_user.email, 
 db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
 )
 
 The only problem is that :
 
 while this renders three members as expected:
 {{=my_org_members}}
 
 This renders the last member's data only:
 
 {{for member in org_member_data:}} 
 {{=member}}
 {{pass}}
 
 
 Thanks.
 
>>> 
>>> org_member_data is set to a single member's data, so it ends up with the 
>>> last one it was set to. 
>>> 
>>> Did you mean to write:
>>> 
>>> {{for member in my_org_members:}} 
>>> {{=member}}
>>> {{pass}}
>>> 
>>> ... or perhaps collect org_member_data instances in a list?
>>> 
>>> 
>> 
>> 
>> 
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
> 
> 
> 
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
member.auth_user.email throws the same error. 
auth_user.email is defined in the select on the controller, as far as i 
understand, 
among other fields from the auth user table..

On Saturday, December 28, 2013 12:35:54 AM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 2:20 PM, Avi A > wrote:
>
> Now I am able to get the list as you suggested with append.
> But i don't know how to render it.
> This is what I try in the view but it says that NameError: name 'auth_user' 
> is not defined:
>
>  {{for member in org_member_data:}}
> {{=member[auth_user.email]}}
>   {{pass}}
>
>
> You want something like member.auth_user.email or maybe member.email. 
> auth_user isn't a variable defined in your controller or view; it's an 
> element of the row.
>
>
>
> On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
>>
>> user logged in
>> the view:
>> if he is in a group:
>> till now he will see the group members' data and take some action later 
>> on.
>> else:
>> will sign up for a group.
>> after page refresh will see the group members' data.
>>
>> (will have a different page for modifying subscription.)
>>
>>
>> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
>>>
>>> On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
>>>
>>> for case my_org is empty i wrote:
>>> if my_org:
>>> not good enough? (if not empty?)
>>>
>>>
>>> If that happens, what does the view see?
>>>
>>>
>>>
>>> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:

 On 27 Dec 2013, at 10:23 AM, Avi A  wrote:

 Thanks,
 I wasn't wrong, this is what I need:

 {{for member in org_member_data:}} 

 what do you mean by:
 "org_member_data is set to a single member's data, so it ends up with 
 the last one it was set to. ?
 or:
 or perhaps collect org_member_data instances in a list?

 i return it as a dict or as locals() and it still renders the last one 
 only.


 You assign org_member_data to the select of a single row at a time. 
 Assigning it three times doesn't mean that it'll contain all three rows.

 Another potential problem is that org_member_data is undefined 
 if my_org is empty; it'd be prudent to initialize it to None (and check 
 for 
 that).

 But I think what you really mean is something like:

 org_member_data = []
 ...
 for member in my_org_members:
 org_member_data.append(db(db.auth_user.id == 
  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
 db.auth_user.email,
  db.auth_user.profile_image,db.auth_user.first_name, 
 db.auth_user.last_name 
 ))


  

 On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>
> Hi,
> I'm doing something like that:
> if auth.user:
> my_org = db(db.t_org_members.f_org_member == auth.user.id
> ).select(db.t_org_members.f_org_rep)
> if my_org:
> for m in my_org:
> my_org_members = db(db.t_org_members.f_org_rep == 
>  m.f_org_rep).select(db.t_org_members.created_by)
> for member in my_org_members:
> org_member_data = db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, 
> db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, 
> db.auth_user.last_name )
>
> The only problem is that :
>
> while this renders three members as expected:
> {{=my_org_members}}
>
> This renders the last member's data only:
>
> {{for member in org_member_data:}} 
> {{=member}}
> {{pass}}
>
>
> Thanks.
>
>
> org_member_data is set to a single member's data, so it ends up with 
> the last one it was set to. 
>
> Did you mean to write:
>
> {{for member in my_org_members:}} 
> {{=member}}
> {{pass}}
>
> ... or perhaps collect org_member_data instances in a list?
>





>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>
>>>
>>>
>>>
>>>
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this mess

Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Jonathan Lundell
On 27 Dec 2013, at 2:42 PM, Avi A  wrote:
> member.auth_user.email throws the same error. 
> auth_user.email is defined in the select on the controller, as far as i 
> understand, among other fields from the auth user table..

It's not.

Try member.email. If that doesn't work, just display member and see what's in 
it.

> 
> On Saturday, December 28, 2013 12:35:54 AM UTC+2, Jonathan Lundell wrote:
> On 27 Dec 2013, at 2:20 PM, Avi A  wrote:
>> Now I am able to get the list as you suggested with append.
>> But i don't know how to render it.
>> This is what I try in the view but it says that NameError: name 'auth_user' 
>> is not defined:
>>  {{for member in org_member_data:}}
>> {{=member[auth_user.email]}}
>>   {{pass}}
> 
> You want something like member.auth_user.email or maybe member.email. 
> auth_user isn't a variable defined in your controller or view; it's an 
> element of the row.
> 
>> 
>> 
>> On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
>> user logged in
>> the view:
>> if he is in a group:
>> till now he will see the group members' data and take some action later on.
>> else:
>> will sign up for a group.
>> after page refresh will see the group members' data.
>> 
>> (will have a different page for modifying subscription.)
>> 
>> 
>> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
>> On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
>>> for case my_org is empty i wrote:
>>> if my_org:
>>> not good enough? (if not empty?)
>> 
>> If that happens, what does the view see?
>> 
>>> 
>>> 
>>> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>>> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
 Thanks,
 I wasn't wrong, this is what I need:
> {{for member in org_member_data:}} 
 what do you mean by:
 "org_member_data is set to a single member's data, so it ends up with the 
 last one it was set to. ?
 or:
 or perhaps collect org_member_data instances in a list?
 
 i return it as a dict or as locals() and it still renders the last one 
 only.
>>> 
>>> You assign org_member_data to the select of a single row at a time. 
>>> Assigning it three times doesn't mean that it'll contain all three rows.
>>> 
>>> Another potential problem is that org_member_data is undefined if my_org is 
>>> empty; it'd be prudent to initialize it to None (and check for that).
>>> 
>>> But I think what you really mean is something like:
>>> 
>>> org_member_data = []
>>> ...
>>> for member in my_org_members:
>>> org_member_data.append(db(db.auth_user.id ==  
>>> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
>>> db.auth_user.email, 
>>> db.auth_user.profile_image,db.auth_user.first_name, db.auth_user.last_name 
>>> ))
>>> 
>>> 
  
 
 On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
 On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
> Hi,
> I'm doing something like that:
> if auth.user:
> my_org = db(db.t_org_members.f_org_member == 
> auth.user.id).select(db.t_org_members.f_org_rep)
> if my_org:
> for m in my_org:
> my_org_members = db(db.t_org_members.f_org_rep ==  
> m.f_org_rep).select(db.t_org_members.created_by)
> for member in my_org_members:
> org_member_data = db(db.auth_user.id ==  
> member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, 
> db.auth_user.last_name )
> 
> The only problem is that :
> 
> while this renders three members as expected:
> {{=my_org_members}}
> 
> This renders the last member's data only:
> 
> {{for member in org_member_data:}} 
> {{=member}}
> {{pass}}
> 
> 
> Thanks.
> 
 
 org_member_data is set to a single member's data, so it ends up with the 
 last one it was set to. 
 
 Did you mean to write:
 
 {{for member in my_org_members:}} 
 {{=member}}
 {{pass}}
 
 ... or perhaps collect org_member_data instances in a list?
 
 
>>> 
>>> 
>>> 
>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> 
>> 
>> 
>> 
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
> 
> 
> 
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.go

Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
yes i tried that one too.
{{=member}} renders inside each option atable with expected data:
auth_user.phone_numauth_user.car_num_0
auth_user.emailauth_user.profile_image
auth_user.first_nameauth_user.last_name0548102940111aviavia4u+1@g...
fileAviAbramovitch

On Saturday, December 28, 2013 12:35:54 AM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 2:20 PM, Avi A > wrote:
>
> Now I am able to get the list as you suggested with append.
> But i don't know how to render it.
> This is what I try in the view but it says that NameError: name 'auth_user' 
> is not defined:
>
>  {{for member in org_member_data:}}
> {{=member[auth_user.email]}}
>   {{pass}}
>
>
> You want something like member.auth_user.email or maybe member.email. 
> auth_user isn't a variable defined in your controller or view; it's an 
> element of the row.
>
>
>
> On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
>>
>> user logged in
>> the view:
>> if he is in a group:
>> till now he will see the group members' data and take some action later 
>> on.
>> else:
>> will sign up for a group.
>> after page refresh will see the group members' data.
>>
>> (will have a different page for modifying subscription.)
>>
>>
>> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:
>>>
>>> On 27 Dec 2013, at 10:53 AM, Avi A  wrote:
>>>
>>> for case my_org is empty i wrote:
>>> if my_org:
>>> not good enough? (if not empty?)
>>>
>>>
>>> If that happens, what does the view see?
>>>
>>>
>>>
>>> On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:

 On 27 Dec 2013, at 10:23 AM, Avi A  wrote:

 Thanks,
 I wasn't wrong, this is what I need:

 {{for member in org_member_data:}} 

 what do you mean by:
 "org_member_data is set to a single member's data, so it ends up with 
 the last one it was set to. ?
 or:
 or perhaps collect org_member_data instances in a list?

 i return it as a dict or as locals() and it still renders the last one 
 only.


 You assign org_member_data to the select of a single row at a time. 
 Assigning it three times doesn't mean that it'll contain all three rows.

 Another potential problem is that org_member_data is undefined 
 if my_org is empty; it'd be prudent to initialize it to None (and check 
 for 
 that).

 But I think what you really mean is something like:

 org_member_data = []
 ...
 for member in my_org_members:
 org_member_data.append(db(db.auth_user.id == 
  member.created_by).select(db.auth_user.phone_num, db.auth_user.car_num_0, 
 db.auth_user.email,
  db.auth_user.profile_image,db.auth_user.first_name, 
 db.auth_user.last_name 
 ))


  

 On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>
> Hi,
> I'm doing something like that:
> if auth.user:
> my_org = db(db.t_org_members.f_org_member == auth.user.id
> ).select(db.t_org_members.f_org_rep)
> if my_org:
> for m in my_org:
> my_org_members = db(db.t_org_members.f_org_rep == 
>  m.f_org_rep).select(db.t_org_members.created_by)
> for member in my_org_members:
> org_member_data = db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, 
> db.auth_user.car_num_0, 
> db.auth_user.email, 
> db.auth_user.profile_image,db.auth_user.first_name, 
> db.auth_user.last_name )
>
> The only problem is that :
>
> while this renders three members as expected:
> {{=my_org_members}}
>
> This renders the last member's data only:
>
> {{for member in org_member_data:}} 
> {{=member}}
> {{pass}}
>
>
> Thanks.
>
>
> org_member_data is set to a single member's data, so it ends up with 
> the last one it was set to. 
>
> Did you mean to write:
>
> {{for member in my_org_members:}} 
> {{=member}}
> {{pass}}
>
> ... or perhaps collect org_member_data instances in a list?
>





>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>
>>>
>>>
>>>
>>>
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
>
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https

[web2py] Re: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Simon Ashley


A little difficult to share to code (done for a client, its similar and but 
not exactly what you're doing i.e. maybe a lot more complicated than what 
you need), but I think you're almost there. 

You need to upload the files to the server, then parse them to get each 
dict. My understanding is that you don't have issues generating the dict 
and there it should be a simple bulk_insert ...  
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=bulk_insert
.

My feeling that you may be having issues with parsing the uploaded file and 
you should be able to get the file name/ location for parsing routines by 
following 
http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: trying to add a submit button to SQLFORM but it does nothing

2013-12-27 Thread Massimo Di Pierro
You cannot have a grid in a form because a grid contains a form. Nested 
forms are not allowed in html.

Massimo

On Monday, 23 December 2013 21:16:52 UTC-6, Tim Richardson wrote:
>
> This works:
>
>
> grid_form = 
> FORM(INPUT(_type="submit",_name="testsubmit",_value="testsubmit"),grid,INPUT(_type="submit",_name="testsubmit1",_value="testsubmit1",_class='btn'),
>  )
>
> That is, adding the submit button before the grid works (the second button 
> still doesn't work)
>
>
>
> On Tuesday, 24 December 2013 09:39:36 UTC+11, Tim Richardson wrote:
>>
>> def test_form():
>> grid = SQLFORM.grid(db.person,
>> links=[dict(header='field1',body=lambda row:INPUT
>> (_type='text',value='123',_name='field1 %s ' % row.id))])
>>
>> grid_form = FORM(grid,INPUT(_type="submit",_name="testsubmit",_value=
>> "testsubmit"))
>>
>> if grid_form.accepts(request,session):
>> print "submit successful"   #never happens
>>
>> return dict(form=grid_form,simple_form=simple_form)
>>
>>
>> In the grid_form, the submit button doesn't submit anything and 
>> grid_form.accepts() is therefore never true.
>> It works if I replace grid_form with a simple FORM (the example for FORM 
>> in the book). 
>>
>> This is with trunk, on os x, python 2.7.6
>>
>> The HTML looks fine. I am using a simple view {{=form}}
>>
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


Re: [web2py] only last item on the dict is rendered.

2013-12-27 Thread Avi A
I created a dict instead of a list and I'm getting there...thanks.

On Saturday, December 28, 2013 12:44:09 AM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 2:42 PM, Avi A > wrote:
>
> member.auth_user.email throws the same error. 
> auth_user.email is defined in the select on the controller, as far as i 
> understand, 
> among other fields from the auth user table..
>
>
> It's not.
>
> Try member.email. If that doesn't work, just display member and see what's 
> in it.
>
>
> On Saturday, December 28, 2013 12:35:54 AM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 2:20 PM, Avi A  wrote:
>>
>> Now I am able to get the list as you suggested with append.
>> But i don't know how to render it.
>> This is what I try in the view but it says that NameError: name 'auth_user' 
>> is not defined:
>>
>>  {{for member in org_member_data:}}
>> {{=member[auth_user.email]}}
>>   {{pass}}
>>
>>
>> You want something like member.auth_user.email or maybe member.email. 
>> auth_user isn't a variable defined in your controller or view; it's an 
>> element of the row.
>>
>>
>>
>> On Friday, December 27, 2013 9:14:55 PM UTC+2, Avi A wrote:
>>>
>>> user logged in
>>> the view:
>>> if he is in a group:
>>> till now he will see the group members' data and take some action later 
>>> on.
>>> else:
>>> will sign up for a group.
>>> after page refresh will see the group members' data.
>>>
>>> (will have a different page for modifying subscription.)
>>>
>>>
>>> On Friday, December 27, 2013 8:54:34 PM UTC+2, Jonathan Lundell wrote:

 On 27 Dec 2013, at 10:53 AM, Avi A  wrote:

 for case my_org is empty i wrote:
 if my_org:
 not good enough? (if not empty?)


 If that happens, what does the view see?



 On Friday, December 27, 2013 8:37:55 PM UTC+2, Jonathan Lundell wrote:
>
> On 27 Dec 2013, at 10:23 AM, Avi A  wrote:
>
> Thanks,
> I wasn't wrong, this is what I need:
>
> {{for member in org_member_data:}} 
>
> what do you mean by:
> "org_member_data is set to a single member's data, so it ends up with 
> the last one it was set to. ?
> or:
> or perhaps collect org_member_data instances in a list?
>
> i return it as a dict or as locals() and it still renders the last one 
> only.
>
>
> You assign org_member_data to the select of a single row at a time. 
> Assigning it three times doesn't mean that it'll contain all three rows.
>
> Another potential problem is that org_member_data is undefined 
> if my_org is empty; it'd be prudent to initialize it to None (and check 
> for 
> that).
>
> But I think what you really mean is something like:
>
> org_member_data = []
> ...
> for member in my_org_members:
> org_member_data.append(db(db.auth_user.id == 
>  member.created_by).select(db.auth_user.phone_num, 
> db.auth_user.car_num_0, 
> db.auth_user.email,
>  db.auth_user.profile_image,db.auth_user.first_name, 
> db.auth_user.last_name 
> ))
>
>
>  
>
> On Friday, December 27, 2013 8:12:15 PM UTC+2, Jonathan Lundell wrote:
>>
>> On 27 Dec 2013, at 9:53 AM, Avi A  wrote:
>>
>> Hi,
>> I'm doing something like that:
>> if auth.user:
>> my_org = db(db.t_org_members.f_org_member == auth.user.id
>> ).select(db.t_org_members.f_org_rep)
>> if my_org:
>> for m in my_org:
>> my_org_members = db(db.t_org_members.f_org_rep == 
>>  m.f_org_rep).select(db.t_org_members.created_by)
>> for member in my_org_members:
>> org_member_data = db(db.auth_user.id == 
>>  member.created_by).select(db.auth_user.phone_num, 
>> db.auth_user.car_num_0, 
>> db.auth_user.email, 
>> db.auth_user.profile_image,db.auth_user.first_name, 
>> db.auth_user.last_name )
>>
>> The only problem is that :
>>
>> while this renders three members as expected:
>> {{=my_org_members}}
>>
>> This renders the last member's data only:
>>
>> {{for member in org_member_data:}} 
>> {{=member}}
>> {{pass}}
>>
>>
>> Thanks.
>>
>>
>> org_member_data is set to a single member's data, so it ends up with 
>> the last one it was set to. 
>>
>> Did you mean to write:
>>
>> {{for member in my_org_members:}} 
>> {{=member}}
>> {{pass}}
>>
>> ... or perhaps collect org_member_data instances in a list?
>>
>
>
>
>
>
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list

[web2py] Re: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Brando
I think i'm pretty close to understanding.  I still have a few questions 
here:

*1. You need to upload the files to the server, then parse them to get each 
dict. *

The code I have to generate my dictionaries follows this format (let's 
assume there are 3 different config formats):

parse.config_type_A(file)  where parse is the class, config_type_A is 
the method, and file is the file I want to parse
parse.config_type_B(file)  where parse is the class, config_type_B is 
the method, and file is the file I want to parse
parse.config_type_C(file)  where parse is the class, config_type_C is 
the method, and file is the file I want to parse

The resulting dictionary looks something like this (this is the default 
dict before the data is pulled):

self.settings = {
'filepath': 'Not Available', #File path.
'filename': 'Not Available', #Name of the file being processed.
'hostname': 'Not Available', #What is the hostname?
'model': 'Not Available', #What type of device are we looking at?
'enable': 'Not Available', #Is there an enable password?  Is it using md5 
encryption?
'domain-name': 'Not Available', #Domain name.
'username': 'Not Available', #Are user accounts using strong encryption 
(non-Cisco 7)?
'logging': 'Not Available', #Are security and event logs being collected?
'log-server': 'Not Available', #Log Servers for centralized log correlation 
and SIEM.
'aaa': 'Not Available', #AAA is advanced radius or tacacs+ based 
authentication.
'sshv2': 'Not Available', #SSHv2 is the current protocol.
'port-security':'Not Available', #SSHv2 is the current protocol.
'intf-inside': 'Not Available', #Inside Interface: Connects to the LAN.
'intf-outside': 'Not Available', #Outside Interface: Connects to the WAN.
'any-any': 'Not Available', #Any-Any Rules can allow overly permissive 
traffic.
'access-group': 'Not Available' #The access-group line ties an ACL to an 
interface.
}

What I end up with is dictionary for each config file that has all the 
relevant settings I am interested in.  I'd like to use a class to parse, 
but I'm not sure if the class should be defined in a  model, controller or 
module.

   1. Where should I define the class?
   2. If I want to insert the self.settings dict (above) is this the 
   correct syntax I need to follow (from your link)?
   
db.config_settings.bulk_insert([{'name':'Alex'}, {'name':'John'}, 
{'name':'Tim'}])

 
  3. Is there a different insert statement that would let me say 
something like. db.config_settings.insert(self.settings) ?




*2. My feeling that you may be having issues with parsing the uploaded 
file.*

Why doesn't the following controller code work? (it gives me the following 
error: (coercing to Unicode: need string or 
buffer, Row found))  What should I be using to open the files?

def showconfig():
files = db().select(db.config_file.ALL)
for file in files:
if 'ASA Version' in open(file).read():
return dict(file=file)
else:
return dict("Not a Firewall")









On Friday, December 27, 2013 3:07:07 PM UTC-8, Simon Ashley wrote:
>
> A little difficult to share to code (done for a client, its similar and 
> but not exactly what you're doing i.e. maybe a lot more complicated than 
> what you need), but I think you're almost there. 
>
> You need to upload the files to the server, then parse them to get each 
> dict. My understanding is that you don't have issues generating the dict 
> and there it should be a simple bulk_insert ...  
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=bulk_insert
> .
>
> My feeling that you may be having issues with parsing the uploaded file 
> and you should be able to get the file name/ location for parsing routines 
> by following 
> http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Simon Ashley

   
   1. We just do it in the controller as a function . Try an .insert but 
   .bulk_insert should be fine for individual records.
   2. You may need a path to find the file.

Following code is cut, pasted and sanitised from a working controller.
(for illustration only)

## initiates getting files from a remote server
def GET():
getfile('_00_S_BTRI')
getfile('_ST_S_ELST')


## reads remote files and writes to a folder on the local server
def getfile(f3):
import datetime
from datetime import date, timedelta
import urllib2
import contextlib
import requests
import time
f0 = 'http://mcs./getfile.aspx?filename='
dr = 15 #target range

today = datetime.date.today()
for x in range(dr):
start = today-timedelta(days=x)
f1 = start.strftime('%Y%m%d')
path = os.path.join(request.folder, 'data//')
f4 = '.xml'
file1 = f0 + f1 + f3 + f4
try:
u = urllib2.urlopen(file1)
except urllib2.HTTPError, e:
print str(e)
else:
if not 'alert' in u.read(100):
rf = requests.get(file1)
wf = open(path + f1 + f3 + f4, 'w')
for line in rf:
newline = line
wf.write(newline)
wf.close()


# scans folder and writes db records of files found
def update_PROCESS():
import os
path = os.path.join(request.folder, 'data\\')
p1 = {}
d1 = {}
d2 = {}
for files in os.listdir(path):
if files.endswith(".xml"):
p1 = path + files
dd1 = {'FILE': p1}
d1.update(dd1)
dd2 = {'PREFIX': p1[-8:-4]}
d1.update(dd2)
d1.update({'UPDATED':0})
d1.update({'RETRIEVED':datetime.now()})
db1.PROCESSING.bulk_insert([d1])
db.commit()


# processes unprocessed files
def PROCESS():
q = db1(db1.PROCESSING.UPDATED == 0).select()
if q:
for row in q:
f1 = row.FILE
if row.PREFIX == 'ASUM':
try:
attend(f1)
d1 = db1.PROCESSING.update_or_insert((db1.PROCESSING.id 
== row.id), UPDATED = 1, PROCESSED=datetime.now())
except:
d1 = db1.PROCESSING.update_or_insert((db1.PROCESSING.id 
== row.id), UPDATED = 2)
db1.commit()


# reads file, create dict, performs bulk_insert
def atten(f1):
from xml.etree import ElementTree
with open(f1, 'rt') as f:
try:
tree = ElementTree.parse(f)
except:
pass
else:
dh = {}
dd = {}

def onlyascii(char):
if ord(char) < 32 or ord(char) > 127: return ''
else: return char

for node in tree.iter():
if node.tag == 'ATTEN':
dh = node.attrib

if node.tag == 'RECORD':
dd = node.attrib
remap = 
{'DATE':'RECORD_DATE','TOTAL':'RECORD_TOTAL','PUBLIC':'RECORD_PUBLIC','MEMS':'RECORD_MEMS','COSE':'RECORD_COSE'}
dd = dict((remap[key], value) for (key, value) in 
dd.items())
dd.update(dh)
db1.ATTEN.bulk_insert([dd])
dd = {}
db1.commit()


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Drop down not showing

2013-12-27 Thread Massimo Di Pierro
It is hard to help. You posted lots of code. Your traceback mentions model 
(or field) use_company but you did not post this model.

 ValueError: invalid literal for long() with base 10: 'user_company'

Can you post a minimal action to reproduce the problem?
Can you reproduce the problem if you remove everything in databases/ I 
suspect you have corrupted data in the database.

On Friday, 27 December 2013 08:12:34 UTC-6, Michel Hayek wrote:
>
> Please any help guys?
>
> *This e-mail is confidential and may also be privileged. If you are not 
> the intended **recipient, please notify the sender immediately, delete it 
> from your system and do **not copy, disseminate, distribute or disclose 
> any information contained therein.*
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] Login form on index page

2013-12-27 Thread Unnikrishnan Patel
Hi ,  i am new at web development with web2py , I want to add login or 
signup form on the index page itself , i tried to go through the codes but 
its quite tough to figure out , can anyone please help me with that?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] link as virtualfield

2013-12-27 Thread Diego Tostes
Hi,

I am trying to create a virtualfield as a link like the this code:

http://pastebin.com/c2wZqECH

But when i create a SQL.grid this virtualfield is displayed as a string.

Is it possible to create a link ?

Rgds,

Diego

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 upload filename in database

2013-12-27 Thread Calvin Morrison
I'm following the documentation trying to figure out how to correctly save 
a filename to my uploads database.

Basically i have the same code as the website shows in it's examples


def submit():


 import datetime


 form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


 form.vars.up_date = datetime.datetime.now()
 form.vars.username = auth.user.email


 if request.vars.up_file != None:
 form.vars.filename = request.vars.up_file.filename


 if form.process().accepted:
 redirect(URL('data', 'index'))
 elif form.errors:
 response.flash = "form has errors"


But my form doesn't appear to be validating correctly. It allows me to hit 
submit even if a file is not supplied. This leads to a error being logged, 
so I want to avoid things getting submitted.  My only thought is that it 
could be my requires not working correctly

ext_regex = '|'.join(quikr_utils.all_ext)

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: "None" if x == None else x
[:45]),
Field('up_file', 'upload', uploadseparate=True, requires=[IS_NOT_EMPTY
(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
Field('up_date', 'datetime'), 
Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
sizeof_fmt(x) ), 
Field('notes', 'text'))

>>> print quikr_utils.all_ext
['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

Any ideas?
Thanks!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] web2py on heroku getting "InternalError: current transaction is aborted..." Ticket

2013-12-27 Thread Ismael Serratos
Hello everybody, today I tried to push my application to Heroku by using 
the setup-web2py-heroku.sh script. It works fine, but when opening my app I 
get a ticket with this content:

web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
2.7.4: /app/.heroku/python/bin/python (prefix: /app/.heroku/python)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.

Traceback (most recent call last):
  File "/app/gluon/restricted.py", line 217, in restricted
exec ccode in environment
  File "/app/applications/init/models/db.py" 
, 
line 16, in 
db = get_db(name="HEROKU_POSTGRESQL_RED_URL", pool_size=10)
  File "/app/gluon/contrib/heroku.py", line 26, in get_db
current.session.connect(current.request, current.response, db=db)
  File "/app/gluon/globals.py", line 833, in connect
migrate=table_migrate,
  File "/app/gluon/dal.py", line 8139, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File "/app/gluon/dal.py", line 8176, in lazy_define_table
polymodel=polymodel)
  File "/app/gluon/dal.py", line 1056, in create_table
query), table)
  File "/app/gluon/dal.py", line 815, in log
logfile = self.file_open(table._loggername, 'a')
  File "/app/gluon/dal.py", line 4488, in file_open
return DatabaseStoredFile(self.db,filename,mode)
  File "/app/gluon/dal.py", line 4416, in __init__
self.db.executesql(sql)
  File "/app/gluon/dal.py", line 8349, in executesql
adapter.execute(query)
  File "/app/gluon/dal.py", line 1916, in execute
return self.log_execute(*a, **b)
  File "/app/gluon/dal.py", line 1910, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
InternalError: current transaction is aborted, commands ignored until end of 
transaction block

I'm getting this ticket with my app and even with a blank copy of web2py and 
the default apps. The admin interface works just fine. What can be the cause of 
this issue?

*Note: In the traceback I pasted here I did replace the get_db connection name 
to the generated one, but the traceback is basically the same if I use the 
default (none).

Best regards,

Ismael Serratos.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 upload filename in database

2013-12-27 Thread Massimo Di Pierro
Let's isolate the problem.

Are you saying that even if you have this:

Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
 IS_UPLOAD_FILENAME(extension=ext_regex)]),

You can submit a form that does not upload a file into up_file?

On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:
>
> I'm following the documentation trying to figure out how to correctly save 
> a filename to my uploads database.
>
> Basically i have the same code as the website shows in it's examples
>
>
> def submit():
>
>
>  import datetime
>
>
>  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)
>
>
>  form.vars.up_date = datetime.datetime.now()
>  form.vars.username = auth.user.email
>
>
>  if request.vars.up_file != None:
>  form.vars.filename = request.vars.up_file.filename
>
>
>  if form.process().accepted:
>  redirect(URL('data', 'index'))
>  elif form.errors:
>  response.flash = "form has errors"
>
>
> But my form doesn't appear to be validating correctly. It allows me to hit 
> submit even if a file is not supplied. This leads to a error being logged, 
> so I want to avoid things getting submitted.  My only thought is that it 
> could be my requires not working correctly
>
> ext_regex = '|'.join(quikr_utils.all_ext)
>
> db.define_table('uploads',
> Field('username', 'string'),
> Field('filename', represent = lambda x, row: "None" if x == None elsex
> [:45]),
> Field('up_file', 'upload', uploadseparate=True, requires=[IS_NOT_EMPTY
> (), IS_UPLOAD_FILENAME(extension=ext_regex)]),
> Field('up_date', 'datetime'), 
> Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
> sizeof_fmt(x) ), 
> Field('notes', 'text'))
>
> >>> print quikr_utils.all_ext
> ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']
>
> Any ideas?
> Thanks!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Login form on index page

2013-12-27 Thread Massimo Di Pierro
You can insert 

def index():
   form = auth.login()
   if auth.user: message="welcome %s" % auth.user.first_name
   else: message = 'login please'
   return dict(form=form, message=message)

and in view:

... {{=form}} {{=message}} ...


On Thursday, 26 December 2013 13:39:07 UTC-6, Unnikrishnan Patel wrote:
>
> Hi ,  i am new at web development with web2py , I want to add login or 
> signup form on the index page itself , i tried to go through the codes but 
> its quite tough to figure out , can anyone please help me with that?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: link as virtualfield

2013-12-27 Thread Massimo Di Pierro
try replace

Field.Virtual('anexos', lambda row: "Teste_%s" % row.parte.id
)

with

Field.Virtual('anexos', lambda row: XML("Teste_%s" % row.
parte.id))
or
Field.Virtual('anexos', lambda row: A('Teste_%s'" % row.parte.id,_href=''))


but you may also want to consider using this instead:

db.parte.id.label = "anexos"
db.parte.id.represent =  lambda id,row: lambda row: A('Teste_%s'" % id
,_href=''))

On Friday, 27 December 2013 12:23:08 UTC-6, Diego Tostes wrote:
>
> Hi,
>
> I am trying to create a virtualfield as a link like the this code:
>
> http://pastebin.com/c2wZqECH
>
> But when i create a SQL.grid this virtualfield is displayed as a string.
>
> Is it possible to create a link ?
>
> Rgds,
>
> Diego
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: web2py on heroku getting "InternalError: current transaction is aborted..." Ticket

2013-12-27 Thread Massimo Di Pierro
Is there any database log to help you? What are the queries being executed 
or failing?

On Friday, 27 December 2013 22:45:24 UTC-6, Ismael Serratos wrote:
>
> Hello everybody, today I tried to push my application to Heroku by using 
> the setup-web2py-heroku.sh script. It works fine, but when opening my app I 
> get a ticket with this content:
>
> web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
> 2.7.4: /app/.heroku/python/bin/python (prefix: /app/.heroku/python)
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
>
> Traceback (most recent call last):
>   File "/app/gluon/restricted.py", line 217, in restricted
> exec ccode in environment
>   File "/app/applications/init/models/db.py" 
> , 
> line 16, in 
> db = get_db(name="HEROKU_POSTGRESQL_RED_URL", pool_size=10)
>   File "/app/gluon/contrib/heroku.py", line 26, in get_db
> current.session.connect(current.request, current.response, db=db)
>   File "/app/gluon/globals.py", line 833, in connect
> migrate=table_migrate,
>   File "/app/gluon/dal.py", line 8139, in define_table
> table = self.lazy_define_table(tablename,*fields,**args)
>   File "/app/gluon/dal.py", line 8176, in lazy_define_table
> polymodel=polymodel)
>   File "/app/gluon/dal.py", line 1056, in create_table
> query), table)
>   File "/app/gluon/dal.py", line 815, in log
> logfile = self.file_open(table._loggername, 'a')
>   File "/app/gluon/dal.py", line 4488, in file_open
> return DatabaseStoredFile(self.db,filename,mode)
>   File "/app/gluon/dal.py", line 4416, in __init__
> self.db.executesql(sql)
>   File "/app/gluon/dal.py", line 8349, in executesql
> adapter.execute(query)
>   File "/app/gluon/dal.py", line 1916, in execute
> return self.log_execute(*a, **b)
>   File "/app/gluon/dal.py", line 1910, in log_execute
> ret = self.cursor.execute(command, *a[1:], **b)
> InternalError: current transaction is aborted, commands ignored until end of 
> transaction block
>
> I'm getting this ticket with my app and even with a blank copy of web2py and 
> the default apps. The admin interface works just fine. What can be the cause 
> of this issue?
>
> *Note: In the traceback I pasted here I did replace the get_db connection 
> name to the generated one, but the traceback is basically the same if I use 
> the default (none).
>
> Best regards,
>
> Ismael Serratos.
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: web2py on heroku getting "InternalError: current transaction is aborted..." Ticket

2013-12-27 Thread Ismael Serratos

>
> The only information that I get is this part of the traceback:
>>
>
(the error is generated since the first time the app launches)
Function argument list

(self=, *a=('CREATE 
TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, 
PRIMARY KEY(path));',), **b={})
Code listing

1905.
1906.
1907.
1908.
1909.
1910.

1911.
1912.
1913.
1914.

command = self.filter_sql_command(command)
if self.db._debug:
LOGGER.debug('SQL: %s' % command)
self.db._lastsql = command
t0 = time.time()
ret = self.cursor.execute(command, *a[1:], **b)

self.db._timings.append((command,time.time()-t0))
del self.db._timings[:-TIMINGSSIZE]
return ret

Variablesselfretundefined
self.cursor.executea('CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), 
content TEXT, PRIMARY KEY(path));',)b{}self.cursorcommand'CREATE TABLE IF NOT EXISTS web2py_filesystem 
(path VARCHAR(255), content TEXT, PRIMARY KEY(path));'
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: web2py on heroku getting "InternalError: current transaction is aborted..." Ticket

2013-12-27 Thread Ismael Serratos
Sorry for the spam :s, digging the heroku logs I get this:

2013-12-28T05:17:30.576403+00:00 app[web.1]: ERROR:web2py.dal:Could not 
retrieve 
applications/init/databases/bad0fba8494e4bab4e99ad1290bcc0d2_web2py_session_init.table

2013-12-28T05:17:30.576403+00:00 app[web.1]: if db.executesql(query):

2013-12-28T05:17:30.576403+00:00 app[web.1]: Traceback (most recent call 
last):

2013-12-28T05:17:30.576403+00:00 app[web.1]:   File "/app/gluon/dal.py", 
line 8349, in executesql

2013-12-28T05:17:30.576403+00:00 app[web.1]:   File "/app/gluon/dal.py", 
line 4470, in exists

2013-12-28T05:17:30.576403+00:00 app[web.1]: return 
self.log_execute(*a, **b)

2013-12-28T05:17:30.576403+00:00 app[web.1]: adapter.execute(query)

2013-12-28T05:17:30.576403+00:00 app[web.1]:   File "/app/gluon/dal.py", 
line 1916, in execute

2013-12-28T05:17:30.576403+00:00 app[web.1]: ret = 
self.cursor.execute(command, *a[1:], **b)

2013-12-28T05:17:30.576667+00:00 app[web.1]: 

2013-12-28T05:17:30.576667+00:00 app[web.1]: 

2013-12-28T05:17:30.576403+00:00 app[web.1]:   File "/app/gluon/dal.py", 
line 1910, in log_execute

2013-12-28T05:17:30.576667+00:00 app[web.1]: ProgrammingError: relation 
"web2py_filesystem" does not exist

2013-12-28T05:17:30.576667+00:00 app[web.1]: LINE 1: SELECT path FROM 
web2py_filesystem WHERE path='applications/...

2013-12-28T05:17:30.576667+00:00 app[web.1]:   

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.