[web2py] Re: how to show login/logout auth in custom layout

2013-02-17 Thread rif
try this:

{{='auth' in globals() and auth.navbar(mode="dropdown") or ''}}

you can also remove the mode="dropdown" parameter.

-rif

duminică, 17 februarie 2013, 07:24:11 UTC+2, 黄祥 a scris:
>
> hi,
>
> i've create the custom layout using 
> http://www.cssportal.com/layout-generator/ and also the menu 
> http://www.cssportal.com/css3-menu-generator/ and tried to use it on 
> web2py application.
>
> views/custom_layout.html
> 
> 
> {{  
> response.files.append(URL('static','css/custom_layout.css'))
> response.files.append(URL('static','css/custom_menu.css'))
> response.files.append(URL('static','css/custom_footer.css'))
> }}
>
> {{include 'web2py_ajax.html'}}
> 
> 
> 
> 
> {{=MENU(response.menu, _id='menu-bar')}}
> *{{='auth' in globals()}}*
> 
> 
> 
> 
>
> the login link is not show up in my custom layout, like in default 
> layout.html the login is on upper right in drop down style, is there anyone 
> know how to show it?
>
> many thanks before.
>

-- 

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




[web2py] Re: Login does not redirect

2013-02-17 Thread António Ramos
can i get some help on this?
thk u

2013/2/14 António Ramos 

> Hello i have an app that with web2py 2.0.9 after pressing login button i
> am redirected to the index page.
> I tested my app with web2py 2.3.2 and the redirection is not done.
>
> I have after pressing login button to change the url and i´m redirected to
> index.
>
> Is this a bug?
>
> I´m using jquery mobile plugin. Do i have to check this plugin?
> I ´m using it for a long time. Maybe it need some kin of update...
>
> Or not...
>
>
> I dont know
>
> Help would be apreciated.
>
> Thank you
>

-- 

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




[web2py] Re: very important! we need to help Python

2013-02-17 Thread Alan Etkin

>
> TLTR: a private company not affiliated with python.org is trying to claim 
> copyright of the name Python in Europe for all software.
>

I found this article with more info, although I'm not sure if it's a good 
source:

http://www.guardian.co.uk/technology/2013/feb/15/python-trademark-bid

-- 

--- 
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] web2py apache2 setup with htaccess authorization

2013-02-17 Thread Chr_M
I come from a PHP background and when I wanted to have a website (or a 
part) behind a login screen (for example for beta testing) I could do that 
with a htaccess and htpasswd file (with Apache2). I have deployed a web2py 
website with Apache2, but I can not figure out how to have this website 
behind an Apache2 login. Is that possible with a web2py with Apache2 setup 
with a htaccess file? Or is there an alternative way to do in with web2py?

Thanks in advance.

Regards, Chris

-- 

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




[web2py] Re: Login does not redirect

2013-02-17 Thread Anthony
(1) Hard to help without some code.
(2) Does the problem occur without the jQuery Mobile plugin?

On Sunday, February 17, 2013 5:23:55 AM UTC-5, Ramos wrote:
>
> can i get some help on this?
> thk u
>
> 2013/2/14 António Ramos >
>
>> Hello i have an app that with web2py 2.0.9 after pressing login button i 
>> am redirected to the index page.
>> I tested my app with web2py 2.3.2 and the redirection is not done.
>>
>> I have after pressing login button to change the url and i´m redirected 
>> to index.
>>
>> Is this a bug?
>>
>> I´m using jquery mobile plugin. Do i have to check this plugin?
>> I ´m using it for a long time. Maybe it need some kin of update...
>>
>> Or not...
>>
>>
>> I dont know
>>
>> Help would be apreciated.
>>
>> Thank you 
>>
>
>

-- 

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




[web2py] Re: how to show login/logout auth in custom layout

2013-02-17 Thread 黄祥
a, it's work, thank you so much rif

-- 

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




[web2py] Re: orderby on an integer field appears to order as if field is a string

2013-02-17 Thread Neil Johnson
Thanks Massimo,

I think what happened was I coded this up without the integer tag on count, 
then realised I needed it, and added it. The first commit occurred with the 
integer tag , so as far as I could see it was always an integer.

Recreating the table fixed it

Neil

On Saturday, February 16, 2013 11:59:34 PM UTC, Neil Johnson wrote:
>
> Hello
>
> I have a query like so 
> result = db(db.tag_count.user_id == user_id).select(db.tag_count.name, 
> db.tag_count.count, orderby=~ db.tag_count.count, limitby=(0, 10))
>
> where db.tag_count is defined as 
>
> db.define_table('tag_count',
> Field('name'),
> Field('user_id', db.auth_user),
> Field('count', 'integer'),
> format='%(title)s')
>
>
> Which aims to return the rows with the highest tag counts
>
> In reality it returns the tag_count based on alphabetical rather numerical 
> order. A sample ordering might be 21, 2,12,1 i.e. 2 > 12 where I would want 
> 21,12,2,1
>
> I am using web2py 2.3.2 and SQLite
>
> Any thoughts on what I'm doing wrong?
>
> Many thanks, 
>
> Neil
>
>

-- 

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




[web2py] Re: Adding a scheduled task using the scheduler results in db error.

2013-02-17 Thread MJo
On Saturday, February 2, 2013 3:56:42 PM UTC+2, Niphlod wrote:
>
> if your db is istantiated with check_reserved=['all'] then you need to 
> fetch the gluon/scheduler.py from trunk and use that, because in 2.3.2 
> stable the column names of the scheduler's table are not compatible. 
>

What is the most elegant way to upgrade web2py? Upgrading core is easy but 
how to deal stuff inside one particular application? Now I utilized 
BeyondCompare3 to sync all those Twitter Bootstrap and so on stuff. 

Considering this Scheduler table problem, can I some how drop all affected 
tables and get new ones automatically created? Trying to stay up to date 
with latest released version, not wanting anything from the trunk.

-- 

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




[web2py] Re: change writable for each record?

2013-02-17 Thread Mark
I think this can be done in "edit" page of each record. If a record is not 
editable based on some conditions, redirect it to another page.

# In edit page of each record
if len(request.args) > 2 and request.args[-3] == 'edit':
record = db[request.args[-2]](request.args[-1])
if record_not_editable:
redirect(URL(some_where_else))


On Saturday, February 16, 2013 6:14:44 AM UTC-5, mweissen wrote:
>
> I want to change the value of "writable" depending on another field, 
> something like
>
> db.define_table('person',
> Field('name'),
> Field('test', 'boolean', writable=False),
> Field('testenable', 'boolean', default=True),
> )
> 
> db.person.test.writable = lambda v,r: r.testenable
>
> This does not work because writable must not be callable.
> Any ideas?
> Maybe something like form[0]... =  ?
>

-- 

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




[web2py] Re: web2py apache2 setup with htaccess authorization

2013-02-17 Thread Massimo Di Pierro
Why do you want to use htaccess instead of web2py own authentication. 
htaccess is such a primitive system. 


On Sunday, 17 February 2013 06:26:09 UTC-6, Chr_M wrote:
>
> I come from a PHP background and when I wanted to have a website (or a 
> part) behind a login screen (for example for beta testing) I could do that 
> with a htaccess and htpasswd file (with Apache2). I have deployed a web2py 
> website with Apache2, but I can not figure out how to have this website 
> behind an Apache2 login. Is that possible with a web2py with Apache2 setup 
> with a htaccess file? Or is there an alternative way to do in with web2py?
>
> Thanks in advance.
>
> Regards, Chris
>

-- 

--- 
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] Replace default /register and /login views

2013-02-17 Thread Alec Taylor
I am trying to replace these views with custom ones I've created.

So I have a folder called "user" with a "login.html" and a "register.html".

Putting this "user" folder in web2py//views does not make the
system use these views. Moving them to the
web2py//views/default folder also has no affect.

How do I use custom views for my auth.* stuff in web2py? (e.g.: so
@auth.requires_login() redirects to the modified views)

Thanks for all suggestions,

Alec Taylor

-- 

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




[web2py] Re: Replace default /register and /login views

2013-02-17 Thread Ron McOuat
The controller and function map to a view file so controller default and 
function user have used up those 2 levels of default view file definition.

You could set response.view = "path to html" in the user function of the 
default controller depending on arg(0) being login or register.

Ron


On Sunday, 17 February 2013 07:34:11 UTC-8, Alec Taylor wrote:
>
> I am trying to replace these views with custom ones I've created. 
>
> So I have a folder called "user" with a "login.html" and a 
> "register.html". 
>
> Putting this "user" folder in web2py//views does not make the 
> system use these views. Moving them to the 
> web2py//views/default folder also has no affect. 
>
> How do I use custom views for my auth.* stuff in web2py? (e.g.: so 
> @auth.requires_login() redirects to the modified views) 
>
> Thanks for all suggestions, 
>
> Alec Taylor 
>

-- 

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




[web2py] Re: Replace default /register and /login views

2013-02-17 Thread Anthony
By default, web2py looks for a view with the same name as the associated 
function in a folder with the same name as the associated controller. In 
the scaffolding app, auth actions are handled by the user() function in the 
default.py controller, so it will automatically use the 
/views/default/user.html view for all auth actions. If you want to set a 
custom view, you can do something like:

def user():
auth_views = dict(login='default/login.html', register=
'default/register.html')
response.view = auth_views.get(request.args(0), response.view)
return dict(form=auth())

You could also create completely separate functions for login and 
registration.

Anthony

On Sunday, February 17, 2013 10:34:11 AM UTC-5, Alec Taylor wrote:
>
> I am trying to replace these views with custom ones I've created. 
>
> So I have a folder called "user" with a "login.html" and a 
> "register.html". 
>
> Putting this "user" folder in web2py//views does not make the 
> system use these views. Moving them to the 
> web2py//views/default folder also has no affect. 
>
> How do I use custom views for my auth.* stuff in web2py? (e.g.: so 
> @auth.requires_login() redirects to the modified views) 
>
> Thanks for all suggestions, 
>
> Alec Taylor 
>

-- 

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




Re: [web2py] Re: change writable for each record?

2013-02-17 Thread Martin Weissenboeck
Thanks to all - regards, Martin.


2013/2/17 Mark 

> I think this can be done in "edit" page of each record. If a record is not
> editable based on some conditions, redirect it to another page.
>
> # In edit page of each record
> if len(request.args) > 2 and request.args[-3] == 'edit':
> record = db[request.args[-2]](request.args[-1])
> if record_not_editable:
> redirect(URL(some_where_else))
>
>
>
> On Saturday, February 16, 2013 6:14:44 AM UTC-5, mweissen wrote:
>>
>> I want to change the value of "writable" depending on another field,
>> something like
>>
>> db.define_table('person',
>> Field('name'),
>> Field('test', 'boolean', writable=False),
>> Field('testenable', 'boolean', default=True),
>> )
>>
>> db.person.test.writable = lambda v,r: r.testenable
>>
>> This does not work because writable must not be callable.
>> Any ideas?
>> Maybe something like form[0]... =  ?
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-17 Thread Martin Weissenboeck
I want to use the utf-8 character set together with pyfpdf.
On https://code.google.com/p/pyfpdf/wiki/Unicode there is pyfpdf version
1.7, which supports utf-8.
But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b

Is there any reason not to use pyfpdf 1.7 in web2py?

Regards, Martin

-- 

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




[web2py] Re: web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-17 Thread Massimo Di Pierro
I just upgraded to the latest pfdf version (had to make a change for 
compatibility). Please check it.

On Sunday, 17 February 2013 11:13:46 UTC-6, mweissen wrote:
>
> I want to use the utf-8 character set together with pyfpdf.
> On https://code.google.com/p/pyfpdf/wiki/Unicode there is pyfpdf version 
> 1.7, which supports utf-8.
> But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b
>
> Is there any reason not to use pyfpdf 1.7 in web2py?
>
> Regards, Martin
>
>
>
>

-- 

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




[web2py] Re: Setting up memcache on GAE - a basic question

2013-02-17 Thread howesc
Andy,

what is the object that you are trying to store in memcache?  this: 
PicklingError: Can't pickle : attribute lookup 
__builtin__.function failed
implies to me that you are trying to store an object that contains a 
function  (which is not pickleable).

i can't remember the exact differences, but there are some things that are 
not pickleable and can't be stored in memcache, but can be stored in 
(non-GAE) cache.ram etc.

christian

On Saturday, February 16, 2013 1:58:31 AM UTC-8, Andy W wrote:
>
> Hi howesc
>
> The stack trace from the SDK log console is:
>
> ERROR2013-02-16 09:50:09,757 restricted.py:161] Traceback (most recent 
> call last):
>
>   File "/Users/andy/www/web2py/gluon/restricted.py", line 212, in 
> restricted
>
> exec ccode in environment
>
>   File 
> "/Users/andy/www/web2py/applications/nurserymgr/controllers/student.py", 
> line 297, in 
>
>   File "/Users/andy/www/web2py/gluon/globals.py", line 193, in 
>
> self._caller = lambda f: f()
>
>   File "/Users/andy/www/web2py/gluon/tools.py", line 2929, in f
>
> return action(*a, **b)
>
>   File 
> "/Users/andy/www/web2py/applications/nurserymgr/controllers/student.py", 
> line 25, in list
>
> 3600)
>
>   File "/Users/andy/www/web2py/gluon/contrib/gae_memcache.py", line 40, in 
> __call__
>
> self.client.set(key, (time.time(), value))
>
>   File 
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py",
>  
> line 793, in set
>
> namespace=namespace)
>
>   File 
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py",
>  
> line 898, in _set_with_policy
>
> time, '', namespace)
>
>   File 
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py",
>  
> line 977, in _set_multi_async_with_policy
>
> stored_value, flags = _validate_encode_value(value, self._do_pickle)
>
>   File 
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py",
>  
> line 227, in _validate_encode_value
>
> stored_value = do_pickle(value)
>
>   File 
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py",
>  
> line 416, in _do_pickle
>
> pickler.dump(value)
>
> PicklingError: Can't pickle : attribute lookup 
> __builtin__.function failed
>
>
> INFO 2013-02-16 09:50:09,757 gaehandler.py:69]  Request: 
> 48.30ms/48.66ms (real time/cpu time)
>
> INFO 2013-02-16 09:50:09,762 recording.py:673] Saved; key: 
> __appstats__:009700, part: 79 bytes, full: 12263 bytes, overhead: 0.001 + 
> 0.004; link: http://localhost:8080/_ah/stats/details?time=1361008209709
>
> INFO 2013-02-16 09:50:09,771 dev_appserver.py:3104] "GET /student/list 
> HTTP/1.1" 500 -
>
>

-- 

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




Re: [web2py] Re: Web2py import doesn't work. It says the modules folder is not found

2013-02-17 Thread Srinath
Hi Massimo and Dana,

What I missed to notice is to have a __init__.py inside my application's
folder.

after putting it in, import started working fine.

Thanks for timely help.

Regards,

Srinath
http://about.me/srinathgs

http://about.me/srinathgs
I write code @ Alamut
Srinath G S



On Sat, Feb 16, 2013 at 11:28 PM, Dana  wrote:

> Not a direct answer but the packed up application is just a gzipped/tar
> file so you could just bypass the import function to see what the
> application looks like and see if there is a problem with paths etc.
>
>
> On Saturday, February 16, 2013 4:42:56 AM UTC-8, Srinath G S wrote:
>>
>> Hi,
>>
>> As mentioned in the subject, when I try importing any code inside the
>> modules forlder of the application's folder, it says,
>> application.modules not found.
>>
>> I tried putting __init__.py file in the modules folder. But that didn't
>> help.
>>
>> Any suggestions?
>> http://about.me/srinathgs
>> I write code @ Alamut
>> Srinath G S
>>
>>   --
>
> ---
> 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.
>
>
>

-- 

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




[web2py] Re: how to select all rows in Google Appengine, to produce a SQLFORM.grid for a whole table?

2013-02-17 Thread howesc
nice find!  note that once you have more than about 1000 rows in a table 
you'll need to have pagination turned on in smartgrid, else the request 
will time out.

On Friday, February 15, 2013 3:15:55 PM UTC-8, Luca wrote:
>
> Found: 
>
> q = db.table
>
> seems to work.  Aha! --Luca
>
> On Friday, February 15, 2013 3:03:34 PM UTC-8, Luca wrote:
>>
>> I need to form a SQLFORM.grid in Google Appengine that will select all 
>> rows. 
>> Normally, I would use something like: 
>>
>> q = (db.table.id > 0)
>> grid = SQLFORM.grid(q, ...)
>>
>> But in GAE, there are restrictions on inequality queries, so it seems 
>> silly to use an inequality to get all rows. 
>>
>> Is there a better solution? 
>>
>> Luca
>>
>

-- 

--- 
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] logging into a web2py application from another app by passing username/password

2013-02-17 Thread Amber Doctor
Currently I have an application (A) that redirects the user to a web2py 
application (B) to log in.  I want to change it so that the application A 
instead calls B with a username/password and gets back dict(user:user) 
where user is the result of auth.login_bare(username,password).  I have 
made a web2py app to mock A calling B with a Post.  I have also created the 
method in B to accept the data.   Controllers provided below.  When I make 
the call, A is correctly getting the user information based on whether or 
not B is able to log in the user.  However, when I try to navigate around 
application B's pages that are behind login, I'm told that I am not logged 
in.  

For a quick sanity check, I also created a controller marked C, that uses 
the auth.login_bare and not a POST and it works to log me into B

Can anyone please provide insight into what I need to be doing differently 
to allow A to log into B by passing username/password?


A
def test_remote_login():
form = SQLFORM(db.remote_login).process()
if form.accepted:
username = form.vars.remote_login_username
password = form.vars.remote_login_password
access_method = form.vars.access_method
import httplib, base64, urllib
params = urllib.urlencode({'username':username,
'password':password
})
base64string = base64.encodestring('%s:%s' % (username , 
password))[:-1]
username_password_combo = "Basic " + base64string
headers = {"Content-type": "application/x-www-form-urlencoded", 
"Accept": "text/plain", "Authorization": username_password_combo}
conn = httplib.HTTPConnection(task_tracker_host_defined)
connection_url = '/tasktracker3/default/remote_login' + 
access_method
conn.request("POST", connection_url, params, headers)
r1 = conn.getresponse()
data1 = r1.read()
conn.close()
response.flash='Accepted'
return locals()


B
@request.restful()
def remote_login():
def POST(username,password):
user = auth.login_bare(username,password)
return dict(user=user)
return locals()

C
def test_remote_login():
username = request.args(0)
password = request.args(1)
user = auth.login_bare(username,password)
return dict(user=user)

-- 

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




[web2py] Re: Adding a scheduled task using the scheduler results in db error.

2013-02-17 Thread Niphlod
don't know how to reply "properly"  the scheduler in "stable" has some 
column names that are incompatible with check_reserved=['all']. 
If you have a db connection with check_reserved=['all'] there's no way to 
have a working scheduler in your app.
The solution is either rely on the stable scheduler and leave out the 
check_reserved parameter or use the scheduler from trunk. 

Table migrations are handled like everything else in web2py, so there's no 
change in that behaviour regarding the update.

On Sunday, February 17, 2013 3:49:27 PM UTC+1, MJo wrote:
>
>
>
> What is the most elegant way to upgrade web2py? Upgrading core is easy but 
> how to deal stuff inside one particular application? Now I utilized 
> BeyondCompare3 to sync all those Twitter Bootstrap and so on stuff. 
>
> Considering this Scheduler table problem, can I some how drop all affected 
> tables and get new ones automatically created? Trying to stay up to date 
> with latest released version, not wanting anything from the trunk.
>

-- 

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




[web2py] Re: web2py apache2 setup with htaccess authorization

2013-02-17 Thread Chr_M
I understand it is a primitive system, but also a quick way to put a 
website behind a login. I do not want to integrate an authentication 
system, because it is only for some betatesters before the website goes 
live.

On Sunday, February 17, 2013 4:25:16 PM UTC+1, Massimo Di Pierro wrote:
>
> Why do you want to use htaccess instead of web2py own authentication. 
> htaccess is such a primitive system. 
>
>
> On Sunday, 17 February 2013 06:26:09 UTC-6, Chr_M wrote:
>>
>> I come from a PHP background and when I wanted to have a website (or a 
>> part) behind a login screen (for example for beta testing) I could do that 
>> with a htaccess and htpasswd file (with Apache2). I have deployed a web2py 
>> website with Apache2, but I can not figure out how to have this website 
>> behind an Apache2 login. Is that possible with a web2py with Apache2 setup 
>> with a htaccess file? Or is there an alternative way to do in with web2py?
>>
>> Thanks in advance.
>>
>> Regards, Chris
>>
>

-- 

--- 
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] login by ajax

2013-02-17 Thread yashar
login form is modal form inside index, and send login form via ajax to 
login() function, but i can not login.

def login():
form=auth.login()
if form.accepts(request,session=None):
return 'logged'
else: return 'failed'

below section is in index page view: 
  


Email

Password

Submit




function login(){
$.ajax({  
  type: "POST",  
url: '{{=URL('default','login')}}',  
  data: 
'email='+$('#email').val()+'&password='+$('#password').val(),
success : function(data){
if (data != 'logged){
$('#login_result').addClass('alert 
alert-error').text('Email Or password were wrong! Please try again.');
} else {
   alert('logged');
   }
}
});  

}



i also tried auth.login_bare in login() function , but it doesnt update 
session. any idea to what should i do to correct this?

-- 

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




Re: [web2py] Re: web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-17 Thread Martin Weissenboeck
I have tried it now. These are my results:

(1) A text like

English: Hello World
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
Russian: Здравствуй, Мир
Vietnamese: Xin chào thế giới
Arabic: مرحبا العالم
Hebrew:  שלום עולם

will be converted to pdf.

(2) But there are problems with right-to-left scripts:
שלום עולםis written as  םלוע םולש
مرحبا العالم   is written as ملاعلا ابحرم

(3) pdf.write_html seems to work only with latin-1
pdf.write_html("äöü") is written as "äöü", but
pdf.write_html("äöü".decode('utf-8').encode('latin-1') gives "äöü" - as
expected.

(4) pdf.write_html does not work with any "&...;" html-character
pdf.write_html(">") gives "#62;"


Maybe something should be improved...
Regards, Martin



2013/2/17 Massimo Di Pierro 

> I just upgraded to the latest pfdf version (had to make a change for
> compatibility). Please check it.
>
>
> On Sunday, 17 February 2013 11:13:46 UTC-6, mweissen wrote:
>>
>> I want to use the utf-8 character set together with pyfpdf.
>> On 
>> https://code.google.com/p/**pyfpdf/wiki/Unicodethere
>>  is pyfpdf version 1.7, which supports utf-8.
>> But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b
>>
>> Is there any reason not to use pyfpdf 1.7 in web2py?
>>
>> Regards, Martin
>>
>>
>>
>>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] Is web2py.com down today?

2013-02-17 Thread wwwgong
cannot access web2py.com today, any clue?

-- 

--- 
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] Is web2py.com down today?

2013-02-17 Thread Michele Comitini
its down

 http://www.websitedown.info/web2py.com

2013/2/17 wwwgong :
> cannot access web2py.com today, any clue?
>
> --
>
> ---
> 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.
>
>

-- 

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




[web2py] Re: logging into a web2py application from another app by passing username/password

2013-02-17 Thread Massimo Di Pierro
Hello Amber,

You do not need to reinvent the wheel for this. Web2py can do it out of the 
box.

Application B. No special code. Just any web2py application that uses Auth 
and exposes the normal default/user action.

Application A. Use decorators like @auth.requires_login() as normal but 
change 

   auth = Auth(db)

into

auth = Auth(db,cas_provider = 
'http://127.0.0.1:8000/applicaiton_B/default/user/cas')


You can read more about this here:

   http://web2py.com/books/default/chapter/29/09?search=cas_provider

If the two applications have different domains you need to add a line like 
this in application B.

auth.settings.cas_domains.append('application_A_domain.com')



On Sunday, 17 February 2013 12:43:28 UTC-6, Amber Doctor wrote:
>
> Currently I have an application (A) that redirects the user to a web2py 
> application (B) to log in.  I want to change it so that the application A 
> instead calls B with a username/password and gets back dict(user:user) 
> where user is the result of auth.login_bare(username,password).  I have 
> made a web2py app to mock A calling B with a Post.  I have also created the 
> method in B to accept the data.   Controllers provided below.  When I make 
> the call, A is correctly getting the user information based on whether or 
> not B is able to log in the user.  However, when I try to navigate around 
> application B's pages that are behind login, I'm told that I am not logged 
> in.  
>
> For a quick sanity check, I also created a controller marked C, that uses 
> the auth.login_bare and not a POST and it works to log me into B
>
> Can anyone please provide insight into what I need to be doing differently 
> to allow A to log into B by passing username/password?
>
>
> A
> def test_remote_login():
> form = SQLFORM(db.remote_login).process()
> if form.accepted:
> username = form.vars.remote_login_username
> password = form.vars.remote_login_password
> access_method = form.vars.access_method
> import httplib, base64, urllib
> params = urllib.urlencode({'username':username,
> 'password':password
> })
> base64string = base64.encodestring('%s:%s' % (username , 
> password))[:-1]
> username_password_combo = "Basic " + base64string
> headers = {"Content-type": "application/x-www-form-urlencoded", 
> "Accept": "text/plain", "Authorization": username_password_combo}
> conn = httplib.HTTPConnection(task_tracker_host_defined)
> connection_url = '/tasktracker3/default/remote_login' + 
> access_method
> conn.request("POST", connection_url, params, headers)
> r1 = conn.getresponse()
> data1 = r1.read()
> conn.close()
> response.flash='Accepted'
> return locals()
>
>
> B
> @request.restful()
> def remote_login():
> def POST(username,password):
> user = auth.login_bare(username,password)
> return dict(user=user)
> return locals()
>
> C
> def test_remote_login():
> username = request.args(0)
> password = request.args(1)
> user = auth.login_bare(username,password)
> return dict(user=user)

-- 

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




Re: [web2py] Re: web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-17 Thread Massimo Di Pierro
Bring it up with Mariano, author of fpdf. ;-)


On Sunday, 17 February 2013 14:37:03 UTC-6, mweissen wrote:
>
> I have tried it now. These are my results:
>
> (1) A text like
>
> English: Hello World
> Greek: Γειά σου κόσμος
> Polish: Witaj świecie
> Portuguese: Olá mundo
> Russian: Здравствуй, Мир
> Vietnamese: Xin chào thế giới
> Arabic: مرحبا العالم
> Hebrew:  שלום עולם
>
> will be converted to pdf.
>
> (2) But there are problems with right-to-left scripts:
> שלום עולםis written as  םלוע םולש
> مرحبا العالم   is written as ملاعلا ابحرم
>
> (3) pdf.write_html seems to work only with latin-1
> pdf.write_html("äöü") is written as "äöü", but
> pdf.write_html("äöü".decode('utf-8').encode('latin-1') gives "äöü" - as 
> expected.
>
> (4) pdf.write_html does not work with any "&...;" html-character
> pdf.write_html(">") gives "#62;"
>
>
> Maybe something should be improved...
> Regards, Martin
>
>
>
> 2013/2/17 Massimo Di Pierro >
>
>> I just upgraded to the latest pfdf version (had to make a change for 
>> compatibility). Please check it.
>>
>>
>> On Sunday, 17 February 2013 11:13:46 UTC-6, mweissen wrote:
>>>
>>>  I want to use the utf-8 character set together with pyfpdf.
>>> On 
>>> https://code.google.com/p/**pyfpdf/wiki/Unicodethere
>>>  is pyfpdf version 1.7, which supports utf-8.
>>> But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b
>>>
>>> Is there any reason not to use pyfpdf 1.7 in web2py?
>>>
>>> Regards, Martin
>>>
>>>
>>>
>>>  -- 
>>  
>> --- 
>> 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] Is web2py.com down today?

2013-02-17 Thread Massimo Di Pierro
It was unreachable at some point but I think it was a network issue. I 
could not ssh either and not is back without me taking any action.


On Sunday, 17 February 2013 16:20:24 UTC-6, Michele Comitini wrote:
>
> its down 
>
>  http://www.websitedown.info/web2py.com 
>
> 2013/2/17 wwwgong >: 
> > cannot access web2py.com today, any clue? 
> > 
> > -- 
> > 
> > --- 
> > 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] Is web2py.com down today?

2013-02-17 Thread 黄祥
already up again, right now

-- 

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




[web2py] Re: web2py apache2 setup with htaccess authorization

2013-02-17 Thread Massimo Di Pierro
Perhaps this can help?
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

Anyway you can mimic it with web2py. In a model add:

if not session.authorized:
 if request.post_vars.password == '123456': session.authorized = True
 else: raise 
HTTP(200,HTML(BODY(FORM('Password:',INPUT(_name='password'),INPUT(_type='submit'.xml())



On Sunday, 17 February 2013 13:22:20 UTC-6, Chr_M wrote:
>
> I understand it is a primitive system, but also a quick way to put a 
> website behind a login. I do not want to integrate an authentication 
> system, because it is only for some betatesters before the website goes 
> live.
>
> On Sunday, February 17, 2013 4:25:16 PM UTC+1, Massimo Di Pierro wrote:
>>
>> Why do you want to use htaccess instead of web2py own authentication. 
>> htaccess is such a primitive system. 
>>
>>
>> On Sunday, 17 February 2013 06:26:09 UTC-6, Chr_M wrote:
>>>
>>> I come from a PHP background and when I wanted to have a website (or a 
>>> part) behind a login screen (for example for beta testing) I could do that 
>>> with a htaccess and htpasswd file (with Apache2). I have deployed a web2py 
>>> website with Apache2, but I can not figure out how to have this website 
>>> behind an Apache2 login. Is that possible with a web2py with Apache2 setup 
>>> with a htaccess file? Or is there an alternative way to do in with web2py?
>>>
>>> Thanks in advance.
>>>
>>> Regards, Chris
>>>
>>

-- 

--- 
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] web2py auth question

2013-02-17 Thread jburosh
I have a web2py application and was curious how to go to the public 
website, enter username/password in a form (or iframe) and if 
authentication is successful, it would load the application into the 
browswer window.  Right now you click a login button and it redirects to 
web2py's login form.  Is there a way to securely pass auth credentials and 
log into the application and bypass the extra step?

-- 

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




Re: [web2py] Re: logging into a web2py application from another app by passing username/password

2013-02-17 Thread Amber Doctor
Hi Massimo,

I'm going to explore this option more.  Just a quick question though.  It
seems like both application A and B need to be web2py.  Is that true?
Application A isn't a web2py application.

Also I learned more about the client's criteria -- they mostly just want a
form on application A's website that has a username and password blank.  On
submit it redirects to a web2py application, authenticates the
username/password and leaves the user logged in and at a page of the web2py
application.  Will the method you described handle this or is there a
better method?


On Sun, Feb 17, 2013 at 5:22 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Hello Amber,
>
> You do not need to reinvent the wheel for this. Web2py can do it out of
> the box.
>
> Application B. No special code. Just any web2py application that uses Auth
> and exposes the normal default/user action.
>
> Application A. Use decorators like @auth.requires_login() as normal but
> change
>
>auth = Auth(db)
>
> into
>
> auth = Auth(db,cas_provider = 
> 'http://127.0.0.1:8000/applicaiton_B/default/user/cas')
>
>
> You can read more about this here:
>
>http://web2py.com/books/default/chapter/29/09?search=cas_provider
>
> If the two applications have different domains you need to add a line like
> this in application B.
>
> auth.settings.cas_domains.append('application_A_domain.com')
>
>
>
> On Sunday, 17 February 2013 12:43:28 UTC-6, Amber Doctor wrote:
>>
>> Currently I have an application (A) that redirects the user to a web2py
>> application (B) to log in.  I want to change it so that the application A
>> instead calls B with a username/password and gets back dict(user:user)
>> where user is the result of auth.login_bare(username,**password).  I
>> have made a web2py app to mock A calling B with a Post.  I have also
>> created the method in B to accept the data.   Controllers provided below.
>> When I make the call, A is correctly getting the user information based on
>> whether or not B is able to log in the user.  However, when I try to
>> navigate around application B's pages that are behind login, I'm told that
>> I am not logged in.
>>
>> For a quick sanity check, I also created a controller marked C, that uses
>> the auth.login_bare and not a POST and it works to log me into B
>>
>> Can anyone please provide insight into what I need to be doing
>> differently to allow A to log into B by passing username/password?
>>
>>
>> A
>> def test_remote_login():
>> form = SQLFORM(db.remote_login).**process()
>> if form.accepted:
>> username = form.vars.remote_login_**username
>> password = form.vars.remote_login_**password
>> access_method = form.vars.access_method
>> import httplib, base64, urllib
>> params = urllib.urlencode({'username':**username,
>>   **  'password':password
>>   **  })
>> base64string = base64.encodestring('%s:%s' % (username ,
>> password))[:-1]
>> username_password_combo = "Basic " + base64string
>> headers = {"Content-type": "application/x-www-form-**urlencoded",
>> "Accept": "text/plain", "Authorization": username_password_combo}
>> conn = httplib.HTTPConnection(task_**tracker_host_defined)
>> connection_url = '/tasktracker3/default/remote_**login' +
>> access_method
>> conn.request("POST", connection_url, params, headers)
>> r1 = conn.getresponse()
>> data1 = r1.read()
>> conn.close()
>> response.flash='Accepted'
>> return locals()
>>
>>
>> B
>> @request.restful()
>> def remote_login():
>> def POST(username,password):
>> user = auth.login_bare(username,**password)
>> return dict(user=user)
>> return locals()
>>
>> C
>> def test_remote_login():
>> username = request.args(0)
>> password = request.args(1)
>> user = auth.login_bare(username,**password)
>> return dict(user=user)
>
>  --
>
> ---
> 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.
>
>
>

-- 

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




Re: [web2py] Re: logging into a web2py application from another app by passing username/password

2013-02-17 Thread Massimo Di Pierro
Yes I assumed both apps are written in web2py. Yet the protocol it uses is 
CAS 2.0 therefore that works even if application A is not written in web2py 
as long as it suports CAS 2.0.

Another possibility is, if application A runs under apache, to use the 
server access control to delegate authentication to web2py (application B). 
For this look into web2py/scripts/access.wsgi.

On Sunday, 17 February 2013 19:10:43 UTC-6, Amber Doctor wrote:
>
> Hi Massimo, 
>
> I'm going to explore this option more.  Just a quick question though.  It 
> seems like both application A and B need to be web2py.  Is that true?  
> Application A isn't a web2py application.  
>
> Also I learned more about the client's criteria -- they mostly just want a 
> form on application A's website that has a username and password blank.  On 
> submit it redirects to a web2py application, authenticates the 
> username/password and leaves the user logged in and at a page of the web2py 
> application.  Will the method you described handle this or is there a 
> better method?
>
>
> On Sun, Feb 17, 2013 at 5:22 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> Hello Amber,
>>
>> You do not need to reinvent the wheel for this. Web2py can do it out of 
>> the box.
>>
>> Application B. No special code. Just any web2py application that uses 
>> Auth and exposes the normal default/user action.
>>
>> Application A. Use decorators like @auth.requires_login() as normal but 
>> change 
>>
>>auth = Auth(db)
>>
>> into
>>
>> auth = Auth(db,cas_provider = 
>> 'http://127.0.0.1:8000/applicaiton_B/default/user/cas')
>>
>>
>> You can read more about this here:
>>
>>http://web2py.com/books/default/chapter/29/09?search=cas_provider
>>
>> If the two applications have different domains you need to add a line 
>> like this in application B.
>>
>> auth.settings.cas_domains.append('application_A_domain.com')
>>
>>
>>
>> On Sunday, 17 February 2013 12:43:28 UTC-6, Amber Doctor wrote:
>>>
>>> Currently I have an application (A) that redirects the user to a web2py 
>>> application (B) to log in.  I want to change it so that the application A 
>>> instead calls B with a username/password and gets back dict(user:user) 
>>> where user is the result of auth.login_bare(username,**password).  I 
>>> have made a web2py app to mock A calling B with a Post.  I have also 
>>> created the method in B to accept the data.   Controllers provided below.  
>>> When I make the call, A is correctly getting the user information based on 
>>> whether or not B is able to log in the user.  However, when I try to 
>>> navigate around application B's pages that are behind login, I'm told that 
>>> I am not logged in.  
>>>
>>> For a quick sanity check, I also created a controller marked C, that 
>>> uses the auth.login_bare and not a POST and it works to log me into B
>>>
>>> Can anyone please provide insight into what I need to be doing 
>>> differently to allow A to log into B by passing username/password?
>>>
>>>
>>> A
>>> def test_remote_login():
>>> form = SQLFORM(db.remote_login).**process()
>>> if form.accepted:
>>> username = form.vars.remote_login_**username
>>> password = form.vars.remote_login_**password
>>> access_method = form.vars.access_method
>>> import httplib, base64, urllib
>>> params = urllib.urlencode({'username':**username,
>>>   **  'password':password
>>>   **  })
>>> base64string = base64.encodestring('%s:%s' % (username , 
>>> password))[:-1]
>>> username_password_combo = "Basic " + base64string
>>> headers = {"Content-type": "application/x-www-form-**urlencoded", 
>>> "Accept": "text/plain", "Authorization": username_password_combo}
>>> conn = httplib.HTTPConnection(task_**tracker_host_defined)
>>> connection_url = '/tasktracker3/default/remote_**login' + 
>>> access_method
>>> conn.request("POST", connection_url, params, headers)
>>> r1 = conn.getresponse()
>>> data1 = r1.read()
>>> conn.close()
>>> response.flash='Accepted'
>>> return locals()
>>>
>>>
>>> B
>>> @request.restful()
>>> def remote_login():
>>> def POST(username,password):
>>> user = auth.login_bare(username,**password)
>>> return dict(user=user)
>>> return locals()
>>>
>>> C
>>> def test_remote_login():
>>> username = request.args(0)
>>> password = request.args(1)
>>> user = auth.login_bare(username,**password)
>>> return dict(user=user)
>>
>>  -- 
>>  
>> --- 
>> 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" gr

Re: [web2py] Re: logging into a web2py application from another app by passing username/password

2013-02-17 Thread Amber Doctor
Thanks I'll explore this route.

On Sun, Feb 17, 2013 at 7:14 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Yes I assumed both apps are written in web2py. Yet the protocol it uses is
> CAS 2.0 therefore that works even if application A is not written in web2py
> as long as it suports CAS 2.0.
>
> Another possibility is, if application A runs under apache, to use the
> server access control to delegate authentication to web2py (application B).
> For this look into web2py/scripts/access.wsgi.
>
> On Sunday, 17 February 2013 19:10:43 UTC-6, Amber Doctor wrote:
>
>> Hi Massimo,
>>
>> I'm going to explore this option more.  Just a quick question though.  It
>> seems like both application A and B need to be web2py.  Is that true?
>> Application A isn't a web2py application.
>>
>> Also I learned more about the client's criteria -- they mostly just want
>> a form on application A's website that has a username and password blank.
>> On submit it redirects to a web2py application, authenticates the
>> username/password and leaves the user logged in and at a page of the web2py
>> application.  Will the method you described handle this or is there a
>> better method?
>>
>>
>> On Sun, Feb 17, 2013 at 5:22 PM, Massimo Di Pierro > > wrote:
>>
>>> Hello Amber,
>>>
>>> You do not need to reinvent the wheel for this. Web2py can do it out of
>>> the box.
>>>
>>> Application B. No special code. Just any web2py application that uses
>>> Auth and exposes the normal default/user action.
>>>
>>> Application A. Use decorators like @auth.requires_login() as normal but
>>> change
>>>
>>>auth = Auth(db)
>>>
>>> into
>>>
>>> auth = Auth(db,cas_provider = 
>>> 'http://127.0.0.1:8000/**applicaiton_B/default/user/cas 
>>> **')
>>>
>>>
>>> You can read more about this here:
>>>
>>>
>>> http://web2py.com/books/**default/chapter/29/09?search=**cas_provider
>>>
>>> If the two applications have different domains you need to add a line
>>> like this in application B.
>>>
>>> auth.settings.cas_domains.**append('application_A_domain.**com')
>>>
>>>
>>>
>>> On Sunday, 17 February 2013 12:43:28 UTC-6, Amber Doctor wrote:

 Currently I have an application (A) that redirects the user to a web2py
 application (B) to log in.  I want to change it so that the application A
 instead calls B with a username/password and gets back dict(user:user)
 where user is the result of auth.login_bare(username,**passw**ord).  I
 have made a web2py app to mock A calling B with a Post.  I have also
 created the method in B to accept the data.   Controllers provided below.
 When I make the call, A is correctly getting the user information based on
 whether or not B is able to log in the user.  However, when I try to
 navigate around application B's pages that are behind login, I'm told that
 I am not logged in.

 For a quick sanity check, I also created a controller marked C, that
 uses the auth.login_bare and not a POST and it works to log me into B

 Can anyone please provide insight into what I need to be doing
 differently to allow A to log into B by passing username/password?


 A
 def test_remote_login():
 form = SQLFORM(db.remote_login).**proce**ss()
 if form.accepted:
 username = form.vars.remote_login_**usernam**e
 password = form.vars.remote_login_**passwor**d
 access_method = form.vars.access_method
 import httplib, base64, urllib
 params = urllib.urlencode({'username':**u**sername,
     'password':password
     })
 base64string = base64.encodestring('%s:%s' % (username ,
 password))[:-1]
 username_password_combo = "Basic " + base64string
 headers = {"Content-type": "application/x-www-form-**urlenc**oded",
 "Accept": "text/plain", "Authorization": username_password_combo}
 conn = httplib.HTTPConnection(task_**tr**acker_host_defined)
 connection_url = '/tasktracker3/default/remote_login' +
 access_method
 conn.request("POST", connection_url, params, headers)
 r1 = conn.getresponse()
 data1 = r1.read()
 conn.close()
 response.flash='Accepted'
 return locals()


 B
 @request.restful()
 def remote_login():
 def POST(username,password):
 user = auth.login_bare(username,**passw**ord)
 return dict(user=user)
 return locals()

 C
 def test_remote_login():
 username = request.args(0)
 password = request.args(1)
 user = auth.login_bare(username,**passw**ord)
 return dict(user=user)
>>>
>>>  --
>>>
>>> ---
>>> You received this message because you a

[web2py] Re: login by ajax

2013-02-17 Thread Anthony

>
> def login():

form=auth.login()
> if form.accepts(request,session=None):
>

auth.login() already handles form processing, so you should not call 
form.accepts(), as that will not work.
 

>   
> 
> 
> Email
> 
> Password
>  placeholder="*">
> Submit
> 
> 
>

web2py SQLFORM's (including the auth forms) include hidden _formname and 
_formkey fields -- if you're creating a custom form, you need to include 
those, or the form will not pass validation when submitted. If you want to 
create a custom form based on a SQLFORM, you should follow 
http://web2py.com/books/default/chapter/29/07#Custom-forms.

Also, rather than manually submitting the form via Ajax, you might consider 
putting the login form in an Ajax component (or even a non-Ajax component 
with ajax_trap set to True). In that case, web2py.js will handle the Ajax 
submission for you. In that case, you may want to create a login_onaccept 
function to avoid the usual post-login redirect (which wouldn't be useful 
for an Ajax login).

Anthony

-- 

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




[web2py] Re: login by ajax

2013-02-17 Thread Massimo Di Pierro
Should we offer something like {{=auth.ajax_login()}} helper which submits 
to /user/login? If would not be difficult to write. 
How should it work?




On Sunday, 17 February 2013 21:37:59 UTC-6, Anthony wrote:
>
> def login():
>
> form=auth.login()
>> if form.accepts(request,session=None):
>>
>
> auth.login() already handles form processing, so you should not call 
> form.accepts(), as that will not work.
>  
>
>>   
>> 
>> 
>> Email
>> 
>> Password
>> > placeholder="*">
>> Submit
>> 
>> 
>>
>
> web2py SQLFORM's (including the auth forms) include hidden _formname and 
> _formkey fields -- if you're creating a custom form, you need to include 
> those, or the form will not pass validation when submitted. If you want to 
> create a custom form based on a SQLFORM, you should follow 
> http://web2py.com/books/default/chapter/29/07#Custom-forms.
>
> Also, rather than manually submitting the form via Ajax, you might 
> consider putting the login form in an Ajax component (or even a non-Ajax 
> component with ajax_trap set to True). In that case, web2py.js will handle 
> the Ajax submission for you. In that case, you may want to create a 
> login_onaccept function to avoid the usual post-login redirect (which 
> wouldn't be useful for an Ajax login).
>
> Anthony
>

-- 

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




[web2py] Re: login by ajax

2013-02-17 Thread yashar
thank you, i solve the problem like this:

def index():
form = auth.login()
form.elements('input',_type='submit')[0]['_Onclick']='login();return 
false;'
return dict(form=form)

def login():
if not auth.login_bare(request.vars.email,request.vars.password):
return 'login failed'
form=auth.login()
if auth.user : return 'logged'
return dict(form=form)

and in the index view:


{{=form}}


function login(){
alert('here');
$.ajax({  
  type: "POST",  
url: '{{=URL('default','login')}}',  
  data: $('form').serialize(),
success : function(data){
if (data != 'True'){
$('#login_result').addClass('alert 
alert-error').text('Email Or password were wrong! Please try again.');
} else {
   
   }
}
});  
return false;
}




-- 

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




[web2py] Re: login by ajax

2013-02-17 Thread yashar
is there any way that i log in user by code?

for example after checking username and password with login_bare, i push 
the user into the session as logged in user? in this case there is no need 
to write ajax/login directly, and the programmer has a better control.

if i write :
def login():

-- 

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




Re: [web2py] Re: web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-17 Thread Martin Weissenboeck
ok, I'll do it.


2013/2/18 Massimo Di Pierro 

> Bring it up with Mariano, author of fpdf. ;-)
>
>
> On Sunday, 17 February 2013 14:37:03 UTC-6, mweissen wrote:
>
>> I have tried it now. These are my results:
>>
>> (1) A text like
>>
>> English: Hello World
>> Greek: Γειά σου κόσμος
>> Polish: Witaj świecie
>> Portuguese: Olá mundo
>> Russian: Здравствуй, Мир
>> Vietnamese: Xin chào thế giới
>> Arabic: مرحبا العالم
>> Hebrew:  שלום עולם
>>
>> will be converted to pdf.
>>
>> (2) But there are problems with right-to-left scripts:
>> שלום עולםis written as  םלוע םולש
>> مرحبا العالم   is written as ملاعلا ابحرم
>>
>> (3) pdf.write_html seems to work only with latin-1
>> pdf.write_html("äöü") is written as "äöü", but
>> pdf.write_html("äöü".decode('**utf-8').encode('latin-1') gives "äöü" -
>> as expected.
>>
>> (4) pdf.write_html does not work with any "&...;" html-character
>> pdf.write_html(">") gives "#62;"
>>
>>
>> Maybe something should be improved...
>> Regards, Martin
>>
>>
>>
>> 2013/2/17 Massimo Di Pierro 
>>
>>> I just upgraded to the latest pfdf version (had to make a change for
>>> compatibility). Please check it.
>>>
>>>
>>> On Sunday, 17 February 2013 11:13:46 UTC-6, mweissen wrote:

  I want to use the utf-8 character set together with pyfpdf.
 On 
 https://code.google.com/p/**pyfp**df/wiki/Unicodethere
  is pyfpdf version 1.7, which supports utf-8.
 But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b

 Is there any reason not to use pyfpdf 1.7 in web2py?

 Regards, Martin



  --
>>>
>>> ---
>>> 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] Re: Setting up memcache on GAE - a basic question

2013-02-17 Thread Andy W
Thanks for the feedback Christian.

It seems to be this that causes the problem on GAE but works on sqlite:

students = cache.ram('students',
lambda:db(db.student.id>0).select(db.student.id, 
db.student.family_name,
...
db.student.student_age),
3600)

Any ideas?

Thanks,
Andy

>
>>

-- 

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




Re: [web2py] Re: Replace default /register and /login views

2013-02-17 Thread Alec Taylor
Thanks

On Mon, Feb 18, 2013 at 3:49 AM, Anthony  wrote:
> By default, web2py looks for a view with the same name as the associated
> function in a folder with the same name as the associated controller. In the
> scaffolding app, auth actions are handled by the user() function in the
> default.py controller, so it will automatically use the
> /views/default/user.html view for all auth actions. If you want to set a
> custom view, you can do something like:
>
> def user():
> auth_views = dict(login='default/login.html',
> register='default/register.html')
> response.view = auth_views.get(request.args(0), response.view)
> return dict(form=auth())
>
> You could also create completely separate functions for login and
> registration.
>
> Anthony
>
> On Sunday, February 17, 2013 10:34:11 AM UTC-5, Alec Taylor wrote:
>>
>> I am trying to replace these views with custom ones I've created.
>>
>> So I have a folder called "user" with a "login.html" and a
>> "register.html".
>>
>> Putting this "user" folder in web2py//views does not make the
>> system use these views. Moving them to the
>> web2py//views/default folder also has no affect.
>>
>> How do I use custom views for my auth.* stuff in web2py? (e.g.: so
>> @auth.requires_login() redirects to the modified views)
>>
>> Thanks for all suggestions,
>>
>> Alec Taylor
>
> --
>
> ---
> 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.
>
>

-- 

--- 
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] auth.settings.login_next has no functionality?

2013-02-17 Thread Alec Taylor
How do I redirect to a different page on login?

Here's what I've tried: auth.settings.login_next = URL('profile')

Thanks for all suggestions,

Alec Taylor

-- 

--- 
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] How to get request.args from an index() function?

2013-02-17 Thread Alec Taylor
I can't get the request.args from an index function.

E.g.: within app 'fruit' I have a controller 'salad', like so:

# web2py/applications/fruit/controllers/salad.py
def index()
print request.args
return dict()

# curl -X GET localhost/fruit/salad/foo

# web2py console output:
[]

How to get request.args from an index() function?

Thanks for all suggestions,

Alec Taylor

-- 

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