Re: [web2py] Migration fails when dropping a column on Postgresql

2017-06-05 Thread Doug Taylor
This is becoming a show-stopper for me now as I cannot ADD fields to an 
exiting table either. I'm pretty sure adding fields worked before when I 
was running on Windows. Made the transition to Linux on my office desktop 
recently and that was when I first encountered the problem. Adding the 
field LocalMountPoint (rname='storage_local_mount'):

self.db.define_table('StorageVolume',
Field('VolumeName', rname='storage_volume_name', type='string', 
length=32, label='Volume', comment='The name of the Storage Volume'),
Field('FileServerId', rname='storage_volume_server_id', 
type='reference FileServer', ondelete='CASCADE', label='Server', 
comment='The Server on which the Storage Volume resides'),
Field('StorageUri', rname='storage_uri', type='string', 
length=256, label='Storage URI', comment='The URI of the Storage Volume'),
Field('LocalMountPoint', rname='storage_local_mount', 
type='string', length=256, label='Local Mount Point', comment='The local 
mount point of the Storage Volume'),
audit,
rname='storage_volume',
format='%(VolumeName)s',
singular='Volume',
plural='Volumes',
migrate=True)
self.db.commit()

results in:

ALTER TABLE storage_volume ADD localmountpoint VARCHAR(256);
success!

Aaaargh! Can anyone give feedback on how long this may take to fix? Can 
someone give me some pointers so I can fix it myself? As I said, bit of a 
noob to python and web2py... but how hard can it be? :)

-- 
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] not authorised flash message when I used SQLFORM.grid, but worked fine with SQLFORM.smartgrid

2017-06-05 Thread Rudy
Right on Anthony, I don't think user_signature=False is the real fix for 
the strange behaviour. When i tested it, i did log in, plus i used 
smartgrid the same way. Thanks for confirming it.

On Monday, June 5, 2017 at 9:14:48 PM UTC+8, Anthony wrote:
>
> On Monday, June 5, 2017 at 1:11:25 AM UTC-4, akshay0...@gmail.com 
>  wrote:
>>
>> I could't use the smartgrid because smartgrid works on complete table but 
>> i had to query the table first.
>>
>
> The smartgrid has the "constraints" argument for that purpose (it is a 
> dictionary with table names as keys and DAL queries as values). See 
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#smartgrid-signature
> .
>  
>
>> I still don't know what the problem was but solution given by @Leandro 
>> Paz worked.
>>
>> you just have to do:
>> grid = SQLFORM.grid (db.auth_user, user_signature = False)
>>
>>
> I don't think that is related to the problem Rudy is having. By default, 
> user_signature=True, which simply means the grid will not display 
> create/edite/delete buttons (nor allow those operations). You wouldn't get 
> a "not authorized" message simply by attempting to load the grid. 
> Furthermore, for logged in users, create/edit/delete is allowed, even with 
> user_signature=True, and Rudy indicated his code started with using the 
> @auth.requires_login() decorator, which requires a logged in user.
>
> 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] not authorised flash message when I used SQLFORM.grid, but worked fine with SQLFORM.smartgrid

2017-06-05 Thread Rudy
Hi Akshay,

Thanks for confirming Leandro Paz suggestion and replying me, I truly think 
this forum needs all of us (even I still have a lot to learn in web2py) to 
participate to share scenarios and solutions.

For smartgrid, you can still use query I believe, I have something like 
below. Good luck, hope to see you here again.

query=db.quotation.id == quote_id
grid = SQLFORM.smartgrid(db.quotation, args=request.args[:1], 
constraints=dict(quotation=query), )

On Monday, June 5, 2017 at 1:11:25 PM UTC+8, akshay0...@gmail.com wrote:
>
> Hi rudy,
>   yes you are right. Web2py editor behaves funny sometimes. 
> Sometimes you get error and same error goes away when you rewrite the same 
> code.
>
> I could't use the smartgrid because smartgrid works on complete table but 
> i had to query the table first. so only option for me was SQLFORM.grid.
>
> I still don't know what the problem was but solution given by @Leandro 
> Paz worked.
>
> you just have to do:
> grid = SQLFORM.grid (db.auth_user, user_signature = False)
>
>
>
> On Friday, June 2, 2017 at 11:24:12 PM UTC+5:30, Rudy wrote:
>>
>> Hi Akshay,
>>
>> I don’t know where the problem was. As mentioned in previous thread, 
>> after i used smartgrid to continue the development for a few days, it went 
>> away. One thing i notice is the editor from the administrative interface 
>> gets funny behavior sometimes, the compiler raises error but I simply can’t 
>> find what goes wrong with the specific line pointed out from the ticket, if 
>> I delete the line and retype exactly the same thing (I even had 2 lines 
>> side by side to compare the difference), the error goes away. But I can’t 
>> explain why below issue complains about “not authorised”, well try to 
>> refresh your editor or use another editor to check the code, perhaps 
>> restart web2py. I know it sounds silly, but they are quick test. cheers!
>>
>> On 2 Jun, 2017, at 7:07 pm, akshay...@gmail.com wrote:
>>
>> hi Rudy,
>>I am facing the same issue. Did you get why this is happeneing?
>> On Saturday, April 22, 2017 at 1:49:15 PM UTC+5:30, Rudy wrote:
>>>
>>> Hi there,
>>>
>>> It feels really strange to me that when i used SQLFORM.grid(), I got a 
>>> flash message "not authorised", but when i used smartgrid(), it worked just 
>>> fine (in both cases i had logged in already). I tried to removed 
>>> @auth.requires_login(), but same behaviour happened. I seem to miss some 
>>> very fundamental knowledge using SQLFORM.grid(). Below is the simplified 
>>> code. Any help is much appreciated.
>>>
>>> @auth.requires_login()
>>> def list_items2():
>>> response.view='accounting/list_items.html'
>>> grid = SQLFORM.grid(db.auth_user)
>>> return locals()
>>>
>>
>> -- 
>> 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/yhj6iVXgHEM/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.


[web2py] Re: download a fille.

2017-06-05 Thread akshay055kumar
I haven't written any download function yet but yes i was planning to use 
the download function available in the controller.
I was just checking in the table by database administration.

is upload subdirectory is not the same subdirectory i am storing my file 
into?? I am storing the file in web2py/applications/uploads/scripts. I am 
creating this scripts folder inside uploads folder an dstoring my files 
into that.



On Monday, June 5, 2017 at 11:29:34 PM UTC+5:30, Dave S wrote:
>
>
>
> On Monday, June 5, 2017 at 6:18:06 AM UTC-7, akshay0...@gmail.com wrote:
>>
>> Hello everyone,
>>  I am creating a file named hello_world.py somehow 
>> and storing that file in location 
>> some_dir/web2py/application/uploads/scripts. I want to give option to 
>> user to download that file.
>>
>> Technique i am using is:
>> I created a table with a filed having type upload as:
>> db.define_table('scripts',
>> Field('s', 
>> 'upload',uploadfolder='/var/www/web2py/applications/uploads/scripts'),
>>
>>
>
> What does your controller look like for downloading the file?  If you use 
> the download()  controller from the sample app, it expects the file to be 
> in the uploads subdirectory.
>
> /dps
>
> and i am storing the file path 
> /var/www/web2py/applications/upload/scripts/hello_world.py 
>> in field 's'.
>>
>> By doing this there is an entry in database, but when i am clicking on 
>> field 's' of table i am getting error '404 file not found'.
>>
>> Can somebody help me with this or suggest me better option to solve the 
>> 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.


[web2py] Re: grid add/edit form label

2017-06-05 Thread T.R.Rajkumar
Thanks icodk for the code. But I do not understand grid[1][0][2][0]. What 
is that? Could you pl. tell me. Thank you once again.

-- 
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: different default application based on the host header - Python anywhere - Go daddy

2017-06-05 Thread Ron Chatterjee
Okay, but Massimo, 

What's the logic to route multiple domain to multiple different apps hosted 
at pythonanywhere? The above don't seem to work (example shown with two 
domains being routed to two apps - doesn't work).

-Ron


On Sunday, June 4, 2017 at 12:14:11 PM UTC-4, Massimo Di Pierro wrote:
>
> I recommend this logic be moved to nginx. web3py will no longer support 
> this.
>
> On Sunday, 4 June 2017 04:52:34 UTC-5, Ron Chatterjee wrote:
>>
>> Would this be same as the domain mapping? 
>>
>>
>> 
>>
>> routers = dict(
>>   BASE  = dict(
>>   domains = {
>>   'domain1.com' : 'app1',
>>   'domain2.com' : 'app2',
>>   }
>>   ),
>> )
>>
>>

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


[web2py] Re: web2py page refresh causes postgres to reach the max number of connections

2017-06-05 Thread Mick
Thank you so much for your help, my pool_size was set to 100, I set it to 1 
and seems to be working ok.

On Sunday, June 4, 2017 at 9:19:03 AM UTC-7, Massimo Di Pierro wrote:
>
> What is your connection string?
>
> web2py does connection pooling. It does not close connections, it stores 
> them and recycle them for speed but you can set DAL(, pool_size=...). 
> Set pool_size to 1 for now and see if you still have the problem. 
>
> On Sunday, 4 June 2017 11:04:52 UTC-5, Mick wrote:
>>
>> Hi all,
>> I'm new at web2py and I have this issue, whenever I refresh the page the 
>> number of connections to postgres increases and in time crashes.  How do I 
>> handle this?  I can't find any good information on closing the connection 
>> after the query is done...
>> Thank you in advance :)
>>
>

-- 
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: Saving to database random type data

2017-06-05 Thread Anthony
Rather than just having a "blob" field, you might instead want an "upload" 
field along with an associated "blob" field. The .store() and .retrieve() 
methods (which are documented here 
),
 
operate on "upload" fields, not "blob" fields. Upload fields store the 
encoded *names *of uploaded files, whereas blob fields (if used in 
conjunction with an upload field) store the actual file contents. If you 
use an upload field, it will manage the encoded naming and retrieval (as 
well as the storage itself if using a SQLFORM).

Also, you didn't show how you did the insert, but the code you did show 
doesn't quite make sense, as the .to_csv() method shown gets passed an 
object called _tmp_data, which is not the StringIO object created in the 
previous line.

Anthony

On Wednesday, May 3, 2017 at 3:02:12 PM UTC-4, Scorpa wrote:
>
> Hello folks ! 
>
> I have database that's have BLOB type to store any kind of data (it's 
> should be binary ?):
>
> Field('f_blob', type='blob',
>   label=T('blob object')),
>
>
> I'm inserting new records with:
>
> db.t_cache.insert(f_name='processed_' + request.vars.filename, f_blob= data)
>
>
> Where data is pandas object which is covnerted to CSV:
>
> data = StringIO.StringIO()
> source.to_csv(_tmp_data)
> data.seek(0)
>
>
> In database DATA record appears. but i can't fnd any information about 
> retrieving this object from db.
>
>
> I tried RETRIEVE method (where the hell documenation about this ? no comments 
> in source)
>
> Such as:
>
> db.t_cache.f_blob.retrieve(db.t_cache[ID].f_blob).f_blob  gives = 
> {TypeError}Can't retrieve  file 
> properties
>
>
> db.t_cache.f_blob.retrieve(db.t_cache[ID]) = {TypeError}expected string or 
> buffer
>
>
> So how to get back BLOB object from databse and use it later ? 
>
>

-- 
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: routes.py and how to activate them

2017-06-05 Thread Dave S


On Monday, June 5, 2017 at 11:59:49 AM UTC-7, Anthony wrote:
>
> Many times when i'm searching for an answer in the official docs about how 
>> to do this or that i'm ending in the stack overflow questions area or in 
>> this group.
>> and thats really frustrating that even simplest tasks can't be done easy.
>>
>
> What are some examples?
>

Some of the OP's recent posts:

Re: Saving to database random type data 


web2py-users  May 7
Saving to database random type data 

 
web2py-users  May 3
Re: Web2py multiple request variables to filter database output 

 
web2py-users  Apr 10
Re: Web2py multiple request variables to filter database output 

 
web2py-users  Apr 9
Re: Web2py multiple request variables to filter database output 

 
web2py-users  Apr 9
Web2py multiple request variables to filter database output 

 
web2py-users  Mar 20
Filter data based on clicked images 

 
web2py-users  Mar 20
His filtering thread relates to tagging, I think.  Tagging is only 
discussed briefly in the book, and my guidelines come from Massimo's 
github'd example and Leonel's comments:
https://groups.google.com/forum/?pli=1#!searchin/web2py/tagging|sort:date/web2py/yLePeLyS7d0/CngIhmXZEgAJ>
I don't know if those help the OP, who seems to have a solution that I 
haven't absorbed yet.

His May posts relate to BLOB types and are unanswered.  I haven't any 
direct experience with BLOBs so I don't know how much is paticular to the 
DB engine and how much the various drivers smooth that out.  I don't store 
images or videos in the DB yet, and the upload files are all I've had to 
deal with (and those are, of course, stored in the filesystem with a 
reference in the DB).

/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: routes.py and how to activate them

2017-06-05 Thread Dave S


On Monday, June 5, 2017 at 12:10:17 PM UTC-7, Anthony wrote:
>
> For example, how actually routes.py works ? I renamed routes.example.py 
>>>  to routes.py according to internal notes. 
>>> Reloaded routes|reloaded web2py and... no effect.
>>>
>>
>> As the docs state, you don't just rename those files -- the routes.py 
>> file must be put in the /web2py root folder. If it is in the right place 
>> and still not working as expected, there is probably something wrong with 
>> the code.
>>
>
> Oh, I see you are referring to the example app-specific routes.py file, 
> which can remain where it is, in its own app's folder. However, you need to 
> make sure you also have a base routes.py file in the /web2py root folder, 
> and as noted in the routes.example.py file, you must change the 
> dictionary key "app" to be the name of your actual application.
>
>
And of course that's described in the book, but as a sub-sub-heading under 
the pattern system subheading.
http://web2py.com/books/default/chapter/29/04/the-core#Pattern-based-system>

(Perhaps instead of being 3rd level, that paragraph should be elevated to 
2nd level?)

/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: routes.py and how to activate them

2017-06-05 Thread Anthony

>
> For example, how actually routes.py works ? I renamed routes.example.py 
>>  to routes.py according to internal notes. 
>> Reloaded routes|reloaded web2py and... no effect.
>>
>
> As the docs state, you don't just rename those files -- the routes.py file 
> must be put in the /web2py root folder. If it is in the right place and 
> still not working as expected, there is probably something wrong with the 
> code.
>

Oh, I see you are referring to the example app-specific routes.py file, 
which can remain where it is, in its own app's folder. However, you need to 
make sure you also have a base routes.py file in the /web2py root folder, 
and as noted in the routes.example.py file, you must change the dictionary 
key "app" to be the name of your actual application.

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: routes.py and how to activate them

2017-06-05 Thread Anthony

>
> Many times when i'm searching for an answer in the official docs about how 
> to do this or that i'm ending in the stack overflow questions area or in 
> this group.
> and thats really frustrating that even simplest tasks can't be done easy.
>

What are some examples?
 

> For example, how actually routes.py works ? I renamed routes.example.py 
>  to routes.py according to internal notes. 
> Reloaded routes|reloaded web2py and... no effect.
>

As the docs state, you don't just rename those files -- the routes.py file 
must be put in the /web2py root folder. If it is in the right place and 
still not working as expected, there is probably something wrong with the 
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.


[web2py] Re: routes.py and how to activate them

2017-06-05 Thread Dave S


On Sunday, June 4, 2017 at 3:33:18 AM UTC-7, Scorpa wrote:
>
> Hello folks ! 
>
>
> Many times when i'm searching for an answer in the official docs about how 
> to do this or that i'm ending in the stack overflow questions area or in 
> this group.
> and thats really frustrating that even simplest tasks can't be done easy.
>

I found, in contrast,  that I could get a lot done by reading the book, and 
even now many of my questions here have answers in the book ... I just lost 
track of where.  (Early on, I got the hardcopy of the book, and read all 
the way through it, putting in a lot of bookmarks.  Now, I mostly use the 
online copy, as I do for Python documentation.)


> For example, how actually routes.py works ? I renamed routes.example.py 
>  to routes.py according to internal notes. 
> Reloaded routes|reloaded web2py and... no effect.
>
> How to actually use this tool ?
>
>
It's cheating to say I just used what was in the book and what was in the 
routes.py sample file, because before I tried I had been reading the group 
for quite a while.  Also, I chose the simpler technique, and have it do 
simple things:

routers = dict(

# base router
BASE=dict(
default_application='LogServer',
root_static = ['favicon.ico', 'robots.txt'],
),
)




 

> By the way, why pyCharm can't find packages  in this file ?
>


I don't use pyCharm; we have a couple people who have posted here about how 
to use pyCharm with web2py;  I believe one of them even got some changes 
adopted by pyCharm to handle web2py better, and those related to directory 
structure IIRC.
 

Good luck!

/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] auth.navbar modification

2017-06-05 Thread Pierre
Hi

I am trying to redirect user after successful login. I do nothing but what 
the book says but i am unable to change default behaviour
here is the code :

in db.py :

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.login_next = URL('default','index')



in layout.html :
{{='auth' in globals() and auth.navbar(mode='dropdown', referrer_actions=
None)}}


book url :
http://web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages

trying hard to stay calm.GRMBBBLEU   GRRBBBMLEUMBLEU

-- 
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: download a fille.

2017-06-05 Thread Dave S


On Monday, June 5, 2017 at 6:18:06 AM UTC-7, akshay0...@gmail.com wrote:
>
> Hello everyone,
>  I am creating a file named hello_world.py somehow and 
> storing that file in location some_dir/web2py/application/uploads/scripts. 
> I want to give option to user to download that file.
>
> Technique i am using is:
> I created a table with a filed having type upload as:
> db.define_table('scripts',
> Field('s', 
> 'upload',uploadfolder='/var/www/web2py/applications/uploads/scripts'),
>
>

What does your controller look like for downloading the file?  If you use 
the download()  controller from the sample app, it expects the file to be 
in the uploads subdirectory.

/dps

and i am storing the file path 
/var/www/web2py/applications/upload/scripts/hello_world.py 
> in field 's'.
>
> By doing this there is an entry in database, but when i am clicking on 
> field 's' of table i am getting error '404 file not found'.
>
> Can somebody help me with this or suggest me better option to solve the 
> 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.


[web2py] Re: Problem sending email with new web2py version on Apache 2.4

2017-06-05 Thread Dave S


On Sunday, June 4, 2017 at 9:42:14 AM UTC-7, e27...@gmail.com wrote:
>
> After upgrading to the last version of Web2py, along which the latest 
> Apache 2.4, we are unable to send email any more. Note that we have access 
> to this remote server only through a browser for our Web2py development.
>
> We have tested different login/passwords/IP (gmail, orange, free) on port 
> 587 which all work fine when put in a regular scripts outside Web2py 
> environment. But in a Web2py controller, no mail is sent, and the 
> mail.send() object keeps returning "false".
>
> I have installed the latest Web2py version on my personal PC, and could 
> send email successfully with exactly the same controller : 
>
> mail = auth.settings.mailer
> mail.settings.server = 'smtp.gmail.com:587'
> mail.settings.sender = 'xx...@gmail.com '
> mail.settings.tls = True
> mail.settings.ssl = False
> mail.settings.login = 'xx...@gmail.com:Y'
> mes = mail.send(to='xx...@gmail.com ', subject='Test', 
> message='Message')
>
> if mes:
> response.flash = ("Mail sent !")
> else:
> response.flash = ("Mail not sent !")
>
> return locals()
>
>  
>
> Two comments at that point : 
>
>  
>
> 1/ The latest Web2py version apparently requires now  'mail.settings.ssl = 
> True'. Otherwise it will no work.
>
>  
>
> 2/ The web2py console is very helpful to see the warning messages and 
> understand what is going on after attempting to send an email. For 
> instance :
>
>  
>
>
> 
>
>   
>
> Here are my questions :
>
>  
>
> 1/ How can we have access to the warning messages above when we are only 
> using a browser with no direct access on the distant machine ? The debug 
> features are not relevant since there is no bug in the controller.
>
>  
>
> 2/ What code should I add in the controller to log or see those warnings ?
>
>  
>
> 3/ It looks like the problem I have could be related to SSL or other 
> protection possibly in the lasted Apache version. Do you have idea ?
>
>  
>
> We would be very grateful to have an answer from you or somebody of your 
> development team. Could you please also teel me how I could have access to 
> the discussion group.
>
>  
> Thank you
>   
>
> Thierry.
>
>  
>

Followups at
https://groups.google.com/d/topic/web2py/9kQU1LVbHMI/discussion>

/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: Get access to warning message when only using WEb2py through a browser on a distant machine

2017-06-05 Thread Dave S


On Sunday, June 4, 2017 at 9:04:52 AM UTC-7, e27...@gmail.com wrote:
>
> Hello,
>
> I am encountering email sending problem with the last web2py version on a 
> distant machine running Apache 2.4.
>
> I have exactly the same controller running fine on a local machine with 
> WEb2py server (not Apache).
>
> On the distant machine the 'mail.send' function returns a False response, 
> but since I do not have access to the Warning Console, I do not know what 
> is hoing.
>
> How is it possible to have this Warning messages on the distant machine 
> only using the browser ?
>
> Thank you very much.
>


Followups in:
https://groups.google.com/d/topic/web2py/9kQU1LVbHMI/discussion>

/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: email sending problem

2017-06-05 Thread Dave S


On Sunday, June 4, 2017 at 9:54:03 AM UTC-7, e27...@gmail.com wrote:
>
>
> Since mail.send() return False or True, there is no error here. I am not 
> sur we can log any error here.
>
> How could I get the same "Warning" information that I can have through the 
> local Web2py console which displays the real reason why an email is not 
> sent ?
>

Massimo is saying that mail.send will put the error information in your log 
file if you enable logging in your application.   In addition to the 
stackoverflow reference he provided, there's a short section in the book

http://web2py.com/books/default/chapter/29/04/the-core#Logging>

It's easy enough to do ... I've managed it, despite being attached to 
"print" statements.
And you should be able to get the failure information you need from the 
logs,
without having to set up a remote console.

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


Re: [web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-05 Thread Anthony
On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>
> Thanks. It's also throwing the identical error when using the app's web 
> page as a logged in user.
>

Are you sure? I tried it as a logged in user and it works fine (using your 
exact table definition and insert 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] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-05 Thread Jordan Ladora
Thanks. It's also throwing the identical error when using the app's web
page as a logged in user.

Suggestions?


On Mon, Jun 5, 2017 at 10:19 AM, Anthony  wrote:

> The problem is that you have auth.signature but are doing inserts without
> a logged in user. As a result, the values of the created_by and modified_by
> fields are None but are required to be id's from the db.auth_user table.
> This should simply result in a failed validation rather than an exception,
> but the IS_IN_DB validator breaks when None values are passed in for id or
> integer fields (I would consider it a bug).
>
> Anthony
>
>
> On Saturday, June 3, 2017 at 2:17:31 PM UTC-4, Jordan Ladora wrote:
>
>> Yes, I was able to reproduce with a fresh install of web2py-
>>
>> Here's what I did-
>> 
>> -
>> extracted new copy of web2py from DL src
>>
>> modified welcome app-
>>  in models/db.py commented out this block-
>>   if not request.env.web2py_runtime_gae: / else:
>>  ..and replaced with-
>>db = DAL('sqlite://storage.sqlite', lazy_tables=True,
>> ignore_field_case=False, pool_size=10, check_reserved=['postgres',
>> 'postgres_nonreserved'])
>>
>> created models/db_data.py and added-
>>
>>  db.define_table('datatable',
>> Field('title', length=128),
>> Field('name', requires=IS_IN_SET(['a','b','c'], multiple=False,
>> zero=None), readable=False, writable=False, length=128),
>> Field('dtype', requires=IS_IN_SET(['1','2','3'], multiple=False),
>> label="Type", readable=False, writable=False, length=128),
>> Field('finished', 'boolean', default=False, readable=False,
>> writable=False),
>> Field('the_timestamp', 'datetime', readable=False, writable=False),
>> Field('alive', 'boolean', default=True, readable=False,
>> writable=False),
>> Field( 'comments', 'text' ),
>> auth.signature, migrate=True,
>> format = '%(title)s %(datatype)s %(species)s'
>> )
>>
>> created welcome/databases folder
>>
>>
>> 
>>
>> launched with-
>>
>> python '.../web2py.py' -S welcome -M
>>
>> >>> from datetime import datetime
>>
>> ## insert two fields-
>> >>> new_record = db.datatable.validate_and_insert(dtype='1',
>> the_timestamp=datetime.utcnow())
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_fields = self._validate_fields(fields)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in
>> _validate_fields
>> value, error = self[fieldname].validate(raw_value)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
>> (value, error) = validator(value)
>>   File ".../gluon/validators.py", line 660, in __call__
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>>
>> ## no fields-
>> >>> new_record = db.datatable.validate_and_insert()
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_fields = self._validate_fields(fields)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in
>> _validate_fields
>> value, error = self[fieldname].validate(raw_value)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
>> (value, error) = validator(value)
>>   File ".../gluon/validators.py", line 660, in __call__
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>>
>> ## 'name' field here should throw error for not being in set defined by
>> model-
>> >>> new_record = db.datatable.validate_and_insert(title='test title',
>> name='test name', dtype='1', finished=False, the_timestamp=datetime.utcnow(),
>> alive=True, comments='this is a test')
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_fields = self._validate_fields(fields)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in
>> _validate_fields
>> value, error = self[fieldname].validate(raw_value)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
>> (value, error) = validator(value)
>>   File ".../gluon/validators.py", line 660, in __call__
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>>
>> ## all fields-
>> >>> new_record = db.datatable.validate_and_insert(title='test title',
>> name='a', dtype='1', finished=False, the_timestamp=datetime.utcnow(),
>> alive=True, comments='this is a test')
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_field

Re: [web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-05 Thread Anthony
The problem is that you have auth.signature but are doing inserts without a 
logged in user. As a result, the values of the created_by and modified_by 
fields are None but are required to be id's from the db.auth_user table. 
This should simply result in a failed validation rather than an exception, 
but the IS_IN_DB validator breaks when None values are passed in for id or 
integer fields (I would consider it a bug).

Anthony

On Saturday, June 3, 2017 at 2:17:31 PM UTC-4, Jordan Ladora wrote:
>
> Yes, I was able to reproduce with a fresh install of web2py-
>
> Here's what I did-
>
> -
> extracted new copy of web2py from DL src
>
> modified welcome app-
>  in models/db.py commented out this block-
>   if not request.env.web2py_runtime_gae: / else:
>  ..and replaced with-
>db = DAL('sqlite://storage.sqlite', lazy_tables=True, 
> ignore_field_case=False, pool_size=10, check_reserved=['postgres', 
> 'postgres_nonreserved'])
>
> created models/db_data.py and added-
>
>  db.define_table('datatable',
> Field('title', length=128),
> Field('name', requires=IS_IN_SET(['a','b','c'], multiple=False, 
> zero=None), readable=False, writable=False, length=128),
> Field('dtype', requires=IS_IN_SET(['1','2','3'], multiple=False), 
> label="Type", readable=False, writable=False, length=128),
> Field('finished', 'boolean', default=False, readable=False, 
> writable=False),
> Field('the_timestamp', 'datetime', readable=False, writable=False),
> Field('alive', 'boolean', default=True, readable=False, 
> writable=False),
> Field( 'comments', 'text' ),
> auth.signature, migrate=True, 
> format = '%(title)s %(datatype)s %(species)s'
> )
>
> created welcome/databases folder
>
>
> 
>
> launched with-
>
> python '.../web2py.py' -S welcome -M
>
> >>> from datetime import datetime
>
> ## insert two fields-
> >>> new_record = db.datatable.validate_and_insert(dtype='1', 
> the_timestamp=datetime.utcnow())
> Traceback (most recent call last):
>   File "", line 1, in 
>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in 
> validate_and_insert
> response, new_fields = self._validate_fields(fields)
>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in 
> _validate_fields
> value, error = self[fieldname].validate(raw_value)
>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
> (value, error) = validator(value)
>   File ".../gluon/validators.py", line 660, in __call__
> if isinstance(value, (int, long)) or value.isdigit():
> AttributeError: 'NoneType' object has no attribute 'isdigit'
>
>
> ## no fields-
> >>> new_record = db.datatable.validate_and_insert()
> Traceback (most recent call last):
>   File "", line 1, in 
>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in 
> validate_and_insert
> response, new_fields = self._validate_fields(fields)
>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in 
> _validate_fields
> value, error = self[fieldname].validate(raw_value)
>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
> (value, error) = validator(value)
>   File ".../gluon/validators.py", line 660, in __call__
> if isinstance(value, (int, long)) or value.isdigit():
> AttributeError: 'NoneType' object has no attribute 'isdigit'
>
>
> ## 'name' field here should throw error for not being in set defined by 
> model-
> >>> new_record = db.datatable.validate_and_insert(title='test title', 
> name='test name', dtype='1', finished=False, 
> the_timestamp=datetime.utcnow(), alive=True, comments='this is a test')
> Traceback (most recent call last):
>   File "", line 1, in 
>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in 
> validate_and_insert
> response, new_fields = self._validate_fields(fields)
>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in 
> _validate_fields
> value, error = self[fieldname].validate(raw_value)
>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
> (value, error) = validator(value)
>   File ".../gluon/validators.py", line 660, in __call__
> if isinstance(value, (int, long)) or value.isdigit():
> AttributeError: 'NoneType' object has no attribute 'isdigit'
>
>
> ## all fields-
> >>> new_record = db.datatable.validate_and_insert(title='test title', 
> name='a', dtype='1', finished=False, the_timestamp=datetime.utcnow(), 
> alive=True, comments='this is a test')
> Traceback (most recent call last):
>   File "", line 1, in 
>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in 
> validate_and_insert
> response, new_fields = self._validate_fields(fields)
>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in 
> _validate_fields
> value, error = self[fieldname].validate(raw_value)
>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
> (value, err

[web2py] Re: Adding extra form elements to SQLFORM

2017-06-05 Thread Karoly Kantor
Thanks.

On Monday, June 5, 2017 at 2:36:50 PM UTC+2, Anthony wrote:
>
> The element you are inserting must have the proper HTML structure 
> (including CSS classes) to fit into the form. Use the browser DOM inspector 
> to get an idea what the HTML should look like for a field in the form.
>
> Anthony
>
> On Monday, June 5, 2017 at 4:19:29 AM UTC-4, Karoly Kantor wrote:
>>
>> I am having trouble properly formatting my extra elements to match the 
>> rest of the form.
>>
>> This is a quote from the web2py book below. Can someone tell me what is 
>> exactly meant by "*The variable my_extra_element should be adapted to 
>> the formstyle*"?
>>
>> I am using bootsrap3_inline as formstyle, and all the parts of my extra 
>> element show up in the leftmost column.
>>
>> Adding extra form elements to SQLFORM
>>
>> Sometimes you may wish to add an extra element to your form after it has 
>> been created. For example, you may wish to add a checkbox which confirms 
>> the user agrees with the terms and conditions of your website:
>>
>> 1
>> 2
>> 3
>>
>> form = SQLFORM(db.yourtable)my_extra_element = TR(LABEL('I agree to the 
>> terms and conditions'),   
>> INPUT(_name='agree',value=True,_type='checkbox'))form[0].insert(-1,my_extra_element)
>>
>> *The variable my_extra_element should be adapted to the formstyle.* In 
>> this example, the default formstyle='table3cols' has been assumed.
>>
>

-- 
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: possible error in autocomplete code

2017-06-05 Thread Anthony
You cannot use autocomplete to search a virtual field. It runs a database 
query, so the field must exist in the database.

Anthony

On Monday, June 5, 2017 at 9:23:51 AM UTC-4, Carlos Kitu wrote:
>
> Good afternoon,
> I'm trying to create an autocomplete field to search in the table 
> db.auth_user, but the search must be done with the full name.
> As db.auth_user has two separate fields (first_name, and last_name), I 
> created a virtual field to compose both fields:
>
> db.auth_user.full_name = Field.Virtual('full_name', lambda row: '%s %s' %(
> row.auth_user.first_name, row.auth_user.last_name))
>
> Then, I used the autocomplete widget in a field:
>
> db.define_table('my_table',
>  Field('my_user', 'reference auth_user', notnull=True, unique=False, label
> ='User'),
>  ...
> )
>
>
> db.my_table.my_user.widget = SQLFORM.widgets.autocomplete(
> request, db.auth_user.full_name, id_field=db.auth_user.id, db=db,
> at_beginning=False, limitby=(0, 10), min_length=2)
>
>
>
> And I get this error when creating a new form:
>
>  'DAL' object has no attribute 'None'
> Versión
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47Rastreo
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
>
> Traceback (most recent call last):
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/restricted.py", 
> line 227, in restricted
> exec ccode in environment
>   File 
> "/home/clm/Documentos/p/productos/web2py_2.14.6/applications/VREscalas/controllers/default.py"
>  
> , 
> line 1119, in 
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/globals.py", 
> line 417, in 
> self._caller = lambda f: f()
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/tools.py", line 
> 4241, in f
> return action(*a, **b)
>   File 
> "/home/clm/Documentos/p/productos/web2py_2.14.6/applications/VREscalas/controllers/default.py"
>  
> , 
> line 140, in programas
> lambda row: A('resumen', _href=URL(
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", 
> line 2307, in grid
> create_form = SQLFORM(table, **sqlformargs)
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", 
> line 1288, in __init__
> inp = field.widget(field, default)
>   File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", 
> line 748, in __call__
> table_rows = 
> self.db(self.db[self.fields[0].tablename]).select(orderby=self.orderby)
>   File 
> "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/packages/dal/pydal/base.py",
>  line 914, in __getitem__
> return self.__getattr__(str(key))
>   File 
> "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/packages/dal/pydal/base.py",
>  line 921, in __getattr__
> return BasicStorage.__getattribute__(self, key)
> AttributeError: 'DAL' object has no attribute 'None':
>
>
> I printed in console the self.fields[0]:
> self.fields {'comment': None, 'represent':  at 
> 0x7f6c907310c8>, 'widget': None, 'name': 'full_name', 'f':   at 0x7f6c90731050>, 'requires': None, 'readable': True, 'label': 
> 'Full 
> name', 'writable': False, 'filter_out': None, 'tablename': None, 
> 'formatter': , 'type': 'string'}
>
> It happens that the db.auth_user.full_name.tablename is None, i.e., the 
> virtual field have no tablename attibute as the autocomplete code seems to 
> expect.
> Should I open a ticket?
>
> Thank you and best regards.
>

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


[web2py] Re: No SSL support included in this Python

2017-06-05 Thread Anthony
May be a problem with your Python installation. See 
https://groups.google.com/d/msg/web2py/e6t_-CarABU/16tefm8XBQAJ.

Anthony

On Monday, June 5, 2017 at 9:36:56 AM UTC-4, e27...@gmail.com wrote:
>
> Hello,
>
> Having problem sending email with regular mail.auth.server, on a distant 
> server running Apache 2.4,I tried to use the regular SMTPLIB.
>
> I got the following message :
>
>  No SSL support included in this Python.
> Here is the script that runs fine on my local compture through Web2py.exe.
>
> Any idea ?
>
> import smtplib
> # Specifying the from and to addresses
> body = 'Coucou. Ceci est un message SMTP de TB'
> subject = 'Message SMTP de TB'
> recipient  = 'e27...@gmail.com'
> sender = 'e27...@gmail.com'
> body = "" + body + ""
>  
> headers = ["From: " + sender,
>"Subject: " + subject,
>"To: " + recipient,
>"MIME-Version: 1.0",
>"Content-Type: text/html"]
> headers = "\r\n".join(headers)
>
> # Gmail Login
> username = 'e27...@gmail.com'
> password = 'XX'
>
> # Sending the mail  
> server = smtplib.SMTP('smtp.gmail.com:587')
> server.starttls()
> server.login(username,password)
> mes = server.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
> server.quit()
>
>

-- 
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: request.vars list object

2017-06-05 Thread Anthony
On Monday, June 5, 2017 at 7:31:02 AM UTC-4, Kiran Subbaraman wrote:
>
> What happens in the case you invoke this url: 
> http://127.0.0.1:8000/com/shortcut/target/1349?edge=34&inID=1297&label=NASM%20Certified%20Personal%20Trainer&_signature=9c33ff589c78426ce3fcdf2f53f4408028189128
> Basically instead of `+`, I have used `%20` as the space character.
>

"+" just gets translated to a space -- it does not imply a list.

Anthony

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


[web2py] Re: request.vars list object

2017-06-05 Thread Anthony
Is this a POST request where one of the post variables is also named 
"label"? If so, request.vars, which combines get_vars and post_vars, will 
make "label" into a list containing both the GET and POST values. If that's 
the problem, a fix would be to change your code to:

label = request.get_vars.label

Anthony

On Monday, June 5, 2017 at 5:33:47 AM UTC-4, Annet wrote:
>
> I have the following URL:
>
>
> http://127.0.0.1:8000/com/shortcut/target/1349?edge=34&inID=1297&label=NASM+Certified+Personal+Trainer&_signature=9c33ff589c78426ce3fcdf2f53f4408028189128
>
>
> In de target function I have these lines of code:
>
> label = request.vars.label
>
> get_flash(response, invertex.name + ' already received a target mail for 
> ' + label, 'warning', 'custom')
>
>
> When I execute the function, I get the following error:
>
>  cannot concatenate 'str' and 'list' objects
>
> File "/Users/iannet/web2py/applications/com/controllers/shortcut.py" 
> , line 
> 251, in target
> get_flash(response, invertex.name + ' already received a target mail for 
> ' + label, 'warning', 'custom')
> TypeError: cannot concatenate 'str' and 'list' objects
>
>
>
> I expected label to be a string, why is it a list?
>
>
> Kind regards,
>
> Annet
>

-- 
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: Access to the console Warning messages within a browser

2017-06-05 Thread Anthony
You can set up logging, as described here: 
http://web2py.com/books/default/chapter/29/04/the-core#Logging. If you copy 
/web2py/examples/logging.example.config to /web2py/logging.config and 
restart the server, you should get warnings logged to a /web2py/web2py.log 
file. You can, of course, customize logging to suit your needs.

Anthony

On Monday, June 5, 2017 at 9:07:17 AM UTC-4, e27...@gmail.com wrote:
>
>
> 
>
> Does anyone know how to get access to the Warning messages, normally 
> displayed on Web2py console, when we have only access Web2py via a browser 
> on a distant machine ?
>
> I would like to retrieve the warning messages explaining why email are not 
> sent properly.
>
> Thank you very much.
>
> Thierry
>

-- 
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] No SSL support included in this Python

2017-06-05 Thread e27gis
Hello,

Having problem sending email with regular mail.auth.server, on a distant 
server running Apache 2.4,I tried to use the regular SMTPLIB.

I got the following message :

 No SSL support included in this Python.
Here is the script that runs fine on my local compture through Web2py.exe.

Any idea ?

import smtplib
# Specifying the from and to addresses
body = 'Coucou. Ceci est un message SMTP de TB'
subject = 'Message SMTP de TB'
recipient  = 'e27...@gmail.com'
sender = 'e27...@gmail.com'
body = "" + body + ""
 
headers = ["From: " + sender,
   "Subject: " + subject,
   "To: " + recipient,
   "MIME-Version: 1.0",
   "Content-Type: text/html"]
headers = "\r\n".join(headers)

# Gmail Login
username = 'e27...@gmail.com'
password = 'XX'

# Sending the mail  
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
mes = server.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
server.quit()

-- 
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] possible error in autocomplete code

2017-06-05 Thread Carlos Kitu
Good afternoon,
I'm trying to create an autocomplete field to search in the table 
db.auth_user, but the search must be done with the full name.
As db.auth_user has two separate fields (first_name, and last_name), I 
created a virtual field to compose both fields:

db.auth_user.full_name = Field.Virtual('full_name', lambda row: '%s %s' %(
row.auth_user.first_name, row.auth_user.last_name))

Then, I used the autocomplete widget in a field:

db.define_table('my_table',
 Field('my_user', 'reference auth_user', notnull=True, unique=False, label=
'User'),
 ...
)


db.my_table.my_user.widget = SQLFORM.widgets.autocomplete(
request, db.auth_user.full_name, id_field=db.auth_user.id, db=db,
at_beginning=False, limitby=(0, 10), min_length=2)



And I get this error when creating a new form:

 'DAL' object has no attribute 'None'
Versión
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47Rastreo

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.

Traceback (most recent call last):
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/restricted.py", 
line 227, in restricted
exec ccode in environment
  File 
"/home/clm/Documentos/p/productos/web2py_2.14.6/applications/VREscalas/controllers/default.py"
 , 
line 1119, in 
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/globals.py", line 
417, in 
self._caller = lambda f: f()
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/tools.py", line 
4241, in f
return action(*a, **b)
  File 
"/home/clm/Documentos/p/productos/web2py_2.14.6/applications/VREscalas/controllers/default.py"
 , 
line 140, in programas
lambda row: A('resumen', _href=URL(
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", line 
2307, in grid
create_form = SQLFORM(table, **sqlformargs)
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", line 
1288, in __init__
inp = field.widget(field, default)
  File "/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/sqlhtml.py", line 
748, in __call__
table_rows = 
self.db(self.db[self.fields[0].tablename]).select(orderby=self.orderby)
  File 
"/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/packages/dal/pydal/base.py",
 line 914, in __getitem__
return self.__getattr__(str(key))
  File 
"/home/clm/Documentos/p/productos/web2py_2.14.6/gluon/packages/dal/pydal/base.py",
 line 921, in __getattr__
return BasicStorage.__getattribute__(self, key)
AttributeError: 'DAL' object has no attribute 'None':


I printed in console the self.fields[0]:
self.fields {'comment': None, 'represent':  at 
0x7f6c907310c8>, 'widget': None, 'name': 'full_name', 'f':  at 0x7f6c90731050>, 'requires': None, 'readable': True, 'label': 'Full 
name', 'writable': False, 'filter_out': None, 'tablename': None, 'formatter'
: , 'type': 'string'}

It happens that the db.auth_user.full_name.tablename is None, i.e., the 
virtual field have no tablename attibute as the autocomplete code seems to 
expect.
Should I open a ticket?

Thank you and best regards.

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


[web2py] download a fille.

2017-06-05 Thread akshay055kumar
Hello everyone,
 I am creating a file named hello_world.py somehow and 
storing that file in location some_dir/web2py/application/uploads/scripts. 
I want to give option to user to download that file.

Technique i am using is:
I created a table with a filed having type upload as:
db.define_table('scripts',
Field('s', 
'upload',uploadfolder='/var/www/web2py/applications/uploads/scripts'),

and i am storing the file path 
/var/www/web2py/applications/upload/scripts/hello_world.py 
in field 's'.

By doing this there is an entry in database, but when i am clicking on 
field 's' of table i am getting error '404 file not found'.

Can somebody help me with this or suggest me better option to solve the 
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] not authorised flash message when I used SQLFORM.grid, but worked fine with SQLFORM.smartgrid

2017-06-05 Thread Anthony
On Monday, June 5, 2017 at 1:11:25 AM UTC-4, akshay055ku...@gmail.com wrote:
>
> I could't use the smartgrid because smartgrid works on complete table but 
> i had to query the table first.
>

The smartgrid has the "constraints" argument for that purpose (it is a 
dictionary with table names as keys and DAL queries as values). See 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#smartgrid-signature.
 

> I still don't know what the problem was but solution given by @Leandro 
> Paz worked.
>
> you just have to do:
> grid = SQLFORM.grid (db.auth_user, user_signature = False)
>
>
I don't think that is related to the problem Rudy is having. By default, 
user_signature=True, which simply means the grid will not display 
create/edite/delete buttons (nor allow those operations). You wouldn't get 
a "not authorized" message simply by attempting to load the grid. 
Furthermore, for logged in users, create/edit/delete is allowed, even with 
user_signature=True, and Rudy indicated his code started with using the 
@auth.requires_login() decorator, which requires a logged in user.

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] Access to the console Warning messages within a browser

2017-06-05 Thread e27gis




Does anyone know how to get access to the Warning messages, normally 
displayed on Web2py console, when we have only access Web2py via a browser 
on a distant machine ?

I would like to retrieve the warning messages explaining why email are not 
sent properly.

Thank you very much.

Thierry

-- 
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: Adding extra form elements to SQLFORM

2017-06-05 Thread Anthony
The element you are inserting must have the proper HTML structure 
(including CSS classes) to fit into the form. Use the browser DOM inspector 
to get an idea what the HTML should look like for a field in the form.

Anthony

On Monday, June 5, 2017 at 4:19:29 AM UTC-4, Karoly Kantor wrote:
>
> I am having trouble properly formatting my extra elements to match the 
> rest of the form.
>
> This is a quote from the web2py book below. Can someone tell me what is 
> exactly meant by "*The variable my_extra_element should be adapted to the 
> formstyle*"?
>
> I am using bootsrap3_inline as formstyle, and all the parts of my extra 
> element show up in the leftmost column.
>
> Adding extra form elements to SQLFORM
>
> Sometimes you may wish to add an extra element to your form after it has 
> been created. For example, you may wish to add a checkbox which confirms 
> the user agrees with the terms and conditions of your website:
>
> 1
> 2
> 3
>
> form = SQLFORM(db.yourtable)my_extra_element = TR(LABEL('I agree to the terms 
> and conditions'),   
> INPUT(_name='agree',value=True,_type='checkbox'))form[0].insert(-1,my_extra_element)
>
> *The variable my_extra_element should be adapted to the formstyle.* In 
> this example, the default formstyle='table3cols' has been assumed.
>

-- 
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: request.vars list object

2017-06-05 Thread Kiran Subbaraman
What happens in the case you invoke this url: 
http://127.0.0.1:8000/com/shortcut/target/1349?edge=34&inID=1297&label=NASM%20Certified%20Personal%20Trainer&_signature=9c33ff589c78426ce3fcdf2f53f4408028189128
Basically instead of `+`, I have used `%20` as the space character.


On Monday, June 5, 2017 at 3:03:47 PM UTC+5:30, Annet wrote:
>
> I have the following URL:
>
>
> http://127.0.0.1:8000/com/shortcut/target/1349?edge=34&inID=1297&label=NASM+Certified+Personal+Trainer&_signature=9c33ff589c78426ce3fcdf2f53f4408028189128
>
>
> In de target function I have these lines of code:
>
> label = request.vars.label
>
> get_flash(response, invertex.name + ' already received a target mail for 
> ' + label, 'warning', 'custom')
>
>
> When I execute the function, I get the following error:
>
>  cannot concatenate 'str' and 'list' objects
>
> File "/Users/iannet/web2py/applications/com/controllers/shortcut.py" 
> , line 
> 251, in target
> get_flash(response, invertex.name + ' already received a target mail for 
> ' + label, 'warning', 'custom')
> TypeError: cannot concatenate 'str' and 'list' objects
>
>
>
> I expected label to be a string, why is it a list?
>
>
> Kind regards,
>
> Annet
>

-- 
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: grid add/edit form label

2017-06-05 Thread icodk
Code example:
else: #person grid
personRow = db(db.person.id == request.args[-1]).select()[0]
title = T("cars owned by :") + personRow.name
addBtn = T("Add new car for: ") + carRow.name
if toCreate:
grid[1][0][2][0] =addBtn



On Monday, June 5, 2017 at 11:47:15 AM UTC+2, T.R.Rajkumar wrote:
>
> Thanks icodk. You  said The last part is after the call to 
> SQLFORM.smartgrid. Here you can manipulate the serialized HTML data by for 
> example changing the "+Add record" text to "+Add person" in the  auto 
> generated button 
>
> I would like to know how you manipulate the html in controller as above 
> for changing the button text. 
>

-- 
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: grid add/edit form label

2017-06-05 Thread T.R.Rajkumar
Thanks icodk. You  said The last part is after the call to 
SQLFORM.smartgrid. Here you can manipulate the serialized HTML data by for 
example changing the "+Add record" text to "+Add person" in the  auto 
generated button 

I would like to know how you manipulate the html in controller as above for 
changing the button text. 

-- 
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] request.vars list object

2017-06-05 Thread 'Annet' via web2py-users
I have the following URL:

http://127.0.0.1:8000/com/shortcut/target/1349?edge=34&inID=1297&label=NASM+Certified+Personal+Trainer&_signature=9c33ff589c78426ce3fcdf2f53f4408028189128


In de target function I have these lines of code:

label = request.vars.label

get_flash(response, invertex.name + ' already received a target mail for ' 
+ label, 'warning', 'custom')


When I execute the function, I get the following error:

 cannot concatenate 'str' and 'list' objects

File "/Users/iannet/web2py/applications/com/controllers/shortcut.py" 
, line 
251, in target
get_flash(response, invertex.name + ' already received a target mail for ' 
+ label, 'warning', 'custom')
TypeError: cannot concatenate 'str' and 'list' objects



I expected label to be a string, why is it a list?


Kind regards,

Annet

-- 
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: grid add/edit form label

2017-06-05 Thread T.R.Rajkumar
Yes, Anthony. It now works. Thank you for your valuable time.

-- 
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] web2py 2.15.1

2017-06-05 Thread Karoly Kantor
Dear Massimo,

I saw your question in the developers group where I cannot post, therefore 
i do it here.

I am currently aware of the following issues to be fixed:

1. Google 2nd generation SQL is definitely a problem. Please note I made a 
temporary hack to fix it, described 
here: https://groups.google.com/forum/?fromgroups=#!topic/web2py/vs39zZpaH7g

2. We have a long overdue issue with the password reset emails not sending 
on GAE (), I am using a temporary dirty workaround that sends a plain text 
new password, search for the issue about "lazyT" object being passed to 
GAE".

3. I am having trouble making the date picker work nicely across all 
browsers, especially where there is a native solution. Microsoft Edge is 
the worst case. In general, would be good to have a nicer date picker

4. General comment: We have "batteries included", however, some of those 
batteries now have much newer versions than included, e.g. bootstrap




-- 
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] Adding extra form elements to SQLFORM

2017-06-05 Thread Karoly Kantor
I am having trouble properly formatting my extra elements to match the rest 
of the form.

This is a quote from the web2py book below. Can someone tell me what is 
exactly meant by "*The variable my_extra_element should be adapted to the 
formstyle*"?

I am using bootsrap3_inline as formstyle, and all the parts of my extra 
element show up in the leftmost column.

Adding extra form elements to SQLFORM

Sometimes you may wish to add an extra element to your form after it has 
been created. For example, you may wish to add a checkbox which confirms 
the user agrees with the terms and conditions of your website:

1
2
3

form = SQLFORM(db.yourtable)my_extra_element = TR(LABEL('I agree to the terms 
and conditions'),   
INPUT(_name='agree',value=True,_type='checkbox'))form[0].insert(-1,my_extra_element)

*The variable my_extra_element should be adapted to the formstyle.* In this 
example, the default formstyle='table3cols' has been assumed.

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