[web2py] Re: a proposal for form improvement

2014-09-09 Thread Leonel Câmara

>
> This is the corresponding JS one optimized for bootstrap 3:
>
> jform.widgets['text'] = function(field) { return 
> jform.tag('textarea',{'name':field.name
> ,'class':'form-control'})(field.value); }
>

Massimo that looks good, however in SQLFORM I can change the textwidget in 
a very specific way - I can change it for a single field on a single table 
on a single controller, changing widgets in jform like this wouldn't work 
because you would change the text widget for all jforms being rendered in 
that webpage. 

Maybe you want to change the widget for just that one form and leave the 
others unchanged. Sometimes, you do want to change your textwidgets 
application wide but sometimes you don't. So things get a little more 
complicated.  

There needs to be some way to define context for jform where you can 
customize just one single form. Basically JForm would need to have a 
dictionary of table or even form specific widgets where you could do 
something like.

jform.widgets.forms[myformid]['text'] = function(field) { return 
jform.tag('textarea',{'name':field.name
,'class':'form-control'})(field.value); }
jform.widgets.tables[tablename]['text'] = function(field) { return 
jform.tag('textarea',{'name':field.name
,'class':'form-control'})(field.value); }

So things do start to get messy. This solution, of course, isn't ideal if 
you are building a single page app as this context you're creating doesn't 
get automatically cleaned every call like it happens on the server side 
with SQLFORM so then you start to get strange interactions and bugs. Hence 
we have to figure out a smarter way to do it where the context is really 
available for just that one form and it goes away with it.


-- 
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/d/optout.


[web2py] Is web2py compatible with Spring Python or Java Spring

2014-09-09 Thread Gurpreet S Anand
I have read the above posts but still wondering if the Spring Python is
compatible with web2py. Is it possible you could provide me with a solution
to my problem or at least direct me in right direction.

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/d/optout.


[web2py] Launching modal form from onupdate callback (Grid)

2014-09-09 Thread Sarbjit
I am using the Dialog plugin from http://dev.s-cubism.com/plugin_dialog to 
display modal dialog form.

My requirement is that whenever the user edits the Grid record, then I 
should do some validation on the form contents (I'll be using onvalidate 
callback for my custom form validation).

Once the validation is complete, I want to display the form with some 
pre-populated fields, if the user accepts this modal form, then I'll run 
one external script in addition to updation of the grid data. If the user 
donot submit the form, it should just update the grid record.

*Example*

This is the example usage shown in the plugin doc.

def index():
dialog = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
close_button='close', renderstyle=True)
return dict(dialog=A('show dialog', _href='#',
 _onclick='%s;return false;' %dialog.show()))
 
def inner():
return DIV('OK!')

What I'm trying is :- (In onupdate callback) 

def myonupdate(form):
print 'update!'
dialog1 = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
close_button='close', renderstyle=True)
dialog1.show()

*Problem :-*

It doesn't opens the modal form, while in the example on clicking button, a 
modal form does appears.

Is there any way, I can make this modal form to appear on editing the grid 
record or I can open a conformer dialog when the user is updating the grid 
such that I can run the additional external process if the answer is yes.

-- 
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/d/optout.


[web2py] How to add a check-box element in grid (update mode only) using view?

2014-09-09 Thread Sarbjit
I am looking for a example on adding a checkbox field for a grid in update 
mode only. This checkbox will be used for some decision at the time of form 
submission and hence I don't want to create a new field in database (since 
this field is useless there).

Is there any way, I can add a checkbox element using views?

{{if grid.update_form:}}
{{=grid.update_form.custom.begin}}
{{=grid}}

{{=grid.update_form.custom.end}}

Thanks
Sarbjit

-- 
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/d/optout.


[web2py] how to iterate through sqlite data and display on web2py

2014-09-09 Thread Maurice Waka


I have several lists in sqlite rows as follows:

ROWID  x
  1['123', '1234', '12345',]
  2['abc', 'abcd', 'abcde',]
  3['1a2b3c', '1a2b3c4d', '1a2b3c4d5e',]

I would like to iterate over these items in a game that matches them with a 
user input, say when a user prints 123, it prints out the answer or gives a 
boolean value. The only problem is that when i print our items in row[1] or 
row[2] i get a none value, but is works well with row[0].

This is part of my code on the sqlite section.

def types():
location = ""
conn = sqlite3.connect("types.db")
c = conn.cursor()
c.execute('select * from types ORDER by X')
for rowid,X in c.execute("select rowid,X from types order by X"):
  return row[:]

-- 
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/d/optout.


[web2py] Re: how to iterate through sqlite data and display on web2py

2014-09-09 Thread Anthony
On Tuesday, September 9, 2014 8:08:00 AM UTC-4, Maurice Waka wrote:
>
> I have several lists in sqlite rows as follows:
>
> ROWID  x
>   1['123', '1234', '12345',]
>   2['abc', 'abcd', 'abcde',]
>   3['1a2b3c', '1a2b3c4d', '1a2b3c4d5e',]
>
> How are you storing the lists in a single SQLite column? Did you convert 
Python lists to strings?
 

> def types():
> location = ""
> conn = sqlite3.connect("types.db")
> c = conn.cursor()
> c.execute('select * from types ORDER by X')
> for rowid,X in c.execute("select rowid,X from types order by X"):
>   return row[:]
>
> Given that the identifier "row" has not been defined, the final line 
should raise an exception. Also, you don't want to return in the for loop, 
as that will terminate the function on the first pass through the loop.

Is this in a web2py app? If so, I would recommend using the DAL and store 
your lists in a list:string field. As far as looping and returning values, 
it's hard to say without more details regarding what you are trying to do. 
Are you just trying to display all the rows in an HTML page?

Anthony

-- 
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/d/optout.


Re: [web2py] Re: how to iterate through sqlite data and display on web2py

2014-09-09 Thread Maurice Waka
Thanks for the input. Yes it is part of a web2py app game.
I have about 1000 rows, but when a user types in the keyword(stored in any
of the rows) i should get a boolean answer which for now displays the
row(different code on this)
Regards

On Tue, Sep 9, 2014 at 3:30 PM, Anthony  wrote:

> On Tuesday, September 9, 2014 8:08:00 AM UTC-4, Maurice Waka wrote:
>>
>> I have several lists in sqlite rows as follows:
>>
>> ROWID  x
>>   1['123', '1234', '12345',]
>>   2['abc', 'abcd', 'abcde',]
>>   3['1a2b3c', '1a2b3c4d', '1a2b3c4d5e',]
>>
>> How are you storing the lists in a single SQLite column? Did you convert
> Python lists to strings?
>
>
>> def types():
>> location = ""
>> conn = sqlite3.connect("types.db")
>> c = conn.cursor()
>> c.execute('select * from types ORDER by X')
>> for rowid,X in c.execute("select rowid,X from types order by X"):
>>   return row[:]
>>
>> Given that the identifier "row" has not been defined, the final line
> should raise an exception. Also, you don't want to return in the for loop,
> as that will terminate the function on the first pass through the loop.
>
> Is this in a web2py app? If so, I would recommend using the DAL and store
> your lists in a list:string field. As far as looping and returning values,
> it's hard to say without more details regarding what you are trying to do.
> Are you just trying to display all the rows in an HTML page?
>
> Anthony
>
> --
> 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/dNtVIOucH9Q/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/d/optout.
>



-- 
Dr Maurice Waka, MBCHB.
Nairobi

-- 
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/d/optout.


Re: [web2py] Re: how to iterate through sqlite data and display on web2py

2014-09-09 Thread Anthony
On Tuesday, September 9, 2014 8:40:04 AM UTC-4, Maurice Waka wrote:
>
> Thanks for the input. Yes it is part of a web2py app game.
> I have about 1000 rows, but when a user types in the keyword(stored in any 
> of the rows) i should get a boolean answer which for now displays the 
> row(different code on this) 
>

OK, but how are the rows stored in SQLite? Are they just strings, like 
"['123', '1234', '12345', ]"? If so, you can do a query searching for the 
string "'[keyword]'," within each row to return rows with a matching 
keyword. Again, I would recommend using the DAL with a list:string field:

db.define_table('keywords',
Field('x', 'list:string'))

This allows you to insert and extract actual Python lists from the field, 
though the lists will be stored in the database as a string in the form 
"|item1|item2|item3|". So, to find rows that match a keyword, you would 
just do:

keyword = '123' # in reality, this is obtained via user input
match_row = db(db.keywords.x.contains('|%s|' % keyword)).select().first()

Your boolean test would then simply be "if match_row:". The list of 
keywords in the matching row would be in match_row.x, which would be an 
actual Python list rather than a string representation of a list.

Anthony

-- 
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/d/optout.


[web2py] insert and update SQLFORM.factory

2014-09-09 Thread Greg Vaughan
I am trying to do a combined update and insert using SQLFORM.factory with 
some redirects for good measure.

Everything works fine except the update which fails to alter the record in 
question.

@auth.requires_login()
def remote_check():
j_id=request.args[0]
for row in db(db.job_requests.id==j_id).select(db.job_requests.
business_name, db.job_requests.cta, db.job_requests.spoke_to, db.
job_requests.job_result, db.job_requests.job_note):
bus = row.business_name
contact = row.spoke_to
cta = row.cta
jn = row.job_note
jr = row.job_result
for row in db(db.clients.id==row.business_name).select(db.clients.id
, db.clients.phone):
c_id=str(row.id)
phone=row.phone
address = get_client_address(c_id)
db.job_requests.id.readable=False
db.job_requests.business_name.default=c_id
db.job_requests.business_name.writable=False
db.job_requests.sr_number.writable=False
db.job_requests.sr_number.readable=False
db.job_requests.cta.default=cta
db.job_requests.cta.writable=False
db.job_requests.send_via.writable=False
db.job_requests.send_via.readable=False
db.job_requests.email_to.writable=False
db.job_requests.email_to.readable=False
db.job_requests.fax_to.writable=False
db.job_requests.fax_to.readable=False
db.job_requests.snd_other.writable=False
db.job_requests.snd_other.readable=False
db.job_requests.spoke_to.default=contact
db.job_requests.spoke_to.writable=False
db.job_requests.job_result.default=jr
db.job_requests.job_note.default=jn
db.job_requests.job_note.writable=False
db.tech_notes.business_name.default=c_id
db.tech_notes.business_name.writable=False
form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name=
'remote_check')
if form.process().accepted:
session.flash = 'Job Updated'
db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
redirect(URL('ops', 'tech_main_page'))
if form.vars.job_result=='Completed':
db.job_requests.update(**db.job_requests._filter_fields(form.
vars))
redirect(URL('ops', 'tech_main_page'))
else:
redirect(URL('ops', 'maintenance_customer_service_request'))
elif form.errors:
response.flash = 'Form has errors'
return dict(form=form,phone=phone,address=address,left_sidebar_enabled=
True,right_sidebar_enabled=True)

Any hints please?

-- 
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/d/optout.


Re: [web2py] Re: how to iterate through sqlite data and display on web2py

2014-09-09 Thread Maurice Waka
Hey thanks alot! let me work on this then.
Kind regards

On Tue, Sep 9, 2014 at 3:55 PM, Anthony  wrote:

> On Tuesday, September 9, 2014 8:40:04 AM UTC-4, Maurice Waka wrote:
>>
>> Thanks for the input. Yes it is part of a web2py app game.
>> I have about 1000 rows, but when a user types in the keyword(stored in
>> any of the rows) i should get a boolean answer which for now displays the
>> row(different code on this)
>>
>
> OK, but how are the rows stored in SQLite? Are they just strings, like
> "['123', '1234', '12345', ]"? If so, you can do a query searching for the
> string "'[keyword]'," within each row to return rows with a matching
> keyword. Again, I would recommend using the DAL with a list:string field:
>
> db.define_table('keywords',
> Field('x', 'list:string'))
>
> This allows you to insert and extract actual Python lists from the field,
> though the lists will be stored in the database as a string in the form
> "|item1|item2|item3|". So, to find rows that match a keyword, you would
> just do:
>
> keyword = '123' # in reality, this is obtained via user input
> match_row = db(db.keywords.x.contains('|%s|' % keyword)).select().first()
>
> Your boolean test would then simply be "if match_row:". The list of
> keywords in the matching row would be in match_row.x, which would be an
> actual Python list rather than a string representation of a list.
>
> Anthony
>
> --
> 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/dNtVIOucH9Q/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/d/optout.
>



-- 
Dr Maurice Waka, MBCHB.
Nairobi

-- 
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/d/optout.


Re: [web2py] Re: web2py app as proxy... but how?

2014-09-09 Thread Manuele Pesenti
Il 19/08/14 10:16, Niphlod ha scritto:
> not really, except that it's not streamed.
Are these any shrewdness I have to use when I proxy images? Something
like base64 encoding before streaming?

Thanks a lot

M.

-- 
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/d/optout.


[web2py] Re: insert and update SQLFORM.factory

2014-09-09 Thread Anthony
You've got a redirect right before the update code, so it will never get to 
execute that code.

Also, your two tables include a field with the same name ("business_name"), 
so putting them both in SQLFORM.factory won't work properly.

Anthony

On Tuesday, September 9, 2014 9:10:50 AM UTC-4, Greg Vaughan wrote:
>
> I am trying to do a combined update and insert using SQLFORM.factory with 
> some redirects for good measure.
>
> Everything works fine except the update which fails to alter the record in 
> question.
>
> @auth.requires_login()
> def remote_check():
> j_id=request.args[0]
> for row in db(db.job_requests.id==j_id).select(db.job_requests.
> business_name, db.job_requests.cta, db.job_requests.spoke_to, db.
> job_requests.job_result, db.job_requests.job_note):
> bus = row.business_name
> contact = row.spoke_to
> cta = row.cta
> jn = row.job_note
> jr = row.job_result
> for row in db(db.clients.id==row.business_name).select(db.clients.
> id, db.clients.phone):
> c_id=str(row.id)
> phone=row.phone
> address = get_client_address(c_id)
> db.job_requests.id.readable=False
> db.job_requests.business_name.default=c_id
> db.job_requests.business_name.writable=False
> db.job_requests.sr_number.writable=False
> db.job_requests.sr_number.readable=False
> db.job_requests.cta.default=cta
> db.job_requests.cta.writable=False
> db.job_requests.send_via.writable=False
> db.job_requests.send_via.readable=False
> db.job_requests.email_to.writable=False
> db.job_requests.email_to.readable=False
> db.job_requests.fax_to.writable=False
> db.job_requests.fax_to.readable=False
> db.job_requests.snd_other.writable=False
> db.job_requests.snd_other.readable=False
> db.job_requests.spoke_to.default=contact
> db.job_requests.spoke_to.writable=False
> db.job_requests.job_result.default=jr
> db.job_requests.job_note.default=jn
> db.job_requests.job_note.writable=False
> db.tech_notes.business_name.default=c_id
> db.tech_notes.business_name.writable=False
> form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name=
> 'remote_check')
> if form.process().accepted:
> session.flash = 'Job Updated'
> db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
> redirect(URL('ops', 'tech_main_page'))
> if form.vars.job_result=='Completed':
> db.job_requests.update(**db.job_requests._filter_fields(form.
> vars))
> redirect(URL('ops', 'tech_main_page'))
> else:
> redirect(URL('ops', 'maintenance_customer_service_request'))
> elif form.errors:
> response.flash = 'Form has errors'
> return dict(form=form,phone=phone,address=address,left_sidebar_enabled
> =True,right_sidebar_enabled=True)
>
> Any hints please?
>

-- 
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/d/optout.


[web2py] Re: Launching modal form from onupdate callback (Grid)

2014-09-09 Thread Sarbjit
I tried using the "dialog" element in the view, but this is also not 
working. Idea is that when the user submits the gird changes, the dialog 
will show (modal dialog). But the below code is not working, can some one 
please point out the problem.

{{if grid.update_form:}}
{{=grid.update_form.custom.begin}}
{{grid.element(_type='submit')['_onclick']='%s;return false' % 
dialog.show()}}
{{=grid}}
{{=grid.update_form.custom.end}}

-- 
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/d/optout.


[web2py] Visual CMS MUSE CC - with web2py

2014-09-09 Thread Dmitry Ermolaev
I found the great visual CMS Muse CC
https://www.youtube.com/watch?v=ESUPCpOZ5Dc

May be it cooperate with python web2py?

-- 
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/d/optout.


[web2py] Re: insert and update SQLFORM.factory

2014-09-09 Thread Greg Vaughan
Thanks Anthony,

Altered the code to fix those two issues and that took me back to the 
original problem that I had which is "syntax not supported"

relevant section is now...

...
form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name='remote_check'
)
if form.process().accepted:
session.flash = 'Job Updated'
db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
db.job_requests.update(**db.job_requests._filter_fields(form.vars))
if form.vars.job_result=='Completed':
redirect(URL('ops', 'tech_main_page'))
else:
redirect(URL('ops', 'maintenance_customer_service_request'))...

and the error...

  File "c:/Users/gsv/Desktop/web2py/applications/eco/controllers/ops.py" 
, line 129, 
in remote_check

db.job_requests.update(**db.job_requests._filter_fields(form.vars))
  File "c:\Users\gsv\Desktop\web2py\gluon\dal.py", line 8790, in update
raise RuntimeError("Syntax Not Supported")
RuntimeError: Syntax Not Supported


Which is not a surprise... I tried to adapt posts from here and the 
examples in the book but I don't get SQLFORM well enough to see where I am 
screwing it up...

Can you point me in the right direction please?

Cheers
Greg


On Tuesday, 9 September 2014 23:30:46 UTC+10, Anthony wrote:
>
> You've got a redirect right before the update code, so it will never get 
> to execute that code.
>
> Also, your two tables include a field with the same name 
> ("business_name"), so putting them both in SQLFORM.factory won't work 
> properly.
>
> Anthony
>
> On Tuesday, September 9, 2014 9:10:50 AM UTC-4, Greg Vaughan wrote:
>>
>> I am trying to do a combined update and insert using SQLFORM.factory with 
>> some redirects for good measure.
>>
>> Everything works fine except the update which fails to alter the record 
>> in question.
>>
>> @auth.requires_login()
>> def remote_check():
>> j_id=request.args[0]
>> for row in db(db.job_requests.id==j_id).select(db.job_requests.
>> business_name, db.job_requests.cta, db.job_requests.spoke_to, db.
>> job_requests.job_result, db.job_requests.job_note):
>> bus = row.business_name
>> contact = row.spoke_to
>> cta = row.cta
>> jn = row.job_note
>> jr = row.job_result
>> for row in db(db.clients.id==row.business_name).select(db.clients
>> .id, db.clients.phone):
>> c_id=str(row.id)
>> phone=row.phone
>> address = get_client_address(c_id)
>> db.job_requests.id.readable=False
>> db.job_requests.business_name.default=c_id
>> db.job_requests.business_name.writable=False
>> db.job_requests.sr_number.writable=False
>> db.job_requests.sr_number.readable=False
>> db.job_requests.cta.default=cta
>> db.job_requests.cta.writable=False
>> db.job_requests.send_via.writable=False
>> db.job_requests.send_via.readable=False
>> db.job_requests.email_to.writable=False
>> db.job_requests.email_to.readable=False
>> db.job_requests.fax_to.writable=False
>> db.job_requests.fax_to.readable=False
>> db.job_requests.snd_other.writable=False
>> db.job_requests.snd_other.readable=False
>> db.job_requests.spoke_to.default=contact
>> db.job_requests.spoke_to.writable=False
>> db.job_requests.job_result.default=jr
>> db.job_requests.job_note.default=jn
>> db.job_requests.job_note.writable=False
>> db.tech_notes.business_name.default=c_id
>> db.tech_notes.business_name.writable=False
>> form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name=
>> 'remote_check')
>> if form.process().accepted:
>> session.flash = 'Job Updated'
>> db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
>> redirect(URL('ops', 'tech_main_page'))
>> if form.vars.job_result=='Completed':
>> db.job_requests.update(**db.job_requests._filter_fields(form.
>> vars))
>> redirect(URL('ops', 'tech_main_page'))
>> else:
>> redirect(URL('ops', 'maintenance_customer_service_request'))
>> elif form.errors:
>> response.flash = 'Form has errors'
>> return dict(form=form,phone=phone,address=address,
>> left_sidebar_enabled=True,right_sidebar_enabled=True)
>>
>> Any hints please?
>>
>

-- 
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/d/optout.


[web2py] Re: insert and update SQLFORM.factory

2014-09-09 Thread Greg Vaughan
Sigh I just realised that I am not specifying a record to update in that 
code... of course that won't work...

On Tuesday, 9 September 2014 23:30:46 UTC+10, Anthony wrote:
>
> You've got a redirect right before the update code, so it will never get 
> to execute that code.
>
> Also, your two tables include a field with the same name 
> ("business_name"), so putting them both in SQLFORM.factory won't work 
> properly.
>
> Anthony
>
> On Tuesday, September 9, 2014 9:10:50 AM UTC-4, Greg Vaughan wrote:
>>
>> I am trying to do a combined update and insert using SQLFORM.factory with 
>> some redirects for good measure.
>>
>> Everything works fine except the update which fails to alter the record 
>> in question.
>>
>> @auth.requires_login()
>> def remote_check():
>> j_id=request.args[0]
>> for row in db(db.job_requests.id==j_id).select(db.job_requests.
>> business_name, db.job_requests.cta, db.job_requests.spoke_to, db.
>> job_requests.job_result, db.job_requests.job_note):
>> bus = row.business_name
>> contact = row.spoke_to
>> cta = row.cta
>> jn = row.job_note
>> jr = row.job_result
>> for row in db(db.clients.id==row.business_name).select(db.clients
>> .id, db.clients.phone):
>> c_id=str(row.id)
>> phone=row.phone
>> address = get_client_address(c_id)
>> db.job_requests.id.readable=False
>> db.job_requests.business_name.default=c_id
>> db.job_requests.business_name.writable=False
>> db.job_requests.sr_number.writable=False
>> db.job_requests.sr_number.readable=False
>> db.job_requests.cta.default=cta
>> db.job_requests.cta.writable=False
>> db.job_requests.send_via.writable=False
>> db.job_requests.send_via.readable=False
>> db.job_requests.email_to.writable=False
>> db.job_requests.email_to.readable=False
>> db.job_requests.fax_to.writable=False
>> db.job_requests.fax_to.readable=False
>> db.job_requests.snd_other.writable=False
>> db.job_requests.snd_other.readable=False
>> db.job_requests.spoke_to.default=contact
>> db.job_requests.spoke_to.writable=False
>> db.job_requests.job_result.default=jr
>> db.job_requests.job_note.default=jn
>> db.job_requests.job_note.writable=False
>> db.tech_notes.business_name.default=c_id
>> db.tech_notes.business_name.writable=False
>> form=SQLFORM.factory(db.job_requests,db.tech_notes,table_name=
>> 'remote_check')
>> if form.process().accepted:
>> session.flash = 'Job Updated'
>> db.tech_notes.insert(**db.tech_notes._filter_fields(form.vars))
>> redirect(URL('ops', 'tech_main_page'))
>> if form.vars.job_result=='Completed':
>> db.job_requests.update(**db.job_requests._filter_fields(form.
>> vars))
>> redirect(URL('ops', 'tech_main_page'))
>> else:
>> redirect(URL('ops', 'maintenance_customer_service_request'))
>> elif form.errors:
>> response.flash = 'Form has errors'
>> return dict(form=form,phone=phone,address=address,
>> left_sidebar_enabled=True,right_sidebar_enabled=True)
>>
>> Any hints please?
>>
>

-- 
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/d/optout.


[web2py] Re: SOAP API authentication

2014-09-09 Thread Stefan van den Eertwegh
Could it be so that it passes and processed the models with basic auth?
Because in the model there is a auth.is_logged_in() check and sets some 
parameters which now not are set..

I hope to hear from you!

Op maandag 1 september 2014 05:32:39 UTC+2 schreef Matheus Cardoso:
>
> You can find your answer here: 
> http://web2py.com/books/default/chapter/29/09/#markmin_basic_authentication
>
> And was working like a charm. ;)
>
> On Sunday, August 31, 2014 9:41:01 AM UTC-3, Stefan van den Eertwegh wrote:
>>
>> Hi,
>>
>> Does anyone know how to set authentication to a web2py SOAP API?
>>
>> Thank you!
>>
>

-- 
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/d/optout.


[web2py] Re: Launching modal form from onupdate callback (Grid)

2014-09-09 Thread Derek
Yes, you cannot do that, you are mixing javascript (LOAD) with Python. You 
have to make the changes to the view, not the controller.

On Tuesday, September 9, 2014 4:24:27 AM UTC-7, Sarbjit wrote:
>
> I am using the Dialog plugin from http://dev.s-cubism.com/plugin_dialog 
> to display modal dialog form.
>
> My requirement is that whenever the user edits the Grid record, then I 
> should do some validation on the form contents (I'll be using onvalidate 
> callback for my custom form validation).
>
> Once the validation is complete, I want to display the form with some 
> pre-populated fields, if the user accepts this modal form, then I'll run 
> one external script in addition to updation of the grid data. If the user 
> donot submit the form, it should just update the grid record.
>
> *Example*
>
> This is the example usage shown in the plugin doc.
>
> def index():
> dialog = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
> close_button='close', renderstyle=True)
> return dict(dialog=A('show dialog', _href='#',
>  _onclick='%s;return false;' %dialog.show()))
>  
> def inner():
> return DIV('OK!')
>
> What I'm trying is :- (In onupdate callback) 
>
> def myonupdate(form):
> print 'update!'
> dialog1 = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
> close_button='close', renderstyle=True)
> dialog1.show()
>
> *Problem :-*
>
> It doesn't opens the modal form, while in the example on clicking button, 
> a modal form does appears.
>
> Is there any way, I can make this modal form to appear on editing the grid 
> record or I can open a conformer dialog when the user is updating the grid 
> such that I can run the additional external process if the answer is yes.
>

-- 
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/d/optout.


[web2py] Re: "validate_and_insert" my new best friend

2014-09-09 Thread Derek
You might want to look at Google Refine if you are dealing a lot with text 
file data sources. 

https://code.google.com/p/google-refine/

It's a very useful tool, and makes massaging text data easy.

On Saturday, September 6, 2014 1:16:59 AM UTC-7, Joe Barnhart wrote:
>
> File this under "stupid but useful web2py tricks"
>
> I have a database that I need to populate from an ASCII text file.  I've 
> been tearing my hair out parsing the file and doing all the formatting by 
> hand for every field, and then inserting the data into the table.  What a 
> joy to find "validate_and_insert" which runs the data through the Field 
> validators first before inserting the data.
>
> My date fields, for instance, are written in the text file in compressed 
> form, like "MMDD" with no delimiters.  I just set the validator on that 
> Field first to IS_DATE(format="%m%d%Y") and it takes care of the conversion 
> automatically.  This is a real timesaver!
>
> I did notice that I need to null out some of the fancier validators that 
> use more than one field on table updates that don't include all the needed 
> fields.  Caveat emptor.  I dunno if it is marginally faster or slower than 
> me doing it by hand, but I can tell you its a whole lot more maintainable, 
> and that is the real winner long term.
>
> -- Joe
>
>

-- 
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/d/optout.


Re: [web2py] Re: web2py app as proxy... but how?

2014-09-09 Thread Niphlod
nope. base64 is just a way to turn binary into text, and you want to stream 
a binary, not the text that represents it in base64.

On Tuesday, September 9, 2014 3:27:41 PM UTC+2, Manuele wrote:
>
> Il 19/08/14 10:16, Niphlod ha scritto: 
> > not really, except that it's not streamed. 
> Are these any shrewdness I have to use when I proxy images? Something 
> like base64 encoding before streaming? 
>
> Thanks a lot 
>
> M. 
>

-- 
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/d/optout.


[web2py] Re: web2py setup scripts for windows

2014-09-09 Thread Niphlod
well, to be fair nginx config takes ~80 rows and other ~20 for uwsgi and 
another ~10 for putting uwsgi under upstart.
apache is ~40 lines. Are they more "flexible" ? Yep. 

Let's not forget that if wfastcgi.py was "embeddable" in web2py as an 
adapter (but I didn't check the license), 10 clicks OR 4 lines of config 
for a proper supported and configured setup for web2py under IIS aren't 
that much. And it works also in Azure, since the baseline is usually 
WS2012R2.

On Monday, September 8, 2014 12:59:47 PM UTC+2, Tim Richardson wrote:
>
> ye gods. One wonders if a virtual linux server is not the answer. 
>

-- 
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/d/optout.


[web2py] db.commit() taking too long to update records

2014-09-09 Thread Luciano Laporta Podazza
Hello,

I'm having a strange issue, I have a website that queries data through an 
ajax call from the server using web2py json services every *5 seconds*. 
Then from the client I can update some data to the server with this:

@service.json
def block_user():
data = json.loads(request.body.read())
user = db(db.users.id==data['id']).select().first()
user.update_record(banned=True, banned_by=auth.user_id)
alerts = db(db.alerts.alerts_id==data['id']).update(archived=True)
db.commit()
return "ok"


There's like 10 records in the database to be updated but the query takes 
like 15-30seconds to process. I have no idea why is happening this.

Any help will be appreciated. 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/d/optout.


[web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Leonel Câmara
My guess would be that you're using sqlite and the database is locking you. 
Which is easy to happen if you have a few people requesting updates every 5 
seconds and you're trying to write on it, as the write will only go forward 
once sqlite gets its process an EXCLUSIVE lock which requires all readers 
which have SHARED locks to stop reading first.

One thing you can do is to cache the result returned in the first case so 
it doesn't hit the database. Then you can clear the cache when you make 
changes that would change the result. If this doesn't work then it's time 
to change databases.

-- 
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/d/optout.


Re: [web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Luciano Laporta Podazza
Sorry, I forgot to mention that I'm using MySQL as db engine.

Thanks.

On Tue, Sep 9, 2014 at 6:45 PM, Leonel Câmara 
wrote:

> My guess would be that you're using sqlite and the database is locking
> you. Which is easy to happen if you have a few people requesting updates
> every 5 seconds and you're trying to write on it, as the write will only go
> forward once sqlite gets its process an EXCLUSIVE lock which requires all
> readers which have SHARED locks to stop reading first.
>
> One thing you can do is to cache the result returned in the first case so
> it doesn't hit the database. Then you can clear the cache when you make
> changes that would change the result. If this doesn't work then it's time
> to change databases.
>
> --
> 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/6z13PTcZ5io/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/d/optout.
>



-- 
Atte
Luciano Laporta Podazza

-- 
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/d/optout.


Re: [web2py] Re: web2py app as proxy... but how?

2014-09-09 Thread Manuele Pesenti
Il 09/09/14 22:22, Niphlod ha scritto:
> nope. base64 is just a way to turn binary into text, and you want to
> stream a binary, not the text that represents it in base64.
I prepared a little example based on my solution. It's a as simple as I
can image proxy composed by a module[1] and a controller[2].
Visiting the url:
http://localhost:8000/test_imgproxy/proxy/index/golf_course.jpg you will
not see the desidered image[3].

Can you tell me what's wrong in my approach?

Thanks a lot

Manuele

[1] http://paste.debian.net/120108/
[2] http://paste.debian.net/120109/
[3] http://creativity103.com/collections/Landscape/golf_course.jpg

-- 
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/d/optout.


[web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Leonel Câmara
Then I'm sorry but I have no idea why it's taking so long. You need to 
profile it.

It may just be a question of tuning MySQL, optimizing the tables, etc. Have 
you tried mysqltuner? 

-- 
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/d/optout.


Re: [web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Luciano Laporta Podazza
Thanks for your help Leonel. I didn't tried it but I'm talking about a dead
simple db structure, it's just updating a few records( like 10 rows or so)
on a single table.



On Tue, Sep 9, 2014 at 7:24 PM, Leonel Câmara 
wrote:

> Then I'm sorry but I have no idea why it's taking so long. You need to
> profile it.
>
> It may just be a question of tuning MySQL, optimizing the tables, etc.
> Have you tried mysqltuner?
>
> --
> 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/6z13PTcZ5io/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/d/optout.
>



-- 
Atte
Luciano Laporta Podazza

-- 
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/d/optout.


[web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread villas
If this is in a controller,  do you need the line:  db.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/d/optout.


Re: [web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Luciano Laporta Podazza
Perhaps I misunderstood this, but following the web2py manual it says that
no recordset is updated until you do db.commit().

Is that right?.

On Tue, Sep 9, 2014 at 7:29 PM, villas  wrote:

> If this is in a controller,  do you need the line:  db.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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/6z13PTcZ5io/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/d/optout.
>



-- 
Atte
Luciano Laporta Podazza

-- 
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/d/optout.


[web2py] Re: db.commit() taking too long to update records

2014-09-09 Thread Leonel Câmara
Well that's true, but web2py automatically calls db.commit for you after 
running the controller. That would not cause the slowdown anyway.

-- 
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/d/optout.


[web2py] Cannot resolve reference error

2014-09-09 Thread José Eloy
Hi!

I'm developing an web2py application that use an external SQL Server 
database. I can connect to the SQL Server database using  migrate=False in 
those tables I need to access. In addition I create my own tables from 
web2py (also they connect to SQL Server). My troubles begin when one of my 
tables (created with web2py) intents to connect with the external database. 
When I try to connect I get the "cannot resolve reference" error.

Below I show the significant code of my application:

In db.py:
db = DAL('mssql://connection to SQL Server database created with web2py') 
db2= DAL('mssql://connection to External SQL Server database')

# Table personal_personal is external (was not created with web2py, it's 
not complete, only show the most important)

db2.define_table('personal_personal',
 Field('foto_personal', 'blob', notnull=False),
 Field('firma_personal', 'blob', notnull=False),
 Field('id_personal', 'id', requires=IS_NOT_IN_DB(db2, 
'personal_personal.id_personal'), unique=True, notnull=True), #Primary key, 
not auto-increment
 Field('id_categoria', db2.personal_catalogo_categoria, 
requires = IS_IN_DB(db2, db2.personal_catalogo_categoria.id_categoria, 
'%(id_categoria)s'), notnull=True),
 Field('id_areataller', db2.mtto_areataller, requires = 
IS_IN_DB(db2, db2.mtto_areataller.id_areataller, '%(id_areataller)s'), 
notnull=False),
 Field('id_area', 'reference general_area.id_area', 
requires = IS_IN_DB(db2, db2.general_area.id_area, '%(id_area)s - 
%(nombre)s'), notnull=True),
 Field('id_depto', 'reference 
general_departamentos.id_depto', requires = IS_IN_DB(db2, 
db2.general_departamentos.id_depto, '%(id_depto)s - %(descripcion)s'), 
notnull=False),
 Field('cant_hijos', 'integer', notnull=False),
 Field('status_foto', 'integer', notnull=False),
 Field('status_firma', 'integer', notnull=False),
 Field('porcent_ret_descuent', 'integer', notnull=False),
 
Migrate=False)

Below personal_personal is defined the following table:

db.define_table('unidades',
Field('nombre', requires=IS_NOT_EMPTY()),
Field('descripcion'),
Field('tipo_unidad', db.tipo_unidades),
Field('operador', 'reference 
db2.personal_personal.id_personal', requires = IS_IN_DB(db2, 
db2.personal_personal.id_personal, '%(nombre)s')),
format='%(operador)s'
)

The 'operador' field reference the table personal_personal.

In a controller I have the following code:

def nueva_unidad():
form=SQLFORM(db.unidades, submit_button="Aceptar")
if form.accepts(request.vars, session):
redirect(URL(r=request, f='nueva_unidad'))
response.flash = 'Se ha creado una nueva unidad'

return dict( form=form)

When I call this function is when I get the error: 
 'Cannot resolve reference 
db2.personal_personal.id_personal in unidades definition'


How can I to correct this error? Any Idea?

Thanks in advanced.

Regards.



-- 
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/d/optout.


[web2py] Re: Using html tags inside checkbox labels

2014-09-09 Thread Tauno Metsalu
I found a solution myself for this specific case. I wrote space instead of 
 and then used white-space:pre-line in css. More information:

http://stackoverflow.com/questions/8661166/custom-css-classes-for-sqlform-widget-input-in-web2py
http://stackoverflow.com/questions/2703601/how-to-give-line-break-from-css-without-using-br

-- 
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/d/optout.


[web2py] Can I interact with code in Java Springs using web2py?

2014-09-09 Thread Gurpreet Singh Anand
I am a Python developer, but a beginner of web2py. I am creating a 
financial website which has a calculation engine. This calculation engine 
has been coded in Java springs. I am stuck at this point and was wondering 
if web2py is compatible with Java Springs. I would be immensely 
appreciative if anyone could either provide a solution to my problem or at 
least point me to the right direction.

-- 
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/d/optout.


[web2py] Re: RSS is an error! What to do?

2014-09-09 Thread Капылов Данил
Does not work. :-)

Error ticket for "welcome"Ticket ID

127.0.0.1.2014-09-09.11-33-31.6f78e65a-5d28-410e-9111-55ded191b520
 'NoneType' object has no attribute 
'encode'Версияweb2py™Version 2.9.9-stable+timestamp.2014.09.08.13.16.54
PythonPython 2.7.6: C:\Python27\python.exe (prefix: C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.

Traceback (most recent call last):
  File 
"C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\restricted.py",
 line 221, in restricted
exec ccode in environment
  File 
"C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\applications\welcome\views\generic.rss",
 line 10, in 
from gluon.serializers import rss}}{{=XML(rss(response._vars))}}
  File 
"C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\serializers.py",
 line 168, in rss
link=str((feed.get('link') or '').encode('utf-8', 'replace')),
AttributeError: 'NoneType' object has no attribute 'encode'

Error snapshot [image: help] 


('NoneType' object has no attribute 
'encode')

inspect attributes
Frames
   
   - 
   
   *File 
   
C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\restricted.py 
   in restricted at line 221* код аргументы переменные
   - 
   
   *File 
   
C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\applications\welcome\views\generic.rss
 
   in  at line 10* код аргументы переменные
   - 
   
   *File 
   
C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\serializers.py 
   in rss at line 168* код аргументы переменные
   Function argument list
   
   (feed={'message': })
   Code listing
   
   163.
   164.
   165.
   166.
   167.
   168.
   
   169.
   170.
   171.
   172.
   
   def rss(feed):
   if not 'entries' in feed and 'items' in feed:
   feed['entries'] = feed['items']
   now = datetime.datetime.now()
   rss = rss2.RSS2(title=str(feed.get('title', '(notitle)').encode('utf-8', 
'replace')),
   link=str((feed.get('link') or '').encode('utf-8', 
'replace')),
   
   description=str(feed.get('description', 
'').encode('utf-8', 'replace')),
   lastBuildDate=feed.get('created_on', now),
   items=[rss2.RSSItem(
  title=str(entry.get('title', 
'(notitle)').encode('utf-8', 'replace')),
   
   Variablesbuiltinstrfeed{'message': }link
   undefinedfeed.get).encodeundefined
   



вторник, 9 сентября 2014 г., 10:32:12 UTC+6 пользователь Massimo Di Pierro 
написал:
>
> very strange. try this:
>
> link=str((feed.get('link') or '').encode('utf-8', 'replace')),
>
>
> On Monday, 8 September 2014 12:45:25 UTC-5, Капылов Данил wrote:
>>
>> File "web2py \ gluon \ serializers.py" I did not change.
>>
>> He was the default
>>
>> I changed the code to your.
>>
>> Does not work.
>>
>>  'NoneType' object has no attribute 
>> 'encode'Версияweb2py™Version 2.9.9-stable+timestamp.2014.09.08.13.16.54
>> PythonPython 2.7.6: C:\Python27\python.exe (prefix: C:\Python27)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>>
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\restricted.py",
>>  line 221, in restricted
>> exec ccode in environment
>>   File 
>> "C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\applications\ads_app_beta\views\generic.rss",
>>  line 10, in 
>> from gluon.serializers import rss}}{{=XML(rss(response._vars))}}
>>   File 
>> "C:\Users\�\Documents\MEGAsync\Web2pyProject\Ad\web2py\gluon\serializers.py",
>>  line 168, in rss
>> link=str(feed.get('link', '').encode('utf-8', 'replace')),
>> AttributeError: 'NoneType' object has no attribute 'encode'
>>
>> Error snapshot [image: help] 
>> 
>>
>> ('NoneType' object has no attribute 
>> 'encode')
>>
>>
>>
>>
>>
>> понедельник, 8 сентября 2014 г., 23:17:02 UTC+6 пользователь Massimo Di 
>> Pierro написал:
>>>
>>> Looks very wrong
>>>
>>> link=str(feed.get('link', None).encode('utf-8', 'replace')),
>>>
>>> *should be*
>>>
>>>  link=str(feed.get('link', '').encode('utf-8', 'replace')),
>>>
>>> On Sunday, 7 September 2014 12:01:10 UTC-5, Капылов Данил wrote:

  'NoneType' object has no attribute 
 'encode'
 *Version *
 web2py™Version 2.9.8-stable+timestamp.2014.09.07.04.13.28PythonPython 
 2.7.5+: /usr/local/bin/uwsgi (prefix: /usr)Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.

 Traceback (most recent call last):
   File "/home/Danilka88/web2py/gluon/restricted.py", line 221, in 
 restricted
 exec ccode in environment
   File "/home/Danilka88/web2py/applications/agro/views/generic.rss", line 
 10, in 
 from gluo

[web2py] Re: dynamically add rows to html table

2014-09-09 Thread trr
Hi Andrew,

I got the point and it works. Thanks for your timely solution. 
Afterthought: Since I need only to append an empty row to the table for the 
user to enter data, java script solution avoided the round trip. I found 
the that here 
.
 
Thank you once again. 

On Saturday, September 6, 2014 12:51:00 PM UTC+5:30, trr wrote:
>
> I have a html table generated in controller. This table gets rendered. Now 
> if the user wants more number of rows added to the table, I give a AddRows 
> button. On the click of AddRows I would like to add rows to the existing 
> table in the controller with empty cells and render it with the additional 
> rows. How to achieve that? I have done this project in .NET. I am now 
> migrating that to web2py. Pl. help. My code in controller is
> def generate_table_from_excel(num_rows):
> 
> up = os.path.join(request.folder,'uploads')
> workbook = xlrd.open_workbook(os.path.join(request.folder,'uploads',
> 'meas.xls'))
> worksheet = workbook.sheet_by_name('Sheet1')
> num_rows = worksheet.nrows - 1
> num_cells = worksheet.ncols - 1
> curr_row = -1
> while curr_row < num_rows:
> d = {}
> curr_row += 1
> row = worksheet.row(curr_row)
> #print 'Row:', curr_row
> curr_cell = -1
> while curr_cell < num_cells:
> curr_cell += 1
> # Cell Types: 0=Empty, 1=Text, 2=Number, 3=Date, 4=Boolean, 
> 5=Error, 6=Blank
> cell_type = worksheet.cell_type(curr_row, curr_cell)
> cell_value = worksheet.cell_value(curr_row, curr_cell)
> #print '', cell_type, ':', cell_value
> if curr_cell == 0:
> d['loc_of_work'] = cell_value
> if curr_cell == 1:
> d['n'] = cell_value
> if curr_cell == 2:
> d['t'] = cell_value
> if curr_cell == 3:
> d['l'] = cell_value
> if curr_cell == 4:
> d['b'] = cell_value
> if curr_cell == 5:
> d['d'] = cell_value
>
> 
> i = 1
> form = FORM( TABLE(
>   TR( TD('AgtNo:'),   TD(session.agt_no)),
>   TR( TD('Jcod:'),TD(session.jcod) ),
>   TR( TD('MeasDate:'),TD(session.meas_date) ),
>   TR( TD('Shift:'),   TD(session.shift)),
>   TR( TD( INPUT(_type='submit',_value='Save') ), TD( 
> INPUT(_type='submit',_value='AddRows',_id='AddRows') ))
>   ),
>  INPUT(_id='txtNoOfRows',_type='hidden',_value=len(l)),
>  TABLE(
> THEAD(TR(
> TH('Loc'),
> TH('n'),
> TH('t'),
> TH('l'),
> TH('b'),
> TH('d'),
> TH('Mat'),
> TH('UWt'),
> TH('Content'),
> TH('Remarks'),
> _style='halign:center'   )),
>
> TBODY([TR(
>  TD(TEXTAREA(_name='txt' + str(i+1) + '1',_id=
> 'txt'+str(i+1) +'1',value = r['loc_of_work'],_style=
> 'width:200px;height:50px;')),
>  TD(INPUT(_name='txt' + str(i+1) + '2',_id=
> 'txt'+str(i+1) + '2',value=r['n'],_style='width:50px',_onblur=
> 'calculate_content()')),
>  TD(INPUT(_name='txt' + str(i+1) + '3',_id=
> 'txt'+str(i+1) + '3' ,value=r['t'],_style='width:50px',_onblur=
> 'calculate_content()')),
>  TD(INPUT(_name='txt' + str(i+1) + '4',_id=
> 'txt'+str(i+1) + 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/d/optout.


[web2py] Re: Best way to store tabular data when database isn't really needed?

2014-09-09 Thread Niels Jensen
Good point.  I guess I'm just used to storing disposable data in disposable 
variables.
I won't worry too much about it seeing as I already have it working and 
focus on getting the editing elements working now.

Thanks for the feedback.

On Monday, 8 September 2014 22:38:39 UTC+1, Derek wrote:
>
> The best way would be sqlite. It's certainly not overkill.
> If you don't know what sqlite is, look here:
> http://www.sqlite.org/about.html
>
> It's a very easy read... the way they describe it: Think of SQLite not as 
> a replacement for Oracle  but 
> as a replacement for fopen() 
> so yea, you're doing it right. I wouldn't bother storing it in ram, since 
> as you said it's not a lot of data, which means that disk access times will 
> be minimal as well.
>
> you could try putting the data in your session object, but that would 
> likely be stored on disk as well, so better leave it as sqlite in that case.
>
> The other option is redis, but if this is only one machine, it would be 
> pointless for that..
>
> in other words, you have a small file, and you are complaining about 
> storing it on disk? why? too much disk space? too much work? Does it make 
> that much of a difference if it takes 15ms to access or 1ms? 
>
> On Monday, September 8, 2014 3:59:39 AM UTC-7, Niels Jensen wrote:
>>
>> Hi All,
>>
>> I've just started learning Python and have a decent understanding on the 
>> core elements.  Most of my programming experience prior to Python was 
>> vb.net, which I'd use it to put together some simple applications that 
>> would help me automate some tasks at work (I'm a sysadmin).  I wanted to 
>> step away from a single platform and look at app development that didn't 
>> depend on the OS that was used.
>>
>> So I developed my first Python application which uses Paramiko to SFTP a 
>> DNS config file from my enterprise's central DNS servers.  It then parses 
>> the file and pulls out the zones and relevant data that's then stored in a 
>> list of tupples.
>>
>> I then thought wouldn't it be great to display these zones in a nice 
>> tabular format that can be edited.  Did some research and found web2py.  
>> I've since run throuth the Overview section of the docs and built my first 
>> Web2Py App.  Instead of saving the information to a list of tupples, it now 
>> saves it to a SQLite DB (which it truncates each time the config file is 
>> fetched).  I can then use SQLFORM.grid to generate a nice looking table in 
>> my app.  I've not got to the editing part yet, but that will come in time.
>>
>> The issue I have with the above method however is that is seems a little 
>> overkill to use a fully functional db.  In vb.net, I'd create a 
>> datatable in memory and manipulate the table before writing the changes 
>> back to the config file when told to do so. As any of my colleagues may 
>> change the DNS config file at any time, loading the config file as required 
>> into RAM makes more sense to me than loading it into a database.
>>  I looked at how I might do this in Python and it seems that I can load a 
>> SQLite db into memory or the user's session but from what I can see in 
>> various searches, people are saying that this may not be a good idea.
>>
>> So I'm just wondering what would be the best way to do this?  Any advice?
>>
>> Thanks
>> Niels
>>
>

-- 
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/d/optout.


[web2py] Code Coverage & Web2Py

2014-09-09 Thread Elliott Hill
I'm trying to get unit tests and code coverage metrics for a web2py app. 

I'd had a quick stab at doing something myself using the unittest 
information here (http://www.web2py.com/AlterEgo/default/show/260). This 
got me unit tests that run within the web2py framework and then exit. These 
results cover controllers within the application. 

Since then I've added coverage metrics by calling coverage.py within those 
tests but the results of that don't seem to report on the controllers. Is 
this due to some quirk of the above method (e.g. using execfile rather than 
importing directly)? 

Thanks for any help that can be provided.

-- 
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/d/optout.


[web2py] get hidden input value in controller

2014-09-09 Thread trr

I have a hidden input in form. I set the hidden value in client by java 
script. But I am not able to get the value in request.vars or 
request.post_vars in controller. It returns None. How to get the hidden 
input values in controller.? I generate the form in controller and is post 
method.

-- 
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/d/optout.


[web2py] Re: a proposal for form improvement

2014-09-09 Thread Massimo Di Pierro
I agree. I have not implemented but I was planning to add this feature. 

On Tuesday, 9 September 2014 03:44:30 UTC-5, Leonel Câmara wrote:
>
> This is the corresponding JS one optimized for bootstrap 3:
>>
>> jform.widgets['text'] = function(field) { return 
>> jform.tag('textarea',{'name':field.name
>> ,'class':'form-control'})(field.value); }
>>
>
> Massimo that looks good, however in SQLFORM I can change the textwidget in 
> a very specific way - I can change it for a single field on a single table 
> on a single controller, changing widgets in jform like this wouldn't work 
> because you would change the text widget for all jforms being rendered in 
> that webpage. 
>
> Maybe you want to change the widget for just that one form and leave the 
> others unchanged. Sometimes, you do want to change your textwidgets 
> application wide but sometimes you don't. So things get a little more 
> complicated.  
>
> There needs to be some way to define context for jform where you can 
> customize just one single form. Basically JForm would need to have a 
> dictionary of table or even form specific widgets where you could do 
> something like.
>
> jform.widgets.forms[myformid]['text'] = function(field) { return 
> jform.tag('textarea',{'name':field.name
> ,'class':'form-control'})(field.value); }
> jform.widgets.tables[tablename]['text'] = function(field) { return 
> jform.tag('textarea',{'name':field.name
> ,'class':'form-control'})(field.value); }
>
> So things do start to get messy. This solution, of course, isn't ideal if 
> you are building a single page app as this context you're creating doesn't 
> get automatically cleaned every call like it happens on the server side 
> with SQLFORM so then you start to get strange interactions and bugs. Hence 
> we have to figure out a smarter way to do it where the context is really 
> available for just that one form and it goes away with it.
>
>
>

-- 
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/d/optout.


[web2py] IS_INT_IN_RANGE() weirdness

2014-09-09 Thread Joe Barnhart
Did anyone notice that the range for the INT validator is min <= value < 
max, while the validator for FLOAT is min <= value <= max?

Since the "max" value is not actually in the range of the INT validator, it 
means you can't do this:

IS_INT_IN_RANGE(1,1)

The above will fail every time, for all time.  Because '1' satisfies the 
lower limit (min <= val) bur it fails the high limit (value < max).

Not a problem if you're looking for it, just seems a weird definition...

-- Joe

-- 
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/d/optout.


[web2py] Customize SQLFORM.grid

2014-09-09 Thread Luciano Laporta Podazza
Hello,

I would like to take advantage of SQLFORM.grid search, listing and 
pagination capabilities to generate a listing from a table, but I need to 
customize the resulting rows like this:


Until now I only have this:

users = SQLFORM.grid(db.users,fields=[db.users.id, db.users.first_name, 
db.users.last_name],
headers={'users.id':'id','users.first_name':'Nombre', 
'users.last_name':'Apellido'},
sortable=False, deletable=False, editable=False, create=False,
csv=False, formstyle="div")

Which results into this:


I'm using Bootstrap 3. Any help will be appreciated.

-- 
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/d/optout.