[web2py] Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Hassan Alnatour
Dear All ,

How Can I Render HTML & CSS & Python code The are Retrieved from the
database ?


Best Regards ,


[web2py] Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Hassan Alnatour
Dear All ,

How Can I Render HTML & CSS & Python code The are Retrieved from the
database ?


Best Regards ,


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread Rahul
okay - Here are a few reasons - 

*@Anthony *- What exactly is it that you are trying to hide? Can you give 
an example?

Here is the example - 
Please consider the below view page source (form when serialized) line when 
I have filled up a form * using a database for my software BugBuster* in 
this case - This is going to be a* post *method -  All the variables are 
shown filled in before the "submit" is done actually. Now it could be very 
easy to pass wrong values using some hacking techniques by malicious people 
(inshort hackers) and send wrong information into the database. 

It is this kind of thing I need to prevent one from doing to my 
application. Please don't get me wrong - I ain't any paranoid when it comes 
to security. Its just that thing,  that I need to make sure that my clients 
feel secure when they are using my application in production (online). I 
dont care if others are able to see parameters for trivial comments posting 
or blogs there off but when it comes to enterprise level security, I think 
we should provide such stuff or at least a way to conceal the information 
being passed. 
Even clients feel confident that such things are being taken care by the 
software itself. I know validations can take care of this to some extent 
but that would eventually be an overkill during post method. And we cannot 
have it for each field anyways. 

*


Ticket No: Team: 
BaseAssets Team
Wealth 
Management

Date Today: 



Category: 


Base System

Sub 
Category: 

Contact 
Manager
Manager: 

John 
Stiefeling

Developer: 
FarzadShantanu

Tester: 


TanviPotnis

Severity: 
CriticalHigh
LowMediumTrivial

Status: 


AFFAcknowledgedApproved
ClosedCode Review
DeferredFixedOpen
OtherPre-Approved
Re-OpenedTested
Type: 
GenericSchema Change

Branches: 


Mainstream
Modified 
Date: 
2012-03-12
Created By: 

sysadmin
Workspace: 

Base
Description: 


Checkin Details: 


Comments: 



Attach File: 




*

--> Also note here I am not exactly trying to lock "View page source" for 
the end users, they may be able to do it as per default browsers 
functionality but rather would see something  very clean and no parameters 
like below pyjamas example view serailized. 

*



PyJamas Auto-Generated HTML file TimeSheet


http://pyjs.org/examples/timesheet/output/bootstrap.js>">


*


--> The above line  *  * is *just a thought*
some html tag could be defined or supported in HTML5 or above  or *even in 
may be web2py 2.0 *that would toggle secure page view and unsecure page 
view ... 
if secure is *True* - users would see some stuff very basic like above 
pyjamas example when viewing page source 
else as usual - normal view page source (what it shows currently) 

I hope I am clear this time and not causing confusions :) 
Thanks, 

Sincerely, Rahul D (www.flockbird.com)
===


On Sunday, March 11, 2012 5:54:23 AM UTC+5:30, pbreit wrote:
>
> Sliverlight works on all browsers as far as I know. But I still don't 
> think it's a very smart platform to target for the vast majority of apps.



[web2py] web2py recipe book

2012-03-12 Thread Massimo Di Pierro
The web2py recipes book is finally out:

http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book

Congratulations to all those who contributed.

Massimo


Re: [web2py] Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Bruno Rocha
On controller

from gluon.template import render

def myaction():
template = db(query).select().first().template_field
data = dict(key="value",...)
return render(template, context=data)

On terminal:
$ python web2py.py -S welcome -M

In [14]: from gluon.template import render
In [15]: template = "Hello {{=name}}"
In [16]: data = dict(name="Bruno")
In [17]: print render(template, context=data)
Hello Bruno





On Mon, Mar 12, 2012 at 4:08 AM, Hassan Alnatour  wrote:

> Dear All ,
>
> How Can I Render HTML & CSS & Python code The are Retrieved from the
> database ?
>
>
> Best Regards ,
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] web2py recipe book

2012-03-12 Thread Bruce Wade
This isn't going to be like the other book right? Where I bought it then
the next day it was available for free online.

On Mon, Mar 12, 2012 at 12:18 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The web2py recipes book is finally out:
>
>
> http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book
>
> Congratulations to all those who contributed.
>
> Massimo
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread weheh
>From what I've read and tinkered with myself, it doesn't seem possible
to prevent others from finding a way to view your html source. My
observation is that you usually trade off security vs. ease of use.
The more locked doors and alarms, the more annoying your system
becomes for the typical user. I prefer an open door policy, myself. As
others have mentioned, on the web, don't publish what you don't want
others to take. One thing that crosses my mind is that you might try
generating pdf on the fly for your pages. I haven't tried the pdf
output capability from web2py, so I don't know how useful it would be
if you had graphics or video, but you might want to check it out. Good
luck and let us know what you come up with. Seems like there are a
bunch of smart folks here who are interested in knowing if there's an
answer to this question.


Re: [web2py] web2py recipe book

2012-03-12 Thread lyn2py
Any idea if future updates to the book will be free if the ebook version is 
purchased?

Thanks!


[web2py] Picture Gallery

2012-03-12 Thread Praveen Bhat
Hello,

Can someone give me a simple example for Photo Gallery with Sliding content?

Thanks in advance!!!

Regards
Praveen


[web2py] Re: Picture Gallery

2012-03-12 Thread peter
If you look in pugin_wiki, you will see slideshow.



On Mar 12, 9:36 am, Praveen Bhat  wrote:
> Hello,
>
> Can someone give me a simple example for Photo Gallery with Sliding content?
>
> Thanks in advance!!!
>
> Regards
> Praveen


[web2py] Re: Picture Gallery

2012-03-12 Thread Praveen Bhat
Hello Peter,

I see the following:

 def 
slideshow(links=None,table=None,field='image',transition='fade',width=200,height=200):
"""
## Embeds a slideshow
It gets the images from a table

- ``table`` is the table name
- ``field`` is the upload field in the table that contains images
- ``transition`` determines the type of transition, e.g. fade, etc.
- ``width`` is the width of the image
- ``height`` is the height of the image
"""

import random
id=str(random.random())[2:]
if table:
rows = db(db[table].id>0).select()
if db[table][field].type=='upload':
images = [IMG(_src=URL('default','download',args=row[field])) for row in 
rows]
else:
images = [IMG(_src=row[field]) for row in rows]
elif links:
images = [IMG(_src=link) for link in links.split(',')]
else:
images = []
return DIV(SCRIPT("jQuery(document).ready(function() 
{jQuery('#slideshow%s').cycle({fx: '%s'});});" % 
(id,transition)),DIV(_id='slideshow'+id,*images))


But how do I use it in my pages?

Regards,
Praveen

On Monday, March 12, 2012 3:28:28 PM UTC+5:30, peter wrote:
>
> If you look in pugin_wiki, you will see slideshow. 
>
>
>
> On Mar 12, 9:36 am, Praveen Bhat  wrote: 
> > Hello, 
> > 
> > Can someone give me a simple example for Photo Gallery with Sliding 
> content? 
> > 
> > Thanks in advance!!! 
> > 
> > Regards 
> > Praveen



Re: [web2py] using form in same page?

2012-03-12 Thread Martín Mulone
To edit an image you need to pass the id of the row to SQLFORM.

Ex.:
row_id = 1
form = SQLFORM(db.ref, row_id)

2012/3/11 juvi1 

> thanks, but now form create always new image in database, and i want
> update image.
> how it can be done??
>
> sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti:
>
>> I don't know why you have two {{pass}} in your view. I think you can do:
>>
>> def jobs():
>> images=db().select(db.ref.id,**db.ref.file)
>> form = SQLFORM(db.ref)
>> if form.process().accepted:
>> response.flash = "Image uploaded"
>>
>> return dict(form=form, images=images)
>>
>> in views:
>> {{for img in images:}}
>>>  src="{{=URL('download', args=img.file)}}" />
>>  
>> {{=img}}
>> {{=img.id}}
>> {{=form}}
>> {{pass}}
>>
>> 2012/3/11 juvi1 
>>
>>> Hello sorry my bad english and i hope that you understand my problem.
>>>
>>> I want show in one page all pictures which are saved in database.
>>> In page i want that i can upload new picture and update it whit forms
>>> (override old one)
>>> My code are
>>>
>>> in controller:
>>> def jobs():
>>> images=db().select(db.ref.id,**db.ref.file)
>>> for img in  images:
>>> formname = "upload_f_%s"%img.id
>>> form = FORM(INPUT(_type="file",_name=**formname),
>>> INPUT(_type='submit'))
>>>
>>> if form.accepts(request.vars, _name=formname):
>>> response.flash = form.vars
>>>
>>> return dict(form=form, img=img, formname=formname, images=images)
>>>
>>> in views:
>>> {{for img in images:}}
>>>>>  src="{{=URL('download', args=img.file)}}" />
>>>  
>>> {{=img}}
>>> {{formname=img.id}}
>>> {{=formname}}
>>> {{=form}}
>>> {{pass}}{{pass}}
>>>
>>> please help!
>>>
>>
>>
>>
>> --
>>  http://www.tecnodoc.com.ar
>>
>>


-- 
 http://www.tecnodoc.com.ar


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread LightDot
This two examples you have given, from your web2py form and from pyjamas, 
are they functionally equivalent? If they are, please post the javascript 
for both pages too, so that we can really compare.

When you mention this secure tag in html5 or web2py 2.0, it seems to me 
that you are still going the wrong way about this issue. What would this 
"secure" tag actually do? If you want it to compile python to javascript, I 
think there is no point in using web2py at all, as there are other projects 
for that. And that wouldn't make your code any more secure anyway, just 
different. Or do you expect it to include and trigger a javascript that 
hides the html source...?

Again, hiding something trivially from the user's view is *not* security 
and should never be considered as such. It takes seconds to get around this.

Some of the basics of web development security are:
- you cannot trust anything that comes from the user side, all data 
received should be validated
- you should not send anything to user side that you don't want the user to 
see.

If you really need to send such information as "*issues_created_by" 
"sysadmin" *trough the form, than it's a fact that users will see them. If 
you are worried that someone will try to change this and it shouldn't, than 
there are two things you can do:
- don't send this trough a form at all (why would you..?)
- validate the information before committing into the db and make sure it's 
still correct.

There are no shortcuts here, no magical "secure" tags that can make these 
requirements go away. You need to design you application accordingly.

On Monday, March 12, 2012 8:11:43 AM UTC+1, Rahul wrote:
>
> okay - Here are a few reasons - 
>
> *@Anthony *- What exactly is it that you are trying to hide? Can you give 
> an example?
>
> Here is the example - 
> Please consider the below view page source (form when serialized) line 
> when I have filled up a form * using a database for my software BugBuster*in 
> this case - This is going to be a
> * post *method -  All the variables are shown filled in before the 
> "submit" is done actually. Now it could be very easy to pass wrong values 
> using some hacking techniques by malicious people (inshort hackers) and 
> send wrong information into the database. 
>
> It is this kind of thing I need to prevent one from doing to my 
> application. Please don't get me wrong - I ain't any paranoid when it comes 
> to security. Its just that thing,  that I need to make sure that my clients 
> feel secure when they are using my application in production (online). I 
> dont care if others are able to see parameters for trivial comments posting 
> or blogs there off but when it comes to enterprise level security, I think 
> we should provide such stuff or at least a way to conceal the information 
> being passed. 
> Even clients feel confident that such things are being taken care by the 
> software itself. I know validations can take care of this to some extent 
> but that would eventually be an overkill during post method. And we cannot 
> have it for each field anyways. 
>
> *
> 
> 
> Ticket No:  id="issues_ticket_no" name="ticket_no" type="text"
> value="" /> class="w2p_fl"> id="issues_team__label">Team:  class="string" id="issues_team" name="team">
> Base value="Assets Team">Assets Team
> Wealth 
> Management
> 
> Date Today: 
> 
>  name="date_today" type="text" value="2012-03-12" />
>  class="w2p_fl">
> Category: 
> 
>  value="">
> Base System class="w2p_fc">
> 
> Sub 
> Category: 
>  name="sub_category">
> Contact 
> Manager
>  for="issues_manager" id="issues_manager__label">Manager: 
>  name="manager">
> John 
> Stiefeling
>  for="issues_developer" id="issues_developer__label">
> Developer:  id="issues_developer" name="developer">
> Farzad value="Shantanu">Shantanu
>  class="w2p_fl">
> Tester: 
> 
> 
> TanviPotnis class="w2p_fc">
>  for="issues_severity" id="issues_severity__label">
> Severity:  id="issues_severity" name="severity">
>  value="Critical">CriticalHigh
> Low value="Medium">MediumTrivial
>  class="w2p_fl">
> Status: 
> 
>  value="">
> AFFAcknowledged value="Approved">Approved
> ClosedCode Review
> Deferred value="Fixed">FixedOpen
> Other value="Pre-Approved">Pre-Approved
> Re-Opened value="Tested">Tested
>  class="w2p_fl"> id="issues_type__label">Type:  class="string" id="issues_type" name="type">
> Generic value="Schema Change">Schema Change
>  id="issues_branches__row">
> Branches: 
> 
>  value="">
> Mainstream id="issues_modified_date__row">
>  id="issues_modified_date__label">Modified Date:  class="w2p_fw">
> 2012-03-12 id="issues_created_by__row">
> Created By: 
> 
> sysadmin id="issues_workspace__row">
> Workspace: 
> 
> Base id="issues_description__row">
>  id="issues_description__label">Description: 
>  id="issues_description" name="description" rows="10">
>  id="issues_checkin_details__row">
>  id="issues_checkin_details__label">Checkin Details: 
>  id="issues_checkin_details" name="checkin_details" rows=

[web2py] Web2py cookbook

2012-03-12 Thread bussiere bussiere
Does anyone know when the web2py cookbook will be available please ?

Regards
Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY


Re: [web2py] Re: Custom register form with personnalised Auth

2012-03-12 Thread bussiere bussiere
Thanks again

regards
Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY




On Mon, Mar 12, 2012 at 1:43 AM, Massimo Di Pierro
 wrote:
> you the fields you do not want to db.table.field.writeable=False and the use
> the regular SQLFORM(db.table)
>
>
> On Sunday, 11 March 2012 11:15:41 UTC-5, bussiere adrien wrote:
>>
>> here is my auth table :
>> (the beginning my table is correct)
>> db.define_table(
>>     auth.settings.table_user_name,
>>    Field('Nom'),
>>    Field('Prenom'),
>>    Field('Telephone'),
>>    # NOte on user is intern and the user don't hve to see it.
>>    Field('Note on user'),
>>
>> How to make a custom sqlform from it ?
>> like :
>> def user():
>>     # i just want some things what is needed (passwd name and all but NOT
>> note on user on the form
>>     form = SQLFORM([auth.settings.Nom,auth.settings.Prenom])
>>     return dict(form=form)
>>
>> Regards
>> Bussiere


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread LightDot
This two examples you have given, from your web2py form and from pyjamas, 
are they functionally equivalent? If they are, please post the javascript 
for both pages too, so that we can really compare.

When you mention this secure tag in html5 or web2py 2.0, it seems to me 
that you are still going the wrong way about this issue. What would this 
"secure" tag actually do? If you want it to compile python to javascript, I 
think there is no point in using web2py at all, as there are other projects 
for that. And that wouldn't make your code any more secure anyway, just 
different. Or do you expect it to trigger a javascript that hides the html 
source...?

Again, hiding something trivially from the user's view is *not* security 
and should never be considered as such. It takes seconds to get around this.

Some of the basics of web development security are:
- you cannot trust anything that comes from the user side, all data 
received should be validated
- you should not send anything to user side that you don't want the user to 
see.

If you really need to send such information as "issues_created_by" 
"sysadmin" trough the form, than you must expect that users will see them. 
If you are worried that someone will try to change this and it shouldn't, 
than there are two things you can do:
- don't send this trough a form at all (why would you..?)
- validate the information before committing into the db and make sure it's 
still correct.

There are no shortcuts here, no magical "secure" tags that can make these 
requirements go away. You need to design your application accordingly, no 
matter what framework you use.

On Monday, March 12, 2012 8:11:43 AM UTC+1, Rahul wrote:
>
> okay - Here are a few reasons - 
>
> *@Anthony *- What exactly is it that you are trying to hide? Can you give 
> an example?
>
> Here is the example - 
> Please consider the below view page source (form when serialized) line 
> when I have filled up a form * using a database for my software BugBuster*in 
> this case - This is going to be a
> * post *method -  All the variables are shown filled in before the 
> "submit" is done actually. Now it could be very easy to pass wrong values 
> using some hacking techniques by malicious people (inshort hackers) and 
> send wrong information into the database. 
>
> It is this kind of thing I need to prevent one from doing to my 
> application. Please don't get me wrong - I ain't any paranoid when it comes 
> to security. Its just that thing,  that I need to make sure that my clients 
> feel secure when they are using my application in production (online). I 
> dont care if others are able to see parameters for trivial comments posting 
> or blogs there off but when it comes to enterprise level security, I think 
> we should provide such stuff or at least a way to conceal the information 
> being passed. 
> Even clients feel confident that such things are being taken care by the 
> software itself. I know validations can take care of this to some extent 
> but that would eventually be an overkill during post method. And we cannot 
> have it for each field anyways. 
>
> *
> 
> 
> Ticket No:  id="issues_ticket_no" name="ticket_no" type="text"
> value="" /> class="w2p_fl"> id="issues_team__label">Team:  class="string" id="issues_team" name="team">
> Base value="Assets Team">Assets Team
> Wealth 
> Management
> 
> Date Today: 
> 
>  name="date_today" type="text" value="2012-03-12" />
>  class="w2p_fl">
> Category: 
> 
>  value="">
> Base System class="w2p_fc">
> 
> Sub 
> Category: 
>  name="sub_category">
> Contact 
> Manager
>  for="issues_manager" id="issues_manager__label">Manager: 
>  name="manager">
> John 
> Stiefeling
>  for="issues_developer" id="issues_developer__label">
> Developer:  id="issues_developer" name="developer">
> Farzad value="Shantanu">Shantanu
>  class="w2p_fl">
> Tester: 
> 
> 
> TanviPotnis class="w2p_fc">
>  for="issues_severity" id="issues_severity__label">
> Severity:  id="issues_severity" name="severity">
>  value="Critical">CriticalHigh
> Low value="Medium">MediumTrivial
>  class="w2p_fl">
> Status: 
> 
>  value="">
> AFFAcknowledged value="Approved">Approved
> ClosedCode Review
> Deferred value="Fixed">FixedOpen
> Other value="Pre-Approved">Pre-Approved
> Re-Opened value="Tested">Tested
>  class="w2p_fl"> id="issues_type__label">Type:  class="string" id="issues_type" name="type">
> Generic value="Schema Change">Schema Change
>  id="issues_branches__row">
> Branches: 
> 
>  value="">
> Mainstream id="issues_modified_date__row">
>  id="issues_modified_date__label">Modified Date:  class="w2p_fw">
> 2012-03-12 id="issues_created_by__row">
> Created By: 
> 
> sysadmin id="issues_workspace__row">
> Workspace: 
> 
> Base id="issues_description__row">
>  id="issues_description__label">Description: 
>  id="issues_description" name="description" rows="10">
>  id="issues_checkin_details__row">
>  id="issues_checkin_details__label">Checkin Details: 
>  id="issues_checkin_details" na

[web2py] Re: Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Hassan Alnatour
it renders the python code but it dosent render the html code in the
view  so i can see the html code !


[web2py] Re:

2012-03-12 Thread Wikus van de Merwe
What exactly are you trying to do? Why you don't use the URL function?


[web2py] Re: Differentiating between URLs in web2py controllers

2012-03-12 Thread Saurabh Kumar
Hi,

Thanks a lot for the replies.

Actually we are implementing FB login for our app. For this we want to 
detect whether /user/login controller was a redirect from facebook (after 
authentication) or a a user noramlly opened /user/login in their browser.

Sometimes FB reidrects to /user/login#_=_ and sometimes to 
/user/login?code=

[
"Change in Session Redirect Behavior. This week, we started adding a 
fragment #_=_ to the redirect_uri when this field is left blank. Please 
ensure that your app can handle this behavior."

https://developers.facebook.com/blog/post/552/ 


]

How can I differentiate b/w the two?

Saurabh


On Sunday, March 11, 2012 1:26:19 AM UTC+5:30, pbreit wrote:
>
> As Anthony noted, what you are showing won't work. What are you trying to 
> do?
>
> You can include any code you want in the user() function.
>


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread dr_v
Especially for posted values and such the source is less interesting.
Anything that is transmitted via http can be logged (and tricked!)
with tools like Charles or Fiddler anyway. This even holds for e.g.
flash based web apps except if you encrypt values before sending them.

On 12 Mrz., 10:30, weheh  wrote:
> From what I've read and tinkered with myself, it doesn't seem possible
> to prevent others from finding a way to view your html source. My
> observation is that you usually trade off security vs. ease of use.
> The more locked doors and alarms, the more annoying your system
> becomes for the typical user. I prefer an open door policy, myself. As
> others have mentioned, on the web, don't publish what you don't want
> others to take. One thing that crosses my mind is that you might try
> generating pdf on the fly for your pages. I haven't tried the pdf
> output capability from web2py, so I don't know how useful it would be
> if you had graphics or video, but you might want to check it out. Good
> luck and let us know what you come up with. Seems like there are a
> bunch of smart folks here who are interested in knowing if there's an
> answer to this question.


Re: [web2py] Re: Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Bruno Rocha
when you do return render(...) it renders the python code into html text
markup.

the browser is the responsible for rendering this markup.

or you can try to output this as pdf using pyfpdf.

what are you trying to do?

http://zerp.ly/rochacbruno
Em 12/03/2012 07:31, "Hassan Alnatour" 
escreveu:

> it renders the python code but it dosent render the html code in the
> view  so i can see the html code !
>


Re: [web2py] using form in same page?

2012-03-12 Thread juvi1



Sry. I dont understand. now all forms update same image (image_id1)
can i send img_id (in view) to form (in controller)?
I also try this code, but that insert always image_id variable = last image 
id in database.
def jobs():
images=db().select(db.ref.id,db.ref.file)
for img in images:
form = SQLFORM(db.ref, img.id)  
 
if form.process().accepted:
response.flash = "Image uploaded"+str(form.vars)
else:
response.flash = form.vars.id

return dict(form=form, images=images)

maanantaina 12. maaliskuuta 2012 12.23.36 UTC+2 Martin.Mulone kirjoitti:
>
> To edit an image you need to pass the id of the row to SQLFORM.
>
> Ex.:
> row_id = 1
> form = SQLFORM(db.ref, row_id)  
>
> 2012/3/11 juvi1 
>
>> thanks, but now form create always new image in database, and i want 
>> update image.
>> how it can be done??
>>
>> sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti:
>>
>>> I don't know why you have two {{pass}} in your view. I think you can do:
>>>
>>> def jobs():
>>> images=db().select(db.ref.id,**db.ref.file)
>>> form = SQLFORM(db.ref) 
>>> if form.process().accepted:
>>> response.flash = "Image uploaded"  
>>> 
>>> return dict(form=form, images=images)
>>>
>>> in views:
>>>  {{for img in images:}}
>>>>>  src="{{=URL('download', args=img.file)}}" />
>>>  
>>> {{=img}}
>>> {{=img.id}}
>>> {{=form}}
>>> {{pass}}
>>>
>>> 2012/3/11 juvi1 
>>>
 Hello sorry my bad english and i hope that you understand my problem. 

 I want show in one page all pictures which are saved in database.
 In page i want that i can upload new picture and update it whit forms 
 (override old one)
 My code are

 in controller:
 def jobs():
 images=db().select(db.ref.id,**db.ref.file)
 for img in  images:
 formname = "upload_f_%s"%img.id
 form = FORM(INPUT(_type="file",_name=**formname), 
 INPUT(_type='submit'))
 
 if form.accepts(request.vars, _name=formname):
 response.flash = form.vars
 
 return dict(form=form, img=img, formname=formname, images=images)

 in views:
 {{for img in images:}}
>>>  src="{{=URL('download', args=img.file)}}" />
  
 {{=img}}
 {{formname=img.id}}
 {{=formname}}
 {{=form}}
 {{pass}}{{pass}}

 please help!

>>>
>>>
>>>
>>> -- 
>>>  http://www.tecnodoc.com.ar
>>>
>>>  
>
>
> -- 
>  http://www.tecnodoc.com.ar
>
>  

Re: [web2py] using form in same page?

2012-03-12 Thread juvi1
this code work but i need create form in controller but how i send the 
img_id variable in controller (form)?
{{for img in images:}}
   
 
{{=img}}
{{=img.id}}
{{row_id=img.id}}
{{form = SQLFORM(db.ref, row_id) 
  if form.process().accepted:
response.flash = "Image uploaded"+str(form.vars)
  else:
response.flash = form.vars.id}}
{{=form}}
{{pass}}{{pass}}

maanantaina 12. maaliskuuta 2012 14.02.10 UTC+2 juvi1 kirjoitti:
>
>
> 
> Sry. I dont understand. now all forms update same image (image_id1)
> can i send img_id (in view) to form (in controller)?
> I also try this code, but that insert always image_id variable = last 
> image id in database.
> def jobs():
> images=db().select(db.ref.id,db.ref.file)
> for img in images:
> form = SQLFORM(db.ref, img.id)  
>  
> if form.process().accepted:
> response.flash = "Image uploaded"+str(form.vars)
> else:
> response.flash = form.vars.id
> 
> return dict(form=form, images=images)
>
> maanantaina 12. maaliskuuta 2012 12.23.36 UTC+2 Martin.Mulone kirjoitti:
>>
>> To edit an image you need to pass the id of the row to SQLFORM.
>>
>> Ex.:
>> row_id = 1
>> form = SQLFORM(db.ref, row_id)  
>>
>> 2012/3/11 juvi1 
>>
>>> thanks, but now form create always new image in database, and i want 
>>> update image.
>>> how it can be done??
>>>
>>> sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti:
>>>
 I don't know why you have two {{pass}} in your view. I think you can do:

 def jobs():
 images=db().select(db.ref.id,**db.ref.file)
 form = SQLFORM(db.ref) 
 if form.process().accepted:
 response.flash = "Image uploaded"  
 
 return dict(form=form, images=images)

 in views:
  {{for img in images:}}
>>>  src="{{=URL('download', args=img.file)}}" />
  
 {{=img}}
 {{=img.id}}
 {{=form}}
 {{pass}}

 2012/3/11 juvi1 

> Hello sorry my bad english and i hope that you understand my problem. 
>
> I want show in one page all pictures which are saved in database.
> In page i want that i can upload new picture and update it whit forms 
> (override old one)
> My code are
>
> in controller:
> def jobs():
> images=db().select(db.ref.id,**db.ref.file)
> for img in  images:
> formname = "upload_f_%s"%img.id
> form = FORM(INPUT(_type="file",_name=**formname), 
> INPUT(_type='submit'))
> 
> if form.accepts(request.vars, _name=formname):
> response.flash = form.vars
> 
> return dict(form=form, img=img, formname=formname, images=images)
>
> in views:
> {{for img in images:}}
>  src="{{=URL('download', args=img.file)}}" />
>  
> {{=img}}
> {{formname=img.id}}
> {{=formname}}
> {{=form}}
> {{pass}}{{pass}}
>
> please help!
>



 -- 
  http://www.tecnodoc.com.ar

  
>>
>>
>> -- 
>>  http://www.tecnodoc.com.ar
>>
>>  

[web2py] SQLFORM.grid, selectable and id

2012-03-12 Thread Johann Spies
When using the following grid:

query = ((db.akb_authors.id.belongs(ids))&
 (db.akb_authors_article_link.author == db.akb_authors.uuid)&
 (db.akb_authors_article_link.article == db.akb_articles.uuid)&
 (db.akb_journal.uuid == db.akb_articles.journal))
left = (db.akb_authors_article_link.on((db.akb_authors.uuid ==
db.akb_authors_article_link.author)&
 (db.akb_authors.id.belongs(ids))&
 (db.akb_authors_article_link.author == db.akb_authors.uuid)&
 (db.akb_authors_article_link.article == db.akb_articles.uuid)&
 (db.akb_journal.uuid == db.akb_articles.journal)))
fields = [db.akb_authors.id, db.akb_authors.surname,
db.akb_authors.firstname,
  db.akb_authors.name, db.akb_authors.birthdate,
db.akb_authors.gender,
  db.akb_authors.race, db.akb_authors.address,
db.akb_journal.title,
  db.akb_journal.subject ]
headers = {'akb_journal.title': 'Journal'}
form = SQLFORM.grid(query, fields=fields, maxtextlength = 100,
deletable = False,
editable = False,
details = False,
create = False,
headers = headers,
selectable = lambda ids: hanteer_verfyning(ids),
orderby = db.akb_authors.auth_id|db.akb_authors.id)

the grid use the id's of the akb_articles.  Is there an easy way to
convince it to use the id specified in [fields] in stead?

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


[web2py] Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

Following is the snippet from my db.py global file:

db = DAL('google:datastore')

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())

auth.settings.login_url = URL('default','index')
auth.settings.logged_url = URL('user','profile')
auth.settings.login_next = URL('user','profile')

auth.define_tables()


In my controller default/index controller I have used the following:

def index():

login_form = auth.login()
if login_form.process(session=None,formname='login').accepted:
pass
elif login_form.errors:
response.write(request.vars)
return dict()

to display the form I have used the SQLForm in HTML technique as mentioned 
in the web2py book

Whenever user enters the correct email and password. auth_event registers a 
login event with the description *User 1 Logged In*.
The next property redirects the URL to /user/profile but auth.user object 
is *None.*
*
*
Is there some auth setting that I am missing or something else is the 
reason of this ?

Thanks,
Sushant




[web2py] Can I change DAL encoding for strings?

2012-03-12 Thread Alexei Vinidiktov
Hello,

I'm considering using DAL in a desktop application written with wxPython.
The problem I've come across is that DAL queries accept and return utf-8
encoded strings. wxPython operates with Unicode strings and I have to
convert every string that I send to or get from DAL to
Python Unicode format. It is not very convenient.

Can anything be done about it? What would you do?

-- 
Alexei Vinidiktov


[web2py] Re: Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Hassan Alnatour
im trying to have somthing like this is the database , in a table
called pages  :

{{=c.name}}


and then get the record from the database and in the view but only
this  :

{{=content}}


Re: [web2py] Re: Rendering HTML & CSS & Python code The are Retrieved from the database

2012-03-12 Thread Bruno Rocha
In controller

rendered = render(.)
return dict(rendered=rendered)

in view

{{=XML(rendered)}}

http://zerp.ly/rochacbruno
Em 12/03/2012 10:27, "Hassan Alnatour" 
escreveu:

> im trying to have somthing like this is the database , in a table
> called pages  :
>
> {{=c.name}}
> 
>
> and then get the record from the database and in the view but only
> this  :
>
> {{=content}}
>


Re: [web2py] Auth.user is still NULL after a successful login

2012-03-12 Thread Bruno Rocha
Why are you passing session=None to .process ?

http://zerp.ly/rochacbruno
Em 12/03/2012 09:43, "Sushant Taneja"  escreveu:

> Hi,
>
> Following is the snippet from my db.py global file:
>
> db = DAL('google:datastore')
>
> from gluon.tools import Auth
> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>
> auth.settings.login_url = URL('default','index')
> auth.settings.logged_url = URL('user','profile')
> auth.settings.login_next = URL('user','profile')
>
> auth.define_tables()
>
>
> In my controller default/index controller I have used the following:
>
> def index():
>
> login_form = auth.login()
> if login_form.process(session=None,formname='login').accepted:
> pass
> elif login_form.errors:
> response.write(request.vars)
> return dict()
>
> to display the form I have used the SQLForm in HTML technique as mentioned
> in the web2py book
>
> Whenever user enters the correct email and password. auth_event registers
> a login event with the description *User 1 Logged In*.
> The next property redirects the URL to /user/profile but auth.user object
> is *None.*
> *
> *
> Is there some auth setting that I am missing or something else is the
> reason of this ?
>
> Thanks,
> Sushant
>
>
>


Re: [web2py] web2py recipe book

2012-03-12 Thread bussiere bussiere
The cookbook is still labelled as pre order.

When will it be out please ?

Regards
Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY




On Mon, Mar 12, 2012 at 10:35 AM, lyn2py  wrote:
> Any idea if future updates to the book will be free if the ebook version is 
> purchased?
>
> Thanks!


[web2py] logical/relationship url mapping

2012-03-12 Thread rdodev
Hello all,

I'm fairly knew to web2py and trying to find things out by myself as much 
as I can. However, I have not been able to find how to create 
logical/relationship URLs. Let's say I have a model named TopThing, which 
has a 1-to-many relationship with MiddleThing, which also has a one-to-many 
relationship with BottomThing. 
(TopThing->1:*->MiddleThing->1:*->BottomThing). So we'd like navigation to 
follow that same idea of 
(/AppName/TopThing/{_Id}/MiddleThing/{_Id}/BottomThing). Is it possible to 
have this in web2py? If so, would some one care to explain? Thx.




Re: [web2py] using form in same page?

2012-03-12 Thread Martín Mulone
The easy way is to add another controller "edit_image" and add a link to
this in each image.

(controller/default.py)

def edit_image():
 row_id = request.args[0]
 form = SQLFORM(db.ref, row_id)
 if form.process().accepted:
   response.flash = "Image uploaded"
 else:
response.flash = form.vars.id


(view)

{{for img in images:}}
   
 
{{=img}}
{{=img.id}}
{{=A('Edit', _href=URL('default', 'edit_image',
args=[img.id]))}}

{{pass}}{{pass}}



2012/3/12 juvi1 

> this code work but i need create form in controller but how i send the
> img_id variable in controller (form)?
>
> {{for img in images:}}
>  src="{{=URL('download', args=img.file)}}" />
>  
> {{=img}}
> {{=img.id}}
> {{row_id=img.id}}
> {{form = SQLFORM(db.ref, row_id)
>   if form.process().accepted:
> response.flash = "Image uploaded"+str(form.vars)
>   else:
> response.flash = form.vars.id}}
> {{=form}}
> {{pass}}{{pass}}
>
> maanantaina 12. maaliskuuta 2012 14.02.10 UTC+2 juvi1 kirjoitti:
>
>>
>> 
>> Sry. I dont understand. now all forms update same image (image_id1)
>> can i send img_id (in view) to form (in controller)?
>> I also try this code, but that insert always image_id variable = last
>> image id in database.
>> def jobs():
>> images=db().select(db.ref.id,**db.ref.file)
>> for img in images:
>> form = SQLFORM(db.ref, img.id)
>>
>> if form.process().accepted:
>> response.flash = "Image uploaded"+str(form.vars)
>> else:
>> response.flash = form.vars.id
>>
>> return dict(form=form, images=images)
>>
>> maanantaina 12. maaliskuuta 2012 12.23.36 UTC+2 Martin.Mulone kirjoitti:
>>>
>>> To edit an image you need to pass the id of the row to SQLFORM.
>>>
>>> Ex.:
>>> row_id = 1
>>> form = SQLFORM(db.ref, row_id)
>>>
>>> 2012/3/11 juvi1 
>>>
 thanks, but now form create always new image in database, and i want
 update image.
 how it can be done??

 sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti:

> I don't know why you have two {{pass}} in your view. I think you can
> do:
>
> def jobs():
> images=db().select(db.ref.id,**d**b.ref.file)
> form = SQLFORM(db.ref)
> if form.process().accepted:
> response.flash = "Image uploaded"
>
> return dict(form=form, images=images)
>
> in views:
>  {{for img in images:}}
>  src="{{=URL('download', args=img.file)}}" />
>  
> {{=img}}
> {{=img.id}}
> {{=form}}
> {{pass}}
>
> 2012/3/11 juvi1 
>
>> Hello sorry my bad english and i hope that you understand my problem.
>>
>> I want show in one page all pictures which are saved in database.
>> In page i want that i can upload new picture and update it whit forms
>> (override old one)
>> My code are
>>
>> in controller:
>> def jobs():
>> images=db().select(db.ref.id,**d**b.ref.file)
>> for img in  images:
>> formname = "upload_f_%s"%img.id
>> form = FORM(INPUT(_type="file",_name=formname),
>> INPUT(_type='submit'))
>>
>> if form.accepts(request.vars, _name=formname):
>> response.flash = form.vars
>>
>> return dict(form=form, img=img, formname=formname, images=images)
>>
>> in views:
>> {{for img in images:}}
>>>  src="{{=URL('download', args=img.file)}}" />
>>  
>> {{=img}}
>> {{formname=img.id}}
>> {{=formname}}
>> {{=form}}
>> {{pass}}{{pass}}
>>
>> please help!
>>
>
>
>
> --
>  http://www.tecnodoc.com.ar
>
>
>>>
>>>
>>> --
>>>  http://www.tecnodoc.com.ar
>>>
>>>


-- 
 http://www.tecnodoc.com.ar


[web2py] Re: need help with unicode decoding/encoding upload file

2012-03-12 Thread Wikus van de Merwe
To convert a string to utf-8 you need to do two operations:
- decode the string to unicode (using the original file codec)
- encode the unicode string using utf-8 codec

This is what decoder.decoder function is doing but it is guessing the 
original codec.
You need to either provide the right codec for decoding (if you know it is 
always the
same) or guess it better (e.g. by catching exception and trying different 
codecs in order).

input_codec = "iso-8592-1"
output = text.decode(input_codec).encode("utf-8")



Re: [web2py] Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

I passed the session=None since I was following example in the book.
I removed it from the process method and now I am using 

   login_form = auth.login()
if login_form.process(formname='login').accepted:
pass
elif login_form.errors:
response.write(request.vars)
return dict()

but now when I try to login, nothing happens. No event is recorded in 
auth_event and there is also no redirection.

On Monday, March 12, 2012 7:20:01 PM UTC+5:30, rochacbruno wrote:
>
> Why are you passing session=None to .process ?
>
> http://zerp.ly/rochacbruno
> Em 12/03/2012 09:43, "Sushant Taneja"  
> escreveu:
>
>> Hi,
>>
>> Following is the snippet from my db.py global file:
>>
>> db = DAL('google:datastore')
>>
>> from gluon.tools import Auth
>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>
>> auth.settings.login_url = URL('default','index')
>> auth.settings.logged_url = URL('user','profile')
>> auth.settings.login_next = URL('user','profile')
>>
>> auth.define_tables()
>>
>>
>> In my controller default/index controller I have used the following:
>>
>> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to display the form I have used the SQLForm in HTML technique as 
>> mentioned in the web2py book
>>
>> Whenever user enters the correct email and password. auth_event registers 
>> a login event with the description *User 1 Logged In*.
>> The next property redirects the URL to /user/profile but auth.user object 
>> is *None.*
>> *
>> *
>> Is there some auth setting that I am missing or something else is the 
>> reason of this ?
>>
>> Thanks,
>> Sushant
>>
>>
>>

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Anthony

>
> def index():
>
> login_form = auth.login()
> if login_form.process(session=None,formname='login').accepted:
> pass
> elif login_form.errors:
> response.write(request.vars)
> return dict()
>
> to display the form I have used the SQLForm in HTML technique as mentioned 
> in the web2py book
>
> Whenever user enters the correct email and password. auth_event registers 
> a login event with the description *User 1 Logged In*.
> The next property redirects the URL to /user/profile but auth.user object 
> is *None.*
>

auth.login() handles it's own form processing, and it uses the session when 
calling form.accepts (which adds a hidden _formkey field to the form, which 
must be present upon form submission). In your code, you do not return the 
form object to the view, which means your view cannot include the hidden 
_formkey field, which is therefore not submitted with the form. So, when 
the form is submitted, the form.accepts in auth.login() fails, which means 
the user object is never stored in session.auth.user -- hence, auth.user is 
None. The reason the login submission is successful is that your index() 
function then does its own processing of the login form, which is 
successful -- but your explicit call to login_form.process() does not do 
anything to set auth.user, so it is never set.

In short, you should not be doing your own processing of the login form -- 
let auth.login() handle that. And if you want to customize the form display 
in the view, you still have to return the form to the view so you can 
include the hidden _formkey and _formname fields in the form (you can use 
form.custom.end to do that).

Anthony


Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Richard Vézina
Curious if the issue I have with my app coulb become from the new pg8000
driver??

https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ

Do I have to change anything in my connection string with the new web2py
1.99.7??

Thanks

Richard

On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> fixing in trunk (while at PyCon print)
>
>
> On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>>
>> Line 1999 in trunk:
>> self.driver = drivers.get('pg8000')
>> Should be:
>> self.driver = self.drivers.get('pg8000')
>>
>> On Mar 10, 8:07 pm, Alan Etkin  wrote:
>> > If something changed (as now pg adapter supports pg8000 driver), old
>> > uri strings would have to be accepted also. I'd say it's is a bug.
>> > There seems to be a list/dict conflict in dal.
>> >
>> > On Mar 10, 2:16 pm, Bruce Wade  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>> /warplyde_**fto')
>> >
>> > > Has something been changed in how we need to make database
>> connections
>> > > to postgres?
>> >
>> > > Traceback (most recent call last):
>> > >   File 
>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/restricted.py",
>>
>> > > line 205, in restricted
>> > > exec ccode in environment
>> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**
>> applications/signon/models/db.**py"
>> > > >,
>> line 14, in
>> > > 
>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>> /warplyde_**fto')
>> > >   File 
>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>
>> > > line 5968, in __init__
>> > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
>> > > (attempts, tb)
>> > > RuntimeError: Failure to connect, tried 5 times:
>> > > Traceback (most recent call last):
>> > >   File 
>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>
>> > > line 5955, in __init__
>> > > self._adapter = ADAPTERS[self._dbname](*args)
>> > >   File 
>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>
>> > > line 1999, in __init__
>> > > self.driver = drivers.get('pg8000')
>> > > AttributeError: 'list' object has no attribute 'get'
>> >
>> > > --
>> > > --
>> > > Regards,
>> > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
>> wadecybertech.comhttp:.
>> ..
>
>


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Thanks for an explanatory answer.
I will try this out.

On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>
> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to display the form I have used the SQLForm in HTML technique as 
>> mentioned in the web2py book
>>
>> Whenever user enters the correct email and password. auth_event registers 
>> a login event with the description *User 1 Logged In*.
>> The next property redirects the URL to /user/profile but auth.user object 
>> is *None.*
>>
>
> auth.login() handles it's own form processing, and it uses the session 
> when calling form.accepts (which adds a hidden _formkey field to the form, 
> which must be present upon form submission). In your code, you do not 
> return the form object to the view, which means your view cannot include 
> the hidden _formkey field, which is therefore not submitted with the form. 
> So, when the form is submitted, the form.accepts in auth.login() fails, 
> which means the user object is never stored in session.auth.user -- hence, 
> auth.user is None. The reason the login submission is successful is that 
> your index() function then does its own processing of the login form, which 
> is successful -- but your explicit call to login_form.process() does not do 
> anything to set auth.user, so it is never set.
>
> In short, you should not be doing your own processing of the login form -- 
> let auth.login() handle that. And if you want to customize the form display 
> in the view, you still have to return the form to the view so you can 
> include the hidden _formkey and _formname fields in the form (you can use 
> form.custom.end to do that).
>
> Anthony
>


[web2py] Re: logical/relationship url mapping

2012-03-12 Thread Anthony
Check out the RESTful web services 
functionality: 
http://web2py.com/books/default/chapter/29/10#Restful-Web-Services, 
in 
particular, 
http://web2py.com/books/default/chapter/29/10#parse_as_rest-(experimental).

You could also handle this specific case in a controller action, with all 
the elements of your URL in request.args:

In default.py:

def TopThing():
rows = db((db.TopThing.id == db.MiddleThing.TopThing_id) &
  (db.MiddleThing.id == db.BottomThing.MiddleThing_id) &
  (db.TopThing.id == request.args(0)) &
  (db.MiddleThing.id = request.args(2))).select()
return dict(rows=rows)

Anthony

On Monday, March 12, 2012 10:05:31 AM UTC-4, rdodev wrote:
>
> Hello all,
>
> I'm fairly knew to web2py and trying to find things out by myself as much 
> as I can. However, I have not been able to find how to create 
> logical/relationship URLs. Let's say I have a model named TopThing, which 
> has a 1-to-many relationship with MiddleThing, which also has a one-to-many 
> relationship with BottomThing. 
> (TopThing->1:*->MiddleThing->1:*->BottomThing). So we'd like navigation to 
> follow that same idea of 
> (/AppName/TopThing/{_Id}/MiddleThing/{_Id}/BottomThing). Is it possible to 
> have this in web2py? If so, would some one care to explain? Thx.
>
>
>

[web2py] Re: Differentiating between URLs in web2py controllers

2012-03-12 Thread Anthony

>
> Actually we are implementing FB login for our app. For this we want to 
> detect whether /user/login controller was a redirect from facebook (after 
> authentication) or a a user noramlly opened /user/login in their browser.
>
> Sometimes FB reidrects to /user/login#_=_ and sometimes to 
> /user/login?code=
>
> [
> "Change in Session Redirect Behavior. This week, we started adding a 
> fragment #_=_ to the redirect_uri when this field is left blank. Please 
> ensure that your app can handle this behavior."
>
> https://developers.facebook.com/blog/post/552/ 
>
>
> ]
>
> How can I differentiate b/w the two?
>

I'm not sure you can when the request is first made, as the server only 
receives a request for /user/login, even if FB redirects to 
/user/login#_=_. After the redirect, you could use Javascript on the client 
side to see if there is a hash in the URL (e.g., using 
window.location.hash), and then possibly send an Ajax request to get the 
appropriate data in either case.

Anthony


[web2py] Multiple Login methods

2012-03-12 Thread Hassan Alnatour
Dear ALL,

I want to use Facebook and linked in and open iD and the normal auth
form form login and registration , how can i do that  and when i use
this things for  my website where dose the user register ??

Best Regards,


Re: [web2py] web2py recipe book

2012-03-12 Thread Jim Steil
I just ordered it and saw that it would be available on the 15th.  I was 
going to order both hardcopy and electronic until I saw that shipping 
cost to the US was over $14.  I just got the e-version.


-Jim

On 3/12/2012 8:49 AM, bussiere bussiere wrote:

The cookbook is still labelled as pre order.

When will it be out please ?

Regards
Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY




On Mon, Mar 12, 2012 at 10:35 AM, lyn2py  wrote:

Any idea if future updates to the book will be free if the ebook version is 
purchased?

Thanks!


[web2py]

2012-03-12 Thread Lim Jia He



Re: [web2py] web2py recipe book

2012-03-12 Thread Bruce Wade
The other book would be version 4 of the official manual. Bought it because
I didn't think it would be free online until much later.

On Mon, Mar 12, 2012 at 8:02 AM, Jim Steil  wrote:

> I just ordered it and saw that it would be available on the 15th.  I was
> going to order both hardcopy and electronic until I saw that shipping cost
> to the US was over $14.  I just got the e-version.
>
>-Jim
>
>
> On 3/12/2012 8:49 AM, bussiere bussiere wrote:
>
>> The cookbook is still labelled as pre order.
>>
>> When will it be out please ?
>>
>> Regards
>> Bussiere
>>
>>
>>
>> "Les nouvelles technologies offrent pleins de nouvelles possibilités,
>> pleins de possibilités d'erreurs surtout en fait."
>> insurance.aes256 : http://goo.gl/gHyAY
>>
>>
>>
>>
>> On Mon, Mar 12, 2012 at 10:35 AM, lyn2py  wrote:
>>
>>> Any idea if future updates to the book will be free if the ebook version
>>> is purchased?
>>>
>>> Thanks!
>>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Bruce Wade
I had to change my connection string to this:

db_users = DAL('postgres:psycopg2://warplyde_fto:password@localhost
/warplyde_fto')

On Mon, Mar 12, 2012 at 7:23 AM, Richard Vézina  wrote:

> Curious if the issue I have with my app coulb become from the new pg8000
> driver??
>
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ
>
> Do I have to change anything in my connection string with the new web2py
> 1.99.7??
>
> Thanks
>
> Richard
>
>
> On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> fixing in trunk (while at PyCon print)
>>
>>
>> On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>>>
>>> Line 1999 in trunk:
>>> self.driver = drivers.get('pg8000')
>>> Should be:
>>> self.driver = self.drivers.get('pg8000')
>>>
>>> On Mar 10, 8:07 pm, Alan Etkin  wrote:
>>> > If something changed (as now pg adapter supports pg8000 driver), old
>>> > uri strings would have to be accepted also. I'd say it's is a bug.
>>> > There seems to be a list/dict conflict in dal.
>>> >
>>> > On Mar 10, 2:16 pm, Bruce Wade  wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>>> /warplyde_**fto')
>>> >
>>> > > Has something been changed in how we need to make database
>>> connections
>>> > > to postgres?
>>> >
>>> > > Traceback (most recent call last):
>>> > >   File 
>>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/restricted.py",
>>>
>>> > > line 205, in restricted
>>> > > exec ccode in environment
>>> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**
>>> applications/signon/models/db.**py"
>>> > > >,
>>> line 14, in
>>> > > 
>>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>>> /warplyde_**fto')
>>> > >   File 
>>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>>
>>> > > line 5968, in __init__
>>> > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
>>> > > (attempts, tb)
>>> > > RuntimeError: Failure to connect, tried 5 times:
>>> > > Traceback (most recent call last):
>>> > >   File 
>>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>>
>>> > > line 5955, in __init__
>>> > > self._adapter = ADAPTERS[self._dbname](*args)
>>> > >   File 
>>> > > "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/**gluon/dal.py",
>>>
>>> > > line 1999, in __init__
>>> > > self.driver = drivers.get('pg8000')
>>> > > AttributeError: 'list' object has no attribute 'get'
>>> >
>>> > > --
>>> > > --
>>> > > Regards,
>>> > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
>>> wadecybertech.comhttp:.
>>> ..
>>
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: web2py site and disabling browser right clicks

2012-03-12 Thread Anthony

>
> Now it could be very easy to pass wrong values using some hacking 
> techniques by malicious people (inshort hackers) and send wrong information 
> into the database.
>

Making your code invisible would not prevent hackers from submitting 
invalid values. The reason is that hackers can generate their own post 
requests without using your web page at all -- they can use their own 
client to send arbitrary post requests to your server (you can do it in 
Python using urllib or urllib2). The way to prevent hacked form submissions 
is to do server side validation, including some form of cross-site request 
forgery protection (which web2py achieves by including a unique formkey in 
each form that is also stored in the user's session on the server for 
comparison). Of course, it also helps to do everything over SSL if you want 
to make sure third parties cannot observe/modify the communication.

Login to your bank account and try viewing the page source -- you will 
likely see all the HTML code for form submissions, etc. Even banks are 
exposing page source code with no worries, as you cannot rely on obscuring 
page code for protection. Proper protection requires server side validation 
(and of course making sure you don't send anything to the client that the 
user shouldn't be allowed to see).
 

> --> Also note here I am not exactly trying to lock "View page source" for 
> the end users, they may be able to do it as per default browsers 
> functionality but rather would see something  very clean and no parameters 
> like below pyjamas example view serailized. 
>
> *
> 
> 
> 
> PyJamas Auto-Generated HTML file TimeSheet
> 
> 
> 
> 
> 
> *
>
>
The source code isn't being hidden in the code above, it just isn't present 
in the main page. Instead, the code that generates the displayed page is in 
the linked Javascript file (which the user can easily view/download) and 
the iframe (for which you can also easily view the source code). You can 
make it more difficult for non-technical users to casually view your page 
code, but you cannot hide your code from hackers (even compiled Flash and 
Silverlight code can be decompiled).
 

> --> The above line  *  * is *just a thought*
> some html tag could be defined or supported in HTML5 or above  or *even 
> in may be web2py 2.0 *that would toggle secure page view and unsecure 
> page view ... 
> if secure is *True* - users would see some stuff very basic like above 
> pyjamas example when viewing page source 
> else as usual - normal view page source (what it shows currently) 
>

Again, standard browsers could build in some kind of "hide the source code" 
functionality, but that wouldn't prevent a hacker from requesting a page 
from your site via some other means and viewing the source. Once you send 
your source code over the wire, you don't know what kind of client will be 
viewing it, so you cannot trust that client to keep it hidden.

Anthony


[web2py] Ways to check auth conditions (aside from decorating a whole function)

2012-03-12 Thread monotasker
In digging through the discussions here I've come across two auth methods 
that allow for checking a user's authorization: 

auth.is_logged_in()

and 

auth.has_permission()

These are really useful, but aren't documented in the web2py book (They're 
used a couple of times in other recipes, but they're never explained or 
highlighted.) So I'm wondering (a) whether these could be highlighted in 
the authorization chapter; and (b) whether there are other similar auth 
methods. Does, for example, auth.is_member(auth.user_id) exist to check for 
group membership?

Don't get me wrong, the decorators are great. But sometimes I need 
something more fine-grained for (e.g.) controlling visibility of elements 
in a view on a per-role basis. 

Thanks,

Ian




Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Richard Vézina
Thank for the answer!

But unfortunately for me it's not the origin of my problem it seems.

Richard

On Mon, Mar 12, 2012 at 11:12 AM, Bruce Wade  wrote:

> I had to change my connection string to this:
>
> db_users = DAL('postgres:psycopg2://warplyde_fto:password@localhost
> /warplyde_fto')
>
>
> On Mon, Mar 12, 2012 at 7:23 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Curious if the issue I have with my app coulb become from the new pg8000
>> driver??
>>
>>
>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ
>>
>> Do I have to change anything in my connection string with the new web2py
>> 1.99.7??
>>
>> Thanks
>>
>> Richard
>>
>>
>> On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> fixing in trunk (while at PyCon print)
>>>
>>>
>>> On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:

 Line 1999 in trunk:
 self.driver = drivers.get('pg8000')
 Should be:
 self.driver = self.drivers.get('pg8000')

 On Mar 10, 8:07 pm, Alan Etkin  wrote:
 > If something changed (as now pg adapter supports pg8000 driver), old
 > uri strings would have to be accepted also. I'd say it's is a bug.
 > There seems to be a list/dict conflict in dal.
 >
 > On Mar 10, 2:16 pm, Bruce Wade  wrote:
 >
 >
 >
 >
 >
 >
 >
 > > db_users = DAL('postgres://warplyde_fto:**password@localhost
 /warplyde_**fto')
 >
 > > Has something been changed in how we need to make database
 connections
 > > to postgres?
 >
 > > Traceback (most recent call last):
 > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/*
 *gluon/restricted.py",
 > > line 205, in restricted
 > > exec ccode in environment
 > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/*
 *applications/signon/models/db.**py"
 > > >,
 line 14, in
 > > 
 > > db_users = DAL('postgres://warplyde_fto:**password@localhost
 /warplyde_**fto')
 > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/*
 *gluon/dal.py",
 > > line 5968, in __init__
 > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
 > > (attempts, tb)
 > > RuntimeError: Failure to connect, tried 5 times:
 > > Traceback (most recent call last):
 > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/*
 *gluon/dal.py",
 > > line 5955, in __init__
 > > self._adapter = ADAPTERS[self._dbname](*args)
 > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/*
 *gluon/dal.py",
 > > line 1999, in __init__
 > > self.driver = drivers.get('pg8000')
 > > AttributeError: 'list' object has no attribute 'get'
 >
 > > --
 > > --
 > > Regards,
 > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
 wadecybertech.comhttp:.
 ..
>>>
>>>
>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


Re: [web2py] web2py recipe book

2012-03-12 Thread bussiere bussiere
Thanks

Just as needed for my project.

Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY




On Mon, Mar 12, 2012 at 4:02 PM, Jim Steil  wrote:
> I just ordered it and saw that it would be available on the 15th.  I was
> going to order both hardcopy and electronic until I saw that shipping cost
> to the US was over $14.  I just got the e-version.
>
>    -Jim
>
>
> On 3/12/2012 8:49 AM, bussiere bussiere wrote:
>>
>> The cookbook is still labelled as pre order.
>>
>> When will it be out please ?
>>
>> Regards
>> Bussiere
>>
>>
>>
>> "Les nouvelles technologies offrent pleins de nouvelles possibilités,
>> pleins de possibilités d'erreurs surtout en fait."
>> insurance.aes256 : http://goo.gl/gHyAY
>>
>>
>>
>>
>> On Mon, Mar 12, 2012 at 10:35 AM, lyn2py  wrote:
>>>
>>> Any idea if future updates to the book will be free if the ebook version
>>> is purchased?
>>>
>>> Thanks!


Re: [web2py] Ways to check auth conditions (aside from decorating a whole function)

2012-03-12 Thread Richard Vézina
I think pretty everithing can be find in this chapter if you read it
carefully.

http://web2py.com/books/default/chapter/29/9#Authorization-and-CRUD

Your is_member =

auth.has_membership(group_id, user_id, role)

*
*

*
*

Does it help?

Richard

On Mon, Mar 12, 2012 at 11:34 AM, monotasker  wrote:

> In digging through the discussions here I've come across two auth methods
> that allow for checking a user's authorization:
>
> auth.is_logged_in()
>
> and
>
> auth.has_permission()
>
> These are really useful, but aren't documented in the web2py book (They're
> used a couple of times in other recipes, but they're never explained or
> highlighted.) So I'm wondering (a) whether these could be highlighted in
> the authorization chapter; and (b) whether there are other similar auth
> methods. Does, for example, auth.is_member(auth.user_id) exist to check for
> group membership?
>
> Don't get me wrong, the decorators are great. But sometimes I need
> something more fine-grained for (e.g.) controlling visibility of elements
> in a view on a per-role basis.
>
> Thanks,
>
> Ian
>
>
>


Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Bruce Wade
Why are you doing this: auth=Auth(globals(),db) ? globals will not even be
processed it will only look at the first param and set it to db if the db
(second param) doesn't exist.
auth = Auth(db) is how it should be

Also I think this is where your problem is:
auth.settings.table_user = auth_table # no idea what this line do...

To customize the auth table:

db.define_table(
   auth.settings.table_user_name,
   # fields
)

custom_auth_table = db[auth.settings.table_user_name]
# add validations

auth.settings.table_user = custom_auth_table


On Mon, Mar 12, 2012 at 8:35 AM, Richard Vézina  wrote:

> Thank for the answer!
>
> But unfortunately for me it's not the origin of my problem it seems.
>
> Richard
>
> On Mon, Mar 12, 2012 at 11:12 AM, Bruce Wade  wrote:
>
>> I had to change my connection string to this:
>>
>> db_users = DAL('postgres:psycopg2://warplyde_fto:password@localhost
>> /warplyde_fto')
>>
>>
>> On Mon, Mar 12, 2012 at 7:23 AM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> Curious if the issue I have with my app coulb become from the new pg8000
>>> driver??
>>>
>>>
>>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ
>>>
>>> Do I have to change anything in my connection string with the new web2py
>>> 1.99.7??
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>>
>>> On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 fixing in trunk (while at PyCon print)


 On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>
> Line 1999 in trunk:
> self.driver = drivers.get('pg8000')
> Should be:
> self.driver = self.drivers.get('pg8000')
>
> On Mar 10, 8:07 pm, Alan Etkin  wrote:
> > If something changed (as now pg adapter supports pg8000 driver), old
> > uri strings would have to be accepted also. I'd say it's is a bug.
> > There seems to be a list/dict conflict in dal.
> >
> > On Mar 10, 2:16 pm, Bruce Wade  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
> /warplyde_**fto')
> >
> > > Has something been changed in how we need to make database
> connections
> > > to postgres?
> >
> > > Traceback (most recent call last):
> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/
> **gluon/restricted.py",
> > > line 205, in restricted
> > > exec ccode in environment
> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/
> **applications/signon/models/db.**py"
> > > >,
> line 14, in
> > > 
> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
> /warplyde_**fto')
> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/
> **gluon/dal.py",
> > > line 5968, in __init__
> > > raise RuntimeError, "Failure to connect, tried %d times:\n%s"
> %
> > > (attempts, tb)
> > > RuntimeError: Failure to connect, tried 5 times:
> > > Traceback (most recent call last):
> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/
> **gluon/dal.py",
> > > line 5955, in __init__
> > > self._adapter = ADAPTERS[self._dbname](*args)
> > >   File "/home/bruce/Development/wct_**dev/web2py_dev/projects/fto/
> **gluon/dal.py",
> > > line 1999, in __init__
> > > self.driver = drivers.get('pg8000')
> > > AttributeError: 'list' object has no attribute 'get'
> >
> > > --
> > > --
> > > Regards,
> > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
> wadecybertech.comhttp:.
> ..


>>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Ways to check auth conditions (aside from decorating a whole function)

2012-03-12 Thread monotasker
Ah . . . you're right. Sorry for not reading more carefully. I think some 
of this *has* been documented better since the version 3 book too, which is 
great.

Ian

On Monday, March 12, 2012 11:44:01 AM UTC-4, Richard wrote:
>
> I think pretty everithing can be find in this chapter if you read it 
> carefully.
>
> http://web2py.com/books/default/chapter/29/9#Authorization-and-CRUD
>
> Your is_member =
>
> auth.has_membership(group_id, user_id, role)
>
> *
> *
>
> *
> *
>
> Does it help?
>
> Richard
>
> On Mon, Mar 12, 2012 at 11:34 AM, monotasker wrote:
>
>> In digging through the discussions here I've come across two auth methods 
>> that allow for checking a user's authorization: 
>>
>> auth.is_logged_in()
>>
>> and 
>>
>> auth.has_permission()
>>
>> These are really useful, but aren't documented in the web2py book 
>> (They're used a couple of times in other recipes, but they're never 
>> explained or highlighted.) So I'm wondering (a) whether these could be 
>> highlighted in the authorization chapter; and (b) whether there are other 
>> similar auth methods. Does, for example, auth.is_member(auth.user_id) exist 
>> to check for group membership?
>>
>> Don't get me wrong, the decorators are great. But sometimes I need 
>> something more fine-grained for (e.g.) controlling visibility of elements 
>> in a view on a per-role basis. 
>>
>> Thanks,
>>
>> Ian
>>
>>
>>
>

Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Bruce Wade
Finally you are missing some required fields in your new auth table:

Look at: http://web2py.com/books/default/chapter/29/9#Customizing-Auth to
see the required fields.

On Mon, Mar 12, 2012 at 8:46 AM, Bruce Wade  wrote:

> Why are you doing this: auth=Auth(globals(),db) ? globals will not even
> be processed it will only look at the first param and set it to db if the
> db (second param) doesn't exist.
> auth = Auth(db) is how it should be
>
> Also I think this is where your problem is:
> auth.settings.table_user = auth_table # no idea what this line do...
>
> To customize the auth table:
>
> db.define_table(
>auth.settings.table_user_name,
># fields
> )
>
> custom_auth_table = db[auth.settings.table_user_name]
> # add validations
>
> auth.settings.table_user = custom_auth_table
>
>
> On Mon, Mar 12, 2012 at 8:35 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Thank for the answer!
>>
>> But unfortunately for me it's not the origin of my problem it seems.
>>
>> Richard
>>
>> On Mon, Mar 12, 2012 at 11:12 AM, Bruce Wade wrote:
>>
>>> I had to change my connection string to this:
>>>
>>> db_users = DAL('postgres:psycopg2://warplyde_fto:password@localhost
>>> /warplyde_fto')
>>>
>>>
>>> On Mon, Mar 12, 2012 at 7:23 AM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 Curious if the issue I have with my app coulb become from the new
 pg8000 driver??


 https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ

 Do I have to change anything in my connection string with the new
 web2py 1.99.7??

 Thanks

 Richard


 On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
 massimo.dipie...@gmail.com> wrote:

> fixing in trunk (while at PyCon print)
>
>
> On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>>
>> Line 1999 in trunk:
>> self.driver = drivers.get('pg8000')
>> Should be:
>> self.driver = self.drivers.get('pg8000')
>>
>> On Mar 10, 8:07 pm, Alan Etkin  wrote:
>> > If something changed (as now pg adapter supports pg8000 driver),
>> old
>> > uri strings would have to be accepted also. I'd say it's is a bug.
>> > There seems to be a list/dict conflict in dal.
>> >
>> > On Mar 10, 2:16 pm, Bruce Wade  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>> /warplyde_**fto')
>> >
>> > > Has something been changed in how we need to make database
>> connections
>> > > to postgres?
>> >
>> > > Traceback (most recent call last):
>> > >   File "/home/bruce/Development/wct_**
>> dev/web2py_dev/projects/fto/**gluon/restricted.py",
>> > > line 205, in restricted
>> > > exec ccode in environment
>> > >   File "/home/bruce/Development/wct_**
>> dev/web2py_dev/projects/fto/**applications/signon/models/db.**py"
>> > > >,
>> line 14, in
>> > > 
>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>> /warplyde_**fto')
>> > >   File "/home/bruce/Development/wct_**
>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>> > > line 5968, in __init__
>> > > raise RuntimeError, "Failure to connect, tried %d times:\n%s"
>> %
>> > > (attempts, tb)
>> > > RuntimeError: Failure to connect, tried 5 times:
>> > > Traceback (most recent call last):
>> > >   File "/home/bruce/Development/wct_**
>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>> > > line 5955, in __init__
>> > > self._adapter = ADAPTERS[self._dbname](*args)
>> > >   File "/home/bruce/Development/wct_**
>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>> > > line 1999, in __init__
>> > > self.driver = drivers.get('pg8000')
>> > > AttributeError: 'list' object has no attribute 'get'
>> >
>> > > --
>> > > --
>> > > Regards,
>> > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
>> wadecybertech.comhttp:.
>> ..
>
>

>>>
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/brucelwade
>>> http://www.wadecybertech.com
>>> http://www.warplydesigned.com
>>> http://www.fitnessfriendsfinder.com
>>>
>>
>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Ways to check auth conditions (aside from decorating a whole function)

2012-03-12 Thread Anthony
auth.has_membership and auth.has_permission are both documented 
here: http://web2py.com/books/default/chapter/29/9#Authorization

Anthony

On Monday, March 12, 2012 11:34:11 AM UTC-4, monotasker wrote:
>
> In digging through the discussions here I've come across two auth methods 
> that allow for checking a user's authorization: 
>
> auth.is_logged_in()
>
> and 
>
> auth.has_permission()
>
> These are really useful, but aren't documented in the web2py book (They're 
> used a couple of times in other recipes, but they're never explained or 
> highlighted.) So I'm wondering (a) whether these could be highlighted in 
> the authorization chapter; and (b) whether there are other similar auth 
> methods. Does, for example, auth.is_member(auth.user_id) exist to check for 
> group membership?
>
> Don't get me wrong, the decorators are great. But sometimes I need 
> something more fine-grained for (e.g.) controlling visibility of elements 
> in a view on a per-role basis. 
>
> Thanks,
>
> Ian
>
>
>

Re: [web2py] Re: Latest version unable to connect to DB

2012-03-12 Thread Richard Vézina
Thanks for your help.

I am developping this app since pretty old version of web2py, I wrote that
2 years ago, so...

I will try the thing you mention and I report back...

On Mon, Mar 12, 2012 at 11:49 AM, Bruce Wade  wrote:

> Finally you are missing some required fields in your new auth table:
>
> Look at: http://web2py.com/books/default/chapter/29/9#Customizing-Auth to
> see the required fields.
>
>
> On Mon, Mar 12, 2012 at 8:46 AM, Bruce Wade  wrote:
>
>> Why are you doing this: auth=Auth(globals(),db) ? globals will not even
>> be processed it will only look at the first param and set it to db if the
>> db (second param) doesn't exist.
>> auth = Auth(db) is how it should be
>>
>> Also I think this is where your problem is:
>> auth.settings.table_user = auth_table # no idea what this line do...
>>
>> To customize the auth table:
>>
>> db.define_table(
>>auth.settings.table_user_name,
>># fields
>> )
>>
>> custom_auth_table = db[auth.settings.table_user_name]
>> # add validations
>>
>> auth.settings.table_user = custom_auth_table
>>
>>
>> On Mon, Mar 12, 2012 at 8:35 AM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> Thank for the answer!
>>>
>>> But unfortunately for me it's not the origin of my problem it seems.
>>>
>>> Richard
>>>
>>> On Mon, Mar 12, 2012 at 11:12 AM, Bruce Wade wrote:
>>>
 I had to change my connection string to this:

 db_users = DAL('postgres:psycopg2://warplyde_fto:password@localhost
 /warplyde_fto')


 On Mon, Mar 12, 2012 at 7:23 AM, Richard Vézina <
 ml.richard.vez...@gmail.com> wrote:

> Curious if the issue I have with my app coulb become from the new
> pg8000 driver??
>
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20my$20app$20not$20works$20with$20web2py$201.99.7/web2py/i7wx6JVTOtw/JlaULRp8G0AJ
>
> Do I have to change anything in my connection string with the new
> web2py 1.99.7??
>
> Thanks
>
> Richard
>
>
> On Sun, Mar 11, 2012 at 8:39 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> fixing in trunk (while at PyCon print)
>>
>>
>> On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>>>
>>> Line 1999 in trunk:
>>> self.driver = drivers.get('pg8000')
>>> Should be:
>>> self.driver = self.drivers.get('pg8000')
>>>
>>> On Mar 10, 8:07 pm, Alan Etkin  wrote:
>>> > If something changed (as now pg adapter supports pg8000 driver),
>>> old
>>> > uri strings would have to be accepted also. I'd say it's is a bug.
>>> > There seems to be a list/dict conflict in dal.
>>> >
>>> > On Mar 10, 2:16 pm, Bruce Wade  wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>>> /warplyde_**fto')
>>> >
>>> > > Has something been changed in how we need to make database
>>> connections
>>> > > to postgres?
>>> >
>>> > > Traceback (most recent call last):
>>> > >   File "/home/bruce/Development/wct_**
>>> dev/web2py_dev/projects/fto/**gluon/restricted.py",
>>> > > line 205, in restricted
>>> > > exec ccode in environment
>>> > >   File "/home/bruce/Development/wct_**
>>> dev/web2py_dev/projects/fto/**applications/signon/models/db.**py"
>>> > > >,
>>> line 14, in
>>> > > 
>>> > > db_users = DAL('postgres://warplyde_fto:**password@localhost
>>> /warplyde_**fto')
>>> > >   File "/home/bruce/Development/wct_**
>>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>>> > > line 5968, in __init__
>>> > > raise RuntimeError, "Failure to connect, tried %d
>>> times:\n%s" %
>>> > > (attempts, tb)
>>> > > RuntimeError: Failure to connect, tried 5 times:
>>> > > Traceback (most recent call last):
>>> > >   File "/home/bruce/Development/wct_**
>>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>>> > > line 5955, in __init__
>>> > > self._adapter = ADAPTERS[self._dbname](*args)
>>> > >   File "/home/bruce/Development/wct_**
>>> dev/web2py_dev/projects/fto/**gluon/dal.py",
>>> > > line 1999, in __init__
>>> > > self.driver = drivers.get('pg8000')
>>> > > AttributeError: 'list' object has no attribute 'get'
>>> >
>>> > > --
>>> > > --
>>> > > Regards,
>>> > > Bruce Wadehttp://ca.linkedin.com/in/**brucelwadehttp://www.**
>>> wadecybertech.comhttp:.
>>> ..
>>
>>
>


 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.warplydesigned.com
 http://www.fitnessfriendsfinder.com

[web2py] Upgrading web2py in Linux

2012-03-12 Thread horridohobbyist
I'm currently running Version 1.99.2 on my Ubuntu Linux server. Is there an 
easy way to upgrade to the latest version (1.99.7)?

My web2py installation says "Checking for upgrades...", but it never 
finishes checking! I presume that if it were to finish checking, there 
would be a way to upgrade automatically?

Thanks.


Re: [web2py] Upgrading web2py in Linux

2012-03-12 Thread Richard Vézina
I am strongly suggest to you to not updating that way. Or if you do so,
backup your web2py folder before.

What I usually do:

download latest source from download page
backup my "staging"/"prod" web2py installation
remove the old installation : cd /home/www-data/ && rm -Rf web2py/
Uncompress the new web2py zip in the folder /home/www-data/
Set permission : sudo chown -R www-data.www-data web2py/
Copy my app in : web2py/applications/my app
Also set permission is required here.

If you are only talking about the dev environnement, I just let the old
web2py in a folder named with the version and add an other folder with the
new version beside and unpack web2py new version there and bring my app in
the new installation.

You don't have to bother with permission since you are only use it for
developpement.

Richard



On Mon, Mar 12, 2012 at 12:45 PM, horridohobbyist  wrote:

> I'm currently running Version 1.99.2 on my Ubuntu Linux server. Is there
> an easy way to upgrade to the latest version (1.99.7)?
>
> My web2py installation says "Checking for upgrades...", but it never
> finishes checking! I presume that if it were to finish checking, there
> would be a way to upgrade automatically?
>
> Thanks.
>


Re: [web2py] Upgrading web2py in Linux

2012-03-12 Thread Bruce Wade
I do something similar but much much more efficient.

My project is under git version control. When upgraded I create a new
branch, unpack the new version of the code, test, if it didn't break
anything I then switch to the old branch and merge the new branch into it.
This prevents you from have to change all the configurations and do crazy
backup's etc... You should use source control for how it was meant to be
used.

On Mon, Mar 12, 2012 at 10:03 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> I am strongly suggest to you to not updating that way. Or if you do so,
> backup your web2py folder before.
>
> What I usually do:
>
> download latest source from download page
> backup my "staging"/"prod" web2py installation
> remove the old installation : cd /home/www-data/ && rm -Rf web2py/
> Uncompress the new web2py zip in the folder /home/www-data/
> Set permission : sudo chown -R www-data.www-data web2py/
> Copy my app in : web2py/applications/my app
> Also set permission is required here.
>
> If you are only talking about the dev environnement, I just let the old
> web2py in a folder named with the version and add an other folder with the
> new version beside and unpack web2py new version there and bring my app in
> the new installation.
>
> You don't have to bother with permission since you are only use it for
> developpement.
>
> Richard
>
>
>
> On Mon, Mar 12, 2012 at 12:45 PM, horridohobbyist <
> horrido.hobb...@gmail.com> wrote:
>
>> I'm currently running Version 1.99.2 on my Ubuntu Linux server. Is there
>> an easy way to upgrade to the latest version (1.99.7)?
>>
>> My web2py installation says "Checking for upgrades...", but it never
>> finishes checking! I presume that if it were to finish checking, there
>> would be a way to upgrade automatically?
>>
>> Thanks.
>>
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Upgrading web2py in Linux

2012-03-12 Thread Bruce Wade
PS: I have my git set to an account that can't ssh to my server. Therefor I
have to ssh then switch user to pull/push to my repository.

On Mon, Mar 12, 2012 at 10:11 AM, Bruce Wade  wrote:

> I do something similar but much much more efficient.
>
> My project is under git version control. When upgraded I create a new
> branch, unpack the new version of the code, test, if it didn't break
> anything I then switch to the old branch and merge the new branch into it.
> This prevents you from have to change all the configurations and do crazy
> backup's etc... You should use source control for how it was meant to be
> used.
>
>
> On Mon, Mar 12, 2012 at 10:03 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> I am strongly suggest to you to not updating that way. Or if you do so,
>> backup your web2py folder before.
>>
>> What I usually do:
>>
>> download latest source from download page
>> backup my "staging"/"prod" web2py installation
>> remove the old installation : cd /home/www-data/ && rm -Rf web2py/
>> Uncompress the new web2py zip in the folder /home/www-data/
>> Set permission : sudo chown -R www-data.www-data web2py/
>> Copy my app in : web2py/applications/my app
>> Also set permission is required here.
>>
>> If you are only talking about the dev environnement, I just let the old
>> web2py in a folder named with the version and add an other folder with the
>> new version beside and unpack web2py new version there and bring my app in
>> the new installation.
>>
>> You don't have to bother with permission since you are only use it for
>> developpement.
>>
>> Richard
>>
>>
>>
>> On Mon, Mar 12, 2012 at 12:45 PM, horridohobbyist <
>> horrido.hobb...@gmail.com> wrote:
>>
>>> I'm currently running Version 1.99.2 on my Ubuntu Linux server. Is there
>>> an easy way to upgrade to the latest version (1.99.7)?
>>>
>>> My web2py installation says "Checking for upgrades...", but it never
>>> finishes checking! I presume that if it were to finish checking, there
>>> would be a way to upgrade automatically?
>>>
>>>  Thanks.
>>>
>>
>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
I tried customizing the form. I have to set the id of the form element to 
login.
To achieve the above I used the following statement in controller:

login_form = auth.login()

# Configure form properties
login_form.attributes['_id']='login'

But it's not working. The generated form does not contain any id attribute.
Is there another way to do it ?

Thanks,
Sushant

On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>
> Thanks for an explanatory answer.
> I will try this out.
>
> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>
>> def index():
>>>
>>> login_form = auth.login()
>>> if login_form.process(session=None,formname='login').accepted:
>>> pass
>>> elif login_form.errors:
>>> response.write(request.vars)
>>> return dict()
>>>
>>> to display the form I have used the SQLForm in HTML technique as 
>>> mentioned in the web2py book
>>>
>>> Whenever user enters the correct email and password. auth_event 
>>> registers a login event with the description *User 1 Logged In*.
>>> The next property redirects the URL to /user/profile but auth.user 
>>> object is *None.*
>>>
>>
>> auth.login() handles it's own form processing, and it uses the session 
>> when calling form.accepts (which adds a hidden _formkey field to the form, 
>> which must be present upon form submission). In your code, you do not 
>> return the form object to the view, which means your view cannot include 
>> the hidden _formkey field, which is therefore not submitted with the form. 
>> So, when the form is submitted, the form.accepts in auth.login() fails, 
>> which means the user object is never stored in session.auth.user -- hence, 
>> auth.user is None. The reason the login submission is successful is that 
>> your index() function then does its own processing of the login form, which 
>> is successful -- but your explicit call to login_form.process() does not do 
>> anything to set auth.user, so it is never set.
>>
>> In short, you should not be doing your own processing of the login form 
>> -- let auth.login() handle that. And if you want to customize the form 
>> display in the view, you still have to return the form to the view so you 
>> can include the hidden _formkey and _formname fields in the form (you can 
>> use form.custom.end to do that).
>>
>> Anthony
>>
>

[web2py] Re: Can I change DAL encoding for strings?

2012-03-12 Thread Wikus van de Merwe
You could inherit from DAL and overwrite the methods with wrappers that do 
the decoding/encoding where needed.
I guess typically only insert, update, select and the constructor have to 
be wrapped.

There is also the "db_codec" keyword argument for DAL constructor defaulted 
to "utf-8". But I'm guessing this only
affects encoding on database level, not the queries.


Re: [web2py] Upgrading web2py in Linux

2012-03-12 Thread Richard Vézina
Use Fabric for about the samething, but since Horrido not to use version
control I leave thing basic.

Richard

On Mon, Mar 12, 2012 at 1:12 PM, Bruce Wade  wrote:

> PS: I have my git set to an account that can't ssh to my server. Therefor
> I have to ssh then switch user to pull/push to my repository.
>
>
> On Mon, Mar 12, 2012 at 10:11 AM, Bruce Wade  wrote:
>
>> I do something similar but much much more efficient.
>>
>> My project is under git version control. When upgraded I create a new
>> branch, unpack the new version of the code, test, if it didn't break
>> anything I then switch to the old branch and merge the new branch into it.
>> This prevents you from have to change all the configurations and do crazy
>> backup's etc... You should use source control for how it was meant to be
>> used.
>>
>>
>> On Mon, Mar 12, 2012 at 10:03 AM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> I am strongly suggest to you to not updating that way. Or if you do so,
>>> backup your web2py folder before.
>>>
>>> What I usually do:
>>>
>>> download latest source from download page
>>> backup my "staging"/"prod" web2py installation
>>> remove the old installation : cd /home/www-data/ && rm -Rf web2py/
>>> Uncompress the new web2py zip in the folder /home/www-data/
>>> Set permission : sudo chown -R www-data.www-data web2py/
>>> Copy my app in : web2py/applications/my app
>>> Also set permission is required here.
>>>
>>> If you are only talking about the dev environnement, I just let the old
>>> web2py in a folder named with the version and add an other folder with the
>>> new version beside and unpack web2py new version there and bring my app in
>>> the new installation.
>>>
>>> You don't have to bother with permission since you are only use it for
>>> developpement.
>>>
>>> Richard
>>>
>>>
>>>
>>> On Mon, Mar 12, 2012 at 12:45 PM, horridohobbyist <
>>> horrido.hobb...@gmail.com> wrote:
>>>
 I'm currently running Version 1.99.2 on my Ubuntu Linux server. Is
 there an easy way to upgrade to the latest version (1.99.7)?

 My web2py installation says "Checking for upgrades...", but it never
 finishes checking! I presume that if it were to finish checking, there
 would be a way to upgrade automatically?

  Thanks.

>>>
>>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Anthony
That should work. Can you show the view code? Also, note you can just do:

login_form['_id'] = 'login'

Anthony

On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>
> I tried customizing the form. I have to set the id of the form element to 
> login.
> To achieve the above I used the following statement in controller:
>
> login_form = auth.login()
>
> # Configure form properties
> login_form.attributes['_id']='login'
>
> But it's not working. The generated form does not contain any id attribute.
> Is there another way to do it ?
>
> Thanks,
> Sushant
>
> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>
>> Thanks for an explanatory answer.
>> I will try this out.
>>
>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>
>>> def index():

 login_form = auth.login()
 if login_form.process(session=None,formname='login').accepted:
 pass
 elif login_form.errors:
 response.write(request.vars)
 return dict()

 to display the form I have used the SQLForm in HTML technique as 
 mentioned in the web2py book

 Whenever user enters the correct email and password. auth_event 
 registers a login event with the description *User 1 Logged In*.
 The next property redirects the URL to /user/profile but auth.user 
 object is *None.*

>>>
>>> auth.login() handles it's own form processing, and it uses the session 
>>> when calling form.accepts (which adds a hidden _formkey field to the form, 
>>> which must be present upon form submission). In your code, you do not 
>>> return the form object to the view, which means your view cannot include 
>>> the hidden _formkey field, which is therefore not submitted with the form. 
>>> So, when the form is submitted, the form.accepts in auth.login() fails, 
>>> which means the user object is never stored in session.auth.user -- hence, 
>>> auth.user is None. The reason the login submission is successful is that 
>>> your index() function then does its own processing of the login form, which 
>>> is successful -- but your explicit call to login_form.process() does not do 
>>> anything to set auth.user, so it is never set.
>>>
>>> In short, you should not be doing your own processing of the login form 
>>> -- let auth.login() handle that. And if you want to customize the form 
>>> display in the view, you still have to return the form to the view so you 
>>> can include the hidden _formkey and _formname fields in the form (you can 
>>> use form.custom.end to do that).
>>>
>>> Anthony
>>>
>>
On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>
> I tried customizing the form. I have to set the id of the form element to 
> login.
> To achieve the above I used the following statement in controller:
>
> login_form = auth.login()
>
> # Configure form properties
> login_form.attributes['_id']='login'
>
> But it's not working. The generated form does not contain any id attribute.
> Is there another way to do it ?
>
> Thanks,
> Sushant
>
> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>
>> Thanks for an explanatory answer.
>> I will try this out.
>>
>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>
>>> def index():

 login_form = auth.login()
 if login_form.process(session=None,formname='login').accepted:
 pass
 elif login_form.errors:
 response.write(request.vars)
 return dict()

 to display the form I have used the SQLForm in HTML technique as 
 mentioned in the web2py book

 Whenever user enters the correct email and password. auth_event 
 registers a login event with the description *User 1 Logged In*.
 The next property redirects the URL to /user/profile but auth.user 
 object is *None.*

>>>
>>> auth.login() handles it's own form processing, and it uses the session 
>>> when calling form.accepts (which adds a hidden _formkey field to the form, 
>>> which must be present upon form submission). In your code, you do not 
>>> return the form object to the view, which means your view cannot include 
>>> the hidden _formkey field, which is therefore not submitted with the form. 
>>> So, when the form is submitted, the form.accepts in auth.login() fails, 
>>> which means the user object is never stored in session.auth.user -- hence, 
>>> auth.user is None. The reason the login submission is successful is that 
>>> your index() function then does its own processing of the login form, which 
>>> is successful -- but your explicit call to login_form.process() does not do 
>>> anything to set auth.user, so it is never set.
>>>
>>> In short, you should not be doing your own processing of the login form 
>>> -- let auth.login() handle that. And if you want to customize the form 
>>> display in the view, you still have to return the form to the view so you 
>>> can include the hidden _formkey and _formname fie

[web2py] add classes to individual menu items

2012-03-12 Thread monotasker
I want each of my app menu items to have a distinct class to ease theming 
(I'm using background images to provide icons in place of text). It looks 
like the MENU helper doesn't allow _class arguments in the items in 
response.menu. So I can just modify the MENU helper, but am I missing some 
way of doing this in the existing api?

I wonder, by the way, whether it would be a good idea to extend the MENU 
interface to allow passing _class and/or _id arguments like this:

(T('my item'), True, URL('default', 'index'), [],* _class = 'my_item_class'*, 
*id = 'my_item_id'*),

Ian


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

I tried both but none seems to be working. Here's my view code:



{{=login_form.custom.begin}}

{{=login_form.custom.widget.email}}


{{=login_form.custom.widget.password}}


Forgot Password?
{{=login_form.custom.submit}}

{{=login_form.custom.end}}


Please suggest.

On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>
> That should work. Can you show the view code? Also, note you can just do:
>
> login_form['_id'] = 'login'
>
> Anthony
>
> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>
>> I tried customizing the form. I have to set the id of the form element to 
>> login.
>> To achieve the above I used the following statement in controller:
>>
>> login_form = auth.login()
>>
>> # Configure form properties
>> login_form.attributes['_id']='login'
>>
>> But it's not working. The generated form does not contain any id 
>> attribute.
>> Is there another way to do it ?
>>
>> Thanks,
>> Sushant
>>
>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>
>>> Thanks for an explanatory answer.
>>> I will try this out.
>>>
>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:

 def index():
>
> login_form = auth.login()
> if login_form.process(session=None,formname='login').accepted:
> pass
> elif login_form.errors:
> response.write(request.vars)
> return dict()
>
> to display the form I have used the SQLForm in HTML technique as 
> mentioned in the web2py book
>
> Whenever user enters the correct email and password. auth_event 
> registers a login event with the description *User 1 Logged In*.
> The next property redirects the URL to /user/profile but auth.user 
> object is *None.*
>

 auth.login() handles it's own form processing, and it uses the session 
 when calling form.accepts (which adds a hidden _formkey field to the form, 
 which must be present upon form submission). In your code, you do not 
 return the form object to the view, which means your view cannot include 
 the hidden _formkey field, which is therefore not submitted with the form. 
 So, when the form is submitted, the form.accepts in auth.login() fails, 
 which means the user object is never stored in session.auth.user -- hence, 
 auth.user is None. The reason the login submission is successful is that 
 your index() function then does its own processing of the login form, 
 which 
 is successful -- but your explicit call to login_form.process() does not 
 do 
 anything to set auth.user, so it is never set.

 In short, you should not be doing your own processing of the login form 
 -- let auth.login() handle that. And if you want to customize the form 
 display in the view, you still have to return the form to the view so you 
 can include the hidden _formkey and _formname fields in the form (you can 
 use form.custom.end to do that).

 Anthony

>>>
> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>
>> I tried customizing the form. I have to set the id of the form element to 
>> login.
>> To achieve the above I used the following statement in controller:
>>
>> login_form = auth.login()
>>
>> # Configure form properties
>> login_form.attributes['_id']='login'
>>
>> But it's not working. The generated form does not contain any id 
>> attribute.
>> Is there another way to do it ?
>>
>> Thanks,
>> Sushant
>>
>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>
>>> Thanks for an explanatory answer.
>>> I will try this out.
>>>
>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:

 def index():
>
> login_form = auth.login()
> if login_form.process(session=None,formname='login').accepted:
> pass
> elif login_form.errors:
> response.write(request.vars)
> return dict()
>
> to display the form I have used the SQLForm in HTML technique as 
> mentioned in the web2py book
>
> Whenever user enters the correct email and password. auth_event 
> registers a login event with the description *User 1 Logged In*.
> The next property redirects the URL to /user/profile but auth.user 
> object is *None.*
>

 auth.login() handles it's own form processing, and it uses the session 
 when calling form.accepts (which adds a hidden _formkey field to the form, 
 which must be present upon form submission). In your code, you do not 
 return the form object to the view, which means your view cannot include 
 the hidden _formkey field, which is ther

Re: [web2py] add classes to individual menu items

2012-03-12 Thread Martín Mulone
I think you can do:

(T('my item'), True, A('My item', _href=URL('default', 'index'), _class =
'my_item_class', id = 'my_item_id'), []),

2012/3/12 monotasker 

> I want each of my app menu items to have a distinct class to ease theming
> (I'm using background images to provide icons in place of text). It looks
> like the MENU helper doesn't allow _class arguments in the items in
> response.menu. So I can just modify the MENU helper, but am I missing some
> way of doing this in the existing api?
>
> I wonder, by the way, whether it would be a good idea to extend the MENU
> interface to allow passing _class and/or _id arguments like this:
>
> (T('my item'), True, URL('default', 'index'), [],* _class =
> 'my_item_class'*, *id = 'my_item_id'*),
>
> Ian
>



-- 
 http://www.tecnodoc.com.ar


[web2py] auth=Auth(globals(),db)

2012-03-12 Thread Richard
Hello,

I notice that in the book auth table customisation explication has 
changed...

I would like to know if this still good :

auth=Auth(globals(),db)
crud=Crud(globals(),db) 

Since in the book it is now just :

auth = Auth(db)

Thank you.

Richard


Re: [web2py] auth=Auth(globals(),db)

2012-03-12 Thread Anthony

>
> auth=Auth(globals(),db)
> crud=Crud(globals(),db) 
>

The above will still work, but globals() will simply be ignored, as it is 
no longer required (instead, the Auth and Crud classes now use the 
"current" object to access the relevant global environment objects).

Anthony


Re: [web2py] auth=Auth(globals(),db)

2012-03-12 Thread Richard Vézina
Thanks Anthony.

Richard

On Mon, Mar 12, 2012 at 2:29 PM, Anthony  wrote:

> auth=Auth(globals(),db)
>> crud=Crud(globals(),db)
>>
>
> The above will still work, but globals() will simply be ignored, as it is
> no longer required (instead, the Auth and Crud classes now use the
> "current" object to access the relevant global environment objects).
>
> Anthony
>


Re: [web2py] auth=Auth(globals(),db)

2012-03-12 Thread Richard Vézina
Are those also part of current now?
service=Service(globals())
mail = Mail(globals())

Richard

On Mon, Mar 12, 2012 at 2:31 PM, Richard Vézina  wrote:

> Thanks Anthony.
>
> Richard
>
>
> On Mon, Mar 12, 2012 at 2:29 PM, Anthony  wrote:
>
>> auth=Auth(globals(),db)
>>> crud=Crud(globals(),db)
>>>
>>
>> The above will still work, but globals() will simply be ignored, as it is
>> no longer required (instead, the Auth and Crud classes now use the
>> "current" object to access the relevant global environment objects).
>>
>> Anthony
>>
>
>


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Anthony
What's not working? When you view the HTML code of the rendered page in the 
browser, is the id not there, or is it just that some client-side CSS or JS 
isn't working as expected? If the latter, the problem could be that you 
have put the form beginning and ending code inside the  tags 
rather than outside, where they belong. Should be:

{{=login_form.custom.begin}} 

[snip]

{{=login_form.custom.end}}

Anthony

On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>
> Hi,
>
> I tried both but none seems to be working. Here's my view code:
>
> 
> 
> {{=login_form.custom.begin}}
> 
>  colspan='2'>{{=login_form.custom.widget.email}}
> 
> 
>  colspan='2'>{{=login_form.custom.widget.password}}
> 
> 
>  class="flipLink">Forgot Password?
> {{=login_form.custom.submit}}
> 
> {{=login_form.custom.end}}
> 
>
> Please suggest.
>
> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>>
>> That should work. Can you show the view code? Also, note you can just do:
>>
>> login_form['_id'] = 'login'
>>
>> Anthony
>>
>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>
>>> I tried customizing the form. I have to set the id of the form element 
>>> to login.
>>> To achieve the above I used the following statement in controller:
>>>
>>> login_form = auth.login()
>>>
>>> # Configure form properties
>>> login_form.attributes['_id']='login'
>>>
>>> But it's not working. The generated form does not contain any id 
>>> attribute.
>>> Is there another way to do it ?
>>>
>>> Thanks,
>>> Sushant
>>>
>>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:

 Thanks for an explanatory answer.
 I will try this out.

 On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>
> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to display the form I have used the SQLForm in HTML technique as 
>> mentioned in the web2py book
>>
>> Whenever user enters the correct email and password. auth_event 
>> registers a login event with the description *User 1 Logged In*.
>> The next property redirects the URL to /user/profile but auth.user 
>> object is *None.*
>>
>
> auth.login() handles it's own form processing, and it uses the session 
> when calling form.accepts (which adds a hidden _formkey field to the 
> form, 
> which must be present upon form submission). In your code, you do not 
> return the form object to the view, which means your view cannot include 
> the hidden _formkey field, which is therefore not submitted with the 
> form. 
> So, when the form is submitted, the form.accepts in auth.login() fails, 
> which means the user object is never stored in session.auth.user -- 
> hence, 
> auth.user is None. The reason the login submission is successful is that 
> your index() function then does its own processing of the login form, 
> which 
> is successful -- but your explicit call to login_form.process() does not 
> do 
> anything to set auth.user, so it is never set.
>
> In short, you should not be doing your own processing of the login 
> form -- let auth.login() handle that. And if you want to customize the 
> form 
> display in the view, you still have to return the form to the view so you 
> can include the hidden _formkey and _formname fields in the form (you can 
> use form.custom.end to do that).
>
> Anthony
>

>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>
>>> I tried customizing the form. I have to set the id of the form element 
>>> to login.
>>> To achieve the above I used the following statement in controller:
>>>
>>> login_form = auth.login()
>>>
>>> # Configure form properties
>>> login_form.attributes['_id']='login'
>>>
>>> But it's not working. The generated form does not contain any id 
>>> attribute.
>>> Is there another way to do it ?
>>>
>>> Thanks,
>>> Sushant
>>>
>>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:

 Thanks for an explanatory answer.
 I will try this out.

 On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>
> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to displa

Re: [web2py] add classes to individual menu items

2012-03-12 Thread monotasker
That does it. Great! Was this in the book somewhere?

Ian

On Monday, March 12, 2012 2:08:18 PM UTC-4, Martin.Mulone wrote:
>
> I think you can do:
>
> (T('my item'), True, A('My item', _href=URL('default', 'index'), _class = 
> 'my_item_class', id = 'my_item_id'), []),
>
> 2012/3/12 monotasker 
>
>> I want each of my app menu items to have a distinct class to ease theming 
>> (I'm using background images to provide icons in place of text). It looks 
>> like the MENU helper doesn't allow _class arguments in the items in 
>> response.menu. So I can just modify the MENU helper, but am I missing some 
>> way of doing this in the existing api?
>>
>> I wonder, by the way, whether it would be a good idea to extend the MENU 
>> interface to allow passing _class and/or _id arguments like this:
>>
>> (T('my item'), True, URL('default', 'index'), [],* _class = 
>> 'my_item_class'*, *id = 'my_item_id'*),
>>
>> Ian
>>
>
>
>
> -- 
>  http://www.tecnodoc.com.ar
>
>

[web2py] Re: custom css

2012-03-12 Thread Wikus van de Merwe
Does the example app that comes with web2py show flash/errors correctly on 
Firefox 10 + Windows?
If so, it would mean you didn't copy all the required CSS rules or you are 
missing a class/id/tag in your layout.



[web2py] Re: custom css

2012-03-12 Thread monotasker
Can you post the parts of your css code that aren't working?

Ian

On Sunday, March 11, 2012 7:39:42 AM UTC-4, frasse wrote:
>
> Hi 
>
> I like to use my custom css and add it to my application base.css mess 
> my application. I have remove base.css and move  classes .flash 
> and .error to my custom css file. when I do that it is not working in 
> FireFox 10 in windows but it works in all other browser and OS (mac 
> Ubuntu , win). 
>
> Can you please help me with that ? 
>
> /F



[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
The rendered form is as:


...


It has no attribute id.

On Tuesday, March 13, 2012 12:05:02 AM UTC+5:30, Anthony wrote:
>
> What's not working? When you view the HTML code of the rendered page in 
> the browser, is the id not there, or is it just that some client-side CSS 
> or JS isn't working as expected? If the latter, the problem could be that 
> you have put the form beginning and ending code inside the  
> tags rather than outside, where they belong. Should be:
>
> {{=login_form.custom.begin}} 
> 
> [snip]
> 
> {{=login_form.custom.end}}
>
> Anthony
>
> On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I tried both but none seems to be working. Here's my view code:
>>
>> 
>> 
>> {{=login_form.custom.begin}}
>> 
>> > colspan='2'>{{=login_form.custom.widget.email}}
>> 
>> 
>> > colspan='2'>{{=login_form.custom.widget.password}}
>> 
>> 
>> > class="flipLink">Forgot Password?
>> {{=login_form.custom.submit}}
>> 
>> {{=login_form.custom.end}}
>> 
>>
>> Please suggest.
>>
>> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>>>
>>> That should work. Can you show the view code? Also, note you can just do:
>>>
>>> login_form['_id'] = 'login'
>>>
>>> Anthony
>>>
>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:

 I tried customizing the form. I have to set the id of the form element 
 to login.
 To achieve the above I used the following statement in controller:

 login_form = auth.login()

 # Configure form properties
 login_form.attributes['_id']='login'

 But it's not working. The generated form does not contain any id 
 attribute.
 Is there another way to do it ?

 Thanks,
 Sushant

 On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>
> Thanks for an explanatory answer.
> I will try this out.
>
> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>
>> def index():
>>>
>>> login_form = auth.login()
>>> if login_form.process(session=None,formname='login').accepted:
>>> pass
>>> elif login_form.errors:
>>> response.write(request.vars)
>>> return dict()
>>>
>>> to display the form I have used the SQLForm in HTML technique as 
>>> mentioned in the web2py book
>>>
>>> Whenever user enters the correct email and password. auth_event 
>>> registers a login event with the description *User 1 Logged In*.
>>> The next property redirects the URL to /user/profile but auth.user 
>>> object is *None.*
>>>
>>
>> auth.login() handles it's own form processing, and it uses the 
>> session when calling form.accepts (which adds a hidden _formkey field to 
>> the form, which must be present upon form submission). In your code, you 
>> do 
>> not return the form object to the view, which means your view cannot 
>> include the hidden _formkey field, which is therefore not submitted with 
>> the form. So, when the form is submitted, the form.accepts in 
>> auth.login() 
>> fails, which means the user object is never stored in session.auth.user 
>> -- 
>> hence, auth.user is None. The reason the login submission is successful 
>> is 
>> that your index() function then does its own processing of the login 
>> form, 
>> which is successful -- but your explicit call to login_form.process() 
>> does 
>> not do anything to set auth.user, so it is never set.
>>
>> In short, you should not be doing your own processing of the login 
>> form -- let auth.login() handle that. And if you want to customize the 
>> form 
>> display in the view, you still have to return the form to the view so 
>> you 
>> can include the hidden _formkey and _formname fields in the form (you 
>> can 
>> use form.custom.end to do that).
>>
>> Anthony
>>
>
>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:

 I tried customizing the form. I have to set the id of the form element 
 to login.
 To achieve the above I used the following statement in controller:

 login_form = auth.login()

 # Configure form properties
 login_form.attributes['_id']='login'

 But it's not working. The generated form does not contain any id 
 attribute.
 Is there another way to do it ?

 Thanks,
 Sushant

 On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>
> Thanks for an explanatory answer.
> I will try this out.
>
> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, An

Re: [web2py] add classes to individual menu items

2012-03-12 Thread Anthony

>
> I think you can do:
>
> (T('my item'), True, A('My item', _href=URL('default', 'index'), _class = 
> 'my_item_class', id = 'my_item_id'), []),
>

Yes, in fact, the third item in the tuple can be any HTML helper (which 
could include nested helpers), and the MENU helper will simply render that 
helper rather than creating its own  tag.

An alternative is to use a SPAN for the first item in the tuple and add the 
class to the span:

(SPAN(T('my item'), _class='my_item_class'), True, URL('default', 'index'))

Again, that first item can be any HTML helper.

I don't think any of this is documented in the book.

Anthony


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Anthony
Hmm, works when I try it. Can you show the full controller code you have 
now?

On Monday, March 12, 2012 2:46:57 PM UTC-4, Sushant Taneja wrote:
>
> The rendered form is as:
>
> 
> ...
> 
>
> It has no attribute id.
>
> On Tuesday, March 13, 2012 12:05:02 AM UTC+5:30, Anthony wrote:
>>
>> What's not working? When you view the HTML code of the rendered page in 
>> the browser, is the id not there, or is it just that some client-side CSS 
>> or JS isn't working as expected? If the latter, the problem could be that 
>> you have put the form beginning and ending code inside the  
>> tags rather than outside, where they belong. Should be:
>>
>> {{=login_form.custom.begin}} 
>> 
>> [snip]
>> 
>> {{=login_form.custom.end}}
>>
>> Anthony
>>
>> On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>>>
>>> Hi,
>>>
>>> I tried both but none seems to be working. Here's my view code:
>>>
>>> 
>>> 
>>> {{=login_form.custom.begin}}
>>> 
>>> >> colspan='2'>{{=login_form.custom.widget.email}}
>>> 
>>> 
>>> >> colspan='2'>{{=login_form.custom.widget.password}}
>>> 
>>> 
>>> >> class="flipLink">Forgot Password?
>>> {{=login_form.custom.submit}}
>>> 
>>> {{=login_form.custom.end}}
>>> 
>>>
>>> Please suggest.
>>>
>>> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:

 That should work. Can you show the view code? Also, note you can just 
 do:

 login_form['_id'] = 'login'

 Anthony

 On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>
> I tried customizing the form. I have to set the id of the form element 
> to login.
> To achieve the above I used the following statement in controller:
>
> login_form = auth.login()
>
> # Configure form properties
> login_form.attributes['_id']='login'
>
> But it's not working. The generated form does not contain any id 
> attribute.
> Is there another way to do it ?
>
> Thanks,
> Sushant
>
> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>
>> Thanks for an explanatory answer.
>> I will try this out.
>>
>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>
>>> def index():

 login_form = auth.login()
 if login_form.process(session=None,formname='login').accepted:
 pass
 elif login_form.errors:
 response.write(request.vars)
 return dict()

 to display the form I have used the SQLForm in HTML technique as 
 mentioned in the web2py book

 Whenever user enters the correct email and password. auth_event 
 registers a login event with the description *User 1 Logged In*.
 The next property redirects the URL to /user/profile but auth.user 
 object is *None.*

>>>
>>> auth.login() handles it's own form processing, and it uses the 
>>> session when calling form.accepts (which adds a hidden _formkey field 
>>> to 
>>> the form, which must be present upon form submission). In your code, 
>>> you do 
>>> not return the form object to the view, which means your view cannot 
>>> include the hidden _formkey field, which is therefore not submitted 
>>> with 
>>> the form. So, when the form is submitted, the form.accepts in 
>>> auth.login() 
>>> fails, which means the user object is never stored in session.auth.user 
>>> -- 
>>> hence, auth.user is None. The reason the login submission is successful 
>>> is 
>>> that your index() function then does its own processing of the login 
>>> form, 
>>> which is successful -- but your explicit call to login_form.process() 
>>> does 
>>> not do anything to set auth.user, so it is never set.
>>>
>>> In short, you should not be doing your own processing of the login 
>>> form -- let auth.login() handle that. And if you want to customize the 
>>> form 
>>> display in the view, you still have to return the form to the view so 
>>> you 
>>> can include the hidden _formkey and _formname fields in the form (you 
>>> can 
>>> use form.custom.end to do that).
>>>
>>> Anthony
>>>
>>
 On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>
> I tried customizing the form. I have to set the id of the form element 
> to login.
> To achieve the above I used the following statement in controller:
>
> login_form = auth.login()
>
> # Configure form properties
> login_form.attributes['_id']='login'
>
> But it's not working. The generated form 

Re: [web2py] auth=Auth(globals(),db)

2012-03-12 Thread Anthony
On Monday, March 12, 2012 2:33:44 PM UTC-4, Richard wrote:
>
> Are those also part of current now?
> service=Service(globals())
> mail = Mail(globals())
>

Yes for Service; doesn't apply for Mail. 


[web2py] 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Cliff
My login is pretty much vanilla Web2py.  No changes to default.py
users.

In the model I have this:

comment = ''
if request.controller=='auth_user':
comment = SPAN('Must be at least 12 characters in length',
   _style='color:orange;'
  )
db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('middle_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('generation', length=128, default=''),
Field('email', length=128, default='', unique=True,
 comment=email_comment), # required
Field('password', 'password', length=128,# required
  readable=False, label='Password',
  comment=comment),
 ),
#  blah blah  more details + required fields
)

custom_auth_table.password.requires = [
IS_STRONG(min=12, max=128, upper=None, lower=None,
 number=None, special=None,), CRYPT()
]

If I set error_message to an empty string or None in the model,
attempting to log in with password 'foo' causes the error banner
to appear with "None" as the caption.  If I don't set error_message
I get the banner with the error message from IS_STRONG().

What am I doing wrong?  What can I do about this?


Re: [web2py] 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Bruce Wade
error_message = '' and error_message = None are treated as the samething.

Try:
error_message = '  '

Haven't tried but that may give you a black message like you want.

On Mon, Mar 12, 2012 at 12:02 PM, Cliff  wrote:

> My login is pretty much vanilla Web2py.  No changes to default.py
> users.
>
> In the model I have this:
>
> comment = ''
> if request.controller=='auth_user':
>comment = SPAN('Must be at least 12 characters in length',
>   _style='color:orange;'
>  )
> db.define_table(
>auth.settings.table_user_name,
>Field('first_name', length=128, default=''),
>Field('middle_name', length=128, default=''),
>Field('last_name', length=128, default=''),
>Field('generation', length=128, default=''),
>Field('email', length=128, default='', unique=True,
> comment=email_comment), # required
>Field('password', 'password', length=128,# required
>  readable=False, label='Password',
>  comment=comment),
> ),
>#  blah blah  more details + required fields
> )
>
> custom_auth_table.password.requires = [
>IS_STRONG(min=12, max=128, upper=None, lower=None,
> number=None, special=None,), CRYPT()
> ]
>
> If I set error_message to an empty string or None in the model,
> attempting to log in with password 'foo' causes the error banner
> to appear with "None" as the caption.  If I don't set error_message
> I get the banner with the error message from IS_STRONG().
>
> What am I doing wrong?  What can I do about this?
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] auth=Auth(globals(),db)

2012-03-12 Thread Richard Vézina
Thanks!

:)

Richard

On Mon, Mar 12, 2012 at 3:01 PM, Anthony  wrote:

> On Monday, March 12, 2012 2:33:44 PM UTC-4, Richard wrote:
>>
>> Are those also part of current now?
>> service=Service(globals())
>> mail = Mail(globals())
>>
>
> Yes for Service; doesn't apply for Mail.
>


[web2py] Re: custom css

2012-03-12 Thread frasse
Yes the example app that comes with web2py show correctly on
Firefox 10 + Windows.
I greed that I am missing some classes from base.css. but I can not
found what .

Here is what I did.

I copy .flash .error to my css file (the_look.css).
It is the copy code:
-
div.flash {
font-weight: bold;
display: none;
position: fixed;
padding: 10px;
top: 40px;
right: 10px;
min-width: 280px;
opacity: 0.85;
margin: 0px 0px 10px 10px;
color: #fff;
vertical-align: middle;
cursor: pointer;
background: #000;
border: 2px solid #fff;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
z-index: 2;
}
div.error {
background-color: red;
color: white;
padding: 3px;
}
---


I have some change in my layout.html here is the change





   




 
 


  












{{#--  require CSS and JS files for this page (read info in
base.css) --}}
{{response.files.append(URL('static','css/the_look.css'))}}
{{# response.files.append(URL('static','css/base.css'))}}
{{response.files.append(URL('static','css/superfish.css'))}}
{{response.files.append(URL('static','js/superfish.js'))}}

{{#-- include web2py specific js code (jquery, calendar, form
stuff) --}}
{{include 'web2py_ajax.html'}}
{{
#using sidebars need to know what sidebar you want to use
#prior of using it, because of static width size of content, you
can use
#left_sidebar, right_sidebar, both or none (False left and
right)
left_sidebar_enabled = globals().get('left_sidebar_enabled',False)
right_sidebar_enabled =
globals().get('right_sidebar_enabled',False)
if left_sidebar_enabled and right_sidebar_enabled:
width_content='63%'
elif left_sidebar_enabled != right_sidebar_enabled:
width_content='740px'
else: width_content='100%'
if left_sidebar_enabled: left_sidebar_style = 'style="display:
block;"'
else: left_sidebar_style = 'style="display: none;"'
if right_sidebar_enabled: right_sidebar_style = 'style="display:
block;"'
else: right_sidebar_style = 'style="display: none;"'
style_content = 'style="width: %s"' % width_content
}}



-->




var sek= {{=session.sec}};
var minut={{=session.min}};
var timme={{=session.hour}};
var dag={{=session.day}};






  
  
  
  
  


{{=response.flash or ''}}




{{include 'huvud.html'}}


{{include 'meny.html'}}




{{include}}







--


/F


On 12 mar, 19:43, monotasker  wrote:
> Can you post the parts of your css code that aren't working?
>
> Ian
>
>
>
>
>
>
>
> On Sunday, March 11, 2012 7:39:42 AM UTC-4, frasse wrote:
>
> > Hi
>
> > I like to use my custom css and add it to my application base.css mess
> > my application. I have remove base.css and move  classes .flash
> > and .error to my custom css file. when I do that it is not working in
> > FireFox 10 in windows but it works in all other browser and OS (mac
> > Ubuntu , win).
>
> > Can you please help me with that ?
>
> > /F


Re: [web2py] Re: No models vs. conditional models -- what's the advantage?

2012-03-12 Thread Pepe Araya
With all the post arguing about no models... I'm asking myself: why web2py 
have "models" folder if it isn't the best way to do the work? only for 
background compatibility? 

what's the reason to load the models every time you make a request? is 
because the automatic migrations? 

are only questions, and why not made a huge change and optimization in a 
brand new version of web2py?

best regards,



On Thursday, March 8, 2012 12:45:41 PM UTC-3, rochacbruno wrote:
>
> another advantage is the fact that you can import modules, you cannot 
> import models. it is very nice to import your tables on external scripts.
>
> http://zerp.ly/rochacbruno
> Em 08/03/2012 12:11, "Anthony" escreveu:
>
>> I think an additional advantage of the module approach is that the module 
>> only has to be loaded once (when it is first imported), but the model files 
>> have to be read on every request.
>>
>> Anthony
>>
>> On Thursday, March 8, 2012 10:04:11 AM UTC-5, Cliff wrote:
>>>
>>> Certainly we want to avoid processing unnecessary table definitions 
>>> with every request. 
>>>
>>> It seems to me that the simplest solution is something like this: 
>>>
>>> if request.controller=='foo': 
>>>   db.define_table('foo', Field...) # main table 
>>>   db.define_table('foo_one_to_**many', Field(foo_id, db.foo...)...) 
>>>   ... 
>>>
>>> What is the advantage of the no models architecture over this?
>>
>>

Re: [web2py] Re: No models vs. conditional models -- what's the advantage?

2012-03-12 Thread Bruce Wade
agreed

On Mon, Mar 12, 2012 at 12:16 PM, Pepe Araya  wrote:

> With all the post arguing about no models... I'm asking myself: why web2py
> have "models" folder if it isn't the best way to do the work? only for
> background compatibility?
>
> what's the reason to load the models every time you make a request? is
> because the automatic migrations?
>
> are only questions, and why not made a huge change and optimization in a
> brand new version of web2py?
>
> best regards,
>
>
>
> On Thursday, March 8, 2012 12:45:41 PM UTC-3, rochacbruno wrote:
>
>> another advantage is the fact that you can import modules, you cannot
>> import models. it is very nice to import your tables on external scripts.
>>
>> http://zerp.ly/rochacbruno
>> Em 08/03/2012 12:11, "Anthony" escreveu:
>>
>> I think an additional advantage of the module approach is that the module
>>> only has to be loaded once (when it is first imported), but the model files
>>> have to be read on every request.
>>>
>>> Anthony
>>>
>>> On Thursday, March 8, 2012 10:04:11 AM UTC-5, Cliff wrote:

 Certainly we want to avoid processing unnecessary table definitions
 with every request.

 It seems to me that the simplest solution is something like this:

 if request.controller=='foo':
   db.define_table('foo', Field...) # main table
   db.define_table('foo_one_to_**ma**ny', Field(foo_id, db.foo...)...)
   ...

 What is the advantage of the no models architecture over this?
>>>
>>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Support for PyPy

2012-03-12 Thread Francisco Costa
Well I've compiled pypy-1.8 from source (without jit) and found that is 
slower than python whyle executing web2py
here are my test results


*PYPY*
ab -n 10 -c 5 http://127.0.0.1:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).done


Server Software:Rocket
Server Hostname:127.0.0.1
Server Port:8000

Document Path:  /
Document Length:18071 bytes

Concurrency Level:  5
Time taken for tests:   5.257 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  184880 bytes
HTML transferred:   180710 bytes
Requests per second:1.90 [#/sec] (mean)
Time per request:   2628.322 [ms] (mean)
Time per request:   525.664 [ms] (mean, across all concurrent requests)
Transfer rate:  34.35 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   0
Processing:  1851 2465 277.7   25832731
Waiting: 1849 2461 275.6   25832705
Total:   1851 2465 277.7   25832731

Percentage of the requests served within a certain time (ms)
  50%   2583
  66%   2610
  75%   2671
  80%   2671
  90%   2731
  95%   2731
  98%   2731
  99%   2731
 100%   2731 (longest request)


*PYTHON*
ab -n 10 -c 5 http://127.0.0.1:8181/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).done


Server Software:Rocket
Server Hostname:127.0.0.1
Server Port:8181

Document Path:  /
Document Length:18071 bytes

Concurrency Level:  5
Time taken for tests:   1.920 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  184890 bytes
HTML transferred:   180710 bytes
Requests per second:5.21 [#/sec] (mean)
Time per request:   960.005 [ms] (mean)
Time per request:   192.001 [ms] (mean, across all concurrent requests)
Transfer rate:  94.04 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.2  0   0
Processing:   694  883 107.48851031
Waiting:  693  880 104.28851030
Total:694  883 107.68851031

Percentage of the requests served within a certain time (ms)
  50%885
  66%889
  75%995
  80%   1017
  90%   1031
  95%   1031
  98%   1031
  99%   1031
 100%   1031 (longest request)



This app uses lots of modules like pymongo, Image, stripogram, dateutil, 
pygeoip,tornado, tornadio, pycurl
I've manage to easy_install all them in pypy, but I couldn't install 
pycurl, so I've commented it for the ab testing

I've also tried with the welcome app and the results were similar: pypy was 
2.5x slower


Any other tests are truly appreciated


[web2py] Re: 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Cliff
Thanks, Bruce.

Tried that approach, but it still gave me the error div on the form,
though there was no message.

If the password is long enough, I get the standard login failed
message in flash.

If the password is too short, login gives me the red error banner,
even if it's blank.

On Mar 12, 3:06 pm, Bruce Wade  wrote:
> error_message = '' and error_message = None are treated as the samething.
>
> Try:
> error_message = '  '
>
> Haven't tried but that may give you a black message like you want.
>
>
>
>
>
>
>
>
>
> On Mon, Mar 12, 2012 at 12:02 PM, Cliff  wrote:
> > My login is pretty much vanilla Web2py.  No changes to default.py
> > users.
>
> > In the model I have this:
>
> > comment = ''
> > if request.controller=='auth_user':
> >    comment = SPAN('Must be at least 12 characters in length',
> >                       _style='color:orange;'
> >                      )
> > db.define_table(
> >    auth.settings.table_user_name,
> >    Field('first_name', length=128, default=''),
> >    Field('middle_name', length=128, default=''),
> >    Field('last_name', length=128, default=''),
> >    Field('generation', length=128, default=''),
> >    Field('email', length=128, default='', unique=True,
> >         comment=email_comment), # required
> >    Field('password', 'password', length=128,            # required
> >          readable=False, label='Password',
> >          comment=comment),
> >         ),
> >    #  blah blah  more details + required fields
> > )
>
> > custom_auth_table.password.requires = [
> >    IS_STRONG(min=12, max=128, upper=None, lower=None,
> >             number=None, special=None,), CRYPT()
> > ]
>
> > If I set error_message to an empty string or None in the model,
> > attempting to log in with password 'foo' causes the error banner
> > to appear with "None" as the caption.  If I don't set error_message
> > I get the banner with the error message from IS_STRONG().
>
> > What am I doing wrong?  What can I do about this?
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Cliff
This works.

custom_auth_table.password.requires = CRYPT()
if request.args(0) != 'login':
    custom_auth_table.password.requires = [
        IS_STRONG(min=12, max=128, upper=None, lower=None,
                 number=None, special=None, error_message=' '),
CRYPT()
    ]

Could also be handled in default.py.

On Mar 12, 3:06 pm, Bruce Wade  wrote:
> error_message = '' and error_message = None are treated as the samething.
>
> Try:
> error_message = '  '
>
> Haven't tried but that may give you a black message like you want.
>
>
>
>
>
>
>
>
>
> On Mon, Mar 12, 2012 at 12:02 PM, Cliff  wrote:
> > My login is pretty much vanilla Web2py.  No changes to default.py
> > users.
>
> > In the model I have this:
>
> > comment = ''
> > if request.controller=='auth_user':
> >    comment = SPAN('Must be at least 12 characters in length',
> >                       _style='color:orange;'
> >                      )
> > db.define_table(
> >    auth.settings.table_user_name,
> >    Field('first_name', length=128, default=''),
> >    Field('middle_name', length=128, default=''),
> >    Field('last_name', length=128, default=''),
> >    Field('generation', length=128, default=''),
> >    Field('email', length=128, default='', unique=True,
> >         comment=email_comment), # required
> >    Field('password', 'password', length=128,            # required
> >          readable=False, label='Password',
> >          comment=comment),
> >         ),
> >    #  blah blah  more details + required fields
> > )
>
> > custom_auth_table.password.requires = [
> >    IS_STRONG(min=12, max=128, upper=None, lower=None,
> >             number=None, special=None,), CRYPT()
> > ]
>
> > If I set error_message to an empty string or None in the model,
> > attempting to log in with password 'foo' causes the error banner
> > to appear with "None" as the caption.  If I don't set error_message
> > I get the banner with the error message from IS_STRONG().
>
> > What am I doing wrong?  What can I do about this?
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] subdomain routes for websites

2012-03-12 Thread Carlos
Hi,

My previous related post: 
 https://groups.google.com/d/topic/web2py/TxACULvgxik/discussion

Following is my url path structure to access websites for multiple 
Organizations (ORG)

http:// domain.com / app / web / site / ORG / args ? vars

I can successfully access the website for DEMO ORG as:

http:// domain.com / app / web / site / DEMO / args ? vars

And I am using the following BASE routes dict:

default_application = 'app'
default_controller = 'web'
default_function = 'site'

So I can now use short urls:

http:// domain.com / site / DEMO / args ? vars

But now I require to access it via subdomain (removing 'site' function and 
ORG first arg, but being able to keep using args and vars):

http:// DEMO.domain.com / args ? vars

Internally rewriting to:  http:// domain.com / app / web / site / DEMO / 
args ? vars

Is there any way I can accomplish this with routes?.

Thanks,

   Carlos



[web2py] Re: Support for PyPy

2012-03-12 Thread Anthony
Maybe related to this: https://bugs.pypy.org/issue1051. Have you tried 1.7?

On Monday, March 12, 2012 3:31:56 PM UTC-4, Francisco Costa wrote:
>
> Well I've compiled pypy-1.8 from source (without jit) and found that is 
> slower than python whyle executing web2py
> here are my test results
>
>
> *PYPY*
> ab -n 10 -c 5 http://127.0.0.1:8000/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
> Licensed to The Apache Software Foundation, http://www.apache.org/
>
> Benchmarking 127.0.0.1 (be patient).done
>
>
> Server Software:Rocket
> Server Hostname:127.0.0.1
> Server Port:8000
>
> Document Path:  /
> Document Length:18071 bytes
>
> Concurrency Level:  5
> Time taken for tests:   5.257 seconds
> Complete requests:  10
> Failed requests:0
> Write errors:   0
> Total transferred:  184880 bytes
> HTML transferred:   180710 bytes
> Requests per second:1.90 [#/sec] (mean)
> Time per request:   2628.322 [ms] (mean)
> Time per request:   525.664 [ms] (mean, across all concurrent requests)
> Transfer rate:  34.35 [Kbytes/sec] received
>
> Connection Times (ms)
>   min  mean[+/-sd] median   max
> Connect:00   0.1  0   0
> Processing:  1851 2465 277.7   25832731
> Waiting: 1849 2461 275.6   25832705
> Total:   1851 2465 277.7   25832731
>
> Percentage of the requests served within a certain time (ms)
>   50%   2583
>   66%   2610
>   75%   2671
>   80%   2671
>   90%   2731
>   95%   2731
>   98%   2731
>   99%   2731
>  100%   2731 (longest request)
>
>
> *PYTHON*
> ab -n 10 -c 5 http://127.0.0.1:8181/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
> Licensed to The Apache Software Foundation, http://www.apache.org/
>
> Benchmarking 127.0.0.1 (be patient).done
>
>
> Server Software:Rocket
> Server Hostname:127.0.0.1
> Server Port:8181
>
> Document Path:  /
> Document Length:18071 bytes
>
> Concurrency Level:  5
> Time taken for tests:   1.920 seconds
> Complete requests:  10
> Failed requests:0
> Write errors:   0
> Total transferred:  184890 bytes
> HTML transferred:   180710 bytes
> Requests per second:5.21 [#/sec] (mean)
> Time per request:   960.005 [ms] (mean)
> Time per request:   192.001 [ms] (mean, across all concurrent requests)
> Transfer rate:  94.04 [Kbytes/sec] received
>
> Connection Times (ms)
>   min  mean[+/-sd] median   max
> Connect:00   0.2  0   0
> Processing:   694  883 107.48851031
> Waiting:  693  880 104.28851030
> Total:694  883 107.68851031
>
> Percentage of the requests served within a certain time (ms)
>   50%885
>   66%889
>   75%995
>   80%   1017
>   90%   1031
>   95%   1031
>   98%   1031
>   99%   1031
>  100%   1031 (longest request)
>
>
>
> This app uses lots of modules like pymongo, Image, stripogram, dateutil, 
> pygeoip,tornado, tornadio, pycurl
> I've manage to easy_install all them in pypy, but I couldn't install 
> pycurl, so I've commented it for the ab testing
>
> I've also tried with the welcome app and the results were similar: pypy 
> was 2.5x slower
>
>
> Any other tests are truly appreciated
>


Re: [web2py] Re: No models vs. conditional models -- what's the advantage?

2012-03-12 Thread Richard Vézina
There is discussion about optimization of web2py.

Basically, MVC is correct approach, but the way web2py implement it seems
to make scalling problematic.

Web2py works pretty well for a couples of tables let says 20 to 50 tables,
but behind that the models files become long and since they have to be read
each time a single function from a controller is trigger your app start to
be less responsive with the amount of table or the number of lines you have
in the files you have in models folder.

The idea of Bruno (and others don't know where it comes from first), is to
put the definition into modules folder that is read only once at boot time
when you start web2py. But it comes with a lot of drawback : appadmin no
longer work out of the box, you have to know programming classes and import
your models where you need them in your controller, etc.

Bruno (and others) says that this approach allow to scale (raise the number
of db models without compromise the responsiveness of your app), so it a
great news.

There is others solutions to allow scalling that are in developpement
principally : model_map

There is already submodel, but it is consider not DRY.

The idea behind the model less alternative is to keep the simplicity of
web2py as allowing bigger app to run smoothly. Also, the idea is to pave
the way to scaling, because the models less approach is only one solution a
great programmer could take to allow it app to scale and before there is 50
differents solutions for scalling (not documented for most of them) it is
better to propose a path to follow for scalling.


Richard

On Mon, Mar 12, 2012 at 3:25 PM, Bruce Wade  wrote:

> agreed
>
>
> On Mon, Mar 12, 2012 at 12:16 PM, Pepe Araya  wrote:
>
>> With all the post arguing about no models... I'm asking myself: why
>> web2py have "models" folder if it isn't the best way to do the work? only
>> for background compatibility?
>>
>> what's the reason to load the models every time you make a request? is
>> because the automatic migrations?
>>
>> are only questions, and why not made a huge change and optimization in a
>> brand new version of web2py?
>>
>> best regards,
>>
>>
>>
>> On Thursday, March 8, 2012 12:45:41 PM UTC-3, rochacbruno wrote:
>>
>>> another advantage is the fact that you can import modules, you cannot
>>> import models. it is very nice to import your tables on external scripts.
>>>
>>> http://zerp.ly/rochacbruno
>>> Em 08/03/2012 12:11, "Anthony" escreveu:
>>>
>>> I think an additional advantage of the module approach is that the
 module only has to be loaded once (when it is first imported), but the
 model files have to be read on every request.

 Anthony

 On Thursday, March 8, 2012 10:04:11 AM UTC-5, Cliff wrote:
>
> Certainly we want to avoid processing unnecessary table definitions
> with every request.
>
> It seems to me that the simplest solution is something like this:
>
> if request.controller=='foo':
>   db.define_table('foo', Field...) # main table
>   db.define_table('foo_one_to_**ma**ny', Field(foo_id, db.foo...)...)
>   ...
>
> What is the advantage of the no models architecture over this?


>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] Re: No models vs. conditional models -- what's the advantage?

2012-03-12 Thread Cliff
With models, grid and smartgrid you can prototype an application very
quickly and know that the database works the way it should.

That's the main attraction of these three things, at least for me.

On Mar 12, 3:16 pm, Pepe Araya  wrote:
> With all the post arguing about no models... I'm asking myself: why web2py
> have "models" folder if it isn't the best way to do the work? only for
> background compatibility?
>
> what's the reason to load the models every time you make a request? is
> because the automatic migrations?
>
> are only questions, and why not made a huge change and optimization in a
> brand new version of web2py?
>
> best regards,
>
>
>
>
>
>
>
> On Thursday, March 8, 2012 12:45:41 PM UTC-3, rochacbruno wrote:
>
> > another advantage is the fact that you can import modules, you cannot
> > import models. it is very nice to import your tables on external scripts.
>
> >http://zerp.ly/rochacbruno
> > Em 08/03/2012 12:11, "Anthony" escreveu:
>
> >> I think an additional advantage of the module approach is that the module
> >> only has to be loaded once (when it is first imported), but the model files
> >> have to be read on every request.
>
> >> Anthony
>
> >> On Thursday, March 8, 2012 10:04:11 AM UTC-5, Cliff wrote:
>
> >>> Certainly we want to avoid processing unnecessary table definitions
> >>> with every request.
>
> >>> It seems to me that the simplest solution is something like this:
>
> >>> if request.controller=='foo':
> >>>   db.define_table('foo', Field...) # main table
> >>>   db.define_table('foo_one_to_**many', Field(foo_id, db.foo...)...)
> >>>   ...
>
> >>> What is the advantage of the no models architecture over this?


Re: [web2py] Re: 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Richard Vézina
Are you sure min form IS_STRONG is apply?

It may be override by the empty CRYPT()??

CRYPT has min_length that could be used for that and if you want to use the
default of auth here you go :

CRYPT(min_length=auth.settings.password_min_length,
  error_message=T('too short'))

Richard

On Mon, Mar 12, 2012 at 3:38 PM, Cliff  wrote:

> This works.
>
> custom_auth_table.password.requires = CRYPT()
> if request.args(0) != 'login':
> custom_auth_table.password.requires = [
> IS_STRONG(min=12, max=128, upper=None, lower=None,
>  number=None, special=None, error_message=' '),
> CRYPT()
> ]
>
> Could also be handled in default.py.
>
> On Mar 12, 3:06 pm, Bruce Wade  wrote:
> > error_message = '' and error_message = None are treated as the samething.
> >
> > Try:
> > error_message = '  '
> >
> > Haven't tried but that may give you a black message like you want.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Mar 12, 2012 at 12:02 PM, Cliff  wrote:
> > > My login is pretty much vanilla Web2py.  No changes to default.py
> > > users.
> >
> > > In the model I have this:
> >
> > > comment = ''
> > > if request.controller=='auth_user':
> > >comment = SPAN('Must be at least 12 characters in length',
> > >   _style='color:orange;'
> > >  )
> > > db.define_table(
> > >auth.settings.table_user_name,
> > >Field('first_name', length=128, default=''),
> > >Field('middle_name', length=128, default=''),
> > >Field('last_name', length=128, default=''),
> > >Field('generation', length=128, default=''),
> > >Field('email', length=128, default='', unique=True,
> > > comment=email_comment), # required
> > >Field('password', 'password', length=128,# required
> > >  readable=False, label='Password',
> > >  comment=comment),
> > > ),
> > >#  blah blah  more details + required fields
> > > )
> >
> > > custom_auth_table.password.requires = [
> > >IS_STRONG(min=12, max=128, upper=None, lower=None,
> > > number=None, special=None,), CRYPT()
> > > ]
> >
> > > If I set error_message to an empty string or None in the model,
> > > attempting to log in with password 'foo' causes the error banner
> > > to appear with "None" as the caption.  If I don't set error_message
> > > I get the banner with the error message from IS_STRONG().
> >
> > > What am I doing wrong?  What can I do about this?
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>


[web2py] web2pyslice auth error

2012-03-12 Thread szimszon
Hi!

I was on the page and I tried to update a slice but got the 
http://www.web2pyslices.com/admin/default/ticket/init/80.99.230.108.2012-03-12.16-43-41.f19c427c-46c8-4120-a189-29f2707ad6d7
 
ticket :(

No I suddenly logged out and if I try to log in via google I got the google 
page with access request and I push OK then I got a facebook auth page :(


[web2py] Re: 1.99.4 login showing password validation messages - what to do?

2012-03-12 Thread Cliff
Richard, good question.

Yes, it is working the way I want it to.

On login, if I enter an invalid email or invalid password, I get the
invalid login message.  I don't get any messages from either
validator.

Using my hand-built form for changing passwords, if I enter a password
that is too short I get the right error message.  If the confirming
password doesn't match I get the correct message also.

All this complication comes from building a multi-tenant application,
where some users will be administering other users from the same
tenant.

On Mar 12, 3:57 pm, Richard Vézina 
wrote:
> Are you sure min form IS_STRONG is apply?
>
> It may be override by the empty CRYPT()??
>
> CRYPT has min_length that could be used for that and if you want to use the
> default of auth here you go :
>
> CRYPT(min_length=auth.settings.password_min_length,
>               error_message=T('too short'))
>
> Richard
>
>
>
>
>
>
>
> On Mon, Mar 12, 2012 at 3:38 PM, Cliff  wrote:
> > This works.
>
> > custom_auth_table.password.requires = CRYPT()
> > if request.args(0) != 'login':
> >     custom_auth_table.password.requires = [
> >         IS_STRONG(min=12, max=128, upper=None, lower=None,
> >                  number=None, special=None, error_message=' '),
> > CRYPT()
> >     ]
>
> > Could also be handled in default.py.
>
> > On Mar 12, 3:06 pm, Bruce Wade  wrote:
> > > error_message = '' and error_message = None are treated as the samething.
>
> > > Try:
> > > error_message = '  '
>
> > > Haven't tried but that may give you a black message like you want.
>
> > > On Mon, Mar 12, 2012 at 12:02 PM, Cliff  wrote:
> > > > My login is pretty much vanilla Web2py.  No changes to default.py
> > > > users.
>
> > > > In the model I have this:
>
> > > > comment = ''
> > > > if request.controller=='auth_user':
> > > >    comment = SPAN('Must be at least 12 characters in length',
> > > >                       _style='color:orange;'
> > > >                      )
> > > > db.define_table(
> > > >    auth.settings.table_user_name,
> > > >    Field('first_name', length=128, default=''),
> > > >    Field('middle_name', length=128, default=''),
> > > >    Field('last_name', length=128, default=''),
> > > >    Field('generation', length=128, default=''),
> > > >    Field('email', length=128, default='', unique=True,
> > > >         comment=email_comment), # required
> > > >    Field('password', 'password', length=128,            # required
> > > >          readable=False, label='Password',
> > > >          comment=comment),
> > > >         ),
> > > >    #  blah blah  more details + required fields
> > > > )
>
> > > > custom_auth_table.password.requires = [
> > > >    IS_STRONG(min=12, max=128, upper=None, lower=None,
> > > >             number=None, special=None,), CRYPT()
> > > > ]
>
> > > > If I set error_message to an empty string or None in the model,
> > > > attempting to log in with password 'foo' causes the error banner
> > > > to appear with "None" as the caption.  If I don't set error_message
> > > > I get the banner with the error message from IS_STRONG().
>
> > > > What am I doing wrong?  What can I do about this?
>
> > > --
> > > --
> > > Regards,
> > > Bruce Wadehttp://
> > ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f...


[web2py] Re: custom css

2012-03-12 Thread monotasker
Regarding the flash message moving to the side, I believe that the 
positioning of the flash div is normally done relative to the auth_navbar 
div. (i.e., if I set left:0 for .flash in base.css the flash div is aligned 
with the auth_navbar's left-hand margin. So if you have removed auth_navbar 
(or moved it on the page) that will move the flash div. You'll just have to 
change the .flash  css class to compensate.

As for the colour not changing in the .error div, could this be because 
you're using the name "red" instead of a hex code? or is it a specificity 
issue, so that another more specific style rule is overriding your theme 
change? If you change the basic page layout that can mess with style 
inheritance until you adjust the style rules. I would inspect the error div 
using Firebug or Chrome dev tools. It will tell you what style rules are 
being recognized and which ones are being overridden.

Ian


On Monday, March 12, 2012 3:11:58 PM UTC-4, frasse wrote:
>
> Yes the example app that comes with web2py show correctly on 
> Firefox 10 + Windows. 
> I greed that I am missing some classes from base.css. but I can not 
> found what . 
>
> Here is what I did. 
>
> I copy .flash .error to my css file (the_look.css). 
> It is the copy code: 
> - 
> div.flash { 
> font-weight: bold; 
> display: none; 
> position: fixed; 
> padding: 10px; 
> top: 40px; 
> right: 10px; 
> min-width: 280px; 
> opacity: 0.85; 
> margin: 0px 0px 10px 10px; 
> color: #fff; 
> vertical-align: middle; 
> cursor: pointer; 
> background: #000; 
> border: 2px solid #fff; 
> -moz-border-radius: 5px; 
> -webkit-border-radius: 5px; 
> z-index: 2; 
> } 
> div.error { 
> background-color: red; 
> color: white; 
> padding: 3px; 
> } 
> --- 
>
>
> I have some change in my layout.html here is the change 
>
>  
>  
>  
>  
> 
>  
>  
>  
>  
>   
>   
>  
>
>
>  
>
>
>
>
>  
>  
>  
>  
>  
>  
>  script> 
> {{#--  require CSS and JS files for this page (read info in 
> base.css) --}} 
> {{response.files.append(URL('static','css/the_look.css'))}} 
> {{# response.files.append(URL('static','css/base.css'))}} 
> {{response.files.append(URL('static','css/superfish.css'))}} 
> {{response.files.append(URL('static','js/superfish.js'))}} 
>
> {{#-- include web2py specific js code (jquery, calendar, form 
> stuff) --}} 
> {{include 'web2py_ajax.html'}} 
> {{ 
> #using sidebars need to know what sidebar you want to use 
> #prior of using it, because of static width size of content, you 
> can use 
> #left_sidebar, right_sidebar, both or none (False left and 
> right) 
> left_sidebar_enabled = globals().get('left_sidebar_enabled',False) 
> right_sidebar_enabled = 
> globals().get('right_sidebar_enabled',False) 
> if left_sidebar_enabled and right_sidebar_enabled: 
> width_content='63%' 
> elif left_sidebar_enabled != right_sidebar_enabled: 
> width_content='740px' 
> else: width_content='100%' 
> if left_sidebar_enabled: left_sidebar_style = 'style="display: 
> block;"' 
> else: left_sidebar_style = 'style="display: none;"' 
> if right_sidebar_enabled: right_sidebar_style = 'style="display: 
> block;"' 
> else: right_sidebar_style = 'style="display: none;"' 
> style_content = 'style="width: %s"' % width_content 
> }} 
>
>
>