[web2py] Re: how can i join 3 tables and output a the all three together joined in web2py?

2013-12-20 Thread Loïc
I posted a response on SO : 
http://stackoverflow.com/questions/20697034/how-can-i-join-3-tables-and-output-a-the-all-three-together-joined-in-web2py/20698864#20698864


Le vendredi 20 décembre 2013 07:06:41 UTC+1, deepak sandhu a écrit :
>
> model:
>
>
> # coding: utf8
> db.define_table('dept',
> Field('name',unique=True,label='Department Name'),
> format='%(name)s')
>
>
> db.define_table('course',
> Field('dept_id','reference dept'),
> Field('name',unique=True,label='Course Name'),
> format='%(name)s')
>
>
> db.define_table('files',
> Field('course_id', 'reference course'),
> Field('documentx','upload'))
>
>
>
>
> controller:
>
> def show_doc():
> rows = db( db.course.id == db.files.course_id , db.dept.id==db.
> course.dept_id).select()
> return rows
>
>
>
>
> What I am trying to do is joining department with course table and course 
> table with files table so when out putting it shows a table with department 
> with course and files all together. the solution doest work. it only 
> creates a join between course table and files table.
>

-- 
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 Pages module (basic CMS)

2013-12-20 Thread Ruud Schroen
We are still working on a plugin.
But we are facing a problem regarding reserved keywords which prevents us 
from creating a plugin.

db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
*check_reserved=['all'] *needs to be removed in order for it to work right 
now, the problem is you can't overrule it somewhere.
If anyone knows a solution that will be greatly appreciated, and we can 
finally make a plugin for it.

On Tuesday, November 19, 2013 9:23:42 AM UTC+1, Ruud Schroen wrote:
>
> Hi,
>
> I'm here to share a great module with you. It's called *web2py-pages*, 
> created 
> by Formatics  which I'm currently working for. 
> You can download it here: 
> web2py-pages
>
> Pages module for web2py gives you a good starting point for any type of 
> CMS. It features a tree of pages with sluggified (URL friendly) names. 
> Pages can consist out of items. 
>
> Current page items are:
>
>- Markmin text
>- HTML text
>- Plain text
>- Image (with optional Fancybox)
>- Imageslider
>- Photoalbum (Google Picasa)
>- FAQ Address
>- File upload
>- Links
>- and a couple of pre defined forms
>
> It also has neat features like:
>
>- CKeditor
>- plugin_tagging
>- Admin Menu
>- Easy way to create a test page with all items
>- Page copy functionality
>- Functionality to change the order of items displayed
>- Two columns (left align, right align, full align)
>- Nivoslider
>- Fancybox
>
> Current available languages:
>
>- Dutch (NL)
>- English (EN)
>
> *Download here!* 
>
>

-- 
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: Visibiity of values created in a module

2013-12-20 Thread Richard Brown
Hi Anthony, that worked thanks - although I had found this solution before 
and tried it without apparent success at the time. I can only assume I put 
it in the wrong place or there was another problem.

A couple of related Scheduler questions if I may:
Firstly, I have included all database accesses in the Scheduler code within 
a try... except statement so if there is a conflict then it just returns 
and tries again on the next pass as timing is not critical. However, is it 
possible that the problem can occur the other way round, where accessing 
the database from a view could happen whilst the Scheduler is also 
accessing it? The chances are very small, but it ought to be covered.

Secondly, how can I get the Scheduler to run automatically on startup? 
Web2py is running on a Raspberry Pi, so at the moment I log in remotely via 
PuTTy and type the start command. It obviously stops when I log out which 
is quite convenient during development, but now it all sort of works I 
would like to make it run by default.

Thanks,

Richard



On Thursday, 19 December 2013 23:34:02 UTC, Richard Brown wrote:

> I am using the Scheduler to perform some control functions and so have an 
> autonomous function, called by the Scheduler via 'poll.py', in a module 
> called 'utilities.py'. This scans some databases to decide what to 
> do, and this seems to work fine (I have (hopefully) coded around any 
> potential database conflicts).
>
> However, I want to report a value back from my function to display in a 
> View. How should I do this? Ideally I would like to update a database 
> record from my module function which I can interrogate and modify from the 
> view, but nothing I have tried so far seems to find its way back. I use 
> db=current.db in the function, but although this allow the function to get 
> parameters from the database, anything I write back does not modify the 
> actual database available to the View, or in 'Database Administration'.
>
> I have also tried using a session variable but that also appears as 'None' 
> when I read it in the view. The function is not called from anywhere so 
> there is no obvious way of using a return value. 
>

-- 
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] response.models_to_run in web2py 2.8.2

2013-12-20 Thread rochacbruno
Hi,

I use web2admin in some applications, I was running older version of web2py 
and them I decided to upgrade to 2.8.2 for testing.

I found an issue with response.models_to_run and reported a ticket in 
web2admin repo: https://github.com/rif/web2admin/issues/9

web2admin uses a conditional model running implemented as:

if request.controller == 'web2admin':
request.controller = 'plugin_web2admin'
response.view = response.view.replace('web2admin', 'plugin_web2admin')
response.models_to_run.append("^plugin_web2admin/\w+\.py")


This is used to get rid of "plugin" prefix in urls, so users can access 
using /welcome/web2admin instead of /welcome/plugin_web2admin (which is a 
bit ugly)

That practice of checking request.controller and change response.view and 
response.controller and models_to_run worked very well until version "2.2.1"

Is that changed?

Thanks.

-- 

*Bruno Rocha - @rochacbruno*
http://github.com/rochacbruno
http://brunorocha.org
http://pythonhub.com

-- 
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: response.models_to_run in web2py 2.8.2

2013-12-20 Thread rochacbruno
If somebody can help ans test it there is an live app here:

https://web2admin.pythonanywhere.com/admin

password: 35c15f36

error: https://web2admin.pythonanywhere.com/welcome/web2admin
ticket: 
https://web2admin.pythonanywhere.com/admin/default/ticket/welcome/177.189.155.195.2013-12-20.11-35-10.50855933-8c61-4d91-b1d2-e765a803f698

But if url is changed it works:

https://web2admin.pythonanywhere.com/welcome/plugin_web2admin/index
user: ad...@example.com
password: admin

note that the problem only occurs  when using the shortcut 'web2admin' 
instead of 'plugin_web2admin'

-- 
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] after_insert - database transaction?

2013-12-20 Thread Johann Spies
I have never used after_insert or before_insert before and the
documentation in the book does not answer enough of my questions.


Having the following models I want to create an invoice and record some of
its particulars in the invoice table and then link the transactions that
were invoiced to the invoice number:

db.define_table('invoice',
Field('invoice_date', 'date',
  requires=IS_NOT_EMPTY()),
Field('client', 'reference client',
  requires=IS_NOT_EMPTY(),
  represent = lambda value, row: A('{}'.format(
row.client.name),

_href=URL('show_client', args=value))),
Field('from_date', 'date'),
Field('to_date', 'date'))

db.define_table('transactions',
Field('client', 'reference client',
  represent = lambda value, row: A('{}'.format(
row.client.name),
  _href=URL('show_client',
args=value))),
 ...
Field('invoice', 'reference invoice'))

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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: response.models_to_run in web2py 2.8.2

2013-12-20 Thread Paolo Valleri
I am not able to debug it a little more but as you can see here: 
https://github.com/web2py/web2py/commits/master/gluon/compileapp.py
a few changes have been made on how models are handled, perhaps something 
broken backward compatibility ?
Have you already tried with 2.7.4 ?

Paolo

On Friday, December 20, 2013 1:04:18 PM UTC+1, rochacbruno wrote:
>
> If somebody can help ans test it there is an live app here:
>
> https://web2admin.pythonanywhere.com/admin
>
> password: 35c15f36
>
> error: https://web2admin.pythonanywhere.com/welcome/web2admin
> ticket: 
> https://web2admin.pythonanywhere.com/admin/default/ticket/welcome/177.189.155.195.2013-12-20.11-35-10.50855933-8c61-4d91-b1d2-e765a803f698
>
> But if url is changed it works:
>
> https://web2admin.pythonanywhere.com/welcome/plugin_web2admin/index
> user: ad...@example.com 
> password: admin
>
> note that the problem only occurs  when using the shortcut 'web2admin' 
> instead of 'plugin_web2admin'
>

-- 
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: after_insert - database transaction?

2013-12-20 Thread Johann Spies
Apologies - message sent prematurely.


On 20 December 2013 15:18, Johann Spies  wrote:

> I have never used after_insert or before_insert before and the
> documentation in the book does not answer enough of my questions.
>
>
> Having the following models I want to create an invoice and record some of
> its particulars in the invoice table and then link the transactions that
> were invoiced to the invoice number:
>
> db.define_table('invoice',
> Field('invoice_date', 'date',
>   requires=IS_NOT_EMPTY()),
> Field('client', 'reference client',
>   requires=IS_NOT_EMPTY(),
>   represent = lambda value, row: A('{}'.format(
> row.client.name),
>
> _href=URL('show_client', args=value))),
> Field('from_date', 'date'),
> Field('to_date', 'date'))
>
> db.define_table('transactions',
> Field('client', 'reference client',
>   represent = lambda value, row: A('{}'.format(
> row.client.name),
>   _href=URL('show_client',
> args=value))),
>  ...
> Field('invoice', 'reference invoice'))
>
>
>
The invoice will be created using the client, from_date and to_date
particulars making a summary of what is going on the transactions-table
which also has a transaction_date field not shown above.

I want to ensure that the invoice record gets inserted and then all the
transactions updated with the invoice-id in a way that if the latter
process fails the transaction will be aborted and the invoice record
deleted from the table.

Can i use after_insert for this or is it better to use the database's
transaction capabilities through db.executesql?

Regards
Johann



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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: after_insert - database transaction?

2013-12-20 Thread Niphlod
every request is done in a cursor. every cursor by default in the dbapi 
spec is executed inside a transaction.
Unless you do db.commit() and db.rollback() manually, every relational 
engine will either "save" all the modifications in a single transaction or 
it will rollback all of them.

On Friday, December 20, 2013 2:23:03 PM UTC+1, Johann Spies wrote:
>
> Apologies - message sent prematurely.
>
>
> On 20 December 2013 15:18, Johann Spies 
> > wrote:
>
>> I have never used after_insert or before_insert before and the 
>> documentation in the book does not answer enough of my questions.
>>
>>
>> Having the following models I want to create an invoice and record some 
>> of its particulars in the invoice table and then link the transactions that 
>> were invoiced to the invoice number:
>>
>> db.define_table('invoice',
>> Field('invoice_date', 'date', 
>>   requires=IS_NOT_EMPTY()),
>> Field('client', 'reference client',
>>   requires=IS_NOT_EMPTY(),
>>   represent = lambda value, row: A('{}'.format(
>> row.client.name),
>>
>> _href=URL('show_client', args=value))),
>> Field('from_date', 'date'),
>> Field('to_date', 'date'))
>>
>> db.define_table('transactions',
>> Field('client', 'reference client',
>>   represent = lambda value, row: A('{}'.format(
>> row.client.name),
>>   
>> _href=URL('show_client', args=value))),
>>  ...
>> Field('invoice', 'reference invoice'))
>>
>>
>>
> The invoice will be created using the client, from_date and to_date 
> particulars making a summary of what is going on the transactions-table 
> which also has a transaction_date field not shown above.
>
> I want to ensure that the invoice record gets inserted and then all the 
> transactions updated with the invoice-id in a way that if the latter 
> process fails the transaction will be aborted and the invoice record 
> deleted from the table.
>
> Can i use after_insert for this or is it better to use the database's 
> transaction capabilities through db.executesql?
>
> Regards
> Johann 
>
>
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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: hide error messages is returning NONE value for messages

2013-12-20 Thread Michel Hayek
Thanks Anthony, works great.

-- 
 

*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.


Re: [web2py] Re: Online classes

2013-12-20 Thread António Ramos
i downloaded the w2p file and got that error.

I git cloned the repo and copied the app to my web2py path.
Works!


2013/12/20 Johann Spies 

> How did you download it?
>
>
> Johann
>
>
> On 19 December 2013 23:39, António Ramos  wrote:
>
>> I get error
>> unable to install application notifier
>>
>> i´m using
>> 2.6.4-stable+timestamp.2013.09.26.13.34.47
>>
>>
>> 2013/12/19 Johann Spies 
>>
>>> +1
>>>
>>>
>>> On 19 December 2013 20:50, Cliff  wrote:
>>>
 These have been very helpful. Thanks!


 On Tuesday, December 3, 2013 1:34:18 AM UTC-5, Massimo Di Pierro wrote:

> Hello everybody,
>
> As you know I teach a certification program about web development with
> Python and I use web2py.
> I posted my most recent classes online:
>
> https://vimeo.com/75499986
> https://vimeo.com/76047107
> https://vimeo.com/76608898
> https://vimeo.com/77179700
> https://vimeo.com/77654974
>
> It is about of 13 hours of web2py lessons and coding.
> Please join me in thanking the students who enrolled in the program
> and supported these classes.
>
> Massimo
>
  --
 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.

>>>
>>>
>>>
>>> --
>>> Because experiencing your loyal love is better than life itself,
>>> my lips will praise you.  (Psalm 63:3)
>>>
>>> --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
> --
> 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.
>

-- 
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: how do I create, multiple forms and precess them, using 'for' statement?

2013-12-20 Thread Ivo
I have chosen to go the custom form way.
The only issue I have is that upon hitting submit, the button submits all 
the forms on the page instead of just the one owning the button. I think 
this also screws up my validation and it prevents records from being 
inserted to the db.  

controller:
def show_form():

users_1 = 
db(db.people.id.belongs(session.people.keys())).select(db.people.user_id)
users_2=[]
for user in users_1:
if user not in users_2:
users_2.append(user)
else:
pass

forms=[]  
for user in users_2:
usr= db(db.auth_user.id==user.user_id).select(db.auth_user.username,
db.auth_user.id)[0]
usr1=usr.username
usr2=usr.id
key=str(usr2)
fields = [
  Field('key',default=key,writable=False),
  Field('username',default=usr1,writable=False),
  Field('address',default='Fill in your 
address',type='text')
  ]

form=SQLFORM.factory(*fields, table_name=key,hidden=dict(ss_id=key),
 buttons=[
  BUTTON("Save Changes", 
_class="btn btn-primary")])
if form.process(formname=key, hideerror=True).accepted:
db.parking.insert(name=usr1, address=form.vars.address)
forms.append(form)

return dict(forms=forms)



view:
{{for form in forms:}}
{{=form.custom.begin}}
User: {{=form.custom.widget.username}} 
Address: {{=form.custom.widget.address}} 
{{form.custom.end}}
{{pass}}


On Wednesday, December 18, 2013 9:45:14 PM UTC+1, Niphlod wrote:
>
> form.process adds little bits to the form to be able to actually process 
> the posted data.
>
> in pseudo-code you need to
>
> list_of_forms = []
> for something in list_of_values:
>  key = something_unique
>  form = SQLFORM()
>  if form.process(formname=something_unique).accepted:
>.code dealing with the posted values, such as form.vars, etc
>  elif form.errors:
>.code dealing with form errors
>
>  list_of_forms.append(form)
> ..
> return dict(list_of_forms=list_of_forms, )
>
> In the view, you can then:
>
> {{for single_form in list_of_forms:}}
> 
> {{=single_form}} #or {{single_form.custom.etc etc etc}}
> 
> 
> {{pass}}
>

-- 
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: after_insert - database transaction?

2013-12-20 Thread Johann Spies
Thanks Niphlod!

Would something like this do the trick?

db.invoice._after_insert.append(lambda id:
function_updating_transactions(id))

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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] Linking program to web service

2013-12-20 Thread sly cooper
I am new to python but before I proceed with the language, I would like to 
know if I can link my python based program to a web service. I will be 
using this for my project, so if I cannot use a web service as my database 
then python will not be useful to me.

-- 
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: after_insert - database transaction?

2013-12-20 Thread Massimo Di Pierro
Mind that _after insert take id, and a Row object:

db.invoice._after_insert.append(lambda row,id: 
function_updating_transactions(id))

On Friday, 20 December 2013 08:25:09 UTC-6, Johann Spies wrote:
>
> Thanks Niphlod!
>
> Would something like this do the trick?
>
> db.invoice._after_insert.append(lambda id: 
> function_updating_transactions(id))
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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] Online classes

2013-12-20 Thread Horia Sar
Thanks so much Massimo.Looking forward to watch the videos!

-- 
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] Populating a SQLFORM select with auth.user

2013-12-20 Thread rsantellan
Hi!

I'm new in web2py and I started to make a simple application to test it.

My db.py file is like this:

# -*- coding: utf-8 -*-
from gluon.tools import *

db = 
DAL('mysql://root:@localhost/web2pyPumpIt',pool_size=5,check_reserved=['all'])

auth = Auth(db)
auth.define_tables()


## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##   'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
##
## >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield
#

db.define_table('brand',
  Field('name', 'string'),
  Field('country', 'string'),
  format='%(name)s')

db.define_table('car',
  Field('name', 'string'),
  Field('brand_id', 'reference brand'),
  Field('modelyear', 'integer'),
  format='%(name)s')

db.define_table('carOwner',
  Field('carowner', 'reference auth_user'),
  Field('car', 'reference car'))

db.define_table('pumpData',
  Field('pumpdate', 'date'),
  Field('km', 'double'),
  Field('liters', 'double'),
  Field('price', 'double'),
  Field('car', 'reference car'),
  Field('created_on', 'datetime', default=request.now),
  Field('created_by', 'reference auth_user', default=auth.user_id))

db.car.id.readable = db.car.id.writable = False
db.car.name.requires = IS_NOT_IN_DB(db, 'car.name')
db.car.name.requires = IS_NOT_EMPTY()
db.car.brand_id.requires = IS_NOT_EMPTY()
db.car.brand_id.requires = IS_IN_DB(db, 'brand.id', '%(name)s')

db.brand.name.requires = IS_NOT_IN_DB(db, 'car.name')
db.brand.name.requires = IS_NOT_EMPTY()
db.brand.country.requires = IS_NOT_EMPTY()

db.pumpData.pumpdate.requires = IS_NOT_EMPTY()
db.pumpData.km.requires = IS_NOT_EMPTY()
db.pumpData.liters.requires = IS_NOT_EMPTY()
db.pumpData.price.requires = IS_NOT_EMPTY()
db.pumpData.car.requires = IS_NOT_EMPTY()
db.pumpData.car.requires = IS_IN_DB(db, 'car.id', '%(name)s')

db.pumpData.created_by.readable = db.pumpData.created_by.writable = False
db.pumpData.created_on.readable = db.pumpData.created_on.writable = False

owners_and_cars = db((db.car.id==db.carOwner.car) & (db.auth_user.id == 
db.carOwner.carowner))
## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db)

I create a user, a brand, a car and then I assigned the car to the user. 

My problem is that when I try to create a SQLFORM of pumpdata in controller 
like this:
@auth.requires_login()
def addpump():
""" add pump """
form = SQLFORM(db.pumpData);
form.process(next=URL('listpumps'))
return dict(form=form)

I get all the cars! Now I only want the cars that the logged user own, not 
all. How can I do that? My other problem is that I put on the fields 
required but all the selects has a empty option.

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/groups/opt_out.


[web2py] call username in query

2013-12-20 Thread Warrick
Hi All,

I am writing a SQLFORM.grid, but I want user to be able to only read, 
delete and edit their own records.

I am wanting to write a query, but how do I reference the logged in user's 
username from .db.auth_user?

query:

query=((db.battle_log.created_by = “”))


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] LDAP Auth

2013-12-20 Thread Richard Vézina
Could you show your mods?

It could help to understand the issue you have how we can solve them...

Richard


On Thu, Dec 19, 2013 at 7:30 PM, Maggs  wrote:

> Yes secure ldap is causing a lot of problems. I hope it gets sorted out
> eventually. For now I'm having to modify the framework for my needs.
>
>
> On Wednesday, November 27, 2013 7:18:45 AM UTC-8, Richard wrote:
>
>> ldap_auth need care, to me it's a draft that need code review, but it
>> works... I had many issue when I deploy ldap_auth with AD... But I didn't
>> have time to work further on these issues, we figure it out what was the
>> bottom of them, but refatoring ldap_auth need time and the most important
>> tests...
>>
>> Richard
>>
>>
>> On Tue, Nov 26, 2013 at 8:12 PM, Maggs  wrote:
>>
>>> I am in this situation where my team is in the process of migrating our
>>> ldap servers to the vpc and as a result I must update my applications to
>>> use secure ldap. I have unfortunately run into an issue with ldap_auth
>>> where it will use secure ldap but it only takes a ca cert file, but I need
>>> to use ca cert, cert and key files all together. This is possible directly
>>> through python-ldap like so:
>>>
>>> con.set_option(ldap.OPT_X_TLS_CACERTFILE, cacert_file)
 con.set_option(ldap.OPT_X_TLS_CERTFILE, cert_file)
 con.set_option(ldap.OPT_X_TLS_KEYFILE, key_file)
>>>
>>>
>>> but doesn't appear to be an option at all through the ldap_auth wrapper
>>> provided through web2py. I am having to modify this code manually to make
>>> this work. I'm just curious why these 2 other files aren't options and the
>>> ca cert is the only option?
>>>
>>> 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+un...@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.
>

-- 
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: response.models_to_run in web2py 2.8.2

2013-12-20 Thread Anthony
I have identified the problem and sent a patch to Massimo (attached). In 
the meantime, it should work if you change:

response.models_to_run.append(...)

to:

response.models_to_run = [...]

When mutating response.models_to_run, it doesn't recognize that it has 
changed, so you need to do a new assignment instead.

Anthony

On Friday, December 20, 2013 7:04:18 AM UTC-5, rochacbruno wrote:
>
> If somebody can help ans test it there is an live app here:
>
> https://web2admin.pythonanywhere.com/admin
>
> password: 35c15f36
>
> error: https://web2admin.pythonanywhere.com/welcome/web2admin
> ticket: 
> https://web2admin.pythonanywhere.com/admin/default/ticket/welcome/177.189.155.195.2013-12-20.11-35-10.50855933-8c61-4d91-b1d2-e765a803f698
>
> But if url is changed it works:
>
> https://web2admin.pythonanywhere.com/welcome/plugin_web2admin/index
> user: ad...@example.com
> password: admin
>
> note that the problem only occurs  when using the shortcut 'web2admin' 
> instead of 'plugin_web2admin'
>

-- 
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.
diff -r ec6720a491e6 gluon/compileapp.py
--- a/gluon/compileapp.py   Tue Dec 17 16:50:42 2013 -0600
+++ b/gluon/compileapp.py   Fri Dec 20 09:41:46 2013 -0500
@@ -528,7 +528,7 @@
 models_to_run = None
 for model in models:
 if response.models_to_run != models_to_run:
-regex = models_to_run = response.models_to_run
+regex = models_to_run = response.models_to_run[:]
 if isinstance(regex, list):
 regex = re_compile('|'.join(regex))
 if models_to_run:


Re: [web2py] Re: after_insert - database transaction?

2013-12-20 Thread Johann Spies

On 20/12/2013 16:32, Massimo Di Pierro wrote:

Mind that _after insert take id, and a Row object:

db.invoice._after_insert.append(lambda row,id:
function_updating_transactions(id))


Thanks Massimo.

Regards
Johann
--
J.H. Spies - Tel. 021-982 2694 / 082 782 0336 / 021-808 4699(w)
 Posbus 4668, Tygervallei 7536

 "Submit yourselves therefore to God. Resist the devil,
  and he will flee from you."  James 4:7

--
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] Can't Start Scheduler Worker

2013-12-20 Thread EW
I've never used a scheduler before and am having trouble starting up. When 
I try to start the workers (tried from command line and from gui), I get 
this error message:
 
 
 starting browser...   
starting scheduler from widget for "namebrowser"... 
  
Exception in thread Thread-14:   
Traceback (most recent call last):   
File "/lib/python2.7/threading.py", line 552, 
in__bootstrap_inner   
self.run()   
File "/lib/python2.7/threading.py", line 505, in run   

self.__target(*self.__args, **self.__kwargs)   

File "/web2py/gluon/widget.py", line 364, instart_schedulers
   
self.update_schedulers()   
File "/web2py/gluon/widget.py", line 341, inupdate_schedulers   

self.schedmenu.delete(0, len(available_apps))   

File "/lib/python2.7/lib-tk/Tkinter.py", line 2652, in 
delete   
num_index1, num_index2 = self.index(index1), self.index(index2) 
  
File "/lib/python2.7/lib-tk/Tkinter.py", line 2671, inindex 
  
i = self.tk.call(self._w, 'index', index)   
TclError: out of stack space (infinite loop?)   
 

 
Is it something with my python installation? I don't think there is 
anything wrong with my scheduler code..I've tried with just this simple 
scheduler.py in my models and still get the same error.
 
 from gluon.scheduler import Scheduler   

def blah():   
print 'blah blah blah'   

scheduler = Scheduler(db)

-- 
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: Can't Start Scheduler Worker

2013-12-20 Thread EW
Never mind...command line works

-- 
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] call username in query

2013-12-20 Thread Federico Ferraro
query=((db.battle_log.created_by == auth.user_id))




2013/12/20 Warrick 

> Hi All,
>
> I am writing a SQLFORM.grid, but I want user to be able to only read,
> delete and edit their own records.
>
> I am wanting to write a query, but how do I reference the logged in user's
> username from .db.auth_user?
>
> query:
>
> query=((db.battle_log.created_by = “”))
>
>
> 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.
>



-- 
--
Federico Ferraro
Usuario Linux : 482533.
--

-- 
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: Linking program to web service

2013-12-20 Thread Leonel Câmara
I don't see what the choice of programming language has to do with being 
able to connect to a webservice. Although, python certainly makes it very 
easy.

-- 
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] Temporarily Poll View

2013-12-20 Thread EW
I have a load component with a grid in it and a user-triggered action that 
could insert/update the database table that my grid's based on.  Depending 
on many factors, the database insert could take a long time, say 45s+.  I 
would like to update the view to show the updating grid while the inserts 
are going on rather than having a stagnant page that looks like it's not 
doing anything for 45s+.  
 
So I created a scheduler and am doing the db inserts in a scheduler task.  
But I'm not sure what the best way is to update the view.  I know that I 
could use the 'times' and 'timeout' parameters in the LOAD.  Or I could 
poll in javascript using setInterval to call web2py_component.  But is it 
burdensome to always have my page updating this, say every second?  The 
scheduler task for my db inserts only happen when the user clicks 
something; at all other times it is unnecessary to reload the grid.  Is 
there a way to make the view constantly update on the user's click but once 
the scheduler task has completed (i.e. finished inserting into the 
database) to stop the view from updating?

-- 
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] janrain login not working anymore?

2013-12-20 Thread Rene Dohmen
Hi,

We use the janrain login method in a couple of our webapps. As of today it 
suddenly stopped working...

Are there any other users that use the janrain login methods? (and have it 
working?)

On the janrain site I found a story about and old and a new way to use 
janrain. The Iframe way seems deprecated.

Kind Regards Rene

-- 
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] Font size and FPDF Report

2013-12-20 Thread Alfonso Pastor Sierra
Hi, I have the code for a PDF Report:

def export_pdf():

title = "Informe de impresiones"

head = THEAD(TR(TH("Fecha/Hora",_width="16%"), 
TH("Impresora",_width="17%"),
TH("Host",_width="10%"),
TH("Usuario",_width="10%"),
TH("Trabajo",_width="33%"),
TH("Pag",_width="4%"), 
TH("Cop",_width="4%"), 
TH("Total",_width="6%"),  
_bgcolor="#A0A0A0"))

   
rowsTable = []
i=0;

rows=consultaInforme()

for r in rows:

col = i % 2 and "#F0F0F0" or "#FF"

documento=r[6].encode("latin_1","replace")[:50]
  
rowsTable.append(TR(TD(r[1], _align="left"),
   TD(r[2], _align="left"),
   TD(r[5], _align="left"),
   TD(r[4], _align="left"),
   TD(documento, _align="left"),
   TD(r[7], _align="center"),
   TD(r[8], _align="center"),
   TD(r[9], _align="center"),
   _bgcolor=col))   

i+=1 

body = TBODY(*rowsTable)
table = TABLE(*[head, body], _border="1", _align="center", _width="100%"
)

class MyFPDF(FPDF, HTMLMixin):

def __init__(self):
FPDF.__init__(self,'L')

def header(self):
self.set_font('Arial','B',15)
self.cell(0,10, title ,1,0,'C')

def footer(self):
self.set_y(-15)
self.set_font('Arial','I',8)
self.cell(0,10,"IES",0,0,'L')
txt = 'Pag. %s de %s' % (self.page_no(), self.alias_nb_pages())
self.cell(0,10,txt,0,0,'R')

pdf=MyFPDF()
pdf.add_page()

pdf.write_html(str(XML(table, sanitize=False)))

response.headers['Content-Type']='application/pdf; charset=utf-8'
doc=pdf.output(dest='S')
doc64=embed64(data=doc,extension='application/pdf')
return 'window.open("%s");' % doc64 

def consultaInforme():

blah..blah.blah
.


consulta=cdb.executesql(sql)

return consulta


And I want to change the font-size of the text inside the table, but I 
can't.
 I have tried without success:

  
  rowsTable.append(TR(TD(r[1], _align="left"),
   TD(r[2], _align="left"),
   TD(r[5], _align="left"),
   TD(r[4], _align="left"),
   TD(documento, _align="left"),
   TD(r[7], _align="center"),
   TD(r[8], _align="center"),
   TD(r[9], _align="center"),
   _bgcolor=col, _style="font-size: 8px;"))

  

and

pdf=MyFPDF()
pdf.add_page()
pdf.set_font('Arial','',10)
pdf.write_html(str(XML(table, sanitize=False)))  

 

But never changes the font size in pdf.

Can you help me?





-- 
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] Blob image to web2py style

2013-12-20 Thread Adam Filić
I have mysql database with lot of blob images in it and I want to migrate 
from PHP to web2py. What is the best and easiest way to expose blob image 
to web2py style? Any suggestion?

-- 
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: Trouble setting up database that chooses predefined options.

2013-12-20 Thread Dave S

On Thursday, December 19, 2013 9:06:27 PM UTC-8, Cliff wrote:
>
> Hi Dave
>
> Thanks for the reply! That was somewhat the path I was on. I like the 
> boolean idea. Where I am hung up now though is how I would list all the 
> bowl games on a page then update picks, like how i mentioned before. Would 
> I be able to use SQLFORM to do this? This is my database setup, i have kept 
> it simple for now.
>
>
As a start, you might look at Loic's answer he linked in to the other 
thread.  Your database should be small enough that Anthony's concern won't 
be a problem.


(I use SQLFORM in my current, but just for a simple table; the trickiest 
thing I do is figuring out maxid so I can limit the range of the table.)
 

>
> db.define_table('persons', Field('person'), Field('email'))
> db.define_table('teams', Field('teamname'), Field('winner', 'boolean', 
> default=False))
> db.define_table('bowls', Field('name'), Field('team1', 'reference 
> teams'),Field('team2', 'reference teams'), Field('gametime', 'date')) 
> db.define_table('picks', Field('person', 'reference persons'), 
> Field('pick', 'reference teams'))
> db.persons.email.requires = IS_EMAIL()
> db.picks.person.requires = IS_IN_DB(db, db.persons.id, '%(person)s')
> db.bowls.team1.requires = IS_IN_DB(db, db.teams.id, '%(teamname)s')
> db.bowls.team2.requires = IS_IN_DB(db, db.teams.id, '%(teamname)s')
>
> On Thursday, December 19, 2013 2:30:20 PM UTC-5, Cliff wrote:
>>
>> Hello.
>>
>> General question here. Me and some friends guess who is going to win 
>> NCAAF bowl games so I thought I would try and make an app for it. So I 
>> started off making a table for users, games, picks. 
>>
>> Users -> Person name | email
>> bowls -> Bowl name | team 1 | team 2 | time | winner
>> picks - > person (reference user) | pick (reference unsure) 
>>
>> What I would like to do is make a page with an arg for user where I can 
>> enter their picks and it store it in a DB for that user. An example would 
>> be Bowl game 1: Team 1 vs Team 2 then a drop down list or radio button to 
>> select the team. Bowl game 2: team 1 vs team 2 drop down list to select the 
>> team etc etc.. Then later be able to list what user is ahead by wins. What 
>> I am getting caught up with is how to setup my databases. 
>>
>> If someone could point me in the right direction I would greatly 
>> appreciate it. 
>>
>

/dps

 

-- 
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: janrain login not working anymore?

2013-12-20 Thread Peter Govers
It seems the Jainrain Legacy Sign-in Widget has hit its end-of-life and has 
been replaced by Social Sign-in Widget.

I've changed RPXAccount login_form 
(gluon/contrib/login_methods/rpc_account.py) to migrate Janrain's Legacy 
Sign-in Widget to the current Social Sign-in Widget. For more info: 
http://developers.janrain.com/documentation/widgets/legacy-sign-in-widget/social-sign-in-migration-guide/

I added a pull request on GitHub and also included a patch as attachment.


Op vrijdag 20 december 2013 20:02:15 UTC+1 schreef Rene Dohmen:
>
> Hi,
>
> We use the janrain login method in a couple of our webapps. As of today it 
> suddenly stopped working...
>
> Are there any other users that use the janrain login methods? (and have it 
> working?)
>
> On the janrain site I found a story about and old and a new way to use 
> janrain. The Iframe way seems deprecated.
>
> Kind Regards Rene
>

-- 
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.
diff --git a/gluon/contrib/login_methods/rpx_account.py b/gluon/contrib/login_methods/rpx_account.py
index 0cd1c56..0116f4a 100644
--- a/gluon/contrib/login_methods/rpx_account.py
+++ b/gluon/contrib/login_methods/rpx_account.py
@@ -98,27 +98,32 @@ class RPXAccount(object):
 def login_form(self):
 request = self.request
 args = request.args
-if self.embed:
-JANRAIN_URL = \
-"https://%s.rpxnow.com/openid/embed?token_url=%s&language_preference=%s";
-rpxform = IFRAME(
-_src=JANRAIN_URL % (
-self.domain, self.token_url, self.language),
-_scrolling="no",
-_frameborder="no",
- _style="width:400px;height:240px;")
-else:
-JANRAIN_URL = \
-"https://%s.rpxnow.com/openid/v2/signin?token_url=%s";
-rpxform = DIV(SCRIPT(_src="https://rpxnow.com/openid/v2/widget";,
- _type="text/javascript"),
-  SCRIPT("RPXNOW.overlay = true;",
- "RPXNOW.language_preference = '%s';" % self.language,
- "RPXNOW.realm = '%s';" % self.domain,
- "RPXNOW.token_url = '%s';" % self.token_url,
- "RPXNOW.show();",
- _type="text/javascript"))
-return rpxform
+rpxform = """
+
+(function() {
+if (typeof window.janrain !== 'object') window.janrain = {};
+if (typeof window.janrain.settings !== 'object') window.janrain.settings = {};
+janrain.settings.tokenUrl = '%(token_url)s';
+function isReady() { janrain.ready = true; };
+if (document.addEventListener) {
+document.addEventListener("DOMContentLoaded", isReady, false);
+} else {
+window.attachEvent('onload', isReady);
+}
+var e = document.createElement('script');
+e.type = 'text/javascript';
+e.id = 'janrainAuthWidget';
+if (document.location.protocol === 'https:') {
+e.src = 'https://rpxnow.com/js/lib/%(domain)s/engage.js';
+} else {
+e.src = 'http://widget-cdn.rpxnow.com/js/lib/%(domain)/engage.js';
+}
+var s = document.getElementsByTagName('script')[0];
+s.parentNode.insertBefore(e, s);
+})();
+
+""" % dict(token_url=self.token_url, domain=self.domain)
+return XML(rpxform)
 
 
 def use_janrain(auth, filename='private/janrain.key', **kwargs):


[web2py] Possibly a problem with CAS redirection in v2.8.2

2013-12-20 Thread Vinicius Assef
Hi guys,
I'm playing around with CAS and faced this error:
 begin here 
The webpage at 
http://localhost:8000/cas/default/user/cas/login?service=http://localhost:8000/consumer/default/user/login#
has resulted in too many redirects. Clearing your cookies for this
site or allowing third-party cookies may fix the problem. If not, it
is possibly a server configuration issue and not a problem with your
computer.

Error code: ERR_TOO_MANY_REDIRECTS
 end here 

It occurs in v2.8.2, but not in v2.7.4.

My scenario is simple:
1- One CAS provider application, called "cas". Actually, a raw copy of
welcome application. Nothing more, nothing less.
2- One CAS consumer, called "consumer". Another copy of welcome
application with just one single modification in db.py:
auth = Auth(db, cas_provider="http://localhost:8000/cas/default/user/cas";)
3- In consumer application, I have a default.py/protected() function
with @auth.requires_login() decorator.

The workflow to reproduce the error is:
1) Try to go to http://localhost:8000/consumer/protected.
2) The login form will show up (from cas application).
3) When I fill the form and click submit, the error happens.

Is there anything I must configure in v2.8.2 to allow CAS to work 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.


[web2py] TclError bad option iconphoto

2013-12-20 Thread Daniel Nogues
Hello,

I'm setting up web2py on a Mac OS X 10.5.8
with Python 2.7.2

I have so far done these steps:

1. create VENV with no_site_packages
2. activate VENV
3. run: pip install web2py
4. run: pip install mercurial
5. run: w2p_clone from VENV
6. launch web2py with: python ./web2py/web2py.py

At step 6 I get this output:

(web2py)mac ~/Data/Envs/web2py: python ./web2py/web2py.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.8.2-stable+timestamp.2013.12.19.20.24.40
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
Ingres(pyodbc), IMAP(imaplib)
Traceback (most recent call last):
  File "./web2py/web2py.py", line 33, in 
gluon.widget.start(cron=True)
  File "/Users/danielnogues/Data/Envs/web2py/web2py/gluon/widget.py", line 
1183, in start
master = web2pyDialog(root, options)
  File "/Users/danielnogues/Data/Envs/web2py/web2py/gluon/widget.py", line 
156, in __init__
self.root.tk.call('wm', 'iconphoto', self.root._w, img)
_tkinter.TclError: bad option "iconphoto": must be aspect, attributes, 
client, colormapwindows, command, deiconify, focusmodel, frame, geometry, 
grid, group, iconbitmap, iconify, iconmask, iconname, iconposition, 
iconwindow, maxsize, minsize, overrideredirect, positionfrom, protocol, 
resizable, sizefrom, stackorder, state, title, transient, or withdraw

The code says:

iconphoto = os.path.join('extras','icons','web2py.gif')
if os.path.exists(iconphoto):
img = Tkinter.PhotoImage(file=iconphoto)
self.root.tk.call('wm', 'iconphoto', self.root._w, img)

So I rename web2py.gif to web2py.gif.old and the Framework runs.

Is this a bug ? Do I need to install something in particular in my virtual 
environment ?  Here's my requirements file:

mercurial==2.8.1
web2py==2.1.1
wsgiref==0.1.2

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] how to define adal model at runtime

2013-12-20 Thread Manuele Pesenti
Il 19/12/13 11:53, Giuseppe D'Amico ha scritto:
> Hi I am new to web2py I need to connect to  a legacy database  that
> could be postgresql or mysql, I would like to know if there is a way
> to define the model of the database at runtime?
could it be of any help?
http://www.web2pyslices.com/slice/show/1491/plugin-lookout

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/groups/opt_out.


[web2py] Re: Linking program to web service

2013-12-20 Thread Dave S

On Friday, December 20, 2013 4:36:14 AM UTC-8, sly cooper wrote:
>
> I am new to python but before I proceed with the language, I would like to 
> know if I can link my python based program to a web service. I will be 
> using this for my project, so if I cannot use a web service as my database 
> then python will not be useful to me.
>

Are you wanting to use a python program as the remote client, and web2py as 
the framework for the service that client accesses?

That shouldn't be too much of problem.  See Chapter 10 of the Web2Py book:

(If you haven't read any of the web2py book yet, you should get familiar 
with it.  The early examples are good experience.)

For the client side, you will need an appropriate library to import.  My 
experience is with SOAP, so I imported SUDS.  The book describes several 
choices of protocols, though, so you aren't stuck with SOAP.

(The SOAP support for Web2Py is pysimplesoap, which the @service.soap 
decorator sets up.  I think I also used the client in an experiment, but I 
think I needed a SUDS feature for accessing a particular third-party 
service.)  (Other decorators are used for JSONRPC and the like.)


/dps

-- 
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] output the name of file stored in table in upload filed?

2013-12-20 Thread deepak sandhu
this is view file:

{{for row in rows:}}

download
{{pass}}




by doing so I get the download link of all the files one by one but all of 
them are named "download" which gets confusing to know which one is which. 
So I was trying to output their name:

row.files.document.name 
or _name or .str()



but nothing works. I am sure the name of file is saved and there is a way 
to retrieve 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/groups/opt_out.


[web2py] Re: janrain login not working anymore?

2013-12-20 Thread Peter Govers
I'm sorry, made a typo in patch above. Also changed code to be backwards 
compatible with older web2py versions.

Updated PR and added new patch. 

Op vrijdag 20 december 2013 20:58:11 UTC+1 schreef Peter Govers:
>
> It seems the Jainrain Legacy Sign-in Widget has hit its end-of-life and 
> has been replaced by Social Sign-in Widget.
>
> I've changed RPXAccount login_form 
> (gluon/contrib/login_methods/rpc_account.py) to migrate Janrain's Legacy 
> Sign-in Widget to the current Social Sign-in Widget. For more info: 
> http://developers.janrain.com/documentation/widgets/legacy-sign-in-widget/social-sign-in-migration-guide/
>
> I added a pull request on GitHub and also included a patch as attachment.
>
>
> Op vrijdag 20 december 2013 20:02:15 UTC+1 schreef Rene Dohmen:
>>
>> Hi,
>>
>> We use the janrain login method in a couple of our webapps. As of today 
>> it suddenly stopped working...
>>
>> Are there any other users that use the janrain login methods? (and have 
>> it working?)
>>
>> On the janrain site I found a story about and old and a new way to use 
>> janrain. The Iframe way seems deprecated.
>>
>> Kind Regards Rene
>>
>

-- 
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.
diff --git a/gluon/contrib/login_methods/rpx_account.py b/gluon/contrib/login_methods/rpx_account.py
index 0cd1c56..d8c47eb 100644
--- a/gluon/contrib/login_methods/rpx_account.py
+++ b/gluon/contrib/login_methods/rpx_account.py
@@ -98,27 +98,32 @@ class RPXAccount(object):
 def login_form(self):
 request = self.request
 args = request.args
-if self.embed:
-JANRAIN_URL = \
-"https://%s.rpxnow.com/openid/embed?token_url=%s&language_preference=%s";
-rpxform = IFRAME(
-_src=JANRAIN_URL % (
-self.domain, self.token_url, self.language),
-_scrolling="no",
-_frameborder="no",
- _style="width:400px;height:240px;")
-else:
-JANRAIN_URL = \
-"https://%s.rpxnow.com/openid/v2/signin?token_url=%s";
-rpxform = DIV(SCRIPT(_src="https://rpxnow.com/openid/v2/widget";,
- _type="text/javascript"),
-  SCRIPT("RPXNOW.overlay = true;",
- "RPXNOW.language_preference = '%s';" % self.language,
- "RPXNOW.realm = '%s';" % self.domain,
- "RPXNOW.token_url = '%s';" % self.token_url,
- "RPXNOW.show();",
- _type="text/javascript"))
-return rpxform
+rpxform = """
+
+(function() {
+if (typeof window.janrain !== 'object') window.janrain = {};
+if (typeof window.janrain.settings !== 'object') window.janrain.settings = {};
+janrain.settings.tokenUrl = '%s';
+function isReady() { janrain.ready = true; };
+if (document.addEventListener) {
+document.addEventListener("DOMContentLoaded", isReady, false);
+} else {
+window.attachEvent('onload', isReady);
+}
+var e = document.createElement('script');
+e.type = 'text/javascript';
+e.id = 'janrainAuthWidget';
+if (document.location.protocol === 'https:') {
+e.src = 'https://rpxnow.com/js/lib/%s/engage.js';
+} else {
+e.src = 'http://widget-cdn.rpxnow.com/js/lib/%s/engage.js';
+}
+var s = document.getElementsByTagName('script')[0];
+s.parentNode.insertBefore(e, s);
+})();
+
+""" % (self.token_url, self.domain, self.domain)
+return XML(rpxform)
 
 
 def use_janrain(auth, filename='private/janrain.key', **kwargs):


[web2py] server slow down when face multiple requests

2013-12-20 Thread sonu kumar
Hi All,
I have built one application using web2py and running on Apache server on 
unix environment. During testing of this application what I found is 
slowing down of my application when two users from different computer 
request my application or submit any job.
I have no idea why it is happening. Are there any changes need at Apache 
server side for handling multiple request or at web2py side.

Please let me know.
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: altering tables and gets database not working. trying to find a way to empty the database.

2013-12-20 Thread Carlos Zenteno
To answer your question.

I go to a SQLITE utility (if your are using SQLITE) and delete the tables 
from there
and then do #1 in your list, delete the database files for the same tables.

It works for me this way...

-- 
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] adding dropdown of 3rd table on 2nd table in form

2013-12-20 Thread deepak sandhu
model: 


# coding: utf8
db.define_table('dept',
Field('name',unique=True,label='Department Name'),
format='%(name)s')


db.define_table('course',
Field('dept_id','reference dept'),
   Field('name',unique=True,label='Course Name'),
format='%(name)s')


db.define_table('files',
Field('course_id', 'reference course'),
Field('documentx','upload'))


controller:

def create_doc():
form = SQLFORM(db.files).process(next=URL('show_doc'))
return dict(form = form)



this works perfectly but the problem is when I open create_doc it shows a 
drop-down for courses only which is fine but how can I make it so that it 
asks to select department(in drop-down) then course(in drop-down) and then 
upload the document.

-- 
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: Populating a SQLFORM select with auth.user

2013-12-20 Thread samuel bonill

try this:

@auth.requires_login()
def addpump():
""" add pump """
form = SQLFORM(db.pumpData)
if form.process().accepted:
redirect(URL('listpumps')) 
   return dict(form=form)

@auth.requires_login()
def listpumps():
  query = db(db.carOwner.carowner==auth_user.id).select()
return dict(query=query)

in the view lispumps.html

{{extend "layout.html"}}

{{fro each in query:}}
  name {{=ath_user.first_name}}

cars   {{=UL(LI(eath.car.name))}}
{{pass}}






El viernes, 20 de diciembre de 2013 06:58:00 UTC-5, rsant...@gmail.com 
escribió:
>
> Hi!
>
> I'm new in web2py and I started to make a simple application to test it.
>
> My db.py file is like this:
>
> # -*- coding: utf-8 -*-
> from gluon.tools import *
>
> db = 
> DAL('mysql://root:@localhost/web2pyPumpIt',pool_size=5,check_reserved=['all'])
>
> auth = Auth(db)
> auth.define_tables()
>
> 
> ## Define your tables below (or better in another model file) for example
> ##
> ## >>> db.define_table('mytable',Field('myfield','string'))
> ##
> ## Fields can be 'string','text','password','integer','double','boolean'
> ##   'date','time','datetime','blob','upload', 'reference TABLENAME'
> ## There is an implicit 'id integer autoincrement' field
> ## Consult manual for more options, validators, etc.
> ##
> ## More API examples for controllers:
> ##
> ## >>> db.mytable.insert(myfield='value')
> ## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
> ## >>> for row in rows: print row.id, row.myfield
> #
>
> db.define_table('brand',
>   Field('name', 'string'),
>   Field('country', 'string'),
>   format='%(name)s')
>
> db.define_table('car',
>   Field('name', 'string'),
>   Field('brand_id', 'reference brand'),
>   Field('modelyear', 'integer'),
>   format='%(name)s')
>
> db.define_table('carOwner',
>   Field('carowner', 'reference auth_user'),
>   Field('car', 'reference car'))
>
> db.define_table('pumpData',
>   Field('pumpdate', 'date'),
>   Field('km', 'double'),
>   Field('liters', 'double'),
>   Field('price', 'double'),
>   Field('car', 'reference car'),
>   Field('created_on', 'datetime', default=request.now),
>   Field('created_by', 'reference auth_user', default=auth.user_id))
>
> db.car.id.readable = db.car.id.writable = False
> db.car.name.requires = IS_NOT_IN_DB(db, 'car.name')
> db.car.name.requires = IS_NOT_EMPTY()
> db.car.brand_id.requires = IS_NOT_EMPTY()
> db.car.brand_id.requires = IS_IN_DB(db, 'brand.id', '%(name)s')
>
> db.brand.name.requires = IS_NOT_IN_DB(db, 'car.name')
> db.brand.name.requires = IS_NOT_EMPTY()
> db.brand.country.requires = IS_NOT_EMPTY()
>
> db.pumpData.pumpdate.requires = IS_NOT_EMPTY()
> db.pumpData.km.requires = IS_NOT_EMPTY()
> db.pumpData.liters.requires = IS_NOT_EMPTY()
> db.pumpData.price.requires = IS_NOT_EMPTY()
> db.pumpData.car.requires = IS_NOT_EMPTY()
> db.pumpData.car.requires = IS_IN_DB(db, 'car.id', '%(name)s')
>
> db.pumpData.created_by.readable = db.pumpData.created_by.writable = False
> db.pumpData.created_on.readable = db.pumpData.created_on.writable = False
>
> owners_and_cars = db((db.car.id==db.carOwner.car) & (db.auth_user.id == 
> db.carOwner.carowner))
> ## after defining tables, uncomment below to enable auditing
> # auth.enable_record_versioning(db)
>
> I create a user, a brand, a car and then I assigned the car to the user. 
>
> My problem is that when I try to create a SQLFORM of pumpdata in 
> controller like this:
> @auth.requires_login()
> def addpump():
> """ add pump """
> form = SQLFORM(db.pumpData);
> form.process(next=URL('listpumps'))
> return dict(form=form)
>
> I get all the cars! Now I only want the cars that the logged user own, not 
> all. How can I do that? My other problem is that I put on the fields 
> required but all the selects has a empty option.
>
> 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/groups/opt_out.


[web2py] Re: Populating a SQLFORM select with auth.user

2013-12-20 Thread samuel bonill
sorry;

@auth.requires_login()
def addpump():
""" add pump """
form = SQLFORM(db.pumpData)
if form.process().accepted:
redirect(URL('listpumps')) 
   return dict(form=form)

@auth.requires_login()
def listpumps():
  query = db(db.carOwner.carowner==auth_user.id).select()
return dict(query=query)

in the view lispumps.html

{{extend "layout.html"}}

{{fro each in query:}}
  name {{=auth_user.first_name}}

cars   {{=UL(LI(each.car.name ))}}
{{pass}}



El viernes, 20 de diciembre de 2013 06:58:00 UTC-5, rsant...@gmail.com 
escribió:
>
> Hi!
>
> I'm new in web2py and I started to make a simple application to test it.
>
> My db.py file is like this:
>
> # -*- coding: utf-8 -*-
> from gluon.tools import *
>
> db = 
> DAL('mysql://root:@localhost/web2pyPumpIt',pool_size=5,check_reserved=['all'])
>
> auth = Auth(db)
> auth.define_tables()
>
> 
> ## Define your tables below (or better in another model file) for example
> ##
> ## >>> db.define_table('mytable',Field('myfield','string'))
> ##
> ## Fields can be 'string','text','password','integer','double','boolean'
> ##   'date','time','datetime','blob','upload', 'reference TABLENAME'
> ## There is an implicit 'id integer autoincrement' field
> ## Consult manual for more options, validators, etc.
> ##
> ## More API examples for controllers:
> ##
> ## >>> db.mytable.insert(myfield='value')
> ## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
> ## >>> for row in rows: print row.id, row.myfield
> #
>
> db.define_table('brand',
>   Field('name', 'string'),
>   Field('country', 'string'),
>   format='%(name)s')
>
> db.define_table('car',
>   Field('name', 'string'),
>   Field('brand_id', 'reference brand'),
>   Field('modelyear', 'integer'),
>   format='%(name)s')
>
> db.define_table('carOwner',
>   Field('carowner', 'reference auth_user'),
>   Field('car', 'reference car'))
>
> db.define_table('pumpData',
>   Field('pumpdate', 'date'),
>   Field('km', 'double'),
>   Field('liters', 'double'),
>   Field('price', 'double'),
>   Field('car', 'reference car'),
>   Field('created_on', 'datetime', default=request.now),
>   Field('created_by', 'reference auth_user', default=auth.user_id))
>
> db.car.id.readable = db.car.id.writable = False
> db.car.name.requires = IS_NOT_IN_DB(db, 'car.name')
> db.car.name.requires = IS_NOT_EMPTY()
> db.car.brand_id.requires = IS_NOT_EMPTY()
> db.car.brand_id.requires = IS_IN_DB(db, 'brand.id', '%(name)s')
>
> db.brand.name.requires = IS_NOT_IN_DB(db, 'car.name')
> db.brand.name.requires = IS_NOT_EMPTY()
> db.brand.country.requires = IS_NOT_EMPTY()
>
> db.pumpData.pumpdate.requires = IS_NOT_EMPTY()
> db.pumpData.km.requires = IS_NOT_EMPTY()
> db.pumpData.liters.requires = IS_NOT_EMPTY()
> db.pumpData.price.requires = IS_NOT_EMPTY()
> db.pumpData.car.requires = IS_NOT_EMPTY()
> db.pumpData.car.requires = IS_IN_DB(db, 'car.id', '%(name)s')
>
> db.pumpData.created_by.readable = db.pumpData.created_by.writable = False
> db.pumpData.created_on.readable = db.pumpData.created_on.writable = False
>
> owners_and_cars = db((db.car.id==db.carOwner.car) & (db.auth_user.id == 
> db.carOwner.carowner))
> ## after defining tables, uncomment below to enable auditing
> # auth.enable_record_versioning(db)
>
> I create a user, a brand, a car and then I assigned the car to the user. 
>
> My problem is that when I try to create a SQLFORM of pumpdata in 
> controller like this:
> @auth.requires_login()
> def addpump():
> """ add pump """
> form = SQLFORM(db.pumpData);
> form.process(next=URL('listpumps'))
> return dict(form=form)
>
> I get all the cars! Now I only want the cars that the logged user own, not 
> all. How can I do that? My other problem is that I put on the fields 
> required but all the selects has a empty option.
>
> 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/groups/opt_out.


[web2py] javascript in controller

2013-12-20 Thread sonu kumar
Hi,

When I use below code in controller to show form. It works fine but when I 
see html source of html page...it shows some charachters...which is shown 
in red below. how to remove them?

form=FORM(TABLE(TR('Select 
protease:',SELECT(values,requires=IS_NOT_EMPTY("choose one 
value"),_name='protease',_onchange="jQuery.post('%s',{'protease':jQuery(this).val()})"
 
% URL('mmp'))),
TR('Enter sequence:',TEXTAREA(_name='fasta',_style = 
'font-family:Courier; width:550px;height:250px;')),

TR("",INPUT(_type="submit",_value="SUBMIT",_onclick='javascript:$.blockUI({message:
 
$("#domMessage") });'

Select 
protease:MMP2
MMP3MMP8MMP9

Enter fasta sequence:




-- 
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: output the name of file stored in table in upload filed?

2013-12-20 Thread 黄祥
i think you still need to use python to retrieve the 
row.files.document.name in the html side.
e.g. not tested
{{=
row.files.document.name}}

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 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: Blob image to web2py style

2013-12-20 Thread 黄祥
please take a look at :
http://web2py.com/books/default/chapter/29/13/deployment-recipes#Uploading-files-in-database

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 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: after_insert - database transaction?

2013-12-20 Thread 黄祥
another way around i think you can do :
e.g.
def __after_insert_invoice(f, id):
db(db.treatment.id == f.treatment_no).update(status = 'Invoice')
treatment = db(db.treatment.id == f.treatment_no).select().first() 
db(db.registration.id == treatment.registration_no).update(status = 
'Invoice')
registration = db(db.registration.id == 
treatment.registration_no).select().first()
if registration.appointment_no:
db(db.appointment.id == registration.appointment_no).update(status = 
'Invoice')

db.invoice._after_insert.append(__after_insert_invoice)

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 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: response.models_to_run in web2py 2.8.2

2013-12-20 Thread Massimo Di Pierro
Thanks. It is in trunk!

On Friday, 20 December 2013 08:56:20 UTC-6, Anthony wrote:
>
> I have identified the problem and sent a patch to Massimo (attached). In 
> the meantime, it should work if you change:
>
> response.models_to_run.append(...)
>
> to:
>
> response.models_to_run = [...]
>
> When mutating response.models_to_run, it doesn't recognize that it has 
> changed, so you need to do a new assignment instead.
>
> Anthony
>
> On Friday, December 20, 2013 7:04:18 AM UTC-5, rochacbruno wrote:
>>
>> If somebody can help ans test it there is an live app here:
>>
>> https://web2admin.pythonanywhere.com/admin
>>
>> password: 35c15f36
>>
>> error: https://web2admin.pythonanywhere.com/welcome/web2admin
>> ticket: 
>> https://web2admin.pythonanywhere.com/admin/default/ticket/welcome/177.189.155.195.2013-12-20.11-35-10.50855933-8c61-4d91-b1d2-e765a803f698
>>
>> But if url is changed it works:
>>
>> https://web2admin.pythonanywhere.com/welcome/plugin_web2admin/index
>> user: ad...@example.com 
>> password: admin
>>
>> note that the problem only occurs  when using the shortcut 'web2admin' 
>> instead of 'plugin_web2admin'
>>
>

-- 
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] setting up web2py for godaddy.com

2013-12-20 Thread AY
Hi,

I am trying to setup web2py for godaddy.com

Anyone with experience with Godaddy.com?

Or any suggestions?

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/groups/opt_out.


[web2py] Wordpress model file

2013-12-20 Thread guruyaya
I have several projects in my work, that require handling wordpress. As I 
hate doing stuff in PHP, and DAL is my prefered tool for a lot of my work, 
I've created a model file of wordpress. I hope you'll find it useful, and 
I'd love to hear your feedback

Have fun:
https://github.com/guruyaya/web2py_wp_model
Yair

-- 
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.