[web2py] Re: Run Web2py as a Service? on Ubuntu Lucid?

2013-03-07 Thread Francisco Barretto
Same problem here. Any hints?

Did the exact procedure described in  
http://web2py.com/book/default/chapter/11#Start-as-Linux-Daemon 
and I get:
$ sudo /etc/init.d/web2py start
No process in pidfile '/var/run/web2py/web2py.pid' found running; none 
killed.
start-stop-daemon: Unable to start /usr/lib/python: Permission denied 
(Permission denied)


On Tuesday, December 21, 2010 4:57:39 PM UTC-2, Christopher Steel wrote:
>
> Hi, 
>
> Mine seemed to work fine right off the bat with Lucid using the 
> installation scripts that are included in web2py/scripts. I am doing 
> some automated installation testing so I will let you know if I run 
> into any issues and how I fixed them. 
>
> In the mean time I am wondering why Web2py is in usr/lib/web2py/ 
> web2py.py on your setup. Unlike many applications, web2py.py in 
> particular, probably does not belong in that location (although I know 
> someone was talking about building a Debian package for web2py at some 
> point in time...). A more standard web2py setup can be obtained be 
> unpacking the Web2py source in /home/www-data. This is what should 
> happen when the included Ubuntu installer script is used. 
>
> If the included Ubuntu installer script is used then the included 
> services script should work as well. 
>
>
> Cheers, 
>
> Chris 
>
>
> On Dec 20, 4:50 pm, ghoulmann  wrote: 
> > Web2py isn't running as a service for me. I relied on the instructions 
> > here:http://web2py.com/book/default/chapter/11#Start-as-Linux-Daemon 
> > . The file, /etc/init.d/web2py is owned by root and executable. Python 
> > is at /bin/python, and web2py is at /usr/lib/web2py/web2py.py . No pid 
> > file is being created in the specified directory. Below, several posts 
> > ago, I posted a pastebin of the web2py file in init.d. I'm working in 
> > the service of Sahana Eden, and don't want to scrap this build, which 
> > is dependent on web2py. However, it can't be completed if web2py won't 
> > run as a service at startup. I've used the feedback I received, but 
> > the problem isn't solved. Please, if you have suggestions, I'd love to 
> > hear them. 
> > 
> > On Dec 19, 1:00 pm, ghoulmann  wrote: 
> > 
> > > SO what to do then? It appears no web2py.pid file is being created. 
> > 
> > > On Dec 18, 3:27 pm, ghoulmann  wrote: 
> > 
> > > > Thanks Kenneth. When I look in the specified dir I see that no 
> web2py 
> > > > existed. I thought maybe you meant changing the value $PIDDIR, so I 
> > > > tried that. I changed it to /root/$name and I ended up with the same 
> > > > result. It created /root/web2py, but the directory is empty. 
> > 
> > > > On Dec 18, 2:18 pm, Kenneth Lundström  
>
> > > > wrote: 
> > 
> > > > > Try to move the web2py.pid file and try again. 
> > 
> > > > > Kenneth 
> > 
> > > > > > Thanks for the tip! Removed --quiet from the two lines. The 
> service 
> > > > > > still doesn't appear to start on startup (after reboot). When I 
> > > > > > manually start with /etc/init.d/web2py (root user) I get this: 
> No 
> > > > > > process in pidfile '/var/run/web2py/web2py.pid' found running; 
> none 
> > > > > > killed. And the service doesn't seem to work. 
> > 
> > > > > > What can be a wise next step? 
> > 
> > > > > > On Dec 18, 10:33 am, jeff  wrote: 
> > > > > >> When I had this kind of problem, I removed the --quiet and -- 
> > > > > >> background in the /etc/init.d/web2py file (line 65 and 67 of 
> your 3rd 
> > > > > >> file). 
> > > > > >> I was then able to get some error messages when doing 
> /etc/init.d/ 
> > > > > >> web2py start 
> > 
> > > > > >> In my case, it helped me to find a stupid error I did. 
> > 
> > > > > >> Good luck. 
> > 
> > > > > >> On Dec 18, 5:59 am, ghoulmann  wrote: 
> > 
> > > > > >>> Thanks so much for the reply. I did try both; retried them 
> when I saw 
> > > > > >>> your response. Both commands start web2py.py listening on 
> :8000. SO, 
> > > > > >>> it does work in these cases. Is there something I can try 
> next? 
> > > > > >>> On Dec 17, 6:34 pm, mdipierro 
>  wrote: 
> > > > >  did you try start it simply with 
> > > > >  python web2py.py -a password 
> > > > >  or 
> > > > >  nohup python web2py.py -a password& 
> > > > >  Does it work fine in these cases? 
> > > > >  On Dec 17, 4:59 pm, ghoulmann  wrote: 
> > > > > > I'm thankful this community is here. I'm working on a 
> project for the 
> > > > > > Sahana-Eden team [1]. It calls for running web2py as a 
> service. I was 
> > > > > > thankful to find documentation in the 3rd edition Official 
> Web2py Book 
> > > > > > [2]. Sadly, when I follow the docs I can't get the service 
> running. / 
> > > > > > etc/init.d/web2py start returns no errors; restart returns 
> no errors, 
> > > > > > and status returns nothing. Netstat tells me the interface 
> isn't 
> > > > > > listening on port 8000. 
> > > > > > I did use the scripts/web2py.ubuntu.sh script, and did as 
> instructed 
> > > > > > in the docum

[web2py] puppet for web2py

2013-08-28 Thread Francisco Barretto
Hi there!

Did Anyone already made some puppet module to manage/install web2py and 
web2py's app management(install/update) through Puppet? I was thinking 
about hosting my app in a git repository and use a puppet module to keep 
web2py updated (by applying both web2py and app changes to client machines).

Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] puppet for web2py

2013-08-28 Thread Francisco Barretto
There is a .sh provided along with the web2py distribution for install 
purposes. The main thing is that when you do it through puppet (
http://puppetlabs.com/) and your machine goes bad for any reason you just 
have to apply your puppet again. Or if you want to replicate your app into 
X new machines, just apply the puppet.

imagine that you have to create a "b" machine so you can balance your 
incoming requests. It is quite hard to keep them synchronized manually. 
Puppet allows you to "puppetize" the configuration and apply at both 
machines. That's why I'm interested in using puppet.

If anybody has ever tried to apply puppet for web2py management, please 
send me a smoke signal! :)

Em quarta-feira, 28 de agosto de 2013 11h31min44s UTC-3, viniciusban 
escreveu:
>
> I don't know puppet, but this weekend I'll be doing it through shell 
> script, to one customer. 
>
> On Wed, Aug 28, 2013 at 11:28 AM, Francisco Barretto 
> > wrote: 
> > Hi there! 
> > 
> > Did Anyone already made some puppet module to manage/install web2py and 
> > web2py's app management(install/update) through Puppet? I was thinking 
> about 
> > hosting my app in a git repository and use a puppet module to keep 
> web2py 
> > updated (by applying both web2py and app changes to client machines). 
> > 
> > Thanks 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] puppet for web2py

2013-08-28 Thread Francisco Barretto
The main thing is that everything else is puppetized here... it would be 
probably better if it could fit in smoothly through puppet. It is possible 
to implement everything from scratch but it's a lot of work. 

Em quarta-feira, 28 de agosto de 2013 13h04min02s UTC-3, nils escreveu:
>
> Hi,
>
> You should take a look a http://docs.saltstack.com/ref/python-api.html 
>
> This is like fabric and puppet all in one and its really easy to use.
>
> Regards,
>
> Nils
>
>
>
> On Wed, Aug 28, 2013 at 3:28 PM, Francisco Barretto 
> 
> > wrote:
>
>> Hi there!
>>
>> Did Anyone already made some puppet module to manage/install web2py and 
>> web2py's app management(install/update) through Puppet? I was thinking 
>> about hosting my app in a git repository and use a puppet module to keep 
>> web2py updated (by applying both web2py and app changes to client machines).
>>
>> Thanks
>>
>> -- 
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] HTTPS Remote Admin Page Access

2012-09-13 Thread Francisco Barretto
Hi There, 

I'm trying to use web2py in a ubuntu server without graphic interface so I 
need to access the admin page remotely.
Started the server with ip 0.0.0.0 and port 8000 and got the message: 
"Admin is disabled because insecure channel"
I saw some users commenting the above part of access.py (inside admin app):

if request.env.http_x_forwarded_for or request.is_https:
session.secure()
elif not request.is_local and not DEMO_MODE:
raise HTTP(200, T('Admin is disabled because insecure channel'))

The problem with this kind of approach is that it raises serious security 
issues if you want to use it in a real production environment. 

So, I tried to set ssh and followed this tutorial: 
http://www.web2py.com/AlterEgo/default/show/140
Setted up without any errors and started web2py as follows: 
 python web2py.py -c server.crt -k server.key -i 0.0.0.0 -p 443
(also tried ports 80 and 8000)

but it raises the following log:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.0.2 (2012-08-30 04:08:18) stable
Database drivers available: SQLite3, pymysql, pg8000, IMAP
WARNING:web2py:GUI not available because Tk library is not installed
choose a password:
please visit:
https://0.0.0.0:443
use "kill -SIGTERM 1120" to shutdown the web2py server
WARNING:web2py:unable to open SSL certificate. SSL is OFF

My question is: is there any "right" way to enable remote admin page access?

Thanks, folks!

-- 





[web2py] HTTPS Admin Page Remote Connection

2012-09-13 Thread Francisco Barretto
Hi There!
 
Deploying web2py on a server gives me some headache about accessing the 
admin page (on server) from a remote machine. First it throwed the message 
"'Admin is disabled because insecure channel'. So I found some posts 
talking about comment the following code
 
   
if request.env.http_x_forwarded_for or request.is_https:   
   
 session.secure()  
elif not request.is_local and not DEMO_MODE:  
 raise HTTP(200, T('Admin is disabled because insecure channel'))

Unfortunatelly, commenting, this part of the access.py file is not the 
right way to do it and I know. Besides, it still shows-me this message 
"ATTENTION: Login requires a secure (HTTPS) connection or running on 
localhost". So, it´s not apropriate and doesn´t even solve the problem.
 
Since I´m using linux as my server OS and it doesn´t have a graphic 
interface I can´t access the admin page through a local browser. My point 
is, how to correctly enable the admin page remote access? Already tryed to 
start with the server IP and 0.0.0.0 using ports 8000, 80 and 443 and still 
nothing. Also tryied to specify the protocol HTTPS on browser but I get 
this error:
 
 SSL received a record that exceeded the maximum permissible length.   
   
  
(Error code: ssl_error_rx_record_too_long) 

So, can anybody point me the right way?
 
Thanks!

-- 





[web2py] Re: HTTPS Admin Page Remote Connection

2012-09-19 Thread Francisco Barretto
Hi Folks!

Here's how I've solved the problem:
I'm now running a web2py local server with regular configuration:
nohup python web2py.py -i 127.0.0.1 -p 8000

Then configured apache2 based on the alternative "mod_proxy" configuration 
described in http://web2py.com/book/default/chapter/13.

NameVirtualHost *:80 NameVirtualHost *:443  deal with requests on port 80 
 Alias / /users/www-data/web2py/applications ### admin 
requires SSL  SSLRequireSSL  ### 
appadmin requires SSL  SSLRequireSSL 
 ### serve static files directly  Order Allow,Deny Allow from all  ### 
proxy all the other requests  Order deny,allow Allow from 
all ProxyPass http://localhost:8000/welcome ProxyPassReverse 
http://localhost:8000/  LogFormat "%h %l %u %t "%r" %>s %b" common 
CustomLog /var/log/apache2/access.log common   
SSLEngine On SSLCertificateFile /etc/apache2/ssl/server.crt 
SSLCertificateKeyFile /etc/apache2/ssl/server.key  Order 
deny,allow Allow from all ProxyPass http://localhost:8000/ ProxyPassReverse 
http://localhost:8000/  LogFormat "%h %l %u %t "%r" %>s %b" common 
CustomLog /var/log/apache2/access.log common 


This way, apaches deals with the incomming connections on ports 80 and 443 
and then redirects these requests to local web2py default server. This way 
I'm still secure since appadmin and admin are forced to be over HTTPS and 
did no bypasses on codes or whatever.

[User (HTTPS)--> Apache  (HTTP)--> Web2PyServer]

Thanks!




On Thursday, September 13, 2012 10:38:45 AM UTC-3, Francisco Barretto wrote:
>
> Hi There!
>  
> Deploying web2py on a server gives me some headache about accessing the 
> admin page (on server) from a remote machine. First it throwed the message 
> "'Admin is disabled because insecure channel'. So I found some posts 
> talking about comment the following code
>  
>
> if request.env.http_x_forwarded_for or request.is_https: 
>  
>  session.secure()  
> elif not request.is_local and not DEMO_MODE:  
>  raise HTTP(200, T('Admin is disabled because insecure channel'))
>
> Unfortunatelly, commenting, this part of the access.py file is not the 
> right way to do it and I know. Besides, it still shows-me this message 
> "ATTENTION: Login requires a secure (HTTPS) connection or running on 
> localhost". So, it´s not apropriate and doesn´t even solve the problem.
>  
> Since I´m using linux as my server OS and it doesn´t have a graphic 
> interface I can´t access the admin page through a local browser. My point 
> is, how to correctly enable the admin page remote access? Already tryed to 
> start with the server IP and 0.0.0.0 using ports 8000, 80 and 443 and still 
> nothing. Also tryied to specify the protocol HTTPS on browser but I get 
> this error:
>  
>  SSL received a record that exceeded the maximum permissible length. 
>  
>   
> (Error code: ssl_error_rx_record_too_long) 
>
> So, can anybody point me the right way?
>  
> Thanks!
>

-- 





[web2py] Re: HTTPS Remote Admin Page Access

2012-09-19 Thread Francisco Barretto
Hi Massimo!

Here's how I've solved the problem:
I'm now running a web2py local server with regular configuration:
nohup python web2py.py -i 127.0.0.1 -p 8000

Then configured apache2 based on the alternative "mod_proxy" configuration 
described in http://web2py.com/book/default/chapter/13.

This way, apaches deals with the incomming connections on ports 80 and 443 
and then redirects these requests to local web2py default server. This way 
I'm still secure since appadmin and admin are forced to be over HTTPS and 
did no bypasses on codes or whatever. Since I've got other applications 
running in apache, that will be replaced by web2py applications this 
managed to be a good solution and will save me some time when migrating to 
a new application version.

Thanks!





On Thursday, September 13, 2012 6:48:21 PM UTC-3, Massimo Di Pierro wrote:
>
>
> Can you try the full path to certificate files? Are you sure they work?
> Meanwhile you can run admin on port 127.0.0.1 and connect via ssl tunnel.
>
>
> On Thursday, 13 September 2012 09:54:18 UTC-5, Francisco Barretto wrote:
>>
>> Hi There, 
>>
>> I'm trying to use web2py in a ubuntu server without graphic interface so 
>> I need to access the admin page remotely.
>> Started the server with ip 0.0.0.0 and port 8000 and got the message: 
>> "Admin is disabled because insecure channel"
>> I saw some users commenting the above part of access.py (inside admin 
>> app):
>>
>> if request.env.http_x_forwarded_for or request.is_https:
>> session.secure()
>> elif not request.is_local and not DEMO_MODE:
>> raise HTTP(200, T('Admin is disabled because insecure channel'))
>>
>> The problem with this kind of approach is that it raises serious security 
>> issues if you want to use it in a real production environment. 
>>
>> So, I tried to set ssh and followed this tutorial: 
>> http://www.web2py.com/AlterEgo/default/show/140
>> Setted up without any errors and started web2py as follows: 
>>  python web2py.py -c server.crt -k server.key -i 0.0.0.0 -p 443
>> (also tried ports 80 and 8000)
>>
>> but it raises the following log:
>>
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2012
>> Version 2.0.2 (2012-08-30 04:08:18) stable
>> Database drivers available: SQLite3, pymysql, pg8000, IMAP
>> WARNING:web2py:GUI not available because Tk library is not installed
>> choose a password:
>> please visit:
>> https://0.0.0.0:443
>> use "kill -SIGTERM 1120" to shutdown the web2py server
>> WARNING:web2py:unable to open SSL certificate. SSL is OFF
>>
>> My question is: is there any "right" way to enable remote admin page 
>> access?
>>
>> Thanks, folks!
>>
>

-- 





[web2py] How to list all groups that a user belongs to (memberships) ?

2012-10-30 Thread Francisco Barretto
Hi Folks!

How do I list all groups that a user belong? I've found out that Auth has 
this function:

groups(self)
displays the groups and their roles for the logged in user

I dont manage to get it working. I've tried something like this:

def myGroups():
return dict(auth.groups(auth.user_id))

and get this error:
 groups() takes exactly 1 argument (2 given)

any idea on how to do this properly? Thanks!

-- 





Re: [web2py] How to list all groups that a user belongs to (memberships) ?

2012-10-30 Thread Francisco Barretto
Ok Richard, I've got it. You are right. Without parameters it works but I 
cant manage to get a userfull list out of it. Accesint the webpage doesn't 
help either, since I need to compare memberships inside the controller 
actions.

I would need a list containing all user groups but I got instead, some kind 
of raw table which I don't know how to iterate with.

Can you help me go further?

Thanks, mate!

On Tuesday, October 30, 2012 2:07:40 PM UTC-2, Richard wrote:
>
> Ok!
>
> I read the book.
>
> You should not pass the user id.
>
> auth.groups() and not auth.groups(auth.user.id)
>
> Also you can go to this URL :
>
> http://127.0.0.1/yourappname/default/user/groups and you will get the 
> list of group your current logged user is in.
>
> Richard
>
> On Tue, Oct 30, 2012 at 11:51 AM, Richard Vézina 
> 
> > wrote:
>
>> I don't know if web2py has a given command or how to use it, but this 
>> query should give you what you the information you are searching :
>>
>> db((db.auth_user.email == 'USER_EMAIL')&(db.auth_membership.user_id == 
>> db.auth_user.id)&(db.auth_group.id
>> ==db.auth_membership.group_id)).select(db.auth_group.ALL)
>>  
>> Richard
>>
>>
>> On Tue, Oct 30, 2012 at 11:15 AM, Francisco Barretto 
>> 
>> > wrote:
>>
>>> Hi Folks!
>>>
>>> How do I list all groups that a user belong? I've found out that Auth 
>>> has this function:
>>>
>>> groups(self)
>>> displays the groups and their roles for the logged in user
>>>
>>> I dont manage to get it working. I've tried something like this:
>>>
>>> def myGroups():
>>> return dict(auth.groups(auth.user_id))
>>>
>>> and get this error:
>>>  groups() takes exactly 1 argument (2 given)
>>>
>>> any idea on how to do this properly? Thanks!
>>>  
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>

-- 





Re: [web2py] How to list all groups that a user belongs to (memberships) ?

2012-10-30 Thread Francisco Barretto
In addition to what I've just said, I've looked up here (
http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools.Auth-class.html)
 
for more info about this groups() method but I've found nothing about what 
"type" does it returns.

On Tuesday, October 30, 2012 2:35:46 PM UTC-2, Francisco Barretto wrote:
>
> Ok Richard, I've got it. You are right. Without parameters it works but I 
> cant manage to get a userfull list out of it. Accesint the webpage doesn't 
> help either, since I need to compare memberships inside the controller 
> actions.
>
> I would need a list containing all user groups but I got instead, some 
> kind of raw table which I don't know how to iterate with.
>
> Can you help me go further?
>
> Thanks, mate!
>
> On Tuesday, October 30, 2012 2:07:40 PM UTC-2, Richard wrote:
>>
>> Ok!
>>
>> I read the book.
>>
>> You should not pass the user id.
>>
>> auth.groups() and not auth.groups(auth.user.id)
>>
>> Also you can go to this URL :
>>
>> http://127.0.0.1/yourappname/default/user/groups and you will get the 
>> list of group your current logged user is in.
>>
>> Richard
>>
>> On Tue, Oct 30, 2012 at 11:51 AM, Richard Vézina 
>> wrote:
>>
>>> I don't know if web2py has a given command or how to use it, but this 
>>> query should give you what you the information you are searching :
>>>
>>> db((db.auth_user.email == 'USER_EMAIL')&(db.auth_membership.user_id == 
>>> db.auth_user.id)&(db.auth_group.id
>>> ==db.auth_membership.group_id)).select(db.auth_group.ALL)
>>>  
>>> Richard
>>>
>>>
>>> On Tue, Oct 30, 2012 at 11:15 AM, Francisco Barretto <
>>> kikoba...@gmail.com> wrote:
>>>
>>>> Hi Folks!
>>>>
>>>> How do I list all groups that a user belong? I've found out that Auth 
>>>> has this function:
>>>>
>>>> groups(self)
>>>> displays the groups and their roles for the logged in user
>>>>
>>>> I dont manage to get it working. I've tried something like this:
>>>>
>>>> def myGroups():
>>>> return dict(auth.groups(auth.user_id))
>>>>
>>>> and get this error:
>>>>  groups() takes exactly 1 argument (2 
>>>> given)
>>>>
>>>> any idea on how to do this properly? Thanks!
>>>>  
>>>> -- 
>>>>  
>>>>  
>>>>  
>>>>
>>>
>>>
>>

-- 





Re: [web2py] How to list all groups that a user belongs to (memberships) ?

2012-10-30 Thread Francisco Barretto
Ok, It does return a table(). I've tried to parse it so I could access the 
information I need (group names) without success.

Richard, Since the name of the db column which stores the group name (role) 
is 
auth_group.role<https://10.1.2.116/DNSAdmin/appadmin/select/db?orderby=auth_group.role>,
 
could the solution be something like this?

groups = []
for row in auth.groups():
groups.append(row.role)

return (groups)

I'm getting
 'TR' object has no attribute 'auth_group'

I've also tried "row.auth_group.role" but I won't work either. Obviously it 
is returning some kind of HTML table formated data. Will I have to parse it 
manually?

On Tuesday, October 30, 2012 2:59:07 PM UTC-2, Niphlod wrote:
>
> groups returns a TABLE(), not a list of records.
>
> On Tuesday, October 30, 2012 5:57:03 PM UTC+1, Richard wrote:
>>
>> I didn't test, but you may try this :
>>
>> for row in auth.groups():
>> print row 
>>
>> row should contain the different column of auth_group table and you can 
>> usually get those column like this row.name (column name in this 
>> example).
>>
>> You could also try as_list() :
>>
>> http://web2py.com/books/default/chapter/29/06#as_dict-and-as_list
>>
>> If it doesn't work, use the query I wrote above :
>>
>> rows = query
>> for row in rows:
>>  do stuff
>>
>> Richard
>>
>> On Tue, Oct 30, 2012 at 12:35 PM, Francisco Barretto > > wrote:
>>
>>> Ok Richard, I've got it. You are right. Without parameters it works but 
>>> I cant manage to get a userfull list out of it. Accesint the webpage 
>>> doesn't help either, since I need to compare memberships inside the 
>>> controller actions.
>>>
>>> I would need a list containing all user groups but I got instead, some 
>>> kind of raw table which I don't know how to iterate with.
>>>
>>> Can you help me go further?
>>>
>>> Thanks, mate!
>>>
>>>
>>> On Tuesday, October 30, 2012 2:07:40 PM UTC-2, Richard wrote:
>>>
>>>> Ok!
>>>>
>>>> I read the book.
>>>>
>>>> You should not pass the user id.
>>>>
>>>> auth.groups() and not auth.groups(auth.user.id)
>>>>
>>>> Also you can go to this URL :
>>>>
>>>> http://127.0.0.1/yourappname/**default/user/groups<http://127.0.0.1/yourappname/default/user/groups>and
>>>>  you will get the list of group your current logged user is in.
>>>>
>>>> Richard
>>>>
>>>> On Tue, Oct 30, 2012 at 11:51 AM, Richard Vézina >>> > wrote:
>>>>
>>>>> I don't know if web2py has a given command or how to use it, but this 
>>>>> query should give you what you the information you are searching :
>>>>>
>>>>> db((db.auth_user.email == 'USER_EMAIL')&(db.auth_**membership.user_id 
>>>>> == db.auth_user.id)&(db.auth_**group.id <http://db.auth_group.id>
>>>>> ==db.auth_membership.**group_id)).select(db.auth_**group.ALL)
>>>>>  
>>>>> Richard
>>>>>
>>>>>
>>>>> On Tue, Oct 30, 2012 at 11:15 AM, Francisco Barretto <
>>>>> kikoba...@gmail.com> wrote:
>>>>>
>>>>>> Hi Folks!
>>>>>>
>>>>>> How do I list all groups that a user belong? I've found out that Auth 
>>>>>> has this function:
>>>>>>
>>>>>> groups(self)
>>>>>> displays the groups and their roles for the logged in user
>>>>>>
>>>>>> I dont manage to get it working. I've tried something like this:
>>>>>>
>>>>>> def myGroups():
>>>>>> return dict(auth.groups(auth.user_id)**)
>>>>>>
>>>>>> and get this error:
>>>>>>  groups() takes exactly 1 argument (2 
>>>>>> given)
>>>>>>
>>>>>> any idea on how to do this properly? Thanks!
>>>>>>  
>>>>>> -- 
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>
>>>>  -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





Re: [web2py] How to list all groups that a user belongs to (memberships) ?

2012-10-30 Thread Francisco Barretto
Got it!

def myGroups():
groups = []
rows = db((db.auth_user.email == 
auth.user.email)&(db.auth_membership.user_id == 
auth.user_id)&(db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL)
for row in rows:
groups.append(row.role)
return (groups)

Works just fine: returns a list of user's group names.

Thanks Richard!

On Tuesday, October 30, 2012 3:19:29 PM UTC-2, Francisco Barretto wrote:
>
> Ok, It does return a table(). I've tried to parse it so I could access the 
> information I need (group names) without success.
>
> Richard, Since the name of the db column which stores the group name 
> (role) is 
> auth_group.role<https://10.1.2.116/DNSAdmin/appadmin/select/db?orderby=auth_group.role>,
>  
> could the solution be something like this?
>
> groups = []
> for row in auth.groups():
> groups.append(row.role)
> 
> return (groups)
>
> I'm getting
>  'TR' object has no attribute 
> 'auth_group'
>
> I've also tried "row.auth_group.role" but I won't work either. Obviously 
> it is returning some kind of HTML table formated data. Will I have to parse 
> it manually?
>
> On Tuesday, October 30, 2012 2:59:07 PM UTC-2, Niphlod wrote:
>>
>> groups returns a TABLE(), not a list of records.
>>
>> On Tuesday, October 30, 2012 5:57:03 PM UTC+1, Richard wrote:
>>>
>>> I didn't test, but you may try this :
>>>
>>> for row in auth.groups():
>>> print row 
>>>
>>> row should contain the different column of auth_group table and you can 
>>> usually get those column like this row.name (column name in this 
>>> example).
>>>
>>> You could also try as_list() :
>>>
>>> http://web2py.com/books/default/chapter/29/06#as_dict-and-as_list
>>>
>>> If it doesn't work, use the query I wrote above :
>>>
>>> rows = query
>>> for row in rows:
>>>  do stuff
>>>
>>> Richard
>>>
>>> On Tue, Oct 30, 2012 at 12:35 PM, Francisco Barretto <
>>> kikoba...@gmail.com> wrote:
>>>
>>>> Ok Richard, I've got it. You are right. Without parameters it works but 
>>>> I cant manage to get a userfull list out of it. Accesint the webpage 
>>>> doesn't help either, since I need to compare memberships inside the 
>>>> controller actions.
>>>>
>>>> I would need a list containing all user groups but I got instead, some 
>>>> kind of raw table which I don't know how to iterate with.
>>>>
>>>> Can you help me go further?
>>>>
>>>> Thanks, mate!
>>>>
>>>>
>>>> On Tuesday, October 30, 2012 2:07:40 PM UTC-2, Richard wrote:
>>>>
>>>>> Ok!
>>>>>
>>>>> I read the book.
>>>>>
>>>>> You should not pass the user id.
>>>>>
>>>>> auth.groups() and not auth.groups(auth.user.id)
>>>>>
>>>>> Also you can go to this URL :
>>>>>
>>>>> http://127.0.0.1/yourappname/**default/user/groups<http://127.0.0.1/yourappname/default/user/groups>and
>>>>>  you will get the list of group your current logged user is in.
>>>>>
>>>>> Richard
>>>>>
>>>>> On Tue, Oct 30, 2012 at 11:51 AM, Richard Vézina <
>>>>> ml.richa...@gmail.com> wrote:
>>>>>
>>>>>> I don't know if web2py has a given command or how to use it, but this 
>>>>>> query should give you what you the information you are searching :
>>>>>>
>>>>>> db((db.auth_user.email == 'USER_EMAIL')&(db.auth_**membership.user_id 
>>>>>> == db.auth_user.id)&(db.auth_**group.id <http://db.auth_group.id>
>>>>>> ==db.auth_membership.**group_id)).select(db.auth_**group.ALL)
>>>>>>  
>>>>>> Richard
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 30, 2012 at 11:15 AM, Francisco Barretto <
>>>>>> kikoba...@gmail.com> wrote:
>>>>>>
>>>>>>> Hi Folks!
>>>>>>>
>>>>>>> How do I list all groups that a user belong? I've found out that 
>>>>>>> Auth has this function:
>>>>>>>
>>>>>>> groups(self)
>>>>>>> displays the groups and their roles for the logged in user
>>>>>>>
>>>>>>> I dont manage to get it working. I've tried something like this:
>>>>>>>
>>>>>>> def myGroups():
>>>>>>> return dict(auth.groups(auth.user_id)**)
>>>>>>>
>>>>>>> and get this error:
>>>>>>>  groups() takes exactly 1 argument (2 
>>>>>>> given)
>>>>>>>
>>>>>>> any idea on how to do this properly? Thanks!
>>>>>>>  
>>>>>>> -- 
>>>>>>>  
>>>>>>>  
>>>>>>>  
>>>>>>>
>>>>>>
>>>>>>
>>>>>  -- 
>>>>  
>>>>  
>>>>  
>>>>
>>>
>>>

-- 





[web2py] Width not working when resizing an image to use it as a submit button

2012-11-16 Thread Francisco Barretto
Hi there!

I'm having some troubles using an image as a substitute for a submit 
button...

I'm generating the form in the controller and using a local image as 
follows:
INPUT(_type="image", _value="Editar", _width="16", _height="16", _alt=
"Editar",  _src="/"+request.application+"/static/images/edit.png"),

The problem is the image is rendered with the right height but the width 
atributte seems to have absolutely no effect. The image's width is always 
210px. The funny thing is that the original hosted image is 128x128, so the 
render is resizing it with a bigger width than the original png width.

Any ideas? Thanks!


-- 





[web2py] Get request.var by it's "name"

2012-11-16 Thread Francisco Barretto
Hi there! How do I get a var value which is being passed by post into a 
controller by its name?

I mean, I don't want to get the values using request.args(0), because I'll 
be stuck with the index. I'd rather do something like 
"request.args['dnsClass'], for example.

Any hints?
vars:dnsClass:INownername:



-- 





[web2py] Re: global logging to file

2012-11-30 Thread Francisco Barretto
Hi There!

Sorry to resurrect this long time dead post but I'm really wondering what 
is the proper way to log actions, errors and warns in 
Web2Py. Tried Hans/Iceberg solution but the log file is not created... Read 
in other topic about some logging functionality integrated but found none 
in web2py book. So, any hints?

Thanks!


On Friday, June 26, 2009 6:28:01 PM UTC-3, Hans wrote:
>
> Mike, 
> instead of importing in your Web2py controller use 
> execfile('your_module.py') 
>
> In your module ... 
> try: 
>   # this variable is available in Web2Py 
>   # but raises an exception if run outside Web2Py 
>   # since its not defined 
> request.env.web2py_version 
>   # put here your web2py related code... 
>  print 'code executed in Web2py %s' % request.env.web2py_version 
> except: 
> # put here your not Web2Py related code 
>  print 'code NOT executed in Web2py environment' 
>
> #put here your general code 
> print 'this part is always executed' 
>
> Hans 
>
> On Jun 25, 10:40 pm, MikeEllis  wrote: 
> > This looks really useful. Thanks for writing it. I'm trying to import 
> > some existing python modules that have logging calls into a web2py 
> > app.  Just putting log.py into my models directory helps some, but I'm 
> > not seeing any messages from my existing modules with level lower than 
> > logging.ERROR. I am, however, getting lower level (down to 
> > logging.DEBUG) from the web2py framework.  I suspect it has something 
> > to do with the customized logger my modules are using.  I don't want 
> > to go through and comment out all the calls to my version of getLogger 
> > () because many of these modules are used by other code.  I'm 
> > wondering if there's a way for a python module to detect at runtime 
> > whether it's being imported from the web2py framework. I might then be 
> > able to make my customized logging setup do nothing when running under 
> > web2py.  Any suggestions? 
> > 
> > Thanks, 
> > Mike Ellus 
> > 
> > On Jun 25, 8:29 am, Hans  
> > wrote: 
> > 
> > > Richard, 
> > 
> > > the following solution works for me in production without any 
> > > problems. I use it for periodic, unattended functions (cron). I've 
> > > send Massimo the code in case he wants to include it into  web2py or 
> > > make it available as optional add-on download. 
> > 
> > > Hans 
> > 
> > > ''' 
> > > To use the per application log file with rotating file handler in 
> > > web2py you need to put this file (log.py) into your models folder. The 
> > > log 
> > > file itself is created in your_web2py_path/applications/ 
> > > your_application/app.log 
> > 
> > > Writing into the log file from your controller works as follows: 
> > > def my_function(): 
> > >logging.debug('my function abc is starting') 
> > >logging.error('huston we got a %s problem.' % 'major') 
> > > return 
> > 
> > > Viewing the log file through your application works as follows: 
> > > def show_log(): 
> > > return get_log() 
> > 
> > > If required the GAE solution needs work. 
> > > A BIG thank you to Iceberg! 
> > > Feedback and usage is welcome ;-) 
> > 
> > > Important note: do *not* 'importlogging' in your controller if you 
> > > use log.py. its done for all your controllers already in the log.py 
> > > model and it would break the log.py magic. 
> > > ''' 
> > 
> > > importlogging 
> > 
> > > def _init_log(level=logging.DEBUG,formatter="%(asctime)s %(levelname)s 
> > > %(funcName)s():%(lineno)d %(message) 
> > > s",filename='app.log',maxBytes=1024*1024,backupCount=2): 
> > > import os,logging.handlers 
> > > logger=logging.getLogger(request.application) 
> > > logger.setLevel(level) 
> > > if request.env.web2py_runtime_gae: # if running on Google App 
> > > Engine 
> > > handler=logging.handlers.HTTPHandler(request.env.http_host,URL 
> > > (r=request,f='log')) # assuming there is an optional log action 
> > > else: 
> > > handler=logging.handlers.RotatingFileHandler(os.path.join 
> > > (request.folder,filename),maxBytes=maxBytes,backupCount=backupCount) 
> > > handler.setLevel(level) 
> > > handler.setFormatter(logging.Formatter(formatter)) 
> > > logger.addHandler(handler) 
> > > logger.debug("web2py application %s starting" % 
> > > request.application) 
> > > return logger 
> > 
> > > def get_log(): 
> > > try: 
> > > f = open(logging.handlers[0].baseFilename, 'r') 
> > > c = f.readlines() 
> > > f.close() 
> > > return {'log':TABLE(*[TR(str(item)) for item in c])} 
> > > except: 
> > > return () 
> > 
> > > logging=cache.ram('mylog',lambda:_init_log(),time_expire=) 
> > 
> >

-- 





[web2py] Email validation url points to local host

2012-12-04 Thread Francisco Barretto
Hi there!

Trying to use email validation for new users and stuck with a problem. 
Web2Py is running in its own container and listens localhost:8000. Apache 
is dealing with incoming requests at ports 80 and 443, since I've got other 
web applications and routes web2py requests to localhost:8000 as follows:


ServerAdmin webmaster@localhost
DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug on

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128



ServerAdmin webmaster@localhost
DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug on

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128

Alias /web2py /home/www-data/web2py/applications
   ### admin requires SSL
   
 SSLRequireSSL
   
   ### appadmin requires SSL
   
 SSLRequireSSL
   
   ### serve static files directly
   
 Order Allow,Deny
 Allow from all
   
   ### proxy all the other requests
   
 Order deny,allow
 Allow from all
 ProxyPass http://localhost:8000/welcome
 ProxyPassReverse http://localhost:8000/
   
   LogFormat "%h %l %u %t %>s %b" common
   CustomLog /var/log/apache2/access.log common



   SSLEngine On
   SSLCertificateFile /etc/apache2/ssl/server.crt
   SSLCertificateKeyFile /etc/apache2/ssl/server.key
   
 Order deny,allow
 Allow from all
 ProxyPass http://localhost:8000/
 ProxyPassReverse http://localhost:8000/
   
   LogFormat "%h %l" common
   CustomLog /var/log/apache2/access.log common


So, the problem is Web2Py thinks it is running and receiving localhost 
requests and therefore sends a localhost email validation link which is 
really a mess, since the user will try to open this link at home and find a 
non-existent url:

Click on the link 
http://localhost:8000/DNSAdmin/default/user/verify_email/12c362dc-ca0e-4699-87a0-997f819ba50d
 to verify your email

Any hints? Thanks!

-- 





[web2py] Re: Email validation url points to local host

2012-12-04 Thread Francisco Barretto
Thanks, man!

On Tuesday, December 4, 2012 1:10:55 PM UTC-2, Niphlod wrote:
>
> http://web2py.com/books/default/chapter/29/09#Mail-and-Auth 
>
> auth.messages.verify_email = 'Click on the link http://' + 
> request.env.http_host + 
>  URL(r=request,c='default',f='user',args=['verify_email']) + 
> '/%(key)s to verify your email' 
>
> auth.messages.reset_password = 'Click on the link http://' + 
> request.env.http_host + 
> URL(r=request,c='default',f='user',args=['reset_password']) + '/%(key)s to 
> reset your password'
>
> replace request.env.http_host with your own and voilà.
>
>
>
> On Tuesday, December 4, 2012 4:07:36 PM UTC+1, Francisco Barretto wrote:
>>
>> Hi there!
>>
>> Trying to use email validation for new users and stuck with a problem. 
>> Web2Py is running in its own container and listens localhost:8000. Apache 
>> is dealing with incoming requests at ports 80 and 443, since I've got other 
>> web applications and routes web2py requests to localhost:8000 as follows:
>>
>> 
>> ServerAdmin webmaster@localhost
>> DocumentRoot /var/www
>> 
>> Options FollowSymLinks
>> AllowOverride None
>> 
>> 
>> Options Indexes FollowSymLinks MultiViews
>> AllowOverride None
>> Order allow,deny
>> allow from all
>> AddHandler mod_python .py
>> PythonHandler mod_python.publisher
>> PythonDebug on
>> 
>> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
>> 
>> AllowOverride None
>> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
>> Order allow,deny
>> Allow from all
>> 
>> ErrorLog /var/log/apache2/error.log
>> # Possible values include: debug, info, notice, warn, error, crit,
>> # alert, emerg.
>> LogLevel warn
>> CustomLog /var/log/apache2/access.log combined
>> Alias /doc/ "/usr/share/doc/"
>> 
>> Options Indexes MultiViews FollowSymLinks
>> AllowOverride None
>> Order deny,allow
>> Deny from all
>> Allow from 127.0.0.0/255.0.0.0 ::1/128
>> 
>>
>> 
>> ServerAdmin webmaster@localhost
>> DocumentRoot /var/www
>> 
>> Options FollowSymLinks
>> AllowOverride None
>> 
>> 
>> Options Indexes FollowSymLinks MultiViews
>> AllowOverride None
>> Order allow,deny
>> allow from all
>> AddHandler mod_python .py
>> PythonHandler mod_python.publisher
>> PythonDebug on
>> 
>> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
>> 
>> AllowOverride None
>> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
>> Order allow,deny
>> Allow from all
>> 
>> ErrorLog /var/log/apache2/error.log
>> # Possible values include: debug, info, notice, warn, error, crit,
>> # alert, emerg.
>> LogLevel warn
>> CustomLog /var/log/apache2/access.log combined
>> Alias /doc/ "/usr/share/doc/"
>> 
>> Options Indexes MultiViews FollowSymLinks
>> AllowOverride None
>> Order deny,allow
>> Deny from all
>> Allow from 127.0.0.0/255.0.0.0 ::1/128
>> 
>> Alias /web2py /home/www-data/web2py/applications
>>### admin requires SSL
>>
>>  SSLRequireSSL
>>
>>### appadmin requires SSL
>>
>>  SSLRequireSSL
>>
>>### serve static files directly
>>
>>  Order Allow,Deny
>>  Allow from all
>>
>>### proxy all the other requests
>>
>>  Order deny,allow
>>  Allow from all
>>  ProxyPass http://localhost:8000/welcome
>>  ProxyPassReverse http://localhost:8000/
>>
>>LogFormat "%h %l %u %t %>s %b" common
>>CustomLog /var/log/apache2/access.log common
>> 
>>
>> 
>>SSLEngine On
>>SSLCertificateFile /etc/apache2/ssl/server.crt
>>SSLCertificateKeyFile /etc/apache2/ssl/server.key
>>
>>  Order deny,allow
>>  Allow from all
>>  ProxyPass http://localhost:8000/
>>  ProxyPassReverse http://localhost:8000/
>>
>>LogFormat "%h %l" common
>>CustomLog /var/log/apache2/access.log common
>> 
>>
>> So, the problem is Web2Py thinks it is running and receiving localhost 
>> requests and therefore sends a localhost email validation link which is 
>> really a mess, since the user will try to open this link at home and find a 
>> non-existent url:
>>
>> Click on the link 
>> http://localhost:8000/DNSAdmin/default/user/verify_email/12c362dc-ca0e-4699-87a0-997f819ba50d
>>  to verify your email
>>
>> Any hints? Thanks!
>>
>>

-- 





[web2py] Changing textarea columns in a regular FORM

2012-12-05 Thread Francisco Barretto
Hi there, it might be (and probably is) a silly but I have a series of 
questions concerning the following form:

form=FORM(TABLE(TR("Nome:",INPUT(_type="text",_name="name", _value=user_name
, _writable=False, requires=IS_NOT_EMPTY())),
TR("Email:",INPUT(_type="text",_name="email", _value
=user_email, _writable=False, requires=IS_EMAIL())),
TR("Message:",INPUT(_type="textarea",_name="message"
, requires=IS_NOT_EMPTY())),
#TD(Recaptcha(request,__conf__.public_key(), 
__conf__.private_key())),
TR(TD(), TD(INPUT(_type="submit", _value="Send"),
INPUT(_type="button",_value="Cancel",_onclick="javascript:history.go(-1);"),INPUT
(_type="button",_value="Clear",_onclick="this.form.reset();")


1) How can I set the number of rows and columns of a textarea in a regular 
form?
2) How can I allow lines breaks ( \n ) in a textarea field? Actually when I 
hit enter, it submits the form.
3) How can I set an input textfield as non-writable? '_writable=False' 
doesnt work

Thanks!




-- 





Re: [web2py] Re: Changing textarea columns in a regular FORM

2012-12-05 Thread Francisco Barretto
Hi, Derek!

Indeed the source is readable, thanks. I had to use TEXTAREA(...) instead
of INPUT(...) in order to get _cols and _rows attributes. Couldn't manage
to edit these parameters through INPUT. There is no main problem with this
change, just a format question. The second point, is that developers in
most cases knows shift+enter creates a new line but does our final users
know it?

Francisco Barretto
Doutorando PPG-Arte - Arte e Tecnologia

Laboratório de Pesquisa em Arte Computacional (Midialab)
Departamento de Artes Visuais
Instituto de Artes
Universidade de Brasília - UnB
Campus Universitário Darcy Ribeiro
Asa Norte
70910-900, Brasília - DF

www.ciurbi.wordpress.com
www.wikinarua.com
www.tectecbaratinha.wordpress.com
www.flickr.com/photos/meiotijolo


2012/12/5 Derek 

> I'd also like to add that you should be able to find this by looking at
> the source code. In gluon/html.py. It is surprisingly readable.
>
>
> On Wednesday, December 5, 2012 9:48:23 AM UTC-7, Derek wrote:
>>
>> 1. for textarea, set _rows and _cols.
>> 2. press shift-enter instead.
>> 3. _disabled?
>>
>> On Wednesday, December 5, 2012 6:46:16 AM UTC-7, Francisco Barretto wrote:
>>>
>>> Hi there, it might be (and probably is) a silly but I have a series of
>>> questions concerning the following form:
>>>
>>> form=FORM(TABLE(TR("Nome:",INP**UT(_type="text",_name="name", _value=
>>> user_name, _writable=False, requires=IS_NOT_EMPTY())),
>>> 
>>> TR("Email:",INPUT(_type="text"**,_name="email",_value
>>> =user_email, _writable=False, requires=IS_EMAIL())),
>>> TR("Message:",INPUT(_type="**textarea",_name=
>>> "message", requires=IS_NOT_EMPTY())),
>>> #TD(Recaptcha(request,__conf__**.public_key(),
>>> __conf__.private_key())),
>>> TR(TD(), TD(INPUT(_type="submit", _value="Send"
>>> ),INPUT(_type="**button",_value="Cancel",_**onclick="javascript:history.
>>> **go(-1);"), INPUT(_type="button",_value="**Clear",_onclick="this.form.*
>>> *reset();")
>>>
>>>
>>> 1) How can I set the number of rows and columns of a textarea in a
>>> regular form?
>>> 2) How can I allow lines breaks ( \n ) in a textarea field? Actually
>>> when I hit enter, it submits the form.
>>> 3) How can I set an input textfield as non-writable? '_writable=False'
>>> doesnt work
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>>>  --
>
>
>
>

-- 





Re: [web2py] Re: Changing textarea columns in a regular FORM

2012-12-05 Thread Francisco Barretto
Anthony, you're right!

Francisco Barretto
Doutorando PPG-Arte - Arte e Tecnologia

Laboratório de Pesquisa em Arte Computacional (Midialab)
Departamento de Artes Visuais
Instituto de Artes
Universidade de Brasília - UnB
Campus Universitário Darcy Ribeiro
Asa Norte
70910-900, Brasília - DF

www.ciurbi.wordpress.com
www.wikinarua.com
www.tectecbaratinha.wordpress.com
www.flickr.com/photos/meiotijolo


2012/12/5 Anthony 

> If you want a  element, then don't use INPUT(_type='textarea')-- 
> instead it should be
> TEXTAREA(). Once you do that, hitting enter will insert a line break
> rather than submit the form, and you'll be able to set the columns and rows
> if you don't like the default size.
>
> Anthony
>
>
> On Wednesday, December 5, 2012 8:46:16 AM UTC-5, Francisco Barretto wrote:
>>
>> Hi there, it might be (and probably is) a silly but I have a series of
>> questions concerning the following form:
>>
>> form=FORM(TABLE(TR("Nome:",INP**UT(_type="text",_name="name", _value=
>> user_name, _writable=False, requires=IS_NOT_EMPTY())),
>> TR("Email:",INPUT(_type="text"**,_name="email",_value
>> =user_email, _writable=False, requires=IS_EMAIL())),
>> TR("Message:",INPUT(_type="**textarea",_name=
>> "message", requires=IS_NOT_EMPTY())),
>> #TD(Recaptcha(request,__conf__**.public_key(),
>> __conf__.private_key())),
>> TR(TD(), TD(INPUT(_type="submit", _value="Send"),
>> INPUT(_type="**button",_value="Cancel",_**onclick="javascript:history.**
>> go(-1);"), INPUT(_type="button",_value="**Clear",_onclick="this.form.**
>> reset();")
>>
>>
>> 1) How can I set the number of rows and columns of a textarea in a
>> regular form?
>> 2) How can I allow lines breaks ( \n ) in a textarea field? Actually when
>> I hit enter, it submits the form.
>> 3) How can I set an input textfield as non-writable? '_writable=False'
>> doesnt work
>>
>> Thanks!
>>
>>
>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: Changing textarea columns in a regular FORM

2012-12-05 Thread Francisco Barretto
Third question is still open. How to set an text type input non-editable?
_disabled does not work. It always fails on validation, even with a default
valid value.

Francisco Barretto
Doutorando PPG-Arte - Arte e Tecnologia

Laboratório de Pesquisa em Arte Computacional (Midialab)
Departamento de Artes Visuais
Instituto de Artes
Universidade de Brasília - UnB
Campus Universitário Darcy Ribeiro
Asa Norte
70910-900, Brasília - DF

www.ciurbi.wordpress.com
www.wikinarua.com
www.tectecbaratinha.wordpress.com
www.flickr.com/photos/meiotijolo


2012/12/5 Francisco Barretto 

> Anthony, you're right!
>
> Francisco Barretto
> Doutorando PPG-Arte - Arte e Tecnologia
>
> Laboratório de Pesquisa em Arte Computacional (Midialab)
> Departamento de Artes Visuais
> Instituto de Artes
> Universidade de Brasília - UnB
> Campus Universitário Darcy Ribeiro
> Asa Norte
> 70910-900, Brasília - DF
>
> www.ciurbi.wordpress.com
> www.wikinarua.com
> www.tectecbaratinha.wordpress.com
> www.flickr.com/photos/meiotijolo
>
>
> 2012/12/5 Anthony 
>
>> If you want a  element, then don't use INPUT(_type='textarea')-- 
>> instead it should be
>> TEXTAREA(). Once you do that, hitting enter will insert a line break
>> rather than submit the form, and you'll be able to set the columns and rows
>> if you don't like the default size.
>>
>> Anthony
>>
>>
>> On Wednesday, December 5, 2012 8:46:16 AM UTC-5, Francisco Barretto wrote:
>>>
>>> Hi there, it might be (and probably is) a silly but I have a series of
>>> questions concerning the following form:
>>>
>>> form=FORM(TABLE(TR("Nome:",INP**UT(_type="text",_name="name", _value=
>>> user_name, _writable=False, requires=IS_NOT_EMPTY())),
>>> 
>>> TR("Email:",INPUT(_type="text"**,_name="email",_value
>>> =user_email, _writable=False, requires=IS_EMAIL())),
>>> TR("Message:",INPUT(_type="**textarea",_name=
>>> "message", requires=IS_NOT_EMPTY())),
>>> #TD(Recaptcha(request,__conf__**.public_key(),
>>> __conf__.private_key())),
>>> TR(TD(), TD(INPUT(_type="submit", _value="Send"
>>> ),INPUT(_type="**button",_value="Cancel",_**onclick="javascript:history.
>>> **go(-1);"), INPUT(_type="button",_value="**Clear",_onclick="this.form.*
>>> *reset();")
>>>
>>>
>>> 1) How can I set the number of rows and columns of a textarea in a
>>> regular form?
>>> 2) How can I allow lines breaks ( \n ) in a textarea field? Actually
>>> when I hit enter, it submits the form.
>>> 3) How can I set an input textfield as non-writable? '_writable=False'
>>> doesnt work
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: Changing textarea columns in a regular FORM

2012-12-05 Thread Francisco Barretto
Works fine, Anthony!

Francisco Barretto
Doutorando PPG-Arte - Arte e Tecnologia

Laboratório de Pesquisa em Arte Computacional (Midialab)
Departamento de Artes Visuais
Instituto de Artes
Universidade de Brasília - UnB
Campus Universitário Darcy Ribeiro
Asa Norte
70910-900, Brasília - DF

www.ciurbi.wordpress.com
www.wikinarua.com
www.tectecbaratinha.wordpress.com
www.flickr.com/photos/meiotijolo


2012/12/5 Anthony 

> Try INPUT(..., _readonly='readonly') -- I think that should work in most
> browsers. Note, when you use SQLFORM with a writable=False field, web2py
> simply displays the value by itself (i.e., not within an 
> element), so you could try that approach as well.
>
> Anthony
>
>
> On Wednesday, December 5, 2012 12:17:07 PM UTC-5, Francisco Barretto wrote:
>
>> Third question is still open. How to set an text type input non-editable?
>> _disabled does not work. It always fails on validation, even with a default
>> valid value.
>>
>> Francisco Barretto
>> Doutorando PPG-Arte - Arte e Tecnologia
>>
>> Laboratório de Pesquisa em Arte Computacional (Midialab)
>> Departamento de Artes Visuais
>> Instituto de Artes
>> Universidade de Brasília - UnB
>> Campus Universitário Darcy Ribeiro
>> Asa Norte
>> 70910-900, Brasília - DF
>>
>> www.ciurbi.wordpress.com
>> www.wikinarua.com
>> www.tectecbaratinha.wordpress.**com<http://www.tectecbaratinha.wordpress.com>
>> www.flickr.com/photos/**meiotijolo<http://www.flickr.com/photos/meiotijolo>
>>
>>
>> 2012/12/5 Francisco Barretto 
>>
>>> Anthony, you're right!
>>>
>>> Francisco Barretto
>>> Doutorando PPG-Arte - Arte e Tecnologia
>>>
>>> Laboratório de Pesquisa em Arte Computacional (Midialab)
>>> Departamento de Artes Visuais
>>> Instituto de Artes
>>> Universidade de Brasília - UnB
>>> Campus Universitário Darcy Ribeiro
>>> Asa Norte
>>> 70910-900, Brasília - DF
>>>
>>> www.ciurbi.wordpress.com
>>> www.wikinarua.com
>>> www.tectecbaratinha.wordpress.**com<http://www.tectecbaratinha.wordpress.com>
>>> www.flickr.com/photos/**meiotijolo<http://www.flickr.com/photos/meiotijolo>
>>>
>>>
>>> 2012/12/5 Anthony 
>>>
>>> If you want a  element, then don't use INPUT(_type='textarea')-- 
>>> instead it should be
>>>> TEXTAREA(). Once you do that, hitting enter will insert a line break
>>>> rather than submit the form, and you'll be able to set the columns and rows
>>>> if you don't like the default size.
>>>>
>>>> Anthony
>>>>
>>>>
>>>> On Wednesday, December 5, 2012 8:46:16 AM UTC-5, Francisco Barretto
>>>> wrote:
>>>>>
>>>>> Hi there, it might be (and probably is) a silly but I have a series of
>>>>> questions concerning the following form:
>>>>>
>>>>> form=FORM(TABLE(TR("Nome:",INPUT(_type="text",_name="name", _value
>>>>> =user_name, _writable=False, requires=IS_NOT_EMPTY())),
>>>>> TR("Email:",INPUT(_type="text",_name=
>>>>> "email", _value=user_email, _writable=False, requires=IS_EMAIL())),
>>>>> TR("Message:",INPUT(_type="**tex**tarea",_name
>>>>> ="message", requires=IS_NOT_EMPTY())),
>>>>> #TD(Recaptcha(request,__conf__.public_key(),
>>>>> __conf__.private_key())),
>>>>> TR(TD(), TD(INPUT(_type="submit", _value=
>>>>> "Send"),INPUT(_type="**bu**tton",_value="Cancel",_**onclick**=
>>>>> "javascript:history.**go(-1);")**, INPUT(_type="button",_value="**C**
>>>>> lear",_onclick="this.form.**rese**t();")
>>>>>
>>>>>
>>>>> 1) How can I set the number of rows and columns of a textarea in a
>>>>> regular form?
>>>>> 2) How can I allow lines breaks ( \n ) in a textarea field? Actually
>>>>> when I hit enter, it submits the form.
>>>>> 3) How can I set an input textfield as non-writable? '_writable=False'
>>>>> doesnt work
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  --
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>  --
>
>
>
>

--