[web2py] Re: membership form with default input values

2013-08-06 Thread Annet
Before form=

db.auth_membership.group_id.default=some_group_id


Kind regards,

Annet


i created a membership form using
> form = crud.create(db.auth_membership)
>
> this gives me a form with two select fields. how do i create the form to 
> have for instance the 3rd option automatically selected?
>

-- 

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




[web2py] Re: DAL does not return correct id when inserting a record where the id is specified

2013-08-06 Thread Anthony
The DAL does this to get the id for MySQL inserts:

self.execute('select last_insert_id();')

Unfortunately, the value of last_insert_id() is only updated when the id is 
auto-generated, so it stores the last auto-generated id (which you 
observed), not the last id.

In order to get the last id (whether auto-generated or not), you need to 
use the MySQL 
mysql_insert_id()C 
API function. I'm not sure if this is available via the pymysql driver, 
but the MySQLdb driver connection object does include a conn.insert_id() 
method to access this function (see 
http://mysql-python.sourceforge.net/MySQLdb.html#mysql-c-api-function-mapping). 
Perhaps the DAL code can be changed to use that method when the MySQLdb 
driver is being used. If you'd like, you can open a Google Code 
issueabout this (and reference 
this thread).

Anthony

On Tuesday, August 6, 2013 11:41:03 PM UTC-4, Jim Gregory wrote:
>
> I'm porting a legacy table to a new table having a different schema. The 
> old table had a field (order_number) that was unique and autoincrementing 
> but not the primary key. I want to use those old values as the primary key 
> in the new table.

-- 

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




[web2py] membership form with default input values

2013-08-06 Thread sasogeek
i created a membership form using
form = crud.create(db.auth_membership)

this gives me a form with two select fields. how do i create the form to 
have for instance the 3rd option automatically selected?

-- 

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




[web2py] Re: DAL does not return correct id when inserting a record where the id is specified

2013-08-06 Thread Jim Gregory
I'm porting a legacy table to a new table having a different schema. The old 
table had a field (order_number) that was unique and autoincrementing but not 
the primary key. I want to use those old values as the primary key in the new 
table.

-- 

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




[web2py] Re: DAL does not return correct id when inserting a record where the id is specified

2013-08-06 Thread Anthony
Why are you specifying the ids?

On Tuesday, August 6, 2013 10:27:03 PM UTC-4, Jim Gregory wrote:
>
> I noticed an odd behavior when inserting a record in a MySQL table.  Given 
> a table:
>
> db.define_table('person', Field('name'))
>
> inserting some records without specifying the id returns the correct id:
> >>> db.person.insert(name='John')
> 1
> >>> db.person.insert(name='Bill')
> 2
>
> But specifying the id when the record is inserted does not:
> >>> db.person.insert(id=3, name='Fred')
> 2
> >>> db.person.insert(id=10, name='George')
> 2
>
> even though the records are inserted correctly:
> >>> print db().select(db.person.ALL)
> 1 John
> 2 Bill
> 3 Fred
> 10 George
>
> Is this unique to MySQL?  Is this a bug or is there a logical reason for 
> this?  
>
> -Jim
>
>

-- 

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




[web2py] DAL does not return correct id when inserting a record where the id is specified

2013-08-06 Thread Jim Gregory
I noticed an odd behavior when inserting a record in a MySQL table.  Given 
a table:

db.define_table('person', Field('name'))

inserting some records without specifying the id returns the correct id:
>>> db.person.insert(name='John')
1
>>> db.person.insert(name='Bill')
2

But specifying the id when the record is inserted does not:
>>> db.person.insert(id=3, name='Fred')
2
>>> db.person.insert(id=10, name='George')
2

even though the records are inserted correctly:
>>> print db().select(db.person.ALL)
1 John
2 Bill
3 Fred
10 George

Is this unique to MySQL?  Is this a bug or is there a logical reason for 
this?  

-Jim

-- 

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




[web2py] Values in request.vars persist/doubled when form submitted after unexpected logout/session deletion

2013-08-06 Thread Lamps902
I have a controller function which is protected by a standard 
authentication decorator ("@auth.requires_login()"). The function presents 
a page containing some forms (which contain a bunch of INPUTS() of _type = 
'hidden' and one INPUT(_type = 'image',  which presents the submission 
button). If a session terminates in a non-standard way (cookies deleted in 
browser, "logout" is clicked and directed to a new tab, etc.), the page 
with the forms is still present on screen, and if one of the forms is 
clicked, the login prompt is presented. After the user logs in, the form is 
processed as usual. However, if the user clicks on the form again, the 
values submitted by the new form will be appended to the corresponding 
values already present in request.vars, making a two-item list for each 
var. That is, something like:

request.vars.action = action1
request.vars.item = 24

will turn into

request.vars.action = action1
  action1
request.vars.item = 24
   24

Why are the new values appending to the old, instead of overwriting them? 
What's the recommended way to deal with this situation? Thank you.

-- 

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




[web2py] Re: read a field from a row based on a (wait for it...) variable

2013-08-06 Thread davedigerati
 
,.-'"...``~., 
.,.-"..."-., 
.,/...":, 
.,?.., 
.../...,}
 
./..,:`^`..}
 
.../...,:"./
 
..?.__.:`.../ 
./__.(."~-,_..,:`../ 
.../(_"~,_"~,_,:`_/ 
..{.._$;_.."=,_..."-,_...,.-~-,},.~";/} 
...((.*~_..."=-._..";,,./`/"../ 
...,,,___.`~,.."~.,`.}../ 
(`=-,,...`(..;_,,-" 
/.`~,..`-./ 
.`~.*-,.|,./.,__ 
,,_..}.>-._...|..`=~-, 
.`=~-,__..`,. 
...`=~-,,.,... 
`:,,...`..__
 
.`=-,...,%`>--==`` 
_..._,-%...` 
..., 

On Sunday, August 4, 2013 3:27:36 PM UTC-4, Anthony wrote:
>
> (actually would've just put the .nine into the select and save a line)
>>
>
> That wouldn't save a line -- still have to specify the field even if the 
> row contains only one field. 
>
>>
>> BUT what if my field name is a variable like so?
>> row = db((db.squares.game_code==session.game_code) & 
>> (db.squares.row_num==row_vis)).select()
>> winner= row[0].[winning_col]
>> (I also tried the winning_col in () and '')
>>
>
> A Row object works like a dictionary, so:
>
> row[0][winning_col]
>
> Mentioned near the end of this 
> sectionin
>  the book.
>
> Anthony
>

-- 

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




[web2py] Re: URL filter chain

2013-08-06 Thread Anthony
Model files are executed on every request before the controller action is 
called, so you could simply put your code in a model file (note, most of 
the code could actually go in a module, which you could then simply import 
in a model). Models are executed in alphabetical order, so if you want your 
code to run before any other model code, just name the model file something 
like 0_intercept.py.

Anthony

On Tuesday, August 6, 2013 8:24:39 PM UTC-4, Marcio Andrey Oliveira wrote:
>
> So I don't know what to do. I was reading about the conditional models but 
> it doesn't seem to be what I want.
>
> I will try to explain (forgive my bad English):
>
> From my own application I want to be able to intercept requests to some / 
> all URLs (it varies based on what I want to do) so that I could decide if I 
> would log the incoming data, redirect or drop it it based in some criteria 
> (is mobile, is from some country, and so on) or even change the request 
> parameters prior it arrives to the target URL.
>
> But I want to do these things without to incorporate this code into my 
> controllers.
>
> On Java this is done using servlet filters.
>
> Any suggestion? A sampke or doc showing this kind of situation?
>
> Thanks.
>

-- 

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




[web2py] Re: web2py hanging after DB error - Windows / rocket / pyodbc / SQL Server

2013-08-06 Thread Andrew Buchan


We have the same (similar) issue using mssql on Windows: when we get a 
pyodbc.ProgrammingError typically relating to a foreign key, we have to 
restart web2py.

This is particularly frustrating problem as these errors happen every time 
you rename/delete a column with a foreign key.

 E.g. create a field that references another table:
.
Field('a_field', db.another_table, ondelete='CASCADE'),

Then remove/rename ;a_field', and you get "ALTER TABLE DROP COLUMN a_field 
failed because one or more objects access this column."

This causes web2py to hang, so we have to go into management studio, delete 
the constraint, and restart web2py because it has become unresponsive.

I think that, aside from resolving why web2py hangs, we could also improve 
migration so that it deletes any constraints automatically when we drop a 
column. 

While we're at it, web2py could check a column actually exists before 
calling a DROP statement. It frequently happens that things do get out of 
synch with fake migrates and manually modifying the table etc, and for a 
DROP statement to be called on a column that has been removed. There is 
really no benefit in web2py failing if the column to delete isn't found.

I thought I'd reply to this thread (ps: right thing to do?) and see if 
anyone had any suggestions/info before I go raising as bugs/features, or 
attempting to produce a patch...



-- 

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




Re: [web2py] Re: URL filter chain

2013-08-06 Thread Vinicius Assef
See this old thread: https://groups.google.com/forum/#!topic/web2py/vW4ygi96LLU

It may help you.

On Tue, Aug 6, 2013 at 9:24 PM, Marcio Andrey Oliveira
 wrote:
> So I don't know what to do. I was reading about the conditional models but
> it doesn't seem to be what I want.
>
> I will try to explain (forgive my bad English):
>
> From my own application I want to be able to intercept requests to some /
> all URLs (it varies based on what I want to do) so that I could decide if I
> would log the incoming data, redirect or drop it it based in some criteria
> (is mobile, is from some country, and so on) or even change the request
> parameters prior it arrives to the target URL.
>
> But I want to do these things without to incorporate this code into my
> controllers.
>
> On Java this is done using servlet filters.
>
> Any suggestion? A sampke or doc showing this kind of situation?
>
> Thanks.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




[web2py] Re: URL filter chain

2013-08-06 Thread Marcio Andrey Oliveira
So I don't know what to do. I was reading about the conditional models but 
it doesn't seem to be what I want.

I will try to explain (forgive my bad English):

>From my own application I want to be able to intercept requests to some / 
all URLs (it varies based on what I want to do) so that I could decide if I 
would log the incoming data, redirect or drop it it based in some criteria 
(is mobile, is from some country, and so on) or even change the request 
parameters prior it arrives to the target URL.

But I want to do these things without to incorporate this code into my 
controllers.

On Java this is done using servlet filters.

Any suggestion? A sampke or doc showing this kind of situation?

Thanks.

-- 

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




[web2py] Re: Good Basic Tutorial: "Twitter Clone in web2py" - source on github.

2013-08-06 Thread samuel bonill
graet !! 

I learned from this book web2py  
link

El martes, 6 de agosto de 2013 10:05:43 UTC-5, Rob_McC escribió:
>
>
> I found a good tutorial today on web2py, there are 3 parts, source on 
> github.
> https://github.com/neilisfragile/witter
>
> Nice to see more and more learning resources for web2py.
>   I seem to learn best from examples.
>
> Twitter Clone Tutorial in web2py
>  30 June, 2013
> Link:  
> http://fragile.org.uk/2013/06/twitter-clone-tutorial-in-web2py-part-1-getting-started/
>
> *Tutorial Introduction:*
>
> Welcome to my getting started with Web2py tutorial.
>
> This tutorial assumes very little on the part of the reader, some 
> knowledge of a programming language will certainly help, but if not don’t 
> worry. I’ll take you from installation through to v1 of your application.
>
> If you don’t want to copy from the tutorial, the full source is hosted on 
> github.
> Why Web2py?
>
> Web2py is a fantastic web development framework for Python, it focuses on
>
>
>- Ease of use
>- Rapid development
>- Security
>
>

-- 

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




[web2py] Re: exercise: automatic conversion of a static site into a web2py site

2013-08-06 Thread Massimo Di Pierro
I just pushed a new version:

https://github.com/web2py/web2py/blob/master/scripts/import_static.py

Massimo

On Tuesday, 6 August 2013 16:51:31 UTC-5, tim spear wrote:
>
> Hi Massimo, 
>
> Thanks for the reply. 
> I'm a bit new to this but I looked in 
> https://github.com/web2py/web2py/tree/master/scripts and in 
> https://code.google.com/p/web2py/
>  and could not find scripts/import_static.py
>
> Not sure I looked in the right place?
>
> Ta, Tim
>
>
> On Tuesday, August 6, 2013 6:38:03 PM UTC+1, Massimo Di Pierro wrote:
>>
>> Try this:
>>
>> scripts/import_static.py
>>
>> I just committed it to trunk. Usage:
>>
>> python scripts/import_static.py source_folder applications/web2py_app
>>
>>
>>
>> On Tuesday, 6 August 2013 08:05:24 UTC-5, tim spear wrote:
>>>
>>> Hi Massimo, if you are still reading this stuff.
>>>
>>> I've been playing with web2py and was thinking it was missing an easy 
>>> way to import static sites and was thinking of writing one similar to your 
>>> proposed challenge. 
>>>
>>> Do you know if anyone did produce a functional solution? I see this 
>>> thread is from nearly three years ago and am not sure what the current 
>>> state of play is.
>>>
>>> Best, Tim Spear
>>>
>>>
>>>
>>>
>>> On Wednesday, November 24, 2010 8:05:21 PM UTC, mdipierro wrote:

 I have a challanage: 

 write a script that takes a folder that contains a static html file 
 and converts it into an HTML site. 

 1) moves all non .html files into static/ 
 2) moves all .html files into views/xxx/ 
 3) creates a controllers/xxx.py and for each yyy.html file add an 
 action 

 def yyy(): return dict() 

 4) loop over all .html files and fixes all the URL to {{=URL(...)}}} 

 OPTIONAL: 
 5) 
 If all .html files start with a similar header and footer, tried to 
 identify them, moves "{{include}}" into views/ 
 layout.html and rewrite the html files to {{extend 'layout.html'}} 

 The original folder and 'xxx' should be uer defined. This could be 
 added to the wizard. 

 Massimo
>>>
>>>

-- 

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




[web2py] Re: onbeforeunload & SQLFORM(db.table) submit

2013-08-06 Thread Antonis Konstantinos Tzorvas
solved this with the following code as you suggested:

populate() fills some data in according tables and does also del 
session.tmpstation
i've added a timeout also, user can refresh or reopen the url from a faulty 
action such as closing page etc

def confirm():
TIMEOUT=60*2
if session.tmpstation:
if not session.laststation
> you need to hook up to the submit event of the form and disabling what you 
> added as onbeforeunload.
> Lots of examples around, e.g. 
> http://stackoverflow.com/questions/1973708/how-to-prevent-onbeforeunload-from-being-called-when-clicking-submit-button
>
>
> On Tuesday, August 6, 2013 8:54:15 PM UTC+2, Antonis Konstantinos Tzorvas 
> wrote:
>>
>> def add():
>> form = SQLFORM.factory(Field('url', 'string'))
>>
>> if form.process().accepted:
>> mystation = info.station(form.vars.url)
>> session.tmpstation = mystation
>> redirect(URL('confirm'))
>> return dict(form=form)
>>
>>
>> def confirm():
>> ... prepopulating form with vars from vars(session.tmpstation) ...
>> form = SQLFORM(db.stations).process(next=URL('populate'), 
>> message=T("record created"))
>> del session.tmpstation
>> return dict(form=form)
>>
>>  confirm.html
>> {{extend 'layout.html'}}
>> {{=form}}
>> window.onbeforeunload = function() {return "form will lose all 
>> data";};
>>
>> is there any way to prevent onbeforeunload if form.submit() is the event 
>> triggering the "onbeforeunload"?
>>
>

-- 

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




[web2py] Re: Security advisory: BREACH and Django

2013-08-06 Thread Anthony
On second thought, if SQLFORM(..., detect_record_change=True), the _formkey 
token is a hash of the record fields rather than a random UUID, so it would 
remain the same from request to request, thus enabling the exploit. Perhaps 
we should add a random string to the record hash in that case.

On Tuesday, August 6, 2013 3:16:53 PM UTC-4, Anthony wrote:
>
>
> I know that there are security experts/security "fans" watching over 
>> web2py's code, so I'll leave this topic to them for further analysis, but 
>> as Anthony suggested it seems that web2py is fine. Django and Rails use a 
>> somewhat "static" token, while web2py generates a new one for every form.
>> This cripples a little bit the javascript interaction, but seems to give 
>> web2py's a nicer security model until BREACH gets somehow fixed at higher 
>> levels. 
>>
>
> Note, I think we're OK on CSRF, but there may be other ways to use the 
> exploit (e.g., to get PII from a page).
>
> Anthony 
>

-- 

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




[web2py] Re: exercise: automatic conversion of a static site into a web2py site

2013-08-06 Thread tim spear
Hi Massimo, 

Thanks for the reply. 
I'm a bit new to this but I looked in 
https://github.com/web2py/web2py/tree/master/scripts and in 
https://code.google.com/p/web2py/
 and could not find scripts/import_static.py

Not sure I looked in the right place?

Ta, Tim


On Tuesday, August 6, 2013 6:38:03 PM UTC+1, Massimo Di Pierro wrote:
>
> Try this:
>
> scripts/import_static.py
>
> I just committed it to trunk. Usage:
>
> python scripts/import_static.py source_folder applications/web2py_app
>
>
>
> On Tuesday, 6 August 2013 08:05:24 UTC-5, tim spear wrote:
>>
>> Hi Massimo, if you are still reading this stuff.
>>
>> I've been playing with web2py and was thinking it was missing an easy way 
>> to import static sites and was thinking of writing one similar to your 
>> proposed challenge. 
>>
>> Do you know if anyone did produce a functional solution? I see this 
>> thread is from nearly three years ago and am not sure what the current 
>> state of play is.
>>
>> Best, Tim Spear
>>
>>
>>
>>
>> On Wednesday, November 24, 2010 8:05:21 PM UTC, mdipierro wrote:
>>>
>>> I have a challanage: 
>>>
>>> write a script that takes a folder that contains a static html file 
>>> and converts it into an HTML site. 
>>>
>>> 1) moves all non .html files into static/ 
>>> 2) moves all .html files into views/xxx/ 
>>> 3) creates a controllers/xxx.py and for each yyy.html file add an 
>>> action 
>>>
>>> def yyy(): return dict() 
>>>
>>> 4) loop over all .html files and fixes all the URL to {{=URL(...)}}} 
>>>
>>> OPTIONAL: 
>>> 5) 
>>> If all .html files start with a similar header and footer, tried to 
>>> identify them, moves "{{include}}" into views/ 
>>> layout.html and rewrite the html files to {{extend 'layout.html'}} 
>>>
>>> The original folder and 'xxx' should be uer defined. This could be 
>>> added to the wizard. 
>>>
>>> Massimo
>>
>>

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Anthony
Can you attach a minimal app that reproduces the problem (preferably in the 
current stable version of web2py)?

As an aside, instead of using your reverse() function, to reverse a string, 
you can do mystring[::-1].

Anthony

On Tuesday, August 6, 2013 4:08:26 PM UTC-4, Annet wrote:
>
> The think the problem is caused by these functions that generate the 
> password:
>
>
> def generate_password(name,now):
> import random
> value=''
> chars=('ABCDEFGHJKLMNOPQRSTUVW')
> symbols=('~!@#$%^&*()_+-=?<>:;{}[]|')
> x1=random.choice(chars)
> y=len(name)
> if y<3:
> x2=reverse(name)
> else:
> z=y-3
> x2=reverse(name[z:y])
> x3=random.choice(chars)
> x4=random.choice(symbols)
> x5=reverse(now)
> value=value+x1+x2+x3+x4+x5
> return value
>
>
> def reverse(x):
> i=len(x)
> value=''
> while i > 0:
> value=value+x[i-1]
> i=i-1
> return value
>
>
> When I replace return value with return '6#TestValue'
> The functions works i.e. it inserts '6#TestValue' into the auth_user table
> and sends the value to the user.
>
> I hope you know what's wrong with this value this function returns?
>
>
> Kind regards,
>
> Annet
>
>
>

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Annet
No matter what I try I keep ending up with two different passwords.

The strange thing is that when I replace this:

password=generate_password(name,now)

with this:

password='6#TestValue'

The function works, '6#TestValue' is both inserted into the auth_user 
table's password field
and sent to the user by mail.

It's this call that messes up the function:

password=generate_password(name,now)


I stripped the function to get a minimal function that reproduces the 
problem given the auth_user table in the post above:

def mock_register_form():
name='vermeer'
now=str(request.now.day)+str(request.now.month)
username='verm8613'
password=generate_password(name,now)
warning='After generate password: ' + password

form=SQLFORM.factory(db.auth_user,ignore_rw=True,submit_button='Registreer',separator='',formstyle='bootstrap')
form.vars.title='mevrouw'
form.vars.first_name='Charlotte'
form.vars.last_name='Vermeer'
form.vars.shortname=username
form.vars.email='jmv...@gmail.com
form.vars.username=username
form.vars.password=password
form.vars.nodeID=3

form[0].insert(8,DIV(LABEL(H5(password),_class="control-label"),_class="control-group"))
if form.process(keepvalues=False).accepted:
userID=db.auth_user.insert(**db.auth_user._filter_fields(form.vars))

context=dict(id=form.vars.nodeID,title=form.vars.title,familyNamePreposition=form.vars.familyNamePreposition,\

lastName=form.vars.last_name,username=form.vars.username,password=password,signature=None)
message=response.render('mail/register.html',context)
recipient=form.vars.email
mail.send(to=[recipient],subject='Your ID to get acces to our 
CMS',message=[None,message])
response.flash=warning
elif form.errors:
response.flash='Form contains errors'
elif not response.flash:
response.flash='Fill out form'
return dict(form=form)


I am working in web2py version 2.4.6
   

Kind regards,

Annet

-- 

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




[web2py] Re: prevent web2py regenerating tables in any situation

2013-08-06 Thread Niphlod
nope. In no possible way web2py drops the tables from the db.
NB: you MUST have tables defined if you want to access them with DAL, but 
this doesn't mean they are dropped in the backend. If you remove a table 
definition from your code, it just means that web2py won't know that that 
table exists.

On Tuesday, August 6, 2013 9:38:22 PM UTC+2, Behnam Izadi wrote:
>
> tanks but I want to delete table definiton on db.py without physical table 
> deletion on hard disk. when I remove a "db.define" statement , the 
> correspondent table will be deleted.
>

-- 

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




Re: [web2py] Re: prevent web2py regenerating tables in any situation

2013-08-06 Thread Marin Pranjić
It is not deleted. You can't see it in /appadmin because you removed
define_table call.

Marin



On Tue, Aug 6, 2013 at 9:38 PM, Behnam Izadi wrote:

> tanks but I want to delete table definiton on db.py without physical table
> deletion on hard disk. when I remove a "db.define" statement , the
> correspondent table will be deleted.
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] Re: prevent web2py regenerating tables in any situation

2013-08-06 Thread Behnam Izadi
tanks but I want to delete table definiton on db.py without physical table 
deletion on hard disk. when I remove a "db.define" statement , the 
correspondent table will be deleted.

-- 

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




[web2py] Re: Security advisory: BREACH and Django

2013-08-06 Thread Anthony


> I know that there are security experts/security "fans" watching over 
> web2py's code, so I'll leave this topic to them for further analysis, but 
> as Anthony suggested it seems that web2py is fine. Django and Rails use a 
> somewhat "static" token, while web2py generates a new one for every form.
> This cripples a little bit the javascript interaction, but seems to give 
> web2py's a nicer security model until BREACH gets somehow fixed at higher 
> levels. 
>

Note, I think we're OK on CSRF, but there may be other ways to use the 
exploit (e.g., to get PII from a page).

Anthony 

-- 

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




[web2py] Re: onbeforeunload & SQLFORM(db.table) submit

2013-08-06 Thread Niphlod
you need to hook up to the submit event of the form and disabling what you 
added as onbeforeunload.
Lots of examples around, e.g. 
http://stackoverflow.com/questions/1973708/how-to-prevent-onbeforeunload-from-being-called-when-clicking-submit-button


On Tuesday, August 6, 2013 8:54:15 PM UTC+2, Antonis Konstantinos Tzorvas 
wrote:
>
> def add():
> form = SQLFORM.factory(Field('url', 'string'))
>
> if form.process().accepted:
> mystation = info.station(form.vars.url)
> session.tmpstation = mystation
> redirect(URL('confirm'))
> return dict(form=form)
>
>
> def confirm():
> ... prepopulating form with vars from vars(session.tmpstation) ...
> form = SQLFORM(db.stations).process(next=URL('populate'), 
> message=T("record created"))
> del session.tmpstation
> return dict(form=form)
>
>  confirm.html
> {{extend 'layout.html'}}
> {{=form}}
> window.onbeforeunload = function() {return "form will lose all 
> data";};
>
> is there any way to prevent onbeforeunload if form.submit() is the event 
> triggering the "onbeforeunload"?
>

-- 

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




[web2py] Re: prevent web2py regenerating tables in any situation

2013-08-06 Thread Niphlod
either setting migrate=False in all tables or setting migrate_enabled=False

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=migrate_enabled

However, loosing all the data is not something that happens unless you drop 
the table: web2py at most just alters the table (adding/removing column(s))

On Tuesday, August 6, 2013 8:46:16 PM UTC+2, Behnam Izadi wrote:
>
> I don't want web2py regenerate or alter my tables any way. I lost my data 
> 3 times because of this. how can I prevent it?
>

-- 

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




[web2py] Re: Is there any way to work with static files outside web2py directory?

2013-08-06 Thread Niphlod
1) web2py is portable, so if this problem originates by lack of space in 
the c: drive, move web2py under d: and your photos to the static folder
2) routes.py can just manage the "realm" of web2py. Having web2py not able 
by default to suffer from directory traversal attacks (i.e. getting access 
by default to all your disks) is a feature, not a "bug".
3) you can serve files building your own serving with python code. Point 2) 
doesn't mean web2py can't, it just mean it can't by default: if you code 
your app to specifically access the d: drive, then web2py has no problems
4) you can use response.stream(file) to serve any image you want: please 
take care in your code about the security implications

You can watch the Expose code to take some inspirations
https://github.com/web2py/web2py/blob/master/gluon/tools.py#L4929


-- 

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




[web2py] onbeforeunload & SQLFORM(db.table) submit

2013-08-06 Thread Antonis Konstantinos Tzorvas
def add():
form = SQLFORM.factory(Field('url', 'string'))

if form.process().accepted:
mystation = info.station(form.vars.url)
session.tmpstation = mystation
redirect(URL('confirm'))
return dict(form=form)


def confirm():
... prepopulating form with vars from vars(session.tmpstation) ...
form = SQLFORM(db.stations).process(next=URL('populate'), 
message=T("record created"))
del session.tmpstation
return dict(form=form)

 confirm.html
{{extend 'layout.html'}}
{{=form}}
window.onbeforeunload = function() {return "form will lose all 
data";};

is there any way to prevent onbeforeunload if form.submit() is the event 
triggering the "onbeforeunload"?

-- 

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




[web2py] Re: Security advisory: BREACH and Django

2013-08-06 Thread Niphlod
well, from what I read it seems that they somehow manage to inspect the 
content-length of the compressed output given that:
- somehow are able to inject a simil-token
- the compression algo is know in advance
hence the estimation of the content-length would give them the right token, 
because if the same token is injected they know how many bytes less to 
expect from the compression algo. Seems to me that it's a kind of a 
bruteforce, 'cause they don't know in advance what token to use but  they 
can only estimate the correctness basing on the content-length.

I know that there are security experts/security "fans" watching over 
web2py's code, so I'll leave this topic to them for further analysis, but 
as Anthony suggested it seems that web2py is fine. Django and Rails use a 
somewhat "static" token, while web2py generates a new one for every form.
This cripples a little bit the javascript interaction, but seems to give 
web2py's a nicer security model until BREACH gets somehow fixed at higher 
levels. 

On Tuesday, August 6, 2013 8:29:29 PM UTC+2, Anthony wrote:
>
> One recommendation is to randomize the "secret" per request (the attack 
> works by guessing the secret one character at a time). web2py already 
> randomizes its CSRF tokens on every request (which I take it Django does 
> not do), so not sure web2py has the same vulnerability with regard to the 
> CSRF token (there may be vulnerabilities with other kinds of secret data, 
> though).
>
> Anthony
>
> On Tuesday, August 6, 2013 1:55:29 PM UTC-4, Massimo Di Pierro wrote:
>>
>> As I understand this has nothing to do with Django. They discovered a ssh 
>> vulnerability that can used to decrypt part of traffic. It will affect all 
>> of us if un patched.
>>
>> On Tuesday, 6 August 2013 10:55:06 UTC-5, Chun-Hung Chen wrote:
>>>
>>> Hi,
>>>
>>> FYI
>>> https://www.djangoproject.com/weblog/2013/aug/06/breach-and-django/
>>
>>

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Alan Etkin
> That's like saying 'Shaolin Kung Fu' is only for physical fitness, not for
> fighting.

LOL, I'm thinking on adding the quote!

-- 

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




[web2py] prevent web2py regenerating tables in any situation

2013-08-06 Thread Behnam Izadi
I don't want web2py regenerate or alter my tables any way. I lost my data 3 
times because of this. how can I prevent it?

-- 

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




Re: [web2py] web2py admin access

2013-08-06 Thread Richard Vézina
You need to set a parameters_PORT.py file that contains a password for
admin... Because admin is disabled for security in production.

Try this from web2py folder in bash on your prod server :

sudo -u www-data python -c "from gluon.main import save_password;
save_password('123456',443)" # 123456 = password, 443 if you are behind SSL

Richard




On Tue, Aug 6, 2013 at 1:24 PM, dougie  wrote:

> hello,
>
> i setup web2py following the commands using one step production
> for
>
> wget http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh
>
> running this on raspbian. i'm unable to get admin access to work from the 
> machine that its on. after a couple days of searching i'm no where closer to 
> enabling this. about to start from scratch, so if anyone's got an idea whats 
> going on i'd apprecaite some assistance. when i try to access the admin 
> button it get a forbidden.
>
>
> Cheers
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Derek
That's like saying 'Shaolin Kung Fu' is only for physical fitness, not for 
fighting. 

Technically, it started as a fitness regimen for monks, but it is also good 
for fighting.

On Tuesday, August 6, 2013 3:00:11 AM UTC-7, Massimo Di Pierro wrote:
>
> Saying "it is only a teaching tool" without explaining why seems to imply 
> that we, the developers, are saying so. Well, we are not saying that. We 
> never did.
>
> One thing is saying that web2py was originally created as a teaching tool 
> (true) another is to dismiss web2py as only a teaching tool (false). It has 
> evolved a lot from its origins thanks to the contribution of many people 
> here. It has its strengths and it has it weaknesses. The fact that it still 
> easy to read and understand it a strength and continue to make it a good 
> teaching tool. This is the very same reason web2py is good for business 
> applications.
>
> Web2py is a good teaching tool BECAUSE it is a good business tool.
>
> Massimo 
>
> On Tuesday, 6 August 2013 04:41:20 UTC-5, Ramos wrote:
>>
>> I think i have a dishonest friend
>>
>>
>> 2013/8/6 Massimo Di Pierro 
>>
>>> I think he is making a joke. Nobody says that but some dishonest people 
>>> form the competition.
>>>
>>> Massimo
>>>
>>>
>>> On Tuesday, 6 August 2013 01:37:39 UTC-5, Relsi Hur Maron wrote:


 web2py is* just* for learning? why?


 Em segunda-feira, 5 de agosto de 2013 16h58min05s UTC-3, Alan Etkin 
 escreveu:
>
> I've proposed a talk At PyConAr (Argentina) about all the criticism 
> web2py has had from a technical standpoint. Particularly, I'll try to 
> demonstrate that it is not quite so that:
>
>   web2py *is not Python*
>   web2py *is less performant*
>   web2py *has too much magic*
>   web2py *is just for learning*
>
> The list was made according to my limited experience and maybe it 
> could modified to address more important or serious criticisms
>
> I belive there's a lot of material already available to take care of 
> while collecting references as for example this list's records and maybe 
> stackoverflow and other Pyhon programming resources; I wonder if anybody 
> could help providing other sources or points of view to add to enhance 
> the 
> research.
>
> Please note that this is a simple talk proposal and so far has not 
> been accepted. However, it could be of help for others in case of further 
> work anyway.
>
>  -- 
>>>  
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>

-- 

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




[web2py] Re: Security advisory: BREACH and Django

2013-08-06 Thread Anthony
One recommendation is to randomize the "secret" per request (the attack 
works by guessing the secret one character at a time). web2py already 
randomizes its CSRF tokens on every request (which I take it Django does 
not do), so not sure web2py has the same vulnerability with regard to the 
CSRF token (there may be vulnerabilities with other kinds of secret data, 
though).

Anthony

On Tuesday, August 6, 2013 1:55:29 PM UTC-4, Massimo Di Pierro wrote:
>
> As I understand this has nothing to do with Django. They discovered a ssh 
> vulnerability that can used to decrypt part of traffic. It will affect all 
> of us if un patched.
>
> On Tuesday, 6 August 2013 10:55:06 UTC-5, Chun-Hung Chen wrote:
>>
>> Hi,
>>
>> FYI
>> https://www.djangoproject.com/weblog/2013/aug/06/breach-and-django/
>
>

-- 

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




[web2py] Re: IS web2py good for largescale

2013-08-06 Thread pythONtherocks
Hi Joe et al,

My first step..
I would use a tool like https://errormator.com/ now, to determine what the 
real issues are. You might be surprised or not. Then if a migration to 
web2py is warranted I would use the same tool during development to 
optimize the application and keep metrics as the user population grows. 
Visibility is utmost importance for a good start.

Regards.


On Thursday, August 1, 2013 11:04:27 PM UTC-4, hello world wrote:
>
> Hey
> I would like to know if web2py framework ...is a good framework for making 
> large scale websites...???..
>

-- 

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




[web2py] web2py admin access

2013-08-06 Thread dougie
hello,

i setup web2py following the commands using one step production
for 

wget http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh

running this on raspbian. i'm unable to get admin access to work from the 
machine that its on. after a couple days of searching i'm no where closer to 
enabling this. about to start from scratch, so if anyone's got an idea whats 
going on i'd apprecaite some assistance. when i try to access the admin button 
it get a forbidden. 


Cheers

-- 

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




[web2py] Re: Security advisory: BREACH and Django

2013-08-06 Thread Massimo Di Pierro
As I understand this has nothing to do with Django. They discovered a ssh 
vulnerability that can used to decrypt part of traffic. It will affect all 
of us if un patched.

On Tuesday, 6 August 2013 10:55:06 UTC-5, Chun-Hung Chen wrote:
>
> Hi,
>
> FYI
> https://www.djangoproject.com/weblog/2013/aug/06/breach-and-django/

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Alan Etkin
El martes, 6 de agosto de 2013 11:20:01 UTC-3, Relsi Hur Maron escribió:
>
>
> Cool, all is better inside the context.
>

I just made a search and saw this
www.slideshare.net/rochacbruno/desmistificando-web2py-tdc2011
(it's been for a while) and I think there's lot of that presentation I can 
use. In fact, now I know where the title came from.

And also found this

https://groups.google.com/d/msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ

And this is really helpful (Anthony has listed some issues about web2py 
core development)
https://groups.google.com/d/msg/web2py/ohtk6Wroh7Q/3MfrqmGK92oJ

How about adding *web2py uses bad practices* to the web2py mythology? For 
example the supposedly bad practice of using exec.

-- 

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




[web2py] Re: exercise: automatic conversion of a static site into a web2py site

2013-08-06 Thread Massimo Di Pierro
Try this:

scripts/import_static.py

I just committed it to trunk. Usage:

python scripts/import_static.py source_folder applications/web2py_app



On Tuesday, 6 August 2013 08:05:24 UTC-5, tim spear wrote:
>
> Hi Massimo, if you are still reading this stuff.
>
> I've been playing with web2py and was thinking it was missing an easy way 
> to import static sites and was thinking of writing one similar to your 
> proposed challenge. 
>
> Do you know if anyone did produce a functional solution? I see this thread 
> is from nearly three years ago and am not sure what the current state of 
> play is.
>
> Best, Tim Spear
>
>
>
>
> On Wednesday, November 24, 2010 8:05:21 PM UTC, mdipierro wrote:
>>
>> I have a challanage: 
>>
>> write a script that takes a folder that contains a static html file 
>> and converts it into an HTML site. 
>>
>> 1) moves all non .html files into static/ 
>> 2) moves all .html files into views/xxx/ 
>> 3) creates a controllers/xxx.py and for each yyy.html file add an 
>> action 
>>
>> def yyy(): return dict() 
>>
>> 4) loop over all .html files and fixes all the URL to {{=URL(...)}}} 
>>
>> OPTIONAL: 
>> 5) 
>> If all .html files start with a similar header and footer, tried to 
>> identify them, moves "{{include}}" into views/ 
>> layout.html and rewrite the html files to {{extend 'layout.html'}} 
>>
>> The original folder and 'xxx' should be uer defined. This could be 
>> added to the wizard. 
>>
>> Massimo
>
>

-- 

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




Re: [web2py] no driver available ('sqlite2', 'sqlite3')

2013-08-06 Thread Martin Weissenboeck
Thank you, I'll try it again...


2013/8/6 Niphlod 

> tested also on ubuntu server 13.04 64 bit: no issues at all.
> once logged in in the freshly-installed server, all I had to do was:
>
> wget
> https://raw.github.com/web2py/web2py/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
> sudo bash setup-web2py-nginx-uwsgi-ubuntu.sh
>
> then right at the end of the process, filling the details about the SSL
> certificate.
> All was ready and fine.
>
>
>
> On Tuesday, August 6, 2013 2:02:22 PM UTC+2, Niphlod wrote:
>>
>> the "modern" script was tested with 12.04 and 12.10. I'm downloading the
>> 13.04 to see if there is any adjustments to make.
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] Upload a file without a form

2013-08-06 Thread Marin Pranjić
Hello Eduardo,

You can use db.table.insert(...) or db.table.field.store(...).

Details:

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads


Marin




On Tue, Aug 6, 2013 at 5:01 PM, Eduardo Cruz  wrote:

> I need to upload a file that I will create on the fly, is there a way to
> do that without using a form?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] Re: URL filter chain

2013-08-06 Thread Massimo Di Pierro
yes


On Tuesday, 6 August 2013 07:14:34 UTC-5, Anthony wrote:
>
>
>
> On Tuesday, August 6, 2013 3:13:48 AM UTC-4, Massimo Di Pierro wrote:
>>
>> The wsgi middleware is really not the web2py way of doing this. It is a 
>> compatibility mode of allowing third party middleware of interoperating 
>> with web2py. It has only been tested in simple cases. It was recently 
>> rewritten (untested) nobody uses it, and I am considering dropping the 
>> feature.
>
>
> You're talking only about the internal 
> middlewarefeature
>  (i.e., @request.wsgi.middleware), right?
>
> Please tell us more what kind of interception you want to do. In my view 
>> some can be done at the web server level, some at the routes.py level and 
>> some at the response._caller level.
>>
>
> Good point -- response._caller is another good option, especially if you 
> need to do something *after* the controller action finishes.
>
> Anthony
>

-- 

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




[web2py] Security advisory: BREACH and Django

2013-08-06 Thread Chun-Hung Chen
Hi,

FYI
https://www.djangoproject.com/weblog/2013/aug/06/breach-and-django/

-- 

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




[web2py] contrib IS_NOT_EMAIL()

2013-08-06 Thread Richard
Here IS_NOT_EMAIL() validator :

class IS_NOT_EMAIL:
def __init__(self, error_message='You can\'t use email as username'):
self.e = error_message
def __call__(self, value):
if not IS_EMAIL()(value)[1]:
return (value, self.e)
return (value, None)

Enjoy

Here the recipe : 

http://www.web2pyslices.com/slice/show/1686/is-not-email-validator

Richard

-- 

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




Re: [web2py] Re: username and email login (auth)

2013-08-06 Thread Richard Vézina
Create a IS_NOT_EMAIL() validator :

class IS_NOT_EMAIL:
def __init__(self, error_message='You can\'t use email as username'):
self.e = error_message
def __call__(self, value):
if not IS_EMAIL()(value)[1]:
return (value, self.e)
return (value, None)

Base on this!!


I wonder why we don't set flag on validators for "reverse validation" when
apply, for instance : IS_EMAIL(..., *complement=True*) will return an error
if input is email... This is use in python petl project :
http://petl.readthedocs.org/en/latest/

Thanks.

Richard


On Sun, Jun 2, 2013 at 9:20 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Do you need the commented lines?
>
> #request.vars.email = request.vars.username
> request.post_vars.email = request.vars.email
> #request.vars.username = None
> request.post_vars.username = None
>
> On Saturday, 1 June 2013 21:27:05 UTC-5, Gustavo Souza wrote:
>>
>> Worked for me the following code:
>>
>> if 'login' in request.args:
>> auth.settings.login_userfield = 'username'
>> if request.vars.username and not IS_EMAIL()(request.vars.**
>> username)[1]:
>> auth.settings.login_userfield = 'email'
>> request.vars.email = request.vars.username
>> request.post_vars.email = request.vars.email
>> request.vars.username = None
>> request.post_vars.username = None
>>
>> return dict(form=auth.login())
>>
>> Em sexta-feira, 9 de dezembro de 2011 10h22min57s UTC-2, Francisco Costa
>> escreveu:
>>>
>>> lots of users on login form submit their email instead of the
>>> username..
>>>
>>> it seems that auth.define_tables(username=**True) forces username login
>>> but it is possible to have both?
>>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] Good Basic Tutorial: "Twitter Clone in web2py" - source on github.

2013-08-06 Thread Rob_McC

I found a good tutorial today on web2py, there are 3 parts, source on 
github.
https://github.com/neilisfragile/witter

Nice to see more and more learning resources for web2py.
  I seem to learn best from examples.

Twitter Clone Tutorial in web2py
 30 June, 2013
Link:  
http://fragile.org.uk/2013/06/twitter-clone-tutorial-in-web2py-part-1-getting-started/

*Tutorial Introduction:*

Welcome to my getting started with Web2py tutorial.

This tutorial assumes very little on the part of the reader, some knowledge 
of a programming language will certainly help, but if not don’t worry. I’ll 
take you from installation through to v1 of your application.

If you don’t want to copy from the tutorial, the full source is hosted on 
github.
Why Web2py?

Web2py is a fantastic web development framework for Python, it focuses on


   - Ease of use
   - Rapid development
   - Security

-- 

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




[web2py] Upload a file without a form

2013-08-06 Thread Eduardo Cruz
I need to upload a file that I will create on the fly, is there a way to do 
that without using a form?

-- 

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




Re: [web2py] Re: Is it possible to know what view was rendered?

2013-08-06 Thread Vinicius Assef
I'll elaborate a bit more. I'll be back soon. ;-)

On Tue, Aug 6, 2013 at 11:06 AM, Anthony  wrote:
> Not sure I understand. If you have multiple possible views that could be
> rendered for a given action, don't you have to explicitly set the value of
> response.view in your app code? The view that gets rendered is either the
> view in response.view or it is the generic view (unless of course your code
> directly calls response.render()). So, can't you just check the value of
> response.view?
>
>
> On Tuesday, August 6, 2013 9:26:49 AM UTC-4, viniciusban wrote:
>>
>> Yes, but there's a more complex scenario.
>>
>> Let's say I have a list page, where I can 2 views: one to show when db
>> is emtpy and other to show when db is populated.
>> Other scenario is to test a logged_in action. If I don't have a logged
>> in user, another page must exist.
>>
>> In all these cases above all views exist, but just one of them must be
>> showed.
>>
>> It's not a matter to check if a view exists or not. It's a matter to
>> know which of them was really rendered.
>>
>> What I'm asking for is to update response.view to represent the
>> rendered view. Or have something new like response.rendered_view
>>
>> Would it be possible?
>>
>>
>> On Tue, Aug 6, 2013 at 10:07 AM, Anthony  wrote:
>> > I think you would have to manually check with the response.view file (or
>> > the
>> > compiled version) is present (if not, assume the generic view was used).
>> >
>> > Anthony
>> >
>> >
>> > On Tuesday, August 6, 2013 7:58:21 AM UTC-4, viniciusban wrote:
>> >>
>> >> I'm working on tests in apps, again.
>> >>
>> >> To test a controller, we usually check if some view was used, but when
>> >> response.view doesn't exist, generic. is used and
>> >> response.view is not updated accordingly.
>> >>
>> >> In this situation, how may know which view was really rendered?
>> >
>> > --
>> >
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "web2py-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to web2py+un...@googlegroups.com.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Annet


>
> In this line of code:
>>
>>
>> form[0].insert(10,DIV(LABEL(H5(password),_class="control-label"),_class="control-group"))
>>
>
> What do you mean? In your example run above, password appears to have the 
> correct value both before and after that line. Are you saying the label 
> shown in the HTML is the wrong value?
>

Yes,

In this line:
warning=warning +' before label: ' + password
password has value: TnewO[86 

In this line
form[0].insert(10,DIV(LABEL(H5(password),_class="control-label"),_class="control-group"))
password has value: HnewN}86

In this line
warning=warning +' after label: ' + password
password has value: TnewO[86 

 
>
>> and for the insert in the auth_user table password has the value: HnewN}86
>
>
> How do you know what gets inserted? Is the password hashed, and you just 
> observed that logging in with that value work, or is it stored in plain 
> text?
> Are you using the standard db.auth_user definition? If not, can we see the 
> definition or any changes you made to the validators, etc.? Is the password 
> field shown in the register form?
>

I know what's inserted, because I am able to log in using this password: 
HnewN}86, 
the other password: TnewO[86  fails. It's hashed.

This is my auth_user table definition:

db.define_table(
auth.settings.table_user_name,
Field('title',length=8,requires=IS_IN_SET(['de 
heer','mevrouw'],zero='Select a title'),label='Aanhef * '),

Field('first_name',length=32,default='',requires=[IS_LENGTH(32,error_message='Lengte
 
overschreidt 32 tekens'),IS_NOT_EMPTY()],notnull=True,label='Voornaam * '),

Field('familyNamePreposition',length=16,requires=IS_LENGTH(16,error_message='Lengte
 
overschreidt 16 tekens'),label='Tussenvoegsel'),

Field('last_name',length=64,default='',requires=[IS_LENGTH(64,error_message='Lengte
 
overschreidt 64 charactrer'),IS_NOT_EMPTY()],notnull=True,label='Achternaam 
* '),

Field('shortname',length=128,requires=[IS_LENGTH(128,error_message='Lengte 
overschreidt 128 
tekens'),IS_EMPTY_OR(IS_NOT_IN_DB(db,'auth_user.shortname',error_message='Shortname
 
al in database'))],unique=True,writable=False,readable=False),
Field('phone',length=16,requires=IS_LENGTH(16,error_message='Lengte 
overschreidt 16 tekens'),label='Telefoon'),

Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message='Lengte
 
overschreidt 128 tekens'),IS_EMAIL(error_message='Ongeldig 
e-mailadres'),IS_NOT_IN_DB(db,'auth_user.email',error_message='E-mailadres 
al in database')],notnull=True,unique=True,label='E-mail * '),

Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message='Lengte
 
overschreidt 32 
charactrer'),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'auth_user.username',error_message='Username
 
al in 
database')],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
 
* '),
Field('password', 
type='password',length=512,requires=[IS_STRONG(),CRYPT()],writable=False,readable=False,label='Wachtwoord
 
* '),
Field('nodeID','reference 
node',default='',requires=IS_EMPTY_OR(IS_IN_DB(db,'node.id','%(id)s',zero='Select
 
a node')),ondelete='CASCADE',label='NodeID * 
',writable=False,readable=False),

Field('registration_key',length=512,default='',writable=False,readable=False),

Field('reset_password_key',length=512,default='',writable=False,readable=False),

Field('registration_id',length=512,default='',writable=False,readable=False),
Field('createdOn',**attributes),
Field('modifiedOn',update=request.now,**attributes))


The password field is shown in the form, because I set: ignore_rw=True
However, I made it read only: 
form.element('#no_table_password')['_readonly']=True

 

> Also, what is the value of form.vars.password after .process() has been 
> called? form.vars.password is the value that actually gets inserted into 
> the database.
>

It's the hashed password. I first had the following line of code to set the 
context:

context=dict(...,username=form.vars.username,password=form.vars.password,...)

In that case the hashed password is mailed to the user, and the user can't 
use it to log in.


Kind regards,

Annet

 

-- 

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




[web2py] Re: How to specify which table to edit during join?

2013-08-06 Thread Anthony
https://groups.google.com/d/msg/web2py/Yl-6-oYA9C4/EkmwLNz3IegJ

Should be the first table mentioned in the query, but there is a feature 
request to make that customizable.

Anthony

On Tuesday, August 6, 2013 7:18:13 AM UTC-4, Alex Glaros wrote:
>
> Using a grid with a join, I'd like to have user edit only records they 
> created. 
>
> How do you let grid know which table you want to edit when there are 
> multiple tables in the join?
>
> Error received is: 'Row' object has no attribute 'created_by'
>
> If you can, please type the answer using example below.
>
> @auth.requires_login()
> def manage_party_addresses(): 
> is_owner = (lambda row: row.created_by == auth.user_id) if auth.user 
> else False
> query =(db.PartyAddressIntersection.partyID==db.Party.id) & 
> (db.PartyAddressIntersection.addressID==db.Address.id)  & 
> (db.PartyAddressIntersection.addressTypeID==db.AddressType.id)
> grid = SQLFORM.grid(query, editable=is_owner, deletable=is_owner, 
> user_signature=True)
> return dict(grid = grid)
>
> thanks,
>
> Alex Glaros
>

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Anthony


> In this line of code:
>
>
> form[0].insert(10,DIV(LABEL(H5(password),_class="control-label"),_class="control-group"))
>

What do you mean? In your example run above, password appears to have the 
correct value both before and after that line. Are you saying the label 
shown in the HTML is the wrong value?
 

> and for the insert in the auth_user table password has the value: HnewN}86


How do you know what gets inserted? Is the password hashed, and you just 
observed that logging in with that value work, or is it stored in plain 
text?

Are you using the standard db.auth_user definition? If not, can we see the 
definition or any changes you made to the validators, etc.? Is the password 
field shown in the register form?

Also, what is the value of form.vars.password after .process() has been 
called? form.vars.password is the value that actually gets inserted into 
the database.

Anthony

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Ovidio Marinho
I think we should not listen to criticism, but not refute them in the
mouth, but with codes. And this is what they are worried about web2py is
picking up and growing in the web development community. Let's Work!




 Ovidio Marinho Falcao Neto
  ITJP.NET.BR
 ovidio...@gmail.com
   83   8826 9088 - Oi
   83   9336 3782 - Claro
Brasil



2013/8/6 Alan Etkin 

> 2013/8/6 Anthony :
> >>   web2py has too much magic
> >
> >
> > A couple of nice quotes from Zed Shaw:
> > https://twitter.com/zedshaw/status/80415443558477825
> > https://twitter.com/zedshaw/status/80418794526351360
>
> Zed Shaw quotes might be slightly unpleasant to some, but we cannot
> say he doesn't go to point. Can we?
>
> I probably use this quotes, they are very funny too.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Relsi Hur Maron

Cool, all is better inside the context.

=)


Em terça-feira, 6 de agosto de 2013 09h47min06s UTC-3, Alan Etkin escreveu:
>
> > I think he is making a joke. Nobody says that but some dishonest people 
> form the 
> > competition. 
>
> Yeah, some of the statements I called criticism are very ridiculous 
> and I would like to mention them because they are funny. However I 
> think that users who do not know web2py except for what is said about 
> it can have a very wrong concept about the framework and it could lead 
> them to choose any other sound framewok without even trying web2py 
> first. The proposal aims to warn potential users about unjustified 
> statements but also to give some background on other more serious 
> comparisons. 
>
> Argentina has lots of django mongers, and maybe the most of the 
> criticism comes from them. I also think it is a mistake to use the zen 
> of Python to discard frameworks because of the "... obvious way of 
> doing things ..." wether we are choosing one or another. Tim Peters or 
> whoever created that was not talking about web development frameworks, 
> but about writing Python programs. 
>

-- 

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




Re: [web2py] Re: Is it possible to know what view was rendered?

2013-08-06 Thread Anthony
Not sure I understand. If you have multiple possible views that could be 
rendered for a given action, don't you have to explicitly set the value of 
response.view in your app code? The view that gets rendered is either the 
view in response.view or it is the generic view (unless of course your code 
directly calls response.render()). So, can't you just check the value of 
response.view?

On Tuesday, August 6, 2013 9:26:49 AM UTC-4, viniciusban wrote:
>
> Yes, but there's a more complex scenario. 
>
> Let's say I have a list page, where I can 2 views: one to show when db 
> is emtpy and other to show when db is populated. 
> Other scenario is to test a logged_in action. If I don't have a logged 
> in user, another page must exist. 
>
> In all these cases above all views exist, but just one of them must be 
> showed. 
>
> It's not a matter to check if a view exists or not. It's a matter to 
> know which of them was really rendered. 
>
> What I'm asking for is to update response.view to represent the 
> rendered view. Or have something new like response.rendered_view 
>
> Would it be possible? 
>
>
> On Tue, Aug 6, 2013 at 10:07 AM, Anthony > 
> wrote: 
> > I think you would have to manually check with the response.view file (or 
> the 
> > compiled version) is present (if not, assume the generic view was used). 
> > 
> > Anthony 
> > 
> > 
> > On Tuesday, August 6, 2013 7:58:21 AM UTC-4, viniciusban wrote: 
> >> 
> >> I'm working on tests in apps, again. 
> >> 
> >> To test a controller, we usually check if some view was used, but when 
> >> response.view doesn't exist, generic. is used and 
> >> response.view is not updated accordingly. 
> >> 
> >> In this situation, how may know which view was really rendered? 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

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




[web2py] Is there any way to work with static files outside web2py directory?

2013-08-06 Thread tech . uz

Hello

I have installed web2py on disk C: but I also have many many static images 
located on disk D:
Of course there easiest way just to move all images files from disk D: to 
static folder of web2py.
But I don't want to do this way.

I tried to use routes.py files but it doesn't work for me.
Maybe I missed something... but if I add any rules to routes_in web2py 
doesn't handle my images files as static.

I even added some code to rewrite.py (regex_url_in) to handle my static 
files (for example if controller is 'mystatic') in my own way and it works.
But I believe there is simple way to work with static files outside web2py 
forlder?! 


Andrey A.

-- 

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




Re: [web2py] no driver available ('sqlite2', 'sqlite3')

2013-08-06 Thread Niphlod
tested also on ubuntu server 13.04 64 bit: no issues at all.
once logged in in the freshly-installed server, all I had to do was:

wget 
https://raw.github.com/web2py/web2py/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
sudo bash setup-web2py-nginx-uwsgi-ubuntu.sh

then right at the end of the process, filling the details about the SSL 
certificate.
All was ready and fine.


On Tuesday, August 6, 2013 2:02:22 PM UTC+2, Niphlod wrote:
>
> the "modern" script was tested with 12.04 and 12.10. I'm downloading the 
> 13.04 to see if there is any adjustments to make.
>

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Alan Etkin
2013/8/6 Anthony :
>>   web2py has too much magic
>
>
> A couple of nice quotes from Zed Shaw:
> https://twitter.com/zedshaw/status/80415443558477825
> https://twitter.com/zedshaw/status/80418794526351360

Zed Shaw quotes might be slightly unpleasant to some, but we cannot
say he doesn't go to point. Can we?

I probably use this quotes, they are very funny too.

-- 

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




Re: [web2py] Re: Is it possible to know what view was rendered?

2013-08-06 Thread Vinicius Assef
Yes, but there's a more complex scenario.

Let's say I have a list page, where I can 2 views: one to show when db
is emtpy and other to show when db is populated.
Other scenario is to test a logged_in action. If I don't have a logged
in user, another page must exist.

In all these cases above all views exist, but just one of them must be showed.

It's not a matter to check if a view exists or not. It's a matter to
know which of them was really rendered.

What I'm asking for is to update response.view to represent the
rendered view. Or have something new like response.rendered_view

Would it be possible?


On Tue, Aug 6, 2013 at 10:07 AM, Anthony  wrote:
> I think you would have to manually check with the response.view file (or the
> compiled version) is present (if not, assume the generic view was used).
>
> Anthony
>
>
> On Tuesday, August 6, 2013 7:58:21 AM UTC-4, viniciusban wrote:
>>
>> I'm working on tests in apps, again.
>>
>> To test a controller, we usually check if some view was used, but when
>> response.view doesn't exist, generic. is used and
>> response.view is not updated accordingly.
>>
>> In this situation, how may know which view was really rendered?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




[web2py] Re: How to make a search form

2013-08-06 Thread Niphlod
assuming your controller receives some request.vars.search that contains 
the term to search for, it's actually pretty easy

term = request.vars.search
tb = db.yourtable
look_into = [fixed list of fields]
#or something like
look_into = [field for field in tb.fields if tb[field].readable and tb[field
].type in ('text', 'list:string', 'string')]

query = reduce(lambda a,b: a|b, [tb[field].contains(term) for field inlook_into
])
resultset = db(query).select()




On Tuesday, August 6, 2013 2:23:03 PM UTC+2, sasogeek wrote:
>
> making a search form using crud is quite simple with the 
> crud.search(db.table) function. but that returns a search field for all the 
> fields in the table. how do i make one search field (a 'search bar') that 
> searches all the fields using the select option 'contains' or any of the 
> given options when a search query is to be made?

-- 

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




[web2py] Re: Is it possible to know what view was rendered?

2013-08-06 Thread Anthony
I think you would have to manually check with the response.view file (or 
the compiled version) is present (if not, assume the generic view was used).

Anthony

On Tuesday, August 6, 2013 7:58:21 AM UTC-4, viniciusban wrote:
>
> I'm working on tests in apps, again. 
>
> To test a controller, we usually check if some view was used, but when 
> response.view doesn't exist, generic. is used and 
> response.view is not updated accordingly. 
>
> In this situation, how may know which view was really rendered? 
>

-- 

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




[web2py] Re: exercise: automatic conversion of a static site into a web2py site

2013-08-06 Thread tim spear
Hi Massimo, if you are still reading this stuff.

I've been playing with web2py and was thinking it was missing an easy way 
to import static sites and was thinking of writing one similar to your 
proposed challenge. 

Do you know if anyone did produce a functional solution? I see this thread 
is from nearly three years ago and am not sure what the current state of 
play is.

Best, Tim Spear




On Wednesday, November 24, 2010 8:05:21 PM UTC, mdipierro wrote:
>
> I have a challanage: 
>
> write a script that takes a folder that contains a static html file 
> and converts it into an HTML site. 
>
> 1) moves all non .html files into static/ 
> 2) moves all .html files into views/xxx/ 
> 3) creates a controllers/xxx.py and for each yyy.html file add an 
> action 
>
> def yyy(): return dict() 
>
> 4) loop over all .html files and fixes all the URL to {{=URL(...)}}} 
>
> OPTIONAL: 
> 5) 
> If all .html files start with a similar header and footer, tried to 
> identify them, moves "{{include}}" into views/ 
> layout.html and rewrite the html files to {{extend 'layout.html'}} 
>
> The original folder and 'xxx' should be uer defined. This could be 
> added to the wizard. 
>
> Massimo

-- 

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




[web2py] Re: Demistifying web2py

2013-08-06 Thread Anthony

>
>   web2py *has too much magic*


A couple of nice quotes from Zed Shaw:
https://twitter.com/zedshaw/status/80415443558477825
https://twitter.com/zedshaw/status/80418794526351360
 

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Annet
Hi Anthony,

I am completely puzzled as to what happens, I added a warning variable to 
the function, to which I write the value of password throughout the code:


password=generate_password(name,now)
warning=' no form: ' + password
form=SQLFORM.factory(db.auth_user,ignore_rw=True,submit_button='Registreer',separator='',formstyle='bootstrap')
warning=warning +' form factory: ' + password
form.vars.title=row.title
form.vars.first_name=row.firstName
form.vars.familyNamePreposition=row.familyNamePreposition
form.vars.last_name=row.lastName
form.vars.shortname=username
form.vars.phone=row.phone
form.vars.email=row.email
form.vars.username=username
warning=warning +' form vars: ' + password
form.vars.password=password
warning=warning +' after form vars: ' + password
form.vars.nodeID=session.userNodeID
form.element('#no_table_username')['_readonly']=True
form.element('#no_table_password')['_readonly']=True
form.element('#no_table_nodeID')['_readonly']=True
form[0].insert(0,DIV(LABEL(H5('Gebruikersgegevens:'),_class="control-label"),_class="control-group"))
form[0].insert(8,DIV(LABEL(H5('Inloggegevens:'),_class="control-label"),_class="control-group"))
warning=warning +' before label: ' + password
form[0].insert(10,DIV(LABEL(H5(password),_class="control-label"),_class="control-group"))
warning=warning +' after label: ' + password
form[0].insert(12,DIV(LABEL(H5('Nodegegevens:'),_class="control-label"),_class="control-group"))
form[0].insert(14,DIV(LABEL(H5('Niet 
invullen!:'),_class="control-label"),_class="control-group"))
warning=warning +' form before process: ' + password
if 
form.process(onvalidation=onvalidation_register_form,keepvalues=False).accepted:
warning=warning +' form after submit: ' + password
id=session.userNodeID
del session.userNodeID
warning=warning + ' userNodeID: ' + password
rating=db(db.rating.nodeID==id).select().first()
if not rating:
db.rating.insert(nodeID=id,rating=categoryID)
else:
rating.update_record(nodeID=id,rating=categoryID)
if categoryID!=FREEVCARDID:

bankaccount=db(db.bankAccount.nodeID==id).select(db.bankAccount.ALL).first()
if bankaccount:
if bankaccount.BIC!=row.BIC or bankaccount.IBAN!=row.IBAN or 
bankaccount.holder!=row.holder:

bankaccount.update_record(BIC=row.BIC,IBAN=row.IBAN,holder=row.holder)
else:

db.bankAccount.insert(nodeID=id,BIC=row.BIC,IBAN=row.IBAN,holder=row.holder) 

db.notification.insert(nodeID=id,notification=BANKACCOUNTCRUD)
warning=warning + ' pre auth_user: ' + password
userID=db.auth_user.insert(**db.auth_user._filter_fields(form.vars))
warning= warning + ' auth_user: ' + password
db.auth_membership.insert(user_id=userID,group_id=PROFILEGROUPID)
db.auth_membership.insert(user_id=userID,group_id=ACCOUNTGROUPID)
db.auth_membership.insert(user_id=userID,group_id=INTERFACEGROUPID)
db.auth_membership.insert(user_id=userID,group_id=TEXTGROUPID)
accountID=db.account.insert(nodeID=id)

interfaces=db(db.interface.nodeID==id).select(orderby=db.interface.categoryID)
if interfaces:
interface=interfaces.last()
if interface:
if interface.customized:
redirect(URL('customizedInterface',args=id))
else:

nodenavs=db((db.nodeNav.nodeID==id)&(db.nodeNav.navID==db.nav.id)).select(orderby=db.nav.id)
if categoryID<=VCARDID:

db.accountInterface.insert(accountID=accountID,interfaceID=interface.id)
if categoryID==FREEVCARDID:

navs=db(db.nav.id.belongs(FREEVCARDID_NAVLIST)).select(orderby=db.nav.id)
elif categoryID==VCARDID:

db.auth_membership.insert(user_id=userID,group_id=GRAPHICSGROUPID)

db.auth_membership.insert(user_id=userID,group_id=NETWORKGROUPID)

navs=db(db.nav.id.belongs(VCARDID_NAVLIST)).select(orderby=db.nav.id)
for n in navs:
process_switchboard(db,id,n.navbarID,n.id,True)
else:
if categoryID<=VCARDID:
interfaceID=db.interface.insert(nodeID=id,categoryID=categoryID)

db.accountInterface.insert(accountID=accountID,interfaceID=interfaceID)
if categoryID==FREEVCARDID:

insert_navbars_navs(id,FREEVCARDID_NAVBARLIST,FREEVCARDID_NAVLIST)
elif categoryID==VCARDID:

db.auth_membership.insert(user_id=userID,group_id=GRAPHICSGROUPID)

db.auth_membership.insert(user_id=userID,group_id=NETWORKGROUPID)
insert_navbars_navs(id,VCARDID_NAVBARLIST,VCARDID_NAVLIST)
row.update_record(nodeID=id,repliedOn=request.now)

context=dict(id=id,title=form.vars.title,familyNamePreposition=form.vars.familyNamePreposition,\

lastName=form.vars.last_name,username=username,userkeyword=password,signature=None)
message=re

Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Alan Etkin
> I think he is making a joke. Nobody says that but some dishonest people form 
> the
> competition.

Yeah, some of the statements I called criticism are very ridiculous
and I would like to mention them because they are funny. However I
think that users who do not know web2py except for what is said about
it can have a very wrong concept about the framework and it could lead
them to choose any other sound framewok without even trying web2py
first. The proposal aims to warn potential users about unjustified
statements but also to give some background on other more serious
comparisons.

Argentina has lots of django mongers, and maybe the most of the
criticism comes from them. I also think it is a mistake to use the zen
of Python to discard frameworks because of the "... obvious way of
doing things ..." wether we are choosing one or another. Tim Peters or
whoever created that was not talking about web development frameworks,
but about writing Python programs.

-- 

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




Re: [web2py] Is it possible to know what view was rendered?

2013-08-06 Thread Ovidio Marinho
If response.view not been completed and finalized, there is no session, so
it was not used.




 Ovidio Marinho Falcao Neto
  ITJP.NET.BR
 ovidio...@gmail.com
   83   8826 9088 - Oi
   83   9336 3782 - Claro
Brasil



2013/8/6 Vinicius Assef 

> I'm working on tests in apps, again.
>
> To test a controller, we usually check if some view was used, but when
> response.view doesn't exist, generic. is used and
> response.view is not updated accordingly.
>
> In this situation, how may know which view was really rendered?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] How to make a search form

2013-08-06 Thread sasogeek
making a search form using crud is quite simple with the 
crud.search(db.table) function. but that returns a search field for all the 
fields in the table. how do i make one search field (a 'search bar') that 
searches all the fields using the select option 'contains' or any of the 
given options when a search query is to be made?

-- 

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




[web2py] Re: How to find and change registration process

2013-08-06 Thread Anthony
Specifically, form=auth() calls the __call__ method of the Auth class, 
which then reads request.args(0) to figure out which Auth action has been 
requested and calls the appropriate Auth method to generate and process the 
form. In this case, it would call auth.register(). If you create your own 
register function, you can call auth.register() directly.

Anthony

On Tuesday, August 6, 2013 8:05:27 AM UTC-4, Niphlod wrote:
>
> just change the url of the registration in the menu to point to your own 
> controller or hack in in the default/user function
>
> def user():
>  if request.args(0) == 'register':
>  your own code, returning.
>  form = whatever
>  .
>  return dict(form=auth())
>
>
>
> On Tuesday, August 6, 2013 6:37:20 AM UTC+2, Alex Glaros wrote:
>>
>> I'd like to add some tables for user to populate when they first 
>> register.  I can't find where the already-existing standard registration 
>> function is so I can add the extra tables.
>>
>> What's the best way to go about changing registration so that when users 
>> click on the registration dropdown menu item on the top right, they are 
>> sent to the updated registration process?
>>
>> thanks,
>>
>> Alex Glaros
>>
>

-- 

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




[web2py] Re: URL filter chain

2013-08-06 Thread Anthony


On Tuesday, August 6, 2013 3:13:48 AM UTC-4, Massimo Di Pierro wrote:
>
> The wsgi middleware is really not the web2py way of doing this. It is a 
> compatibility mode of allowing third party middleware of interoperating 
> with web2py. It has only been tested in simple cases. It was recently 
> rewritten (untested) nobody uses it, and I am considering dropping the 
> feature.


You're talking only about the internal 
middlewarefeature
 (i.e., @request.wsgi.middleware), right?

Please tell us more what kind of interception you want to do. In my view 
> some can be done at the web server level, some at the routes.py level and 
> some at the response._caller level.
>

Good point -- response._caller is another good option, especially if you 
need to do something *after* the controller action finishes.

Anthony

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Anthony

>
> userID=db.auth_user.insert(**db.auth_user._filter_fields(
> form.vars))


> db.auth_membership.insert(user_id=userID,group_id=PROFILEGROUPID)
> 
> db.auth_membership.insert(user_id=userID,group_id=ACCOUNTGROUPID)
> 
> db.auth_membership.insert(user_id=userID,group_id=INTERFACEGROUPID)
> 
> db.auth_membership.insert(user_id=userID,group_id=TEXTGROUPID)
> ...
> row.update_record(nodeID=id,repliedOn=request.now)
> 
> context=dict(id=id,title=form.vars.title,familyNamePreposition=form.vars.familyNamePreposition,\
> 
> lastName=form.vars.last_name,username=username,userkeyword=password,signature=None)
> message=response.render('mail/register.html',context)
>

Can we see the code in the "..." section above, as well as the 
register.html template? Are you sure the password is changing, or is the 
login just not working (possibly for some other reason)?

Anthony 

-- 

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




[web2py] Re: Nice change to admin interface for editing files, what about static files?

2013-08-06 Thread Rob_McC

I just discovered, it wasn't obvious to me, that the headings will *COLLAPSE
* the file list.

I also like to 
Cmd- Click 
on a file to open in a NEW tab in my Browser.



Collapse Feature Example:
While editing a file, like db.py,
the menu is:

models
db.py
menu.py

controllers
appadmin.py
default.py
views
__init__.py
appadmin.html
default/index.ht
etc..

Then, click on controllers, the controller files collapse
models
db.py
menu.py

controllers

views
__init__.py
appadmin.html
default/index.ht
etc.

A very nice improvement to UI. I spend a lot of time playing around with 
web2py, and the ability to edit files quickly in admin is helpful,
lately, I use Sublime Text 2 as my primary editor, but still play with the 
editing feature inside of web2py.
http://www.sublimetext.com/
but, it took me a long time to understand how powerful it is, and that 
installing plugins is essential to productivity,
it's great for Python, with the correct plugins, and changes the way I code.
https://tutsplus.com/course/improve-workflow-in-sublime-text-2/

Sublime will open up the web2py.app package on my mac, and I see all the 
files there.

R 



-- 

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




[web2py] Re: How to find and change registration process

2013-08-06 Thread Niphlod
just change the url of the registration in the menu to point to your own 
controller or hack in in the default/user function

def user():
 if request.args(0) == 'register':
 your own code, returning.
 form = whatever
 .
 return dict(form=auth())



On Tuesday, August 6, 2013 6:37:20 AM UTC+2, Alex Glaros wrote:
>
> I'd like to add some tables for user to populate when they first register. 
>  I can't find where the already-existing standard registration function is 
> so I can add the extra tables.
>
> What's the best way to go about changing registration so that when users 
> click on the registration dropdown menu item on the top right, they are 
> sent to the updated registration process?
>
> thanks,
>
> Alex Glaros
>

-- 

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




Re: [web2py] no driver available ('sqlite2', 'sqlite3')

2013-08-06 Thread Niphlod
the "modern" script was tested with 12.04 and 12.10. I'm downloading the 
13.04 to see if there is any adjustments to make.

-- 

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




[web2py] Is it possible to know what view was rendered?

2013-08-06 Thread Vinicius Assef
I'm working on tests in apps, again.

To test a controller, we usually check if some view was used, but when
response.view doesn't exist, generic. is used and
response.view is not updated accordingly.

In this situation, how may know which view was really rendered?

-- 

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




[web2py] How to specify which table to edit during join?

2013-08-06 Thread Alex Glaros
Using a grid with a join, I'd like to have user edit only records they 
created. 

How do you let grid know which table you want to edit when there are 
multiple tables in the join?

Error received is: 'Row' object has no attribute 'created_by'

If you can, please type the answer using example below.

@auth.requires_login()
def manage_party_addresses(): 
is_owner = (lambda row: row.created_by == auth.user_id) if auth.user 
else False
query =(db.PartyAddressIntersection.partyID==db.Party.id) & 
(db.PartyAddressIntersection.addressID==db.Address.id)  & 
(db.PartyAddressIntersection.addressTypeID==db.AddressType.id)
grid = SQLFORM.grid(query, editable=is_owner, deletable=is_owner, 
user_signature=True)
return dict(grid = grid)

thanks,

Alex Glaros

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Annet
Massimo,

Thanks fro your reply.

strange. when you say python 2.6.4 do you mean the problem is only present 
> with this version or that you have only tested it with this version of 
> python?
>

I meant web2py version 2.4.6, which I am running at the moment. I coded the 
function a while ago, in an earlier version of web2py, generating and 
mailing the password worked then.

I narrowed the problem down by setting userkeyword='testvalue', when I 
submit the form both the password inserted into auth_user and the one 
mailed are identical in this case. So, in my code  
generate_userkeyword(name,now) apparently gets called twice.

These are the functions involved:


def onvalidation_register_form(form):
user=db(db.auth_user.nodeID==session.userNodeID).select().first()
if user:
form.errors.last_name='The database already contains a user for 
this node'

@auth.requires(lambda: auth.has_membership(ADMIN))
def process_register_form():
if not len(request.args):
redirect(URL('register'))
else:

row=categoryID=subTypeID=rowset=count=organization=person=session.userNodeID=name=plural=now=username=userkeyword=\

form=rating=bankaccount=userID=accountID=interfaces=interface=nodenavs=None
row=db(db.register.id==int(request.args(0))).select().first()
if row:
categoryID=row.categoryID
if row.subTypeID==ST_ORGANIZATION:

elif row.subTypeID==ST_PERSON:
...
if len(name)>4:
slice0=name[:4]
else:
slice0=name
now=str(request.now.day)+str(request.now.month)
username=str(slice0)+str(now)+str(request.now.year)[2:]
userkeyword=generate_userkeyword(name,now)

form=SQLFORM.factory(db.auth_user,submit_button='Registrer',separator='',formstyle='bootstrap')
form.vars.title=row.title
form.vars.first_name=row.firstName
form.vars.familyNamePreposition=row.familyNamePreposition
form.vars.last_name=row.lastName
form.vars.phone=row.phone
form.vars.email=row.email
form[0].insert(0,DIV(LABEL(H5('Gebruikersgegevens:' + 
userkeyword),_class="control-label"),_class="control-group"))
if 
form.process(onvalidation=onvalidation_register_form,keepvalues=False).accepted:
id=session.userNodeID
del session.userNodeID
...

userID=db.auth_user.insert(title=row.title,first_name=row.firstName,familyNamePreposition=row.familyNamePreposition,\

last_name=row.lastName,shortname=username,phone=row.phone,email=row.email,username=username,password=userkeyword,nodeID=id)

db.auth_membership.insert(user_id=userID,group_id=PROFILEGROUPID)

db.auth_membership.insert(user_id=userID,group_id=ACCOUNTGROUPID)

db.auth_membership.insert(user_id=userID,group_id=INTERFACEGROUPID)

db.auth_membership.insert(user_id=userID,group_id=TEXTGROUPID)

row.update_record(nodeID=id,repliedOn=request.now)

context=dict(id=id,title=row.title,familyNamePreposition=row.familyNamePreposition,\

lastName=row.lastName,username=username,userkeyword=userkeyword,signature=None)
message=response.render('mail/register.html',context)
recipient=row.email
   mail.send(to=[recipient],subject='Uw Leonexus ID voor de 
toegang tot Leonexus CMS',message=[None,message])
elif form.errors:
response.flash=response_flash('formerror',session)
elif not response.flash:
response.flash=response.flash + REQUIRED
session.alert='alert-info'
else:
session.flash='De URL bevat ongeldige argumenten'
session.alert='alert-block'
redirect(URL('register'))
return dict(form=form)


def generate_userkeyword(name,now):
import random
value=''

return value


Kind regards,

Annet

-- 

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




[web2py] Re: Generated password changes between functions

2013-08-06 Thread Massimo Di Pierro
strange. when you say python 2.6.4 do you mean the problem is only present 
with this version or that you have only tested it with this version of 
python?

On Tuesday, 6 August 2013 04:46:12 UTC-5, Annet wrote:
>
> In my application I have a custom registration function. The function 
> processes registration forms and sends the user
> an email with his username and password, this worked well in previous 
> versions of web2py, however, in version 2.4.6
> the generated password changes between inserting a record into the 
> auth_user table and sending the mail. I have no idea why.
> This is the relevant code:
>
>
> @auth.requires(lambda: auth.has_membership(ADMIN))
> def process_register_form():
> if not len(request.args):
> redirect(URL('register'))
> else:
> ...
> userkeyword=generate_userkeyword(name,now)
> form=SQLFORM.factory(db.auth_user,submit_button='Sign 
> up',separator='',formstyle='bootstrap')
> form[0].insert(0,DIV(LABEL(H5('Gebruikersgegevens: ' + 
> userkeyword),_class="control-label"),_class="control-group")) # gives me 
> the userkeyword OreeH+86
> if 
> form.process(onvalidation=onvalidation_register_form,keepvalues=False).accepted:
> ...
> 
> userID=db.auth_user.insert(title=row.title,first_name=row.firstName,familyNamePreposition=row.familyNamePreposition,\
> 
> last_name=row.lastName,shortname=username,phone=row.phone,email=row.email,username=username,password=userkeyword,nodeID=id)
> 
> 
> context=dict(id=id,title=row.title,familyNamePreposition=row.familyNamePreposition,\
> 
> lastName=row.lastName,username=username,userkeyword=userkeyword) # this 
> userkeywords differs from the one inserted above JreeE~86
> message=response.render('mail/register.html',context)
> recipient=row.email
> mail.send(to=[recipient],subject='Uw Leonexus ID voor de 
> toegang tot Leonexus CMS',message=[None,message])
> elif form.errors:
> response.flash=response_flash('formerror',session)
> elif not response.flash:
> response.flash=response.flash + REQUIRED
> session.alert='alert-info'
> return dict(form=form)
>
>
> What happens between inserting the userkeyword in auth_user and adding the 
> userkeyword in a dict() to the context of the mail, that changes the value 
> of userkeyword?
>
>
> Kind regards,
>
> Annet
>

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread Massimo Di Pierro
Saying "it is only a teaching tool" without explaining why seems to imply 
that we, the developers, are saying so. Well, we are not saying that. We 
never did.

One thing is saying that web2py was originally created as a teaching tool 
(true) another is to dismiss web2py as only a teaching tool (false). It has 
evolved a lot from its origins thanks to the contribution of many people 
here. It has its strengths and it has it weaknesses. The fact that it still 
easy to read and understand it a strength and continue to make it a good 
teaching tool. This is the very same reason web2py is good for business 
applications.

Web2py is a good teaching tool BECAUSE it is a good business tool.

Massimo 

On Tuesday, 6 August 2013 04:41:20 UTC-5, Ramos wrote:
>
> I think i have a dishonest friend
>
>
> 2013/8/6 Massimo Di Pierro >
>
>> I think he is making a joke. Nobody says that but some dishonest people 
>> form the competition.
>>
>> Massimo
>>
>>
>> On Tuesday, 6 August 2013 01:37:39 UTC-5, Relsi Hur Maron wrote:
>>>
>>>
>>> web2py is* just* for learning? why?
>>>
>>>
>>> Em segunda-feira, 5 de agosto de 2013 16h58min05s UTC-3, Alan Etkin 
>>> escreveu:

 I've proposed a talk At PyConAr (Argentina) about all the criticism 
 web2py has had from a technical standpoint. Particularly, I'll try to 
 demonstrate that it is not quite so that:

   web2py *is not Python*
   web2py *is less performant*
   web2py *has too much magic*
   web2py *is just for learning*

 The list was made according to my limited experience and maybe it could 
 modified to address more important or serious criticisms

 I belive there's a lot of material already available to take care of 
 while collecting references as for example this list's records and maybe 
 stackoverflow and other Pyhon programming resources; I wonder if anybody 
 could help providing other sources or points of view to add to enhance the 
 research.

 Please note that this is a simple talk proposal and so far has not been 
 accepted. However, it could be of help for others in case of further work 
 anyway.

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

-- 

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




[web2py] Generated password changes between functions

2013-08-06 Thread Annet
In my application I have a custom registration function. The function 
processes registration forms and sends the user
an email with his username and password, this worked well in previous 
versions of web2py, however, in version 2.4.6
the generated password changes between inserting a record into the 
auth_user table and sending the mail. I have no idea why.
This is the relevant code:


@auth.requires(lambda: auth.has_membership(ADMIN))
def process_register_form():
if not len(request.args):
redirect(URL('register'))
else:
...
userkeyword=generate_userkeyword(name,now)
form=SQLFORM.factory(db.auth_user,submit_button='Sign 
up',separator='',formstyle='bootstrap')
form[0].insert(0,DIV(LABEL(H5('Gebruikersgegevens: ' + 
userkeyword),_class="control-label"),_class="control-group")) # gives me 
the userkeyword OreeH+86
if 
form.process(onvalidation=onvalidation_register_form,keepvalues=False).accepted:
...

userID=db.auth_user.insert(title=row.title,first_name=row.firstName,familyNamePreposition=row.familyNamePreposition,\

last_name=row.lastName,shortname=username,phone=row.phone,email=row.email,username=username,password=userkeyword,nodeID=id)


context=dict(id=id,title=row.title,familyNamePreposition=row.familyNamePreposition,\

lastName=row.lastName,username=username,userkeyword=userkeyword) # this 
userkeywords differs from the one inserted above JreeE~86
message=response.render('mail/register.html',context)
recipient=row.email
mail.send(to=[recipient],subject='Uw Leonexus ID voor de 
toegang tot Leonexus CMS',message=[None,message])
elif form.errors:
response.flash=response_flash('formerror',session)
elif not response.flash:
response.flash=response.flash + REQUIRED
session.alert='alert-info'
return dict(form=form)


What happens between inserting the userkeyword in auth_user and adding the 
userkeyword in a dict() to the context of the mail, that changes the value 
of userkeyword?


Kind regards,

Annet

-- 

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




Re: [web2py] Re: Demistifying web2py

2013-08-06 Thread António Ramos
I think i have a dishonest friend


2013/8/6 Massimo Di Pierro 

> I think he is making a joke. Nobody says that but some dishonest people
> form the competition.
>
> Massimo
>
>
> On Tuesday, 6 August 2013 01:37:39 UTC-5, Relsi Hur Maron wrote:
>>
>>
>> web2py is* just* for learning? why?
>>
>>
>> Em segunda-feira, 5 de agosto de 2013 16h58min05s UTC-3, Alan Etkin
>> escreveu:
>>>
>>> I've proposed a talk At PyConAr (Argentina) about all the criticism
>>> web2py has had from a technical standpoint. Particularly, I'll try to
>>> demonstrate that it is not quite so that:
>>>
>>>   web2py *is not Python*
>>>   web2py *is less performant*
>>>   web2py *has too much magic*
>>>   web2py *is just for learning*
>>>
>>> The list was made according to my limited experience and maybe it could
>>> modified to address more important or serious criticisms
>>>
>>> I belive there's a lot of material already available to take care of
>>> while collecting references as for example this list's records and maybe
>>> stackoverflow and other Pyhon programming resources; I wonder if anybody
>>> could help providing other sources or points of view to add to enhance the
>>> research.
>>>
>>> Please note that this is a simple talk proposal and so far has not been
>>> accepted. However, it could be of help for others in case of further work
>>> anyway.
>>>
>>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] Re: How to create a hyperlink from a display field in sqlForm?

2013-08-06 Thread Johann Spies
if you use Massimo's suggested code:

db.TaxonomyDetail.objectID.represent =  lambda id, record:A(record.objectID,
 _target = "_blank", _href = URL('manage_object_super_type',id))

Then in ' manage_object_super_type'  do something like this:



def manage_object_super_type(): ##
data = crud.read(db.ObjectSuperType.id ==request.args(0))
#grid = SQLFORM.smartgrid(db.ObjectSuperType),
#return dict(grid=grid)
return(dict(grid=data)

Regards
Johann

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

-- 

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




[web2py] Re: Demistifying web2py

2013-08-06 Thread Massimo Di Pierro
I think he is making a joke. Nobody says that but some dishonest people 
form the competition.

Massimo

On Tuesday, 6 August 2013 01:37:39 UTC-5, Relsi Hur Maron wrote:
>
>
> web2py is* just* for learning? why?
>
>
> Em segunda-feira, 5 de agosto de 2013 16h58min05s UTC-3, Alan Etkin 
> escreveu:
>>
>> I've proposed a talk At PyConAr (Argentina) about all the criticism 
>> web2py has had from a technical standpoint. Particularly, I'll try to 
>> demonstrate that it is not quite so that:
>>
>>   web2py *is not Python*
>>   web2py *is less performant*
>>   web2py *has too much magic*
>>   web2py *is just for learning*
>>
>> The list was made according to my limited experience and maybe it could 
>> modified to address more important or serious criticisms
>>
>> I belive there's a lot of material already available to take care of 
>> while collecting references as for example this list's records and maybe 
>> stackoverflow and other Pyhon programming resources; I wonder if anybody 
>> could help providing other sources or points of view to add to enhance the 
>> research.
>>
>> Please note that this is a simple talk proposal and so far has not been 
>> accepted. However, it could be of help for others in case of further work 
>> anyway.
>>
>>

-- 

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




[web2py] Re: URL filter chain

2013-08-06 Thread Massimo Di Pierro
The wsgi middleware is really not the web2py way of doing this. It is a 
compatibility mode of allowing third party middleware of interoperating 
with web2py. It has only been tested in simple cases. It was recently 
rewritten (untested) nobody uses it, and I am considering dropping the 
feature.

Please tell us more what kind of interception you want to do. In my view 
some can be done at the web server level, some at the routes.py level and 
some at the response._caller level.

On Monday, 5 August 2013 21:44:15 UTC-5, Marcio Andrey Oliveira wrote:
>
>
> Thank you both for replying.
>
> It seems wsgi middleware fits better my needs.
>
> Regards.
>
>
> Em segunda-feira, 5 de agosto de 2013 23h15min59s UTC-3, Marcio Andrey 
> Oliveira escreveu:
>>
>> Hi.
>>
>> In Java there is the concept of URL filter chain (implemented by one or 
>> more servlets). These filters may intercept requests to a specif URL or a 
>> bunch of them prior the request arrive to the controller(servlet) 
>> responsible to handle it.
>>
>> Is there such concept on web2py?
>>
>> How could I implement it?
>>
>> Thank you in advance.
>>
>

-- 

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