Re: [web2py] Re: IMPORTANT - WEB2PY CONSULTING

2016-02-26 Thread Gael Princivalle
Just wait to publish, I've saw in the thread other updates to apply.

--
Gael Princivalle

2016-02-27 6:29 GMT+01:00 Gael Princivalle :

> Hello Massimo.
>
> I've saw that some of these website companies are offline:
> http://web2py.com/init/default/support
>
> I suggest to delete these websites from the support list.
>
> Best regards.
>
> Il giorno venerdì 26 febbraio 2016 14:50:26 UTC+1, Gael Princivalle ha
> scritto:
>>
>> Hello Massimo.
>>
>> Can you add us?
>>
>> www.tasko.it
>>
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/j_AV4YeI-zA/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.
>

-- 
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: IMPORTANT - WEB2PY CONSULTING

2016-02-26 Thread Gael Princivalle
Hello Massimo.

I've saw that some of these website companies are offline:
http://web2py.com/init/default/support

I suggest to delete these websites from the support list.

Best regards. 

Il giorno venerdì 26 febbraio 2016 14:50:26 UTC+1, Gael Princivalle ha 
scritto:
>
> Hello Massimo.
>  
> Can you add us?
>
> www.tasko.it
>
> 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.


Re: [web2py] My session.counter is not counting

2016-02-26 Thread Joe
Hi Kiran,

Thanks very much for your reply.

I tried to initialize session.one_counter/two_counter/three_counter but it 
seems my understanding of the session variables in this case is not 
sufficient to get this right.
Basically, I am stuck with this one.

My aim is to count the clicks to image.id *1*, image.id *2* and image.id *3* 
separately, so I can compare them.

If you could guide me in the right direction so I can have a better 
understanding and solve this problem or if you could correct my code, I 
would really appreciate it.

Thanks again.

Cheers,

Joe

On Saturday, February 27, 2016 at 12:31:11 PM UTC+8, Kiran Subbaraman wrote:
>
> You seem to be incrementing 'counter' in the session (the counter is user 
> session specific then). 
> Also, you are using session.one_counter/two_counter/three_counter, without 
> having initialized it. Is that a typo?
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Sat, 27-02-2016 6:35 AM, Joe wrote:
>
> I am trying to use session.counter to count clicks on images on a page. 
> My problem is that my session.counter is not counting...
> I am doing something wrong, not sure exactly what.
> I am pretty sure the issue is the* if image.id  == 1*
> I'd appreciate some help with this.
>
> *Controller:*
>
> def index():
> images = db().select(db.image.ALL, orderby=db.image.id)
> return dict(images=images)
>
> def show():
> image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
> one_counter = []
> two_counter = []
> three_counter = []
> if image.id == 1:
> session.counter = (session.counter or 0)+1
> one_counter=session.one_counter
> elif image.id == 2:
> session.counter = (session.counter or 0)+1
> two_counter=session.two_counter
> elif image.id == 3:
> session.counter = (session.counter or 0)+1
> three_counter=session.three_counter
> return dict(image=image)
>
> def download():
> return response.download(request, db)
>
> *View:*
>
> show:
> {{=0 if session.one_counter is None else session.one_counter}}
> {{=0 if session.two_counter is None else session.two_counter}}
> {{=0 if session.three_counter is None else session.three_counter}}
>
> -- 
> 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/d/optout.
>
>
>

-- 
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] My session.counter is not counting

2016-02-26 Thread Kiran Subbaraman
You seem to be incrementing 'counter' in the session (the counter is 
user session specific then).
Also, you are using session.one_counter/two_counter/three_counter, 
without having initialized it. Is that a typo?



Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Sat, 27-02-2016 6:35 AM, Joe wrote:

I am trying to use session.counter to count clicks on images on a page.
My problem is that my session.counter is not counting...
I am doing something wrong, not sure exactly what.
I am pretty sure the issue is the/if image.id == 1/
I'd appreciate some help with this.

*Controller:*

def index():
images = db().select(db.image.ALL, orderby=db.image.id)
return dict(images=images)

def show():
image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
one_counter = []
two_counter = []
three_counter = []
if image.id == 1:
session.counter = (session.counter or 0)+1
one_counter=session.one_counter
elif image.id == 2:
session.counter = (session.counter or 0)+1
two_counter=session.two_counter
elif image.id == 3:
session.counter = (session.counter or 0)+1
three_counter=session.three_counter
return dict(image=image)

def download():
return response.download(request, db)

*View:*

show:
{{=0 if session.one_counter is None else session.one_counter}}
{{=0 if session.two_counter is None else session.two_counter}}
{{=0 if session.three_counter is None else 
session.three_counter}}


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


--
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] My session.counter is not counting

2016-02-26 Thread Joe
I am trying to use session.counter to count clicks on images on a page.
My problem is that my session.counter is not counting...
I am doing something wrong, not sure exactly what.
I am pretty sure the issue is the* if image.id == 1*
I'd appreciate some help with this.

*Controller:*

def index():
images = db().select(db.image.ALL, orderby=db.image.id)
return dict(images=images)

def show():
image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
one_counter = []
two_counter = []
three_counter = []
if image.id == 1:
session.counter = (session.counter or 0)+1
one_counter=session.one_counter
elif image.id == 2:
session.counter = (session.counter or 0)+1
two_counter=session.two_counter
elif image.id == 3:
session.counter = (session.counter or 0)+1
three_counter=session.three_counter
return dict(image=image)

def download():
return response.download(request, db)

*View:*

show:
{{=0 if session.one_counter is None else session.one_counter}}
{{=0 if session.two_counter is None else session.two_counter}}
{{=0 if session.three_counter is None else session.three_counter}}

-- 
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] Sublime Text? Plugins?

2016-02-26 Thread Dave
I am not sure if any of you are using Sublime Text to write you code it, 
but I absolutely love it.  With the right plugins, it really makes writing 
code a joy.  Far more useful than any IDE I have ever used (even xcode and 
eclipse).  Anyway, I was installing a few new plugins this week and 
discovered there are a couple plugins out there for template language and 
code generation for Django.  I was wondering if any of you have created 
anything for web2py?  Of course, since web2py uses python as a template 
language there shouldn't be much to do except making the editor recognize 
{{ / }} and pass statements to end blocks.

Anybody have anything they would like to share?  Perhaps I will see what 
functionality is there for some of the other python based frameworks and 
see what it would take to duplicate some of the automation in a web2py 
friendly way.  I just don't want to have to recreate the wheel if someone 
else has already done some of this work.

-- 
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: Basic syntax question

2016-02-26 Thread Anthony
And note, {{=some_expression}} only works when the "=" comes immediately 
after the "{{". It is a shortcut for:

{{response.write(some_expression)}}

Also, note that "print" will have no effect on the generated HTML. Instead, 
you must write to the response.body (which is what response.write does).

Anthony

On Friday, February 26, 2016 at 2:35:10 PM UTC-5, Niphlod wrote:
>
> the correct syntax would be
>
> {{foreach element in elements:}}
> {{=each}}
> {{pass}}
>
>
> please read the book (especially the part about views (
> http://web2py.com/books/default/chapter/29/05/the-views))
>
> On Friday, February 26, 2016 at 7:49:07 PM UTC+1, Marty Jones wrote:
>>
>> I'm just getting started with web2py and I'm struggling to figure out how 
>> to call variables passed from the controller to the view, without using the 
>> {{=variable}} method.
>>
>> For example, I have the following code in my controller:
>>
>> def manage():
>> list = []
>> for row in db(db.auth_user.registration_key[0]=='p').select():
>> if row.company=='Chosen company':
>> list.append({row.last_name:{"first":row.first_name}})
>> return dict(list=list)
>>
>> And the following code in my view:
>>
>> {{for each in =list}}
>> {{print each}}
>> {{pass}}
>>
>> Which generates an error... How do I call the list variable without using 
>> the = syntax?
>>
>

-- 
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] dynamic multiple form field instances error

2016-02-26 Thread Richard Vézina
You fall on an empty "name" vars... Could you have forget to pass the name
vars throught url?

Richard

On Fri, Feb 26, 2016 at 3:14 PM,  wrote:

> Can someone please tell me why I am getting this error and how to fix it?
>
>
> numpatients = int(request.vars.name);
>  int() argument must be a string or a number,
> not 'NoneType'
>
> *db.py*
>
>
> db.define_table('post',
> Field('patient'),
> Field('attime'),
> Field('age')
> )
>
> *view.html*
>
> *index.html*
>
> 
> How many patients?:  
> 
>
>
>
> *postform.html*
>
> {{=BEAUTIFY(form)}}
>
>
> *controller.py*
>
>
> def postform():
> inputs = [];
> numpatients = int(request.vars.name);
> for i in range(0, numpatients):
> inputs.append(db.post.patient.clone(name='%s_%s' % (
> db.post.patient.name, i)))
> inputs.append(db.post.attime.clone(name='%s_%s' % (
> db.post.attime.name, i)))
> inputs.append(db.post.age.clone(name='%s_%s' % (db.post.age.name,
> i)))
> form = SQLFORM.factory(*inputs)
> if form.process().accepted:
> for i in range(0,numpatients):
> db.post.insert(post=form.vars['patient_%s' % i])
> db.post.insert(post=form.vars['attime_%s' % i])
> db.post.insert(post=form.vars['age_%s' % i])
> elif form.errors:
> response.flash = 'form has errors'
> return dict(form=form)
>
>
>
>
> I want to prompt the user to enter a value of how many patients to enter
> for the session, they are redirected to a page where a single form is
> displayed and there are multiple form field instances displayed based on
> the number of patients they want to enter for that session. When I click
> submit after filling the form, I keep getting that error and I don't
> understand why or how to change it because I need that value from the
> previous page to know how many form field instances to display.
>
> --
> 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.
>

-- 
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] auth_permission

2016-02-26 Thread Richard Vézina
Yes why not?

As long as you populate them correctly it all fine to do it...

Richard

On Fri, Feb 26, 2016 at 11:08 AM, prashant joshi 
wrote:

> we can create permissin table in manually
>
> --
> 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.
>

-- 
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] dynamic multiple form field instances error

2016-02-26 Thread aetagothno
Can someone please tell me why I am getting this error and how to fix it?


numpatients = int(request.vars.name);
 int() argument must be a string or a number, 
not 'NoneType'

*db.py*


db.define_table('post',
Field('patient'),
Field('attime'),
Field('age')
)

*view.html*

*index.html*


How many patients?:  




*postform.html*

{{=BEAUTIFY(form)}}


*controller.py*


def postform():
inputs = [];
numpatients = int(request.vars.name);
for i in range(0, numpatients):
inputs.append(db.post.patient.clone(name='%s_%s' % 
(db.post.patient.name, i)))
inputs.append(db.post.attime.clone(name='%s_%s' % 
(db.post.attime.name, i)))
inputs.append(db.post.age.clone(name='%s_%s' % (db.post.age.name, 
i)))
form = SQLFORM.factory(*inputs)
if form.process().accepted:
for i in range(0,numpatients):
db.post.insert(post=form.vars['patient_%s' % i])
db.post.insert(post=form.vars['attime_%s' % i])
db.post.insert(post=form.vars['age_%s' % i])
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)




I want to prompt the user to enter a value of how many patients to enter 
for the session, they are redirected to a page where a single form is 
displayed and there are multiple form field instances displayed based on 
the number of patients they want to enter for that session. When I click 
submit after filling the form, I keep getting that error and I don't 
understand why or how to change it because I need that value from the 
previous page to know how many form field instances to display.

-- 
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: Basic syntax question

2016-02-26 Thread Niphlod
good catch. I was writing javascript right now hehehehehe

On Friday, February 26, 2016 at 8:41:38 PM UTC+1, Marty Jones wrote:
>
> Thank you. That works, although using "for" rather than "foreach".
>
> On Friday, February 26, 2016 at 1:35:10 PM UTC-6, Niphlod wrote:
>>
>> the correct syntax would be
>>
>> {{foreach element in elements:}}
>> {{=each}}
>> {{pass}}
>>
>>
>> please read the book (especially the part about views (
>> http://web2py.com/books/default/chapter/29/05/the-views))
>>
>> On Friday, February 26, 2016 at 7:49:07 PM UTC+1, Marty Jones wrote:
>>>
>>> I'm just getting started with web2py and I'm struggling to figure out 
>>> how to call variables passed from the controller to the view, without using 
>>> the {{=variable}} method.
>>>
>>> For example, I have the following code in my controller:
>>>
>>> def manage():
>>> list = []
>>> for row in db(db.auth_user.registration_key[0]=='p').select():
>>> if row.company=='Chosen company':
>>> list.append({row.last_name:{"first":row.first_name}})
>>> return dict(list=list)
>>>
>>> And the following code in my view:
>>>
>>> {{for each in =list}}
>>> {{print each}}
>>> {{pass}}
>>>
>>> Which generates an error... How do I call the list variable without 
>>> using the = syntax?
>>>
>>

-- 
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: Basic syntax question

2016-02-26 Thread Marty Jones
Thank you. That works, although using "for" rather than "foreach".

On Friday, February 26, 2016 at 1:35:10 PM UTC-6, Niphlod wrote:
>
> the correct syntax would be
>
> {{foreach element in elements:}}
> {{=each}}
> {{pass}}
>
>
> please read the book (especially the part about views (
> http://web2py.com/books/default/chapter/29/05/the-views))
>
> On Friday, February 26, 2016 at 7:49:07 PM UTC+1, Marty Jones wrote:
>>
>> I'm just getting started with web2py and I'm struggling to figure out how 
>> to call variables passed from the controller to the view, without using the 
>> {{=variable}} method.
>>
>> For example, I have the following code in my controller:
>>
>> def manage():
>> list = []
>> for row in db(db.auth_user.registration_key[0]=='p').select():
>> if row.company=='Chosen company':
>> list.append({row.last_name:{"first":row.first_name}})
>> return dict(list=list)
>>
>> And the following code in my view:
>>
>> {{for each in =list}}
>> {{print each}}
>> {{pass}}
>>
>> Which generates an error... How do I call the list variable without using 
>> the = syntax?
>>
>

-- 
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: Basic syntax question

2016-02-26 Thread Niphlod
the correct syntax would be

{{foreach element in elements:}}
{{=each}}
{{pass}}


please read the book (especially the part about views 
(http://web2py.com/books/default/chapter/29/05/the-views))

On Friday, February 26, 2016 at 7:49:07 PM UTC+1, Marty Jones wrote:
>
> I'm just getting started with web2py and I'm struggling to figure out how 
> to call variables passed from the controller to the view, without using the 
> {{=variable}} method.
>
> For example, I have the following code in my controller:
>
> def manage():
> list = []
> for row in db(db.auth_user.registration_key[0]=='p').select():
> if row.company=='Chosen company':
> list.append({row.last_name:{"first":row.first_name}})
> return dict(list=list)
>
> And the following code in my view:
>
> {{for each in =list}}
> {{print each}}
> {{pass}}
>
> Which generates an error... How do I call the list variable without using 
> the = syntax?
>

-- 
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] Basic syntax question

2016-02-26 Thread Marty Jones
I'm just getting started with web2py and I'm struggling to figure out how 
to call variables passed from the controller to the view, without using the 
{{=variable}} method.

For example, I have the following code in my controller:

def manage():
list = []
for row in db(db.auth_user.registration_key[0]=='p').select():
if row.company=='Chosen company':
list.append({row.last_name:{"first":row.first_name}})
return dict(list=list)

And the following code in my view:

{{for each in =list}}
{{print each}}
{{pass}}

Which generates an error... How do I call the list variable without using 
the = syntax?

-- 
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] Grouping db rows, and showing row with the lowest value for a particular field, within a grid

2016-02-26 Thread Boa
 


Given a DB table (called db.t_schedule, with the field names/types and 
corresponding values show below), is there a way to generate an 
SQLFORM.grid based on the db.t_schedule table such that:

   - There is no grid row which has the same 'f_uuid' as any other grid row
   - For each grid row, the earliest ‘start_time’ for a particular 'f_uuid' 
   is displayed
   - The ‘user_id’ and ‘user_id_2’ values corresponding to the 
   db.t_schedule row with the earliest ‘start_time’ for a given 'f_uuid' are 
   displayed
   -  The grid is sorted by the ‘f_start’ field

The db.t_schedule DB data: 

 

id   

 

f_uuid 

(string)

f_start 

(date)

user_id

(reference db.auth_user.id)

user_id_2

(reference db.auth_user.id)

1

123

2/24/16

1

4

2

123

1/24/16

2

5

3

123

1/15/16

3

6

4

234

2/23/16

4

4

5

234

2/27/16

5

2

6

234

1/2/16

6

8

7

345

2/25/16

7

6

8

345

2/26/16

8

5

 

The desired SQLFORM.grid resembles the following:

 

f_uui 

(string)

f_start 

(date)

user_id

(reference db.auth_user.id)

user_id_2

(reference db.auth_user.id)

123

1/15/16

3

6

234

1/2/16

6

8

345

2/25/16

7

6


I guess one way to do it would be something like the following, but this 
doesn’t seem to be the most efficient or practical way of going about it, 
especially if dealing with a large number of rows:

 
dict__ids = {}  # key: uuid, val = schedule ID

fields__select = [db.t_schedule.f_uuid,db.t_schedule.id,db.t_schedule.
f_start] 

for row__appointment in db(query__select).select(*fields__select, orderby =~ 
db.t_schedule.f_start):
if not row__appointment['id'] in dict__ids.keys(): 
dict__ids[row__appointment['f_uuid']] = row__appointment['id'] 

query = db.t_schedule.id.belongs(dict__ids.values())

grid = SQLFORM.grid(query, ...)


 

I’ve been tinkering with a variety of query variants, and combinations of 
groupby/orderby, but I’m not sure about the most efficient way to generate 
a grid which meets the above conditions. Any help would be much 
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.


[web2py] Re: Weird select().first()

2016-02-26 Thread Anthony
On Friday, February 26, 2016 at 10:51:58 AM UTC-5, Massimo Di Pierro wrote:
>
> you have
>
> hist_id = db.sales_cycle_history.insert(sales_cycle_id=scid, ...)
>
> so you should do
>
> row = db(db.sales_cycles.id == hist_id).select().first()
>
> or
>
> row = db(db.sales_cycles.sales_cycle_id == scid).select().first()
>
> but NOT 
>
> row = db(db.sales_cycles.id == scid).select().first()
>

Note, the query is on the db.sales_cycle table, but hist_id is the id of a 
record inserted into a *different *table (db.sales_cycle_history). He also 
claims to get an actual record returned when passing the row to 
response.json (i.e., mysteriously, it is not None in that case). I think we 
need to see more code.

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] Preventing hackers from exploiting web2py with wsgi

2016-02-26 Thread Anthony
On Friday, February 26, 2016 at 10:57:19 AM UTC-5, Robin Manoli wrote:
>
>
> So, is the above log entry from the *other* server (i.e., not the one you 
>> control)? I presume the "server.ip" value is the IP address of your server, 
>> hence the belief that this request is coming from your server, correct? If 
>> so, how did you get this log entry? Did the owner of the server contact you 
>> and provide it? Did they request any information from you? Can you trust 
>> that this is real (as opposed to a social engineering attempt)?
>>
>
> Yes this was the entry from the other server. The report of the entry was 
> sent to the VPS provider by bitninja.io, and the VPS provider forwarded 
> it to me asking for a solution. Bitninja didn't ask for anything else than 
> those logs I posted here, and they said pretty much the same thing about 
> attempting proxy requests. They seem trustable to me, although I don't see 
> how these requests from my server keep happening on port 80 on that server 
> after I blocked it for outgoing traffic.
>

Note, Bitninja sells server security services (i.e., they have an interest 
in convincing you that you've got a vulnerability so you will buy their 
services). A lot of folks seem to think they generate fake reports as a 
marketing scam -- see:

https://www.lowendtalk.com/discussion/69911/hukot-net-and-bitninja-io
https://www.lowendtalk.com/discussion/69248/bitninja-abuse-reports

Also, on their home page , both the counter and the 
"live" list of "attacks" are fake -- generated client-side via Javascript 
(no live updates from the server).

I'm not sure if they sent you more details, but I notice the alleged server 
log record from them does not include the timestamp, and it does not appear 
they gave you the host name or IP address of the allegedly attacked server. 
This means there is no way for you to correlate their alleged records with 
your own logs (i.e., you cannot match the external host/ip nor the time of 
the request). They have sent you a very generic and common type of attack, 
so it may be likely that you would have a matching request in your logs 
just by chance.

If you think they're for real, tell them you at least want to see 
timestamps -- if you don't see a matching request in your logs around the 
same time, I would highly doubt their reports are real.

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] Preventing hackers from exploiting web2py with wsgi

2016-02-26 Thread Massimo Di Pierro
I agree with Anthony's comments here. Nothing of what is shown is web2py 
related. This appears to be a php exploit.

Massimo

P.S. I stand by Niphlod. He did not say anything offending and his comment 
was insightful. We do not recommend apache+mod_wsgi because there are 
better ways (nginx+uwsgi). Although this is nothing to do with the php 
exploit above.

On Friday, 26 February 2016 06:46:36 UTC-6, Anthony wrote:
>
> On Friday, February 26, 2016 at 4:57:47 AM UTC-5, Robin Manoli wrote:
>>
>>
>> *About the exploit*There is an exploit is was happening. I thought they 
>> were related to a web2py app on Apache, but I'm sure any more. What is 
>> happening is that another web server keeps getting this type of requests 
>> from a server I'm working on. This keeps happening although the ports 80 
>> and 443 (and almost all other ports) for outbound traffic of the servers 
>> are closed. ModProxy is disabled.
>>
>> server.ip - - [  -0500] "GET 
>> /index.php?page=../../../../../../../../proc/self/environ%00 HTTP/1.1" 
>> 200 7792 "-" "Mozilla/4.76 [en] (Win98; U)"
>>
>
> So, is the above log entry from the *other* server (i.e., not the one you 
> control)? I presume the "server.ip" value is the IP address of your server, 
> hence the belief that this request is coming from your server, correct? If 
> so, how did you get this log entry? Did the owner of the server contact you 
> and provide it? Did they request any information from you? Can you trust 
> that this is real (as opposed to a social engineering attempt)?
>  
>
>> I did find some suspicious apache logs which made me think it was related 
>> to a web2py app:
>> 213.152.162.134 - - [23/Feb/2016:22:32:19 +0100] "GET 
>> http://stream-full.selfip.com:8000/get.php?username=anonyme1520091ef3=anonyme1520091ef3=m3u=mpegts&1=anonyme1520091ef
>> 3 HTTP/1.0" 400 804 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en) 
>> AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3"
>> 185.25.148.240 - - [24/Feb/2016:14:38:31 +0100] "GET 
>> http://testp3.pospr.waw.pl/testproxy.php HTTP/1.1" 404 267 "-" "Mozilla/5.0 
>> (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/31.0"
>> 213.152.162.134 - - [24/Feb/2016:19:44:56 +0100] "GET 
>> http://stream-full.selfip.com:8000/get.php?username=whatisashelly=whatisashelly=m3u=mpegts&1=whatisashelly
>>  
>> HTTP/1.0"
>> 500 1091 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; .NET 
>> CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 
>> 3.5.30729)"
>>
>>
> I don't see how any of these requests would be related to web2py/WSGI (as 
> they are not for internal URLs that would be served by web2py), nor how 
> they would be related to the alleged external request to the other server 
> (which is not at any of these URLs). Looks like someone was just trying 
> (and failing) to proxy requests through your server.
>
> I did not wish to say that web2py has any specific issues, but rather to 
>> learn about potential and perhaps common mistakes people do when creating 
>> web2py or wsgi apps.
>>
>
> With regard to "proxy abuse" specifically, WSGI and web2py play no role -- 
> this is simply an issue of the web server (and it seems not to be a problem 
> in your case).
>  
>
>>
>> *About why I use apache*You are right of course Niphlod. The full story 
>> is just that I had a working setup with Apache without any issues, so I was 
>> focusing on app development and not choosing web servers. It worked very 
>> well so far in the context, and it's not really important to discuss this 
>> any further. I have my reasons for why things are like they are, and of 
>> course I can move to nginx.
>>
>
> If you can, it might not be a bad idea to switch to Nginx, but at the 
> moment, it's not clear that Apache is really causing any problems here.
>
> 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] auth_permission

2016-02-26 Thread prashant joshi
we can create permissin table in manually

-- 
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: What are the platforms for free web hosting of web2py apps?

2016-02-26 Thread António Ramos
webfaction is very good

2016-02-26 15:59 GMT+00:00 Massimo Di Pierro :

> I agree:
>
> pythonanywhere.com (free with limitation)
> google app engine (also free with limitations)
> digital ocean is $5/month for a full VM
>
>
> On Friday, 26 February 2016 09:03:30 UTC-6, Manches spainspots wrote:
>>
>> It depends on your needs.  I am new to web2py, so I just needed a small
>> place to learn.  I found that at pythonanywhere.com and a decent free
>> tutorial at Udemy.
>> Good Luck!
>>
>> On Saturday, February 20, 2016 at 10:38:46 PM UTC-8, Rgb Aston wrote:
>>>
>>> Which one's the best to go for?
>>>
>> --
> 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.
>

-- 
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: What are the platforms for free web hosting of web2py apps?

2016-02-26 Thread Massimo Di Pierro
I agree:

pythonanywhere.com (free with limitation)
google app engine (also free with limitations)
digital ocean is $5/month for a full VM


On Friday, 26 February 2016 09:03:30 UTC-6, Manches spainspots wrote:
>
> It depends on your needs.  I am new to web2py, so I just needed a small 
> place to learn.  I found that at pythonanywhere.com and a decent free 
> tutorial at Udemy.
> Good Luck!
>
> On Saturday, February 20, 2016 at 10:38:46 PM UTC-8, Rgb Aston wrote:
>>
>> Which one's the best to go for?
>>
>

-- 
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: Want to build a web scraper that runs as web2py app. Where to start?

2016-02-26 Thread Massimo Di Pierro
You can use this. http://scrapy.org/
But do not run into web2py. Run it as a separate process and have web2py 
communicate to it by reading each other files or xmlrpc or the web2py 
scheduler.

On Friday, 26 February 2016 09:03:30 UTC-6, Marty Jones wrote:
>
> I have some familiarity with scraping but only from my local machine, not 
> from a server. I'd like to set up a basic scraping app as a web2py app that 
> I can eventually run on a server. Anybody seen any tutorials for anything 
> along these lines or know of a good module for doing this?
>

-- 
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 create dating profiles on web2py

2016-02-26 Thread Massimo Di Pierro
You can use extra fields to add fields to profile.

auth.settings.extra_fields['auth_user'] = [Field('gender'), 
Field('eyes_color'), Field('overall_hotness')]

You can make the profile of a user public:

# http://./profile/1
def profile():
 user = db.auth_user(request.args(0))
 if user: # remove fields you do not want to accidentally expose
  del user.password
  del user.registration_key
 return dict(user=user)

To check who is online you need to use a websocket server. Web2py has one 
in gluon/contrib/websocket_messaging.py. It requires tornado. The example 
is in the code itself. If you understand how it works it only requires 2-3 
lines of JavaScript coding.

Massimo


On Friday, 26 February 2016 09:03:30 UTC-6, meanrhei nqiofg wrote:
>
> How do you create dating profiles like in a dating site in web2py? I want 
> one to see other profiles once they are created.
> I also want one to see who is online when the users are created.
>

-- 
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] Preventing hackers from exploiting web2py with wsgi

2016-02-26 Thread Robin Manoli


> So, is the above log entry from the *other* server (i.e., not the one you 
> control)? I presume the "server.ip" value is the IP address of your server, 
> hence the belief that this request is coming from your server, correct? If 
> so, how did you get this log entry? Did the owner of the server contact you 
> and provide it? Did they request any information from you? Can you trust 
> that this is real (as opposed to a social engineering attempt)?
>

Yes this was the entry from the other server. The report of the entry was 
sent to the VPS provider by bitninja.io, and the VPS provider forwarded it 
to me asking for a solution. Bitninja didn't ask for anything else than 
those logs I posted here, and they said pretty much the same thing about 
attempting proxy requests. They seem trustable to me, although I don't see 
how these requests from my server keep happening on port 80 on that server 
after I blocked it for outgoing traffic.


-- 
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: Weird select().first()

2016-02-26 Thread Massimo Di Pierro
you have

hist_id = db.sales_cycle_history.insert(sales_cycle_id=scid, ...)

so you should do

row = db(db.sales_cycles.id == hist_id).select().first()

or

row = db(db.sales_cycles.sales_cycle_id == scid).select().first()

but NOT 

row = db(db.sales_cycles.id == scid).select().first()


On Friday, 26 February 2016 09:03:30 UTC-6, Louis Beetge wrote:
>
> HI everybody
>
> I have a REALLY weird problem. Take a look at this code:
>
> def save_disposition():
> dispo_id = request.vars.disposition_id
> dispo_name = request.vars.disposition_name
> scid = request.vars.sales_cycle_id
> linked_scid = request.vars.linked_contact_sc_id
>
>
> questions = db(db.disposition_questions.disposition_id == dispo_id).
> select()
>
>
> hist_id = db.sales_cycle_history.insert(sales_cycle_id=scid, 
> disposition_id=dispo_id, action_performed=dispo_name)
>
>
> row = db(db.sales_cycles.id == scid).select().first()
> pid = row.product_id
>
> I get the following error:
>  'NoneType' object has no attribute 
> 'product_id' for this line: pid = row.product_id
>
> Before everybody starts yelling that it's returning an empty object, lemme 
> explain. When I comment out "pid = row.product_id" and return 
> response.json(row), it returns the fetched row without any issue ie:
>
> {"application_id": 8, "product_id": 13, "modified_by": 138, "is_active": 
> true, "created_by": 138, "linked_contact_sc_id": null, "request_tenant": 
> "2", "created_on": "2016-02-24 19:00:59", "contact_id": 9823, 
> "modified_on": "2016-02-24 19:00:59", "disposition_id": null, "id": 9853}
>
> This is extremely frustrating and I cant seem to find anyone else who has 
> had the same issue.
>
> ANY ideas or pointing in the right direction would be greatly 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.


[web2py] Re: Weird select().first()

2016-02-26 Thread Anthony
Can you pack and attach a minimal app the demonstrates the problem?

On Friday, February 26, 2016 at 10:03:30 AM UTC-5, Louis Beetge wrote:
>
> HI everybody
>
> I have a REALLY weird problem. Take a look at this code:
>
> def save_disposition():
> dispo_id = request.vars.disposition_id
> dispo_name = request.vars.disposition_name
> scid = request.vars.sales_cycle_id
> linked_scid = request.vars.linked_contact_sc_id
>
>
> questions = db(db.disposition_questions.disposition_id == dispo_id).
> select()
>
>
> hist_id = db.sales_cycle_history.insert(sales_cycle_id=scid, 
> disposition_id=dispo_id, action_performed=dispo_name)
>
>
> row = db(db.sales_cycles.id == scid).select().first()
> pid = row.product_id
>
> I get the following error:
>  'NoneType' object has no attribute 
> 'product_id' for this line: pid = row.product_id
>
> Before everybody starts yelling that it's returning an empty object, lemme 
> explain. When I comment out "pid = row.product_id" and return 
> response.json(row), it returns the fetched row without any issue ie:
>
> {"application_id": 8, "product_id": 13, "modified_by": 138, "is_active": 
> true, "created_by": 138, "linked_contact_sc_id": null, "request_tenant": 
> "2", "created_on": "2016-02-24 19:00:59", "contact_id": 9823, 
> "modified_on": "2016-02-24 19:00:59", "disposition_id": null, "id": 9853}
>
> This is extremely frustrating and I cant seem to find anyone else who has 
> had the same issue.
>
> ANY ideas or pointing in the right direction would be greatly 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.


[web2py] Re: Setting up the scheduler, and letting it run from a certain point of time

2016-02-26 Thread Lucas Schreiber
It finally worked. thank you very, very much for you patience and help. 
It took a while but thanks to you i finally understood how the scheduler 
works.

Thankyou one more time :)

Am Mittwoch, 24. Februar 2016 00:11:47 UTC+1 schrieb Lucas Schreiber:
>
> Hi there,
> while trying to understand how to use the scheduler, i found this post:
> https://groups.google.com/forum/#!topic/web2py/VCPZmSc0vLc
>
> In the Post, this code is writen:
> db.scheduler_task.insert(function_name='task1',
>  task_name='task1',
>  stop_time = now + timedelta(days=9),
>  repeats=0,
>  period=10)
> g
> Where do i put this code? in the model? I think this was partly answered 
> in the post, but i dont understand it. can someone explain this to me?
>
> Also, is there a way to let a scheduler run at a time writen in a db once 
> and then rest until the next time occurs? or is a permanent run every few 
> seconds checking for certain criteria the better solution?
>
> And just to see if I understood this so far correctly:
> the scheduler function is basically a function I write into the model, 
> offering everything a "normal" function offers, exectued at times i 
> determine?
>
> Kind regards 
> And
>

-- 
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: Unpickle session_data from a MySQL database

2016-02-26 Thread Anthony
I believe this has been resolved here: 
http://stackoverflow.com/a/35613922/440323

Anthony

On Friday, February 26, 2016 at 10:03:30 AM UTC-5, NeoToren wrote:
>
> In order for a progress bar using cache.ram, and an ajax call to work 
> properly, there is a need to clean (or just unlock?) sessions.
> If the app doesn't use session variables to pass to other controllers then 
> session.forget(response) is sufficient.
>
> If on the other hand, the app needs session variables (as my app does 
> indeed) - then session.forget doesn't do much good since it brakes the 
> session variables chain of transmission to other controllers.
>
> As per Anthony suggestion in another post (Progress bar and sessions):
>
> I tried first using the cookies (with maximum zlib compression - level 9) 
> . 
> Still it's not enough for my needs ... I need more than 10k per session to 
> be passed to other controllers, and as mentioned in the book - keeping 
> sessions in cookies is not a good solution if the session are expected to 
> be large (more than 4k/cookie I assume).
>
> So I am trying session.connect with a MySQL db.
> I can see the table *web2py_session_AppName* being populated and I 
> understand the *session_data* column is pickled with cPickle.
> However...It looks the data in this column, *session_data* is encrypted, 
> not just pickled.
>
> *How do I unpickle the information in session_data column from a MySQL 
> table ?* 
> I tried using cPickle.loads...with the data as is, with the data as a 
> string...but it still throws a "bad pickle error"
>
> 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: Massimo for President!

2016-02-26 Thread Pierre
Massimo is already our President.
Guido would make a good Prime Minister

-- 
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: What are the platforms for free web hosting of web2py apps?

2016-02-26 Thread Manches spainspots
It depends on your needs.  I am new to web2py, so I just needed a small 
place to learn.  I found that at pythonanywhere.com and a decent free 
tutorial at Udemy.
Good Luck!

On Saturday, February 20, 2016 at 10:38:46 PM UTC-8, Rgb Aston wrote:
>
> Which one's the best to go for?
>

-- 
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] SQLFORM.grid() control detect_record_change

2016-02-26 Thread domezzzz


Ante todo, un saludo al Sr. Massimo Di Pierro y toda la colectividad que lo 
secunda, por este excelente framework, que no deja de sorprenderme.

 

Contexto del problema:

   Versión de web2py: 2.13.4 para windows (EXE) (siempre voy al día ;-))

   Sistema operativo: windows XP SP3.

   Db: postgresql 9.4

 

Estoy usando como mecanismo general de tratamiento CRUD y funcionalidad 
asociada a los reg.de una tabla, el método SQLFORM(grid).

Pero me tope con un problema no menor: dos (o más) usuarios que acceden al 
mismo registro en un mismo lapso de tiempo -están mirando la misma 
información obviamente-, uno de ellos denominado “primero”, actualiza los 
datos -nada que objetar-, pero luego, un “segundo usuario”, que tiene 
todavía una "vista de datos viejos", al dar confirmar para actualizar los 
suyos, termina realizando cambios sobre datos no previamente refrescados  como 
correspondería, si no que, además, campos que “segundo” no actualizó y 
están con valores “de la vista vieja”…..¡¡ se terminan restaurando ¡!!, 
anulando los valores que  “primero” realizó…..

 

 No encontré un mecanismo para detectar este hecho, y proceder a advertir a 
los usuarios, que deben refrescar los datos para proceder nuevamente a 
realizar cambios si corresponde, similar al que si poseen los formularios 
individuales con SQLFORM(form), como es, la acción DETECT_RECORD_CHANGE 
para el evento PROCESS().

 

Aclaro que no me estoy refiriendo al mecanismo transaccional de web2py y la 
DB -uso POSTGRESQL-, que funciona correctamente.


La solución que busco -si alguien ya la descubrió- , sería un mecanismo 
general para SQLFORM(grid), no para uno en particular. Quiero evitar el 
crear y asignar FORMs individuales para SQLFORM(grid) dado que, obviamente, 
se dispararían los tiempos de desarrollo, incrementando innecesariamente, 
la cantidad de objetos de la aplicación.

Previamente, intenté solucionar esto en el evento ONVALIDATION, consultando 
el objeto form que recibe como parámetro, en sus atributos (record, latest, 
detect_changed, detect_record_change). Pero no obtuve resultados.

La idea, es que esto debiera ser un chequeo normal del GRID y cualquier 
otro tipo de  FORM. Inclusive, debiera estar siempre activado y poder 
devolver un error específico y/o realizar una acción a sus efectos.


Gracias de antemano desde Montevideo/Uruguay.

-- 
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] Weird select().first()

2016-02-26 Thread Louis Beetge
HI everybody

I have a REALLY weird problem. Take a look at this code:

def save_disposition():
dispo_id = request.vars.disposition_id
dispo_name = request.vars.disposition_name
scid = request.vars.sales_cycle_id
linked_scid = request.vars.linked_contact_sc_id


questions = db(db.disposition_questions.disposition_id == dispo_id).
select()


hist_id = db.sales_cycle_history.insert(sales_cycle_id=scid, 
disposition_id=dispo_id, action_performed=dispo_name)


row = db(db.sales_cycles.id == scid).select().first()
pid = row.product_id

I get the following error:
 'NoneType' object has no attribute 
'product_id' for this line: pid = row.product_id

Before everybody starts yelling that it's returning an empty object, lemme 
explain. When I comment out "pid = row.product_id" and return 
response.json(row), it returns the fetched row without any issue ie:

{"application_id": 8, "product_id": 13, "modified_by": 138, "is_active": 
true, "created_by": 138, "linked_contact_sc_id": null, "request_tenant": 
"2", "created_on": "2016-02-24 19:00:59", "contact_id": 9823, 
"modified_on": "2016-02-24 19:00:59", "disposition_id": null, "id": 9853}

This is extremely frustrating and I cant seem to find anyone else who has 
had the same issue.

ANY ideas or pointing in the right direction would be greatly 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.


[web2py] Unpickle session_data from a MySQL database

2016-02-26 Thread NeoToren
In order for a progress bar using cache.ram, and an ajax call to work 
properly, there is a need to clean (or just unlock?) sessions.
If the app doesn't use session variables to pass to other controllers then 
session.forget(response) is sufficient.

If on the other hand, the app needs session variables (as my app does 
indeed) - then session.forget doesn't do much good since it brakes the 
session variables chain of transmission to other controllers.

As per Anthony suggestion in another post (Progress bar and sessions):

I tried first using the cookies (with maximum zlib compression - level 9) . 
Still it's not enough for my needs ... I need more than 10k per session to 
be passed to other controllers, and as mentioned in the book - keeping 
sessions in cookies is not a good solution if the session are expected to 
be large (more than 4k/cookie I assume).

So I am trying session.connect with a MySQL db.
I can see the table *web2py_session_AppName* being populated and I 
understand the *session_data* column is pickled with cPickle.
However...It looks the data in this column, *session_data* is encrypted, 
not just pickled.

*How do I unpickle the information in session_data column from a MySQL 
table ?* 
I tried using cPickle.loads...with the data as is, with the data as a 
string...but it still throws a "bad pickle error"

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] Want to build a web scraper that runs as web2py app. Where to start?

2016-02-26 Thread Marty Jones
I have some familiarity with scraping but only from my local machine, not 
from a server. I'd like to set up a basic scraping app as a web2py app that 
I can eventually run on a server. Anybody seen any tutorials for anything 
along these lines or know of a good module for doing this?

-- 
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 create dating profiles on web2py

2016-02-26 Thread meanrhei nqiofg
How do you create dating profiles like in a dating site in web2py? I want 
one to see other profiles once they are created.
I also want one to see who is online when the users are created.

-- 
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] Multiple Ajax calls and session variables - can we have both ?

2016-02-26 Thread NeoToren

up vote
down votefavorite 


In order for a progress bar using cache.ram, and an ajax call to work 
properly, there is a need to clean (or just unlock?) sessions. If the app 
doesn't use session variables to pass to other controllers then 
*session.forget(response)* is sufficient to unlock the sessions and let the 
Ajax do multiple calls. (Without the *session.forget(response)* - the 
progress bar will run only the first time, requiring clearing the sessions 
manually each time).

If on the other hand, the app needs session variables (as my app does 
indeed) - then session.forget doesn't do much good since it brakes the 
session variables chain of transmission to other controllers.

As per Anthony suggestion in another post (Progress bar and sessions):

I tried first storing sessions in cookies (with maximum zlib compression - 
level 9) . Still it's not enough for my needs ... I need more than 10k per 
session to be passed to other controllers, and as mentioned in the book - 
keeping sessions in cookies is not a good solution if the session are 
expected to be large (more than 4k/cookie, I assume).

So I am trying session.connect with a MySQL db. I can see the table 
web2py_session_AppName being populated and I understand the session_data 
column is pickled with cPickle. 

How do I unpickle the information in session_data column from a MySQL table 
? I tried using cPickle.loads...with the data as is, with the data as a 
string...but it still throws a "bad pickle error"

Here is the controller:

def index():

`session.Yawza = 'Yawza from index'`

`cache.ram(CacheKeyUID, lambda: 0, 0)`

`return dict()`

As a simulation of the lengthy process I need the progress bar for:

def cache_in_ram():

`for i in range(int(1e5)):`

`avoda = int((i/(1e5))*100)`

`cache.ram(CacheKeyUID, lambda:avoda, 0)`

`session.Yawza = " Yawza from the cache_in_ram"`

`redirect(URL('Test'))`

And this is the function used by the Ajax calls to provide values for the 
progress bar:

def cache_reader():

`return cache.ram(CacheKeyUID, lambda: None, None)`

def Test():

`return dict(message = 'Long process ended')`

The above will have the progress bar work ONLY the first time. After that 
progress bar will not work (due to locking by the multiple ajax calls) - 
unless I manually clear sessions or programmatically do a 
*session.forget(response)* which will unfortunately eliminate the 
session.Yawza. I need this session.Yawza for OTHER purposes than the 
progress bar, in other controllers downstream.

Adding 
*session.connect(request,response,cookie_key='yoursecret',compression_level=9)* 
to 
my db.py helps, but is limited to 4k size cookies. I need bigger cookies 
than that. Thus, I moved towards storing sessions in the db, which in my 
case is a MySQL db.

Defined *session.connect(request, response, db)* in db.py. I can see in 
MySQL the table *web2py_session_AppName* being populated, but I do NOT have 
access to session.Yawza at all. Not the one coming from the index function 
and not from the cache_in_ram function.

That's the reason I thought I should MANUALLY unpickle the session_data 
column...to get access to session.Yawza which must be hiding there.

Here is a small sample of what can be found in the session_data column in 
the MySQL table for web2py_sessions_MyAppName : 
gAJjZ2x1b24uZ2xvYmFscwpTZXNzaW9uCnEBfXECVQVZYXd6YXEDVQ1mcm9tIHRleHQgYm9...etc...etc..

It doesn't look like a kosher pickle to me ... ;-))

What am I doing or not doing correctly in order to benefit from the 
multiple ajax calls, no sessions locking and still use session variables to 
transfer info to other controllers ?

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: Massimo for President!

2016-02-26 Thread Ron Chatterjee
lol. I will vote for him. 

On Friday, February 26, 2016 at 9:35:18 AM UTC-5, Massimo Di Pierro wrote:
>
> They misspelled Guido's last name. I swear I said it correctly.
>
> On Friday, 26 February 2016 02:27:05 UTC-6, Nico Zanferrari wrote:
>>
>> Hi all,
>>
>> I've found this article this morning: 
>> http://www.corrierecomunicazioni.it/it-world/39758_coding-cosi-funziona-il-mio-programma-che-mette-il-turbo-a-python.htm
>> It's an Italian  interview to Massimo - with a bad title but still worth 
>> reading.
>>
>> Congratulations! Bravo!
>>
>>
>>

-- 
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: Massimo for President!

2016-02-26 Thread Massimo Di Pierro
They misspelled Guido's last name. I swear I said it correctly.

On Friday, 26 February 2016 02:27:05 UTC-6, Nico Zanferrari wrote:
>
> Hi all,
>
> I've found this article this morning: 
> http://www.corrierecomunicazioni.it/it-world/39758_coding-cosi-funziona-il-mio-programma-che-mette-il-turbo-a-python.htm
> It's an Italian  interview to Massimo - with a bad title but still worth 
> reading.
>
> Congratulations! Bravo!
>
>
>

-- 
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: Importing CSV file

2016-02-26 Thread Joe
Hello Anthony, Thanks for your reply.
I exported the CSV after adding some records, as you suggested, and I see 
no difference in the format. I tried to change the format several times but 
I can't import it. I either get the None records or an error depending on 
how I tried to modify the format.

On Friday, February 26, 2016 at 8:56:07 PM UTC+8, Anthony wrote:
>
> Maybe manually enter a few records, export to CSV, and inspect the 
> exported file to make sure your imported file has everything in the proper 
> format.
>
> Anthony
>
> On Friday, February 26, 2016 at 4:46:52 AM UTC-5, Joe wrote:
>>
>> I tried to import a CSV file  but all the values are None.
>>
>> This is what I did:
>>
>> def index():
>> if request.vars.csvfile != None:
>> table = db[request.vars.table]
>> file = request.vars.csvfile.file
>> table.import_from_csv_file(file)
>> return dict()
>>
>> My tables look like this:
>>
>> db.define_table('animation',
>> Field('activity', widget=SQLFORM.widgets.radio.widget, 
>> requires=IS_IN_SET({'Co-prod', 'Buyer','Sales', 'Producer', 'Director'})), 
>> Field('business', widget=SQLFORM.widgets.radio.widget, 
>> requires=IS_IN_SET({'Distribution', 'Broadcaster','Production', 'Internet', 
>> 'Financing', 'MNO', 'Press'})), Field('company', 'string', 
>> requires=[IS_NOT_EMPTY()]), Field('country', requires=[IS_NOT_EMPTY()]), 
>> Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]), Field('first_name', 
>> 'string',requires=IS_NOT_EMPTY()), Field('last_name', 
>> 'string',requires=IS_NOT_EMPTY()), Field('position_title', 
>> 'string',requires=IS_NOT_EMPTY()), Field('website', 
>> 'string',requires=[IS_NOT_EMPTY(), IS_URL]), Field('date_made', 'datetime', 
>> default = request.now, writable=False, readable=False, requires = 
>> IS_DATE(format=('%d-%m-%Y'
>>
>> My view:
>> {{extend 'layout.html'}}
>>
>> {{=FORM(INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='animation',_name='table'),INPUT(_type='submit',_value='Upload'))}}
>>
>> The CSV file has the same headers as the table names. The CSV is 
>> imported, the length of the rows in the database are the same as in the CSV 
>> file but the records are all None.
>> What I want to do is to be able to import CSV files to this db as well as 
>> input values manually using a form. This is why I am using a radio.widget.
>> What am I doing wrong?
>>
>> Thanks.
>>
>> 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] Re: IMPORTANT - WEB2PY CONSULTING

2016-02-26 Thread Gael Princivalle


Il giorno domenica 15 febbraio 2015 23:21:36 UTC+1, Massimo Di Pierro ha 
scritto:
>
> We need to update the list of companies that provide web2py consulting.
> This list is obsolete:
>
> http://web2py.com/init/default/support
>
> Some links are broke. Most pages do not even mention web2py. Some of them 
> have a design that is simply not acceptable for a web development company.
>
> That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
> page to have a decent design and MENTION WEB2PY on the main site. Then 
> respond to this thread by providing an updated link and the country were 
> you incorporated. If you have a self-employed individual list your country 
> of residence.
>
>

-- 
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: Compute return only the last result

2016-02-26 Thread Gael Princivalle
Hi Dave.

Yes it is. Now it works, thanks a lot for your help.

Il giorno venerdì 26 febbraio 2016 08:52:16 UTC+1, Dave S ha scritto:
>
>
>
> On Thursday, February 25, 2016 at 5:45:57 AM UTC-8, Gael Princivalle wrote:
>>
>> Hello all.
>>
>> I use this function for resizing images for full size and thumbnails:
>>
>> def SMARTHUMB(image, box, fit=True, name="thumb"):
>> #Downsample the image.
>> #@param img: Image -  an Image-object
>> #@param box: tuple(x, y) - the bounding box of the result image
>> #@param fit: boolean - crop the image to fill the box
>> if image:
>> request = current.request
>> img = Image.open(request.folder + 'uploads/' + image)
>> #preresize image with factor 2, 4, 8 and fast algorithm
>> factor = 1
>> while img.size[0] / factor > 2 * box[0] and img.size[1] * 2 / 
>> factor > 2 * box[1]:
>> factor *= 2
>> if factor > 1:
>> img.thumbnail((img.size[0] / factor, img.size[1] / factor), 
>> Image.NEAREST)
>>
>> #calculate the cropping box and get the cropped part
>> if fit:
>> x1 = y1 = 0
>> x2, y2 = img.size
>> wRatio = 1.0 * x2 / box[0]
>> hRatio = 1.0 * y2 / box[1]
>> if hRatio > wRatio:
>> y1 = int(y2 / 2 - box[1] * wRatio / 2)
>> y2 = int(y2 / 2 + box[1] * wRatio / 2)
>> else:
>> x1 = int(x2 / 2 - box[0] * hRatio / 2)
>> x2 = int(x2 / 2 + box[0] * hRatio / 2)
>> img = img.crop((x1, y1, x2, y2))
>>
>> #Resize the image with best quality algorithm ANTI-ALIAS
>> img.thumbnail(box, Image.ANTIALIAS)
>>
>> root, ext = os.path.splitext(image)
>> thumb = '%s_%s%s' % (root, name, ext)
>> img.save(request.folder + 'uploads/' + thumb)
>> return thumb
>>
>> In the db:
>> db.define_table('news',
>> Field('title', type='string'),
>> Field('image', 'upload'),
>> Field('image_thumb', 'upload'),
>> Field('image_big', 'upload'))
>>
>> box_thumb = (270, 158)
>> db.news.image_thumb.compute = lambda row: SMARTHUMB(row.image, box_thumb)
>> box_big = (770, 435)
>> db.news.image_big.compute = lambda row: SMARTHUMB(row.image, box_big)
>>
>> The problem is that image_thumb have the same size as image_big.
>>
>> Someone know why?
>>
>> Thanks, regards.
>>
>
> Is it because you don't override the name parameter, so your thumb file 
> gets over-written by the big file?
>
> /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/d/optout.


[web2py] Re: Importing CSV file

2016-02-26 Thread villas
I'm not sure whether this will be of any help,  but I have found the 
following useful when working with CSV files in the past...

https://github.com/mdipierro/csvstudio

-- 
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: SQLFORM.factory upload field can't show link

2016-02-26 Thread Anthony


> for t in db.project:
> query = (t.id == request.vars.id) 
> __copydata(db(query).select(limitby=(0,1)).first(), form.vars, 
> t.fields)
>

The above is confusing and cannot be the actual code, as it would raise an 
exception. When you iterate over db.project, you get its Field objects (so 
each value of "t" is a Field object). Field objects do not have ".id" or 
".fields" attributes, so both of the next two lines would result in errors. 
Perhaps you instead mean to be iterating over Table objects, but it's not 
clear why you would be doing that, as the form is based on just a single 
table.

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] Re: Importing CSV file

2016-02-26 Thread Anthony
Maybe manually enter a few records, export to CSV, and inspect the exported 
file to make sure your imported file has everything in the proper format.

Anthony

On Friday, February 26, 2016 at 4:46:52 AM UTC-5, Joe wrote:
>
> I tried to import a CSV file  but all the values are None.
>
> This is what I did:
>
> def index():
> if request.vars.csvfile != None:
> table = db[request.vars.table]
> file = request.vars.csvfile.file
> table.import_from_csv_file(file)
> return dict()
>
> My tables look like this:
>
> db.define_table('animation',
> Field('activity', widget=SQLFORM.widgets.radio.widget, 
> requires=IS_IN_SET({'Co-prod', 'Buyer','Sales', 'Producer', 'Director'})), 
> Field('business', widget=SQLFORM.widgets.radio.widget, 
> requires=IS_IN_SET({'Distribution', 'Broadcaster','Production', 'Internet', 
> 'Financing', 'MNO', 'Press'})), Field('company', 'string', 
> requires=[IS_NOT_EMPTY()]), Field('country', requires=[IS_NOT_EMPTY()]), 
> Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]), Field('first_name', 
> 'string',requires=IS_NOT_EMPTY()), Field('last_name', 
> 'string',requires=IS_NOT_EMPTY()), Field('position_title', 
> 'string',requires=IS_NOT_EMPTY()), Field('website', 
> 'string',requires=[IS_NOT_EMPTY(), IS_URL]), Field('date_made', 'datetime', 
> default = request.now, writable=False, readable=False, requires = 
> IS_DATE(format=('%d-%m-%Y'
>
> My view:
> {{extend 'layout.html'}}
>
> {{=FORM(INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='animation',_name='table'),INPUT(_type='submit',_value='Upload'))}}
>
> The CSV file has the same headers as the table names. The CSV is imported, 
> the length of the rows in the database are the same as in the CSV file but 
> the records are all None.
> What I want to do is to be able to import CSV files to this db as well as 
> input values manually using a form. This is why I am using a radio.widget.
> What am I doing wrong?
>
> Thanks.
>
> 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] Preventing hackers from exploiting web2py with wsgi

2016-02-26 Thread Anthony
On Friday, February 26, 2016 at 4:57:47 AM UTC-5, Robin Manoli wrote:
>
>
> *About the exploit*There is an exploit is was happening. I thought they 
> were related to a web2py app on Apache, but I'm sure any more. What is 
> happening is that another web server keeps getting this type of requests 
> from a server I'm working on. This keeps happening although the ports 80 
> and 443 (and almost all other ports) for outbound traffic of the servers 
> are closed. ModProxy is disabled.
>
> server.ip - - [  -0500] "GET 
> /index.php?page=../../../../../../../../proc/self/environ%00 HTTP/1.1" 200 
> 7792 "-" "Mozilla/4.76 [en] (Win98; U)"
>

So, is the above log entry from the *other* server (i.e., not the one you 
control)? I presume the "server.ip" value is the IP address of your server, 
hence the belief that this request is coming from your server, correct? If 
so, how did you get this log entry? Did the owner of the server contact you 
and provide it? Did they request any information from you? Can you trust 
that this is real (as opposed to a social engineering attempt)?
 

> I did find some suspicious apache logs which made me think it was related 
> to a web2py app:
> 213.152.162.134 - - [23/Feb/2016:22:32:19 +0100] "GET 
> http://stream-full.selfip.com:8000/get.php?username=anonyme1520091ef3=anonyme1520091ef3=m3u=mpegts&1=anonyme1520091ef
> 3 HTTP/1.0" 400 804 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en) 
> AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3"
> 185.25.148.240 - - [24/Feb/2016:14:38:31 +0100] "GET 
> http://testp3.pospr.waw.pl/testproxy.php HTTP/1.1" 404 267 "-" "Mozilla/5.0 
> (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/31.0"
> 213.152.162.134 - - [24/Feb/2016:19:44:56 +0100] "GET 
> http://stream-full.selfip.com:8000/get.php?username=whatisashelly=whatisashelly=m3u=mpegts&1=whatisashelly
>  
> HTTP/1.0"
> 500 1091 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; .NET CLR 
> 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
>
>
I don't see how any of these requests would be related to web2py/WSGI (as 
they are not for internal URLs that would be served by web2py), nor how 
they would be related to the alleged external request to the other server 
(which is not at any of these URLs). Looks like someone was just trying 
(and failing) to proxy requests through your server.

I did not wish to say that web2py has any specific issues, but rather to 
> learn about potential and perhaps common mistakes people do when creating 
> web2py or wsgi apps.
>

With regard to "proxy abuse" specifically, WSGI and web2py play no role -- 
this is simply an issue of the web server (and it seems not to be a problem 
in your case).
 

>
> *About why I use apache*You are right of course Niphlod. The full story 
> is just that I had a working setup with Apache without any issues, so I was 
> focusing on app development and not choosing web servers. It worked very 
> well so far in the context, and it's not really important to discuss this 
> any further. I have my reasons for why things are like they are, and of 
> course I can move to nginx.
>

If you can, it might not be a bad idea to switch to Nginx, but at the 
moment, it's not clear that Apache is really causing any problems here.

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] Re: All HTTP requests redirected to HTTPS

2016-02-26 Thread Joe
I don't have a SSL yet, so before I get one, users will have an issue when 
they visit the site. In any case, I better just get the SSL and then I 
don't have to worry about this. But, still I don't understand the problem. 
I definitely didn't uncomment it and this issue only happened after I 
reloaded my app. Now, it's actually fine, back to http not sure what caused 
it.

On Wednesday, February 24, 2016 at 11:08:10 PM UTC+8, Niphlod wrote:
>
> why should it be a problem only lord knows, https should be everywhere in 
> 2016. but if you have request.requires_https() anywhere it tells to 
> redirect the request over to https ... 
> sure you "didn't uncomment it"  ?
>
> On Wednesday, February 24, 2016 at 3:08:08 PM UTC+1, Joe wrote:
>>
>> I just reloaded my app on Pythonanywhere and after reloading, my site is 
>> forced to https for some reason.
>> All HTTP requests are redirected to HTTPS. I didn't uncomment the 
>> #request.requires_https()
>> Anyone had a similar issue? What is the best way to resolve this?
>>
>> I asked Python anywhere, they said it "sounds like a web2py config 
>> thing". The only time I need the https is when I login to the admin as 
>> Pythonanywhere requires https there.
>> When the rest of my URLs are forced to https, it's kind of a problem. 
>>
>

-- 
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] Preventing hackers from exploiting web2py with wsgi

2016-02-26 Thread Robin Manoli

*About the exploit*There is an exploit is was happening. I thought they 
were related to a web2py app on Apache, but I'm sure any more. What is 
happening is that another web server keeps getting this type of requests 
from a server I'm working on. This keeps happening although the ports 80 
and 443 (and almost all other ports) for outbound traffic of the servers 
are closed. ModProxy is disabled.

server.ip - - [  -0500] "GET 
/index.php?page=../../../../../../../../proc/self/environ%00 HTTP/1.1" 200 
7792 "-" "Mozilla/4.76 [en] (Win98; U)"


I did find some suspicious apache logs which made me think it was related 
to a web2py app:
213.152.162.134 - - [23/Feb/2016:22:32:19 +0100] "GET 
http://stream-full.selfip.com:8000/get.php?username=anonyme1520091ef3=anonyme1520091ef3=m3u=mpegts&1=anonyme1520091ef
3 HTTP/1.0" 400 804 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en) 
AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3"
185.25.148.240 - - [24/Feb/2016:14:38:31 +0100] "GET 
http://testp3.pospr.waw.pl/testproxy.php HTTP/1.1" 404 267 "-" "Mozilla/5.0 
(Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/31.0"
213.152.162.134 - - [24/Feb/2016:19:44:56 +0100] "GET 
http://stream-full.selfip.com:8000/get.php?username=whatisashelly=whatisashelly=m3u=mpegts&1=whatisashelly
 
HTTP/1.0"
500 1091 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; .NET CLR 
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"


I did not wish to say that web2py has any specific issues, but rather to 
learn about potential and perhaps common mistakes people do when creating 
web2py or wsgi apps. Though this might as well be related to a php site or 
something else completely.



*About naming this thread*When I wrote the name I thought it was related to 
one of my web2py apps, although it would probably be me who is responsible. 
Though I see what you mean *Anthony*, and I only wish to support web2py, as 
I find it to be the very best framework for creating server side web 
appplications. And I do not have any logs of the chat.



*About why I use apache*You are right of course Niphlod. The full story is 
just that I had a working setup with Apache without any issues, so I was 
focusing on app development and not choosing web servers. It worked very 
well so far in the context, and it's not really important to discuss this 
any further. I have my reasons for why things are like they are, and of 
course I can move to nginx.

Thanks for your replies so far!
- Robin



Den torsdag 25 februari 2016 kl. 23:20:34 UTC+2 skrev Anthony:
>
>
> Perhaps the question was ill posed, but not knowing the true role of wsgi 
>> I don't know how I could have posted it differently.
>>
>
> I'd say if you don't really have an understanding of an issue, avoid 
> definitive, sensational headlines like "Preventing hackers from exploiting 
> web2py with wsgi", as that makes it sound like this is a proven exploit in 
> need of prevention. Instead, maybe something like, "Question about possible 
> WSGI security issue." The reason for aiming to be more circumspect is that 
> this is a public forum, and so anything negative posted here, even if 
> untrue or misinformed, can quickly spread as FUD on the internets.
>
> Also, it sounds like you believe you might be experiencing a current 
> exploit. If that's the case, it would be better to present details and 
> evidence about your concern.
>
> 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] Re: plural forms dict for French

2016-02-26 Thread Pierre
solved !

I edited the plural-fr.py manually and it works..I thought it was 
some other kind of magic whereas it's only a dict :)


by the way I acknowledge : Massimo must be a President...even if Donald 
disagrees with that

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Importing CSV file

2016-02-26 Thread Joe
I tried to import a CSV file  but all the values are None.

This is what I did:

def index():
if request.vars.csvfile != None:
table = db[request.vars.table]
file = request.vars.csvfile.file
table.import_from_csv_file(file)
return dict()

My tables look like this:

db.define_table('animation',
Field('activity', widget=SQLFORM.widgets.radio.widget, 
requires=IS_IN_SET({'Co-prod', 'Buyer','Sales', 'Producer', 'Director'})), 
Field('business', widget=SQLFORM.widgets.radio.widget, 
requires=IS_IN_SET({'Distribution', 'Broadcaster','Production', 'Internet', 
'Financing', 'MNO', 'Press'})), Field('company', 'string', 
requires=[IS_NOT_EMPTY()]), Field('country', requires=[IS_NOT_EMPTY()]), 
Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]), Field('first_name', 
'string',requires=IS_NOT_EMPTY()), Field('last_name', 
'string',requires=IS_NOT_EMPTY()), Field('position_title', 
'string',requires=IS_NOT_EMPTY()), Field('website', 
'string',requires=[IS_NOT_EMPTY(), IS_URL]), Field('date_made', 'datetime', 
default = request.now, writable=False, readable=False, requires = 
IS_DATE(format=('%d-%m-%Y'

My view:
{{extend 'layout.html'}}
{{=FORM(INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='animation',_name='table'),INPUT(_type='submit',_value='Upload'))}}

The CSV file has the same headers as the table names. The CSV is imported, 
the length of the rows in the database are the same as in the CSV file but 
the records are all None.
What I want to do is to be able to import CSV files to this db as well as 
input values manually using a form. This is why I am using a radio.widget.
What am I doing wrong?

Thanks.

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] Re: Massimo for President!

2016-02-26 Thread eric cuver
thank you for sharing  

Le vendredi 26 février 2016 09:27:05 UTC+1, Nico Zanferrari a écrit :
>
> Hi all,
>
> I've found this article this morning: 
> http://www.corrierecomunicazioni.it/it-world/39758_coding-cosi-funziona-il-mio-programma-che-mette-il-turbo-a-python.htm
> It's an Italian  interview to Massimo - with a bad title but still worth 
> reading.
>
> Congratulations! Bravo!
>
>
>

-- 
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] Massimo for President!

2016-02-26 Thread Nico Zanferrari
Hi all,

I've found this article this morning:
http://www.corrierecomunicazioni.it/it-world/39758_coding-cosi-funziona-il-mio-programma-che-mette-il-turbo-a-python.htm
It's an Italian  interview to Massimo - with a bad title but still worth
reading.

Congratulations! Bravo!

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