Re: [web2py] SQLFORM Validation and Password Hashes

2015-03-10 Thread Johann Spies
On 10 March 2015 at 06:53, horridohobbyist horrido.hobb...@gmail.com
wrote:

I use SQLFORM to add records to a table. However, one of the fields is a
 password which requires=[IS_STRONG(upper=2),CRYPT(salt=False)].

 I would like to use SQLFORM to update records in the table, but I run into
 a problem:  the password field contains the hash of the password, which
 will not pass validation. So even if I don't change the password field,
 SQLFORM insists that I enter something that can be validated.

 If I can't use SQLFORM, then I will have to build my own form and do
 everything from scratch, essentially mimicking SQLFORM. That seems to me to
 be a lot of unnecessary work.

 Is there an easy workaround?

 (Yeah, I'm still a web2py newbie.)


Showing your code will help people on this list to help you.

Regards
Johann

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


Re: [web2py] Select categories that are in use

2015-03-10 Thread Niphlod
2 queries ? no

subselect - way, 1 query.

db(db.news_categories.id.belongs(db(db.news.id0)._select(db.news.category, 
distinct=True))).select()

technically, there is also another one, more useful in case you'd like to 
select, e.g., only categories with at least x news, but that's another 
story.

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


[web2py] Re: IMPORTANT - WEB2PY CONSULTING

2015-03-10 Thread João Saraiva
Hi, Massimo,

My company also does web2py consulting and development. The link 
is http://www.definescope.com/ .
web2py itself is mentioned 
in http://www.definescope.com/en/services/consulting/ 
and http://www.definescope.com/en/services/software-development/ (I just 
noticed now that the first page mentions web2py but does not contain a link 
to the website; I'll correct this later when I get home).

Thanks!


Best regards to everyone,
João Saraiva


On Sunday, February 15, 2015 at 10:21:36 PM UTC, Massimo Di Pierro wrote:

 We need to update the list of companies that provide web2py consulting.
 This list is obsolete:

 http://web2py.com/init/default/support

 Some links are broke. Most pages do not even mention web2py. Some of them 
 have a design that is simply not acceptable for a web development company.

 That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
 page to have a decent design and MENTION WEB2PY on the main site. Then 
 respond to this thread by providing an updated link and the country were 
 you incorporated. If you have a self-employed individual list your country 
 of residence.



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


Re: [web2py] Select categories that are in use

2015-03-10 Thread Johann Spies
Try this (untested)


categories_used = [x.category for x in
db().select(db.news.category,orderby=db.news.category))]

categories = db(db.news_categories.id.belongs(categories_used).select(
db.news_categories.name)

Johann

On 9 March 2015 at 18:53, Gael Princivalle gaelprinciva...@gmail.com
wrote:


  Hello all.

 I've got some news categories:
 db.define_table('news_categories',
 Field('name', type='string', requires=IS_NOT_EMPTY(),
 label='Nome'),
 format = '%(name)s')

 And some news:
 db.define_table('news',
 Field('title', type='string', requires=IS_NOT_EMPTY()),
 Field('body', type='text''),
 Field('category', 'reference news_categories', requires =
 IS_IN_DB(db, db.news_categories.id,'%(name)s'),
   represent=lambda id, r: db.news_categories[id].name))

 How can I select only the news_categories that have almost one news of
 that category ?
 Now I've got all categories.
 categories=db().select(db.news_categories.ALL)

 Thanks.

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




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

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


Re: [web2py] SQLFORM Validation and Password Hashes

2015-03-10 Thread horridohobbyist
The table definition is:

db.define_table('teams',

Field('team_email',requires=[IS_EMAIL(),IS_NOT_IN_DB(db,'teams.team_email')]),

Field('password',requires=[IS_STRONG(upper=2),CRYPT(salt=False)]),

Field('team_name',requires=[IS_TEAM_NAME(),IS_NOT_IN_DB(db,'teams.team_name')]),

Field('reg_date','datetime',readable=False,writable=False,default=datetime.datetime.today()),
Field('reg_key',readable=False,writable=False),
Field('team_size',requires=IS_IN_SET([1,2,3,4])),
Field('team_captain',requires=IS_NOT_EMPTY()),
Field('second_member',requires=IS_CONDENSED()),
Field('third_member',requires=IS_CONDENSED()),
Field('fourth_member',requires=IS_CONDENSED()),
Field('school',requires=IS_NOT_EMPTY()),
Field('teachers_email',requires=IS_EMAIL()))

The call to SQLFORM in the default controller is:

record = db.teams(id)
form = SQLFORM(db.teams, record)
if form.process().accepted:
response.flash = 'profile updated'

What other code would be helpful??


On Tuesday, 10 March 2015 02:13:26 UTC-4, Johann Spies wrote:

 On 10 March 2015 at 06:53, horridohobbyist horrido...@gmail.com 
 javascript: wrote:

 I use SQLFORM to add records to a table. However, one of the fields is a 
 password which requires=[IS_STRONG(upper=2),CRYPT(salt=False)].

 I would like to use SQLFORM to update records in the table, but I run 
 into a problem:  the password field contains the hash of the password, 
 which will not pass validation. So even if I don't change the password 
 field, SQLFORM insists that I enter something that can be validated.

 If I can't use SQLFORM, then I will have to build my own form and do 
 everything from scratch, essentially mimicking SQLFORM. That seems to me to 
 be a lot of unnecessary work.

 Is there an easy workaround?

 (Yeah, I'm still a web2py newbie.)


 Showing your code will help people on this list to help you.

 Regards
 Johann 


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


[web2py] Re: Check file size before upload process

2015-03-10 Thread William Chen
I believe you can use 'onvalidation' to check the file size before upload. 

http://web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation

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


[web2py] Re: list reference with ondelete=set null breaking when delete parent

2015-03-10 Thread Francisco Costa
Hi Paolo, but how do you find the tables (and records) that use the deleted 
record as a Foreign Key?

I don't know if those records should have the is_active set to False, or 
the Foreign Key set to None


On Tuesday, 10 March 2015 07:34:22 UTC, Paolo Valleri wrote:

 ondelete is for reference field.
 At a first sight, a possible workaround would be to write your own 
 'ondelete' by using the _before_delete and _after_delete callbacks

 Paolo

 On Monday, March 9, 2015 at 7:09:54 PM UTC+1, Ron Chatterjee wrote:

 Wonder if he can try to make it a list and do list.remove?

 Have you tried that?

 On Thursday, March 20, 2014 at 3:07:47 PM UTC-4, Leonel Câmara wrote:

 I think you should have a third table anyway or searches for T-shirts of 
 a given colour will be quite slow.



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


[web2py] Re: Can we disable moderation in the group?

2015-03-10 Thread Massimo Di Pierro
We only moderate the first post. We get lots of spam.

On Friday, 6 March 2015 20:12:30 UTC-6, Jack Kuan wrote:

 I don't see the need and think it can be off putting for new comers. 


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


[web2py] cannot perform INSERT RETURNING on VIEW

2015-03-10 Thread Val K
Hi! 
I am falling in love with  web2py!!! But I had got a little problem when 
migrated to 2.9.11-stable+timestamp.2014.09.15.23.35.11.
After submit  INSERT-form, I had got an error:   
class 'psycopg2.NotSupportedError' cannot perform INSERT RETURNING on 
relation table_view HINT: You need an unconditional ON INSERT DO INSTEAD 
rule with a RETURNING clause.
I use web2py+Postgresql. In summary of my little research I was surprised, 
that DAL construct  INSERT-query with RETURNING.
It's no problem while INSERT into TABLE, but not  for VIEW
If you want to support RETURNING queries on the view, you need to make the 
rules include RETURNING clauses that compute the view rows. This is usually 
pretty trivial for views on a single table, but it's a bit tedious for join 
views http://www.postgresql.org/docs/current/interactive/rules-update.html

RETURNING from join view looks like this:
...
RETURNINGins_table.id, 
   ins_table.f1,
   ins_table.f2,
  (SELECT table1.f1 FROM  table1 WHERE  table1.id= 
ins_table.id),
  (SELECT table1.f2 FROM  table1 WHERE  table1.id= 
ins_table.id);

Keep in mind,  that (SELECT table1.f1,  table1.f2 FROM  table1 WHERE  
table1.id= ins_table.id) - not works! i.e. оne field  - one SELECT.
RETURNING clause should include all fields from  VIEW, order is important.

I suggest following:
include this error in exceptions, if it happens  - use currval(id_sequence) 
to get ID of new record, i.e. something from earlier versions. 

With very best regards

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


[web2py] Invalid reset password (and another issue)

2015-03-10 Thread NeoToren
*Using the scaffolding app (2.9.12), here is the db.py of TEST app:*

# For the LOCAL / Development Site:
db = DAL('mysql://root:sqlpwd@localhost/TestDB', fake_migrate_all=True)

from gluon.tools import Auth
auth = Auth(db)
auth.define_tables(username=False,signature=False)
auth.settings.create_user_groups = None
auth.settings.remember_me_form = True
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.messages.verify_email = 'Click on the link http://' + 
request.env.http_host + 
URL(r=request,c='default',f='user',args=['verify_email']) + '/%(key)s 
to verify your email and complete the registration to TEST site'
auth.messages.reset_password = 'Click on the link http://' + 
request.env.http_host + 
URL(r=request,c='default',f='user',args=['reset_password']) + '/%(key)s 
to reset your password on TEST site'

# Configure MAIL registration with GMAIL 
from gluon.tools import Mail
mail=auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'gmaila...@gmail.com'
mail.settings.login = 'gmaila...@gmail.com:gmailpwd'

*ISSUES (?):*

*1. While the registration using gmail works fine, and the password reset 
sends an email as expected, when user clicks on the link in the email - W2P 
flashes Invalid reset password.*

*The only solution I found working / bypassing this bug (?) is to eliminate 
the line:*

auth.messages.reset_password = 'Click on the link http://' + 
request.env.http_host + 
URL(r=request,c='default',f='user',args=['reset_password']) + '/%(key)s 
to reset your password on TEST site'

*Then W2P still sends an email with a generic instruction to click ...to 
reset your password (without my words on TEST site) - and that one 
WORKS !*

*2. Playing with the various options in db.py trying to figue the first 
issue, I have noticed another strange behavior. **If I modify the line:*

auth.settings.reset_password_requires_verification = True

*to *

auth.settings.reset_password_requires_verification = False

*W2P still sends an email when a password reset is required, even though it 
was NOT supposed to (unless I have misunderstood this command...)*

*Is the above behavior a bug or I am doing something incorrectly ?*

*Thanks*
*NeoToren*


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


[web2py] Does not work registration and authorization. What to look for?

2015-03-10 Thread Сергей Петрови
Veb2po launched on the server does not work authorization and registration. 
More precisely gives this error, break the Internet, could not find an 
answer ... read the book, did not find an answer ...

Traceback (most recent call last):
  File C:\sites\tkp-dv.ru\tkts\web2py\gluon\main.py, line 475, in wsgibase
session._try_store_in_cookie_or_file(request, response)
  File C:\sites\tkp-dv.ru\tkts\web2py\gluon\globals.py, line 1126, in 
_try_store_in_cookie_or_file
return self._try_store_in_file(request, response)
  File C:\sites\tkp-dv.ru\tkts\web2py\gluon\globals.py, line 1133, in 
_try_store_in_file
or self._unchanged(response)):
  File C:\sites\tkp-dv.ru\tkts\web2py\gluon\globals.py, line 1078, in 
_unchanged
session_pickled = cPickle.dumps(self)
  File C:\Python27\Lib\copy_reg.py, line 84, in _reduce_ex
dict = getstate()
TypeError: 'NoneType' object is not callable


Of the authorization code only
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

auth.define_tables(username=False, signature=False)

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

What to look for? 

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


[web2py] Re: Query Production Oracle database using DAL

2015-03-10 Thread Michel Krav


Thanks paolo for the user permission idea.

And* cpdb.py* and also *oracle_extract_models.py* will be helpful.

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


[web2py] Re: SQLFORM.grid search with multiple terms

2015-03-10 Thread Massimo Di Pierro
please open a ticket. We need to check this. Can you also post your model?

On Monday, 9 March 2015 15:09:23 UTC-5, Ian Holser wrote:

 The search function on SQLFORM grid works fine for single terms, but when 
 typing multiple terms, it doesn't seem to work.

 For example:
 If I have a field value of 'example example1', it will find it with a 
 search for 'example' or 'example1'.  A search for 'example example1' comes 
 up with the whole list (no search performed)

 What is causing this behavior and can it be fixed?

 Thanks,
 Ian Holser


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


[web2py] Ajax User Registration

2015-03-10 Thread naveed
I have ajax login working using auth.login_bare, but I can't figure out how 
to do the same for register. I do see register_bare, but it's probably not 
what I need.

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


[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread Brian M
Actually just surround your big long multi line SQL statement with triple 
quotes and it will work fine. I do that all the time. No need for the \ at 
each line break then either. You can declare and set your @variables all 
within one executesql query too.

On Tuesday, March 10, 2015 at 2:36:28 PM UTC-5, naveed wrote:

 I need to execute multiple lines of SQL in web2py, something like this:

 db.executesql(set @num := 0, @type := '';)\
 rows = db.executesql(select type, variety, price\
 from (\
select type, variety, price,\
   @num := if(@type = type, @num + 1, 1) as row_number,\
   @type := type as dummy\
   from fruits\
   order by type, price\
 ) as x where x.row_number = 2;)

 But, when I run it I don't get expected results in web2py (the variables 
 don't get initialized), even though it works from the mysql console. What 
 am I doing wrong?

 They don't work, even if I put the variable initialization in the same 
 call. This piece of SQL is from here: 
 http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/


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


Re: [web2py] Re: Compute insert-only

2015-03-10 Thread Anthony
Got it. In that case, compute wouldn't have worked anyway.

On Tuesday, March 10, 2015 at 1:09:12 PM UTC-4, Louis Amon wrote:

 My url builder requires the « id » field so _before_insert wouldn’t work.

 That’s a good suggestion though!

 Thanks Anthony :)

 Le 10 mars 2015 à 18:00, Anthony abasta...@gmail.com a écrit :

 Might be easier with a _before_insert callback, so you can add the new 
 value along with the initial insert instead of after:

 db.mytable._before_insert.append(lambda fields: fields.update(url=make_url
 (fields)))

 Anthony

 On Tuesday, March 10, 2015 at 12:10:12 PM UTC-4, Niphlod wrote:

 code an _after_insert callback.

 On Tuesday, March 10, 2015 at 4:21:26 PM UTC+1, Louis Amon wrote:

 I'm trying to hard-code URLs for SEO purposes so I have a function 
 (make_url(row)) that builds the paths based on other fields.

 I was thinking of using compute=make_url, but it seems that update 
 operations also call the compute.


 Is there a way to use compute only on INSERT operations, and not on 
 UPDATE ?


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




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


Re: [web2py] SQLFORM Validation and Password Hashes

2015-03-10 Thread horridohobbyist
Nobody has any ideas?? Surely, this is a common use case...


On Tuesday, 10 March 2015 07:41:45 UTC-4, horridohobbyist wrote:

 The table definition is:

 db.define_table('teams',
 
 Field('team_email',requires=[IS_EMAIL(),IS_NOT_IN_DB(db,'teams.team_email')]),
 
 Field('password',requires=[IS_STRONG(upper=2),CRYPT(salt=False)]),
 
 Field('team_name',requires=[IS_TEAM_NAME(),IS_NOT_IN_DB(db,'teams.team_name')]),
 
 Field('reg_date','datetime',readable=False,writable=False,default=datetime.datetime.today()),
 Field('reg_key',readable=False,writable=False),
 Field('team_size',requires=IS_IN_SET([1,2,3,4])),
 Field('team_captain',requires=IS_NOT_EMPTY()),
 Field('second_member',requires=IS_CONDENSED()),
 Field('third_member',requires=IS_CONDENSED()),
 Field('fourth_member',requires=IS_CONDENSED()),
 Field('school',requires=IS_NOT_EMPTY()),
 Field('teachers_email',requires=IS_EMAIL()))

 The call to SQLFORM in the default controller is:

 record = db.teams(id)
 form = SQLFORM(db.teams, record)
 if form.process().accepted:
 response.flash = 'profile updated'

 What other code would be helpful??


 On Tuesday, 10 March 2015 02:13:26 UTC-4, Johann Spies wrote:

 On 10 March 2015 at 06:53, horridohobbyist horrido...@gmail.com wrote:

 I use SQLFORM to add records to a table. However, one of the fields is a 
 password which requires=[IS_STRONG(upper=2),CRYPT(salt=False)].

 I would like to use SQLFORM to update records in the table, but I run 
 into a problem:  the password field contains the hash of the password, 
 which will not pass validation. So even if I don't change the password 
 field, SQLFORM insists that I enter something that can be validated.

 If I can't use SQLFORM, then I will have to build my own form and do 
 everything from scratch, essentially mimicking SQLFORM. That seems to me to 
 be a lot of unnecessary work.

 Is there an easy workaround?

 (Yeah, I'm still a web2py newbie.)


 Showing your code will help people on this list to help you.

 Regards
 Johann 



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


[web2py] Re: Compute insert-only

2015-03-10 Thread Anthony
Might be easier with a _before_insert callback, so you can add the new 
value along with the initial insert instead of after:

db.mytable._before_insert.append(lambda fields: fields.update(url=make_url(
fields)))

Anthony

On Tuesday, March 10, 2015 at 12:10:12 PM UTC-4, Niphlod wrote:

 code an _after_insert callback.

 On Tuesday, March 10, 2015 at 4:21:26 PM UTC+1, Louis Amon wrote:

 I'm trying to hard-code URLs for SEO purposes so I have a function 
 (make_url(row)) that builds the paths based on other fields.

 I was thinking of using compute=make_url, but it seems that update 
 operations also call the compute.


 Is there a way to use compute only on INSERT operations, and not on 
 UPDATE ?



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


[web2py] Re: Can we disable moderation in the group?

2015-03-10 Thread Rufus
(Must be those Django fanboys trying to disrupt the site!)  

On Tuesday, March 10, 2015 at 10:39:46 AM UTC-4, Massimo Di Pierro wrote:

 We only moderate the first post. We get lots of spam.

 On Friday, 6 March 2015 20:12:30 UTC-6, Jack Kuan wrote:

 I don't see the need and think it can be off putting for new comers. 



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


Re: [web2py] Select categories that are in use

2015-03-10 Thread Gael Princivalle
Thank's again Niphlod for the explanation and the solution.

Il giorno martedì 10 marzo 2015 21:56:20 UTC+1, Niphlod ha scritto:

 I guess you're in a small typo hiccup

 recap without long table and field names:


 db(db.what_i_need.id.belongs(db(otherquery)._select(otherfield))).select(db.what_i_need.field)

 you can get it rewritten (more understandable)

 mysubquery = db(otherquery)._select(otherfield)
 myquerywithbelongs = db.what_i_need.id.belongs(mysubquery)
 thefinalquery = db(myquerywithbelongs).select(db.what_i_need.field)


 You can't order inside the subselect (the one starting with the 
 underscore, it's just a condition), as what you want returned isn't 
 there it's in the upper select (the one without the underscore, i.e. 
 the ACTUAL select)

 categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
 _select(db.news.category, distinct=True, orderby=db.news.category.name))).
 select()

 should be rewritten as

 categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
 _select(db.news.category, distinct=True))).select(orderby=db.news_
 categories.name)



 On Tuesday, March 10, 2015 at 9:42:31 PM UTC+1, Gael Princivalle wrote:

 Thanks all.
 Niphlod what a great query.
 I'm just disappointed about the orderby, it don't have any effect:
 categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
 _select(db.news.category, distinct=True, orderby=db.news.category.name
 ))).select()

 Do you know why?

 Il giorno martedì 10 marzo 2015 12:44:55 UTC+1, Niphlod ha scritto:

 2 queries ? no

 subselect - way, 1 query.

 db(db.news_categories.id.belongs(db(db.news.id0)._select(db.news.category, 
 distinct=True))).select()

 technically, there is also another one, more useful in case you'd like 
 to select, e.g., only categories with at least x news, but that's another 
 story.



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


[web2py] Compute insert-only

2015-03-10 Thread Louis Amon
I'm trying to hard-code URLs for SEO purposes so I have a function 
(make_url(row)) that builds the paths based on other fields.

I was thinking of using compute=make_url, but it seems that update 
operations also call the compute.


Is there a way to use compute only on INSERT operations, and not on UPDATE ?

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


Re: [web2py] Select categories that are in use

2015-03-10 Thread Gael Princivalle
Thanks all.
Niphlod what a great query.
I'm just disappointed about the orderby, it don't have any effect:
categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
_select(db.news.category, distinct=True, orderby=db.news.category.name))).
select()

Do you know why?

Il giorno martedì 10 marzo 2015 12:44:55 UTC+1, Niphlod ha scritto:

 2 queries ? no

 subselect - way, 1 query.

 db(db.news_categories.id.belongs(db(db.news.id0)._select(db.news.category, 
 distinct=True))).select()

 technically, there is also another one, more useful in case you'd like to 
 select, e.g., only categories with at least x news, but that's another 
 story.


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


Re: [web2py] Select categories that are in use

2015-03-10 Thread Niphlod
I guess you're in a small typo hiccup

recap without long table and field names:

db(db.what_i_need.id.belongs(db(otherquery)._select(otherfield))).select(db.what_i_need.field)

you can get it rewritten (more understandable)

mysubquery = db(otherquery)._select(otherfield)
myquerywithbelongs = db.what_i_need.id.belongs(mysubquery)
thefinalquery = db(myquerywithbelongs).select(db.what_i_need.field)


You can't order inside the subselect (the one starting with the underscore, 
it's just a condition), as what you want returned isn't there it's 
in the upper select (the one without the underscore, i.e. the ACTUAL 
select)

categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
_select(db.news.category, distinct=True, orderby=db.news.category.name))).
select()

should be rewritten as

categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
_select(db.news.category, distinct=True))).select(orderby=db.news_categories
.name)



On Tuesday, March 10, 2015 at 9:42:31 PM UTC+1, Gael Princivalle wrote:

 Thanks all.
 Niphlod what a great query.
 I'm just disappointed about the orderby, it don't have any effect:
 categories=db(db.news_categories.id.belongs(db(db.news.on_line==True).
 _select(db.news.category, distinct=True, orderby=db.news.category.name))).
 select()

 Do you know why?

 Il giorno martedì 10 marzo 2015 12:44:55 UTC+1, Niphlod ha scritto:

 2 queries ? no

 subselect - way, 1 query.

 db(db.news_categories.id.belongs(db(db.news.id0)._select(db.news.category, 
 distinct=True))).select()

 technically, there is also another one, more useful in case you'd like to 
 select, e.g., only categories with at least x news, but that's another 
 story.



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


[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread Niphlod
executesql doesn't allow more than one statement per invocation. 
You'll get the same issues running execute() with the underlying driver. 
What are you really trying to execute isn't a query: it's more of a stored 
procedure that returns a set of results.

On Tuesday, March 10, 2015 at 8:36:28 PM UTC+1, naveed wrote:

 I need to execute multiple lines of SQL in web2py, something like this:

 db.executesql(set @num := 0, @type := '';)\
 rows = db.executesql(select type, variety, price\
 from (\
select type, variety, price,\
   @num := if(@type = type, @num + 1, 1) as row_number,\
   @type := type as dummy\
   from fruits\
   order by type, price\
 ) as x where x.row_number = 2;)

 But, when I run it I don't get expected results in web2py (the variables 
 don't get initialized), even though it works from the mysql console. What 
 am I doing wrong?

 They don't work, even if I put the variable initialization in the same 
 call. This piece of SQL is from here: 
 http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/


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


[web2py] Re: how to insert dynamic record id into field in form

2015-03-10 Thread Niphlod
there's something wrong with the code

something = db.table.insert(**mapping)

returns the db.table.id that has been inserted. in this piece of code, 
using messageID.id doesn't really make much sense...

On Tuesday, March 10, 2015 at 8:49:05 PM UTC+1, Alex Glaros wrote:

 I want to insert the record id into one of its fields during record 
 creation in form

 right now, using work-around right after the record is created.

 here is the record being created

 messageID = db.InternalMessage.insert(**db.InternalMessage._filter_fields(
 form.vars))

 right afterwards, this is executed

 db(db.InternalMessage.id == messageID.id).update(messageThreadID = 
 messageID.id) 

 it finds the record just created and updates it.

 so I want field messageThreadID field to be populated with the record id 
 field. Can it be done using less resources?  Is there a way to put the id 
 in form.vars so that the top line above is all that's needed?

 thanks

 Alex Glaros



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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
The main problem is that when I set auth.settings.login_form = X509Auth()  
as specified in the book I get the error: Login not allowed. No valid x509 
credentials. 

My httpd.conf is exactly out of the book as specified for mod_wsgi

http://web2py.com/books/default/chapter/29/13/deployment-recipes#mod_wsgi

I want to pass the certificate credentials to the x509_auth class that 
web2py has, but its raising an exception because its not finding any 
certificate present. My browser has certificates in them as I checked them 
on other sites and they work fine. So its something between the browser, 
mod_wsgi, wsgi_handler.py or my httpd.conf


On Tuesday, March 10, 2015 at 3:57:12 PM UTC-4, LoveWeb2py wrote:

 *httpd* - Apache Hypertext Transfer Protocol Server 

 my httpd.conf has the certificates and is serving https out properly, I 
 just can't seem to read the user certificates when they visit the site.

 On Tuesday, March 10, 2015 at 3:36:53 PM UTC-4, Richard wrote:

 This works out of the box with Rocket (the web2py built-in web server) 
 but you may need some extra configuration work on the web server side if 
 you are using a different web server. In particular you need to tell your 
 web server where the certificates are located on local host and that it 
 needs to verify certificates coming from the clients. How to do it is web 
 server dependent and therefore omitted here.

 Which server do you use?

 Richard



 On Tue, Mar 10, 2015 at 3:35 PM, Richard Vézina ml.richa...@gmail.com 
 wrote:

 Is M2Crypto there??

 Basic, but you know...

 On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayl...@gmail.com wrote:

 Just the basic stuff like first name and last name. But when I try to 
 login using the x509 tutorial in the book I am getting Login not allowed. 
 No valid x509 credentials. This tells me that my certificate isn't being 
 read properly by web2py or I'm not passing the variables through uwsgi 
 properly? Do I need to put something in the wsgi-handler, change my 
 httpd.conf, or something else? 

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site 
 over SSL. I'm guessing I'll have to parse out the information through the 
 WSGI handler? If anyone has insight or could provide direction I'd really 
 appreciate it.

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





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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
*httpd* - Apache Hypertext Transfer Protocol Server 

my httpd.conf has the certificates and is serving https out properly, I 
just can't seem to read the user certificates when they visit the site.

On Tuesday, March 10, 2015 at 3:36:53 PM UTC-4, Richard wrote:

 This works out of the box with Rocket (the web2py built-in web server) 
 but you may need some extra configuration work on the web server side if 
 you are using a different web server. In particular you need to tell your 
 web server where the certificates are located on local host and that it 
 needs to verify certificates coming from the clients. How to do it is web 
 server dependent and therefore omitted here.

 Which server do you use?

 Richard



 On Tue, Mar 10, 2015 at 3:35 PM, Richard Vézina ml.richa...@gmail.com 
 javascript: wrote:

 Is M2Crypto there??

 Basic, but you know...

 On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayl...@gmail.com 
 javascript: wrote:

 Just the basic stuff like first name and last name. But when I try to 
 login using the x509 tutorial in the book I am getting Login not allowed. 
 No valid x509 credentials. This tells me that my certificate isn't being 
 read properly by web2py or I'm not passing the variables through uwsgi 
 properly? Do I need to put something in the wsgi-handler, change my 
 httpd.conf, or something else? 

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site over 
 SSL. I'm guessing I'll have to parse out the information through the WSGI 
 handler? If anyone has insight or could provide direction I'd really 
 appreciate it.

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





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


[web2py] Re: how do I add form attributes to SQLFORM.factory?

2015-03-10 Thread Oliver Holloway
Read part of the book, tried with just FORM. The following worked.

  score_box = FORM(INPUT(_name='score',requires=IS_NOT_EMPTY(),
 _style='height:80px; width:80px; font-size:50px;',
 _autofocus='autofocus', _type='tel', 
_autocomplete='off'
 )
   )



On Monday, March 9, 2015 at 5:53:24 PM UTC-4, Oliver Holloway wrote:


 How do I get the form to autofocus the cursor into the text box? Here's 
 one of the approaches I've tried. 

   attributes = {'_autofocus':'autofocus', '_type':'tel', 
 '_autocomplete':'off', '_style':'height:80px; width:80px'}
   score_box = SQLFORM.factory(Field('score', 'integer'), **attributes)

 Interestingly, the autocomplete attribute is definitely getting through, 
 I've tested that repeatedly. None of the other ones are. 

 I did see the post about doing this with a form.custom.widget 
 https://groups.google.com/forum/#!searchin/web2py/autofocus/web2py/PC2nDnltGic/OiYEpQEORnkJ
  
 setting, but couldn't figure out how to make that work in my case. I've 
 also experimented with using keepvalues=True, from looking through the 
 book.

 Any help is much appreciated. This is the last thing on my list to have 
 this demo ready. 


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


[web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
Just the basic stuff like first name and last name. But when I try to login 
using the x509 tutorial in the book I am getting Login not allowed. No 
valid x509 credentials. This tells me that my certificate isn't being read 
properly by web2py or I'm not passing the variables through uwsgi properly? 
Do I need to put something in the wsgi-handler, change my httpd.conf, or 
something else? 

On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site over 
 SSL. I'm guessing I'll have to parse out the information through the WSGI 
 handler? If anyone has insight or could provide direction I'd really 
 appreciate it.


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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
Is M2Crypto in my wsgi handler? I have the module installed if that's what 
you mean.

On Tuesday, March 10, 2015 at 3:35:17 PM UTC-4, Richard wrote:

 Is M2Crypto there??

 Basic, but you know...

 On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayl...@gmail.com 
 javascript: wrote:

 Just the basic stuff like first name and last name. But when I try to 
 login using the x509 tutorial in the book I am getting Login not allowed. 
 No valid x509 credentials. This tells me that my certificate isn't being 
 read properly by web2py or I'm not passing the variables through uwsgi 
 properly? Do I need to put something in the wsgi-handler, change my 
 httpd.conf, or something else? 

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site over 
 SSL. I'm guessing I'll have to parse out the information through the WSGI 
 handler? If anyone has insight or could provide direction I'd really 
 appreciate it.

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




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


[web2py] how to insert dynamic record id into field in form

2015-03-10 Thread Alex Glaros
I want to insert the record id into one of its fields during record 
creation in form

right now, using work-around right after the record is created.

here is the record being created

messageID = db.InternalMessage.insert(**db.InternalMessage._filter_fields(
form.vars))

right afterwards, this is executed

db(db.InternalMessage.id == messageID.id).update(messageThreadID = messageID
.id) 

it finds the record just created and updates it.

so I want field messageThreadID field to be populated with the record id 
field. Can it be done using less resources?  Is there a way to put the id 
in form.vars so that the top line above is all that's needed?

thanks

Alex Glaros

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


[web2py] PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
Hello,

I'm wondering how to get the users details when they visit my site over 
SSL. I'm guessing I'll have to parse out the information through the WSGI 
handler? If anyone has insight or could provide direction I'd really 
appreciate it.

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


Re: [web2py] SQLFORM Validation and Password Hashes

2015-03-10 Thread Dave S


On Tuesday, March 10, 2015 at 10:44:36 AM UTC-7, horridohobbyist wrote:

 Nobody has any ideas?? Surely, this is a common use case...


Does it work to make the password field readable=writable=False in the 
form?  If it does, you can probably add a button for change password to 
toggle those on.

/dps


 On Tuesday, 10 March 2015 07:41:45 UTC-4, horridohobbyist wrote:

 The table definition is:

 db.define_table('teams',
 
 Field('team_email',requires=[IS_EMAIL(),IS_NOT_IN_DB(db,'teams.team_email')]),
 
 Field('password',requires=[IS_STRONG(upper=2),CRYPT(salt=False)]),
 
 Field('team_name',requires=[IS_TEAM_NAME(),IS_NOT_IN_DB(db,'teams.team_name')]),
 
 Field('reg_date','datetime',readable=False,writable=False,default=datetime.datetime.today()),
 Field('reg_key',readable=False,writable=False),
 Field('team_size',requires=IS_IN_SET([1,2,3,4])),
 Field('team_captain',requires=IS_NOT_EMPTY()),
 Field('second_member',requires=IS_CONDENSED()),
 Field('third_member',requires=IS_CONDENSED()),
 Field('fourth_member',requires=IS_CONDENSED()),
 Field('school',requires=IS_NOT_EMPTY()),
 Field('teachers_email',requires=IS_EMAIL()))

 The call to SQLFORM in the default controller is:

 record = db.teams(id)
 form = SQLFORM(db.teams, record)
 if form.process().accepted:
 response.flash = 'profile updated'

 What other code would be helpful??


 On Tuesday, 10 March 2015 02:13:26 UTC-4, Johann Spies wrote:

 On 10 March 2015 at 06:53, horridohobbyist horrido...@gmail.com wrote:

 I use SQLFORM to add records to a table. However, one of the fields is a 
 password which requires=[IS_STRONG(upper=2),CRYPT(salt=False)].

 I would like to use SQLFORM to update records in the table, but I run 
 into a problem:  the password field contains the hash of the password, 
 which will not pass validation. So even if I don't change the password 
 field, SQLFORM insists that I enter something that can be validated.

 If I can't use SQLFORM, then I will have to build my own form and do 
 everything from scratch, essentially mimicking SQLFORM. That seems to me 
 to 
 be a lot of unnecessary work.

 Is there an easy workaround?

 (Yeah, I'm still a web2py newbie.)


 Showing your code will help people on this list to help you.

 Regards
 Johann 



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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread Richard Vézina
Is M2Crypto there??

Basic, but you know...

On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayloru...@gmail.com wrote:

 Just the basic stuff like first name and last name. But when I try to
 login using the x509 tutorial in the book I am getting Login not allowed.
 No valid x509 credentials. This tells me that my certificate isn't being
 read properly by web2py or I'm not passing the variables through uwsgi
 properly? Do I need to put something in the wsgi-handler, change my
 httpd.conf, or something else?

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site over
 SSL. I'm guessing I'll have to parse out the information through the WSGI
 handler? If anyone has insight or could provide direction I'd really
 appreciate it.

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


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


[web2py] Running multiple lines of SQL in executesql

2015-03-10 Thread naveed


I need to execute multiple lines of SQL in web2py, something like this:

db.executesql(set @num := 0, @type := '';)\
rows = db.executesql(select type, variety, price\
from (\
   select type, variety, price,\
  @num := if(@type = type, @num + 1, 1) as row_number,\
  @type := type as dummy\
  from fruits\
  order by type, price\
) as x where x.row_number = 2;)

But, when I run it I don't get expected results in web2py (the variables 
don't get initialized), even though it works from the mysql console. What 
am I doing wrong?

They don't work, even if I put the variable initialization in the same 
call. This piece of SQL is from here: 
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread Richard Vézina
This works out of the box with Rocket (the web2py built-in web server) but
you may need some extra configuration work on the web server side if you
are using a different web server. In particular you need to tell your web
server where the certificates are located on local host and that it needs
to verify certificates coming from the clients. How to do it is web server
dependent and therefore omitted here.

Which server do you use?

Richard



On Tue, Mar 10, 2015 at 3:35 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Is M2Crypto there??

 Basic, but you know...

 On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayloru...@gmail.com wrote:

 Just the basic stuff like first name and last name. But when I try to
 login using the x509 tutorial in the book I am getting Login not allowed.
 No valid x509 credentials. This tells me that my certificate isn't being
 read properly by web2py or I'm not passing the variables through uwsgi
 properly? Do I need to put something in the wsgi-handler, change my
 httpd.conf, or something else?

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site over
 SSL. I'm guessing I'll have to parse out the information through the WSGI
 handler? If anyone has insight or could provide direction I'd really
 appreciate it.

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




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


[web2py] Re: list reference with ondelete=set null breaking when delete parent

2015-03-10 Thread Paolo Valleri
ondelete is for reference field.
At a first sight, a possible workaround would be to write your own 
'ondelete' by using the _before_delete and _after_delete callbacks

Paolo

On Monday, March 9, 2015 at 7:09:54 PM UTC+1, Ron Chatterjee wrote:

 Wonder if he can try to make it a list and do list.remove?

 Have you tried that?

 On Thursday, March 20, 2014 at 3:07:47 PM UTC-4, Leonel Câmara wrote:

 I think you should have a third table anyway or searches for T-shirts of 
 a given colour will be quite slow.



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


Re: [web2py] Re: Global search form example

2015-03-10 Thread Johann Spies
On 9 March 2015 at 20:08, Ron Chatterjee achatterjee...@gmail.com wrote:

 SQLFORM.build_query[(db.table.field)]

 Passing a list ([]) into that will give you a text in that field. and then
 you can use a form input to do the display like the book on page 84 on the
 book. Damn I am getting good at this!


Which book are you talking about.  Although I can see SQLFORM.build_query
in the code (sqlhtml.py), I could find no reference to it in the online
book.

Also finding page 84 on the online book is a bit difficult ... :)

Regards
Johann

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


[web2py] Re: how to insert dynamic record id into field in form

2015-03-10 Thread Niphlod
uhm. there's a hiccup in the process (or at least in what you think should 
be the process).
You're using factory(), so you need to handle your own db i/o.
If you want to insert a new record, how can you know in advance its id if 
you didn't actually insert it into the table ? There is no way around it.

On Tuesday, March 10, 2015 at 10:05:15 PM UTC+1, Alex Glaros wrote:

 I don't know enough to be able to reply.  Here is code that works.   
 Please let me know if there's better way.   messageID captures the record 
 ID so it can populate children further down the process


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


Re: [web2py] Re: how to insert dynamic record id into field in form

2015-03-10 Thread Alex Glaros
that's what I needed to know

thanks Niphlod

On Tue, Mar 10, 2015 at 2:20 PM, Niphlod niph...@gmail.com wrote:

 uhm. there's a hiccup in the process (or at least in what you think should
 be the process).
 You're using factory(), so you need to handle your own db i/o.
 If you want to insert a new record, how can you know in advance its id if
 you didn't actually insert it into the table ? There is no way around it.

 On Tuesday, March 10, 2015 at 10:05:15 PM UTC+1, Alex Glaros wrote:

 I don't know enough to be able to reply.  Here is code that works.
 Please let me know if there's better way.   messageID captures the record
 ID so it can populate children further down the process

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


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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
Thanks Niphlod,

I had SSLOptions +stdEnvVars setup, but still no luck. I think that's 
definitely the problem though (Maybe I'm misplacing them) Hopefully Michele 
can chyme in.


On Tuesday, March 10, 2015 at 5:12:44 PM UTC-4, Niphlod wrote:

 not everyone needs client certificates, so of course the default config 
 needs tuning.
 AFAIK (@michele can chime in any time, he's the original author) what is 
 needed are a few environmental variables passed along, such as 

 SSL_CLIENT_CERT
 SSL_CLIENT_RAW_CERT
 SSL_CLIENT_VERIFY
 SSL_CLIENT_SERIAL
 etc etc etc

 Apache docs mention that those should be enabled setting the directive 

 SSLOptions +stdEnvVars




 On Tuesday, March 10, 2015 at 9:57:01 PM UTC+1, LoveWeb2py wrote:

 The main problem is that when I set auth.settings.login_form = 
 X509Auth()  as specified in the book I get the error: Login not allowed. No 
 valid x509 credentials. 

 My httpd.conf is exactly out of the book as specified for mod_wsgi

 http://web2py.com/books/default/chapter/29/13/deployment-recipes#mod_wsgi

 I want to pass the certificate credentials to the x509_auth class that 
 web2py has, but its raising an exception because its not finding any 
 certificate present. My browser has certificates in them as I checked them 
 on other sites and they work fine. So its something between the browser, 
 mod_wsgi, wsgi_handler.py or my httpd.conf


 On Tuesday, March 10, 2015 at 3:57:12 PM UTC-4, LoveWeb2py wrote:

 *httpd* - Apache Hypertext Transfer Protocol Server 

 my httpd.conf has the certificates and is serving https out properly, I 
 just can't seem to read the user certificates when they visit the site.

 On Tuesday, March 10, 2015 at 3:36:53 PM UTC-4, Richard wrote:

 This works out of the box with Rocket (the web2py built-in web server) 
 but you may need some extra configuration work on the web server side if 
 you are using a different web server. In particular you need to tell your 
 web server where the certificates are located on local host and that it 
 needs to verify certificates coming from the clients. How to do it is web 
 server dependent and therefore omitted here.

 Which server do you use?

 Richard



 On Tue, Mar 10, 2015 at 3:35 PM, Richard Vézina ml.richa...@gmail.com 
 wrote:

 Is M2Crypto there??

 Basic, but you know...

 On Tue, Mar 10, 2015 at 3:18 PM, LoveWeb2py atayl...@gmail.com 
 wrote:

 Just the basic stuff like first name and last name. But when I try to 
 login using the x509 tutorial in the book I am getting Login not 
 allowed. 
 No valid x509 credentials. This tells me that my certificate isn't being 
 read properly by web2py or I'm not passing the variables through uwsgi 
 properly? Do I need to put something in the wsgi-handler, change my 
 httpd.conf, or something else? 

 On Tuesday, March 10, 2015 at 2:53:58 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm wondering how to get the users details when they visit my site 
 over SSL. I'm guessing I'll have to parse out the information through 
 the 
 WSGI handler? If anyone has insight or could provide direction I'd 
 really 
 appreciate it.

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





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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread LoveWeb2py
so I did {{=request.env}} and I can see the SSL DATA certificate in another 
app, but for some reason the app that requires the data isn't being passed. 
Going to keep troubleshooting that app because I really want to use the 
x509 authentication with web2py!!

for some reason the x509 auth isn't working still. Going to keep pressing 
and will post a fix when I find it. Thank you so much for your help 
Niphlod. I hope this helps others in the future!



On Tuesday, March 10, 2015 at 6:40:29 PM UTC-4, Niphlod wrote:

 what if you return somewhere this dict (takes the SSL* env variables and 
 prints it) 

 def yourcode():
 .
 debug_values = {}
 for k, v in request.env.iteritems():
 if k.lower().startswith('ssl'):
 debug_values[k] = v
 .
 return dict(., debug_values=debug_values)

 just to see if those gets indeed passed along.



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


[web2py] Re: SQLFORM.grid search with multiple terms

2015-03-10 Thread Ian Holser
I found a previous thread that solved my issue. 
 https://groups.google.com/forum/#!msg/web2py/9_1ECdKHKUo/8OISg7o8OVIJ
The search bar does not behave as most users would expect.  The ability to 
type multiple words into the search, but not be considered a valid query is 
problematic.  My changes to css had obscured the 'invalid query' text.
I do like the query builder search functionality, but the search bar really 
should behave in a way that normal users would expect.

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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread Niphlod
what if you return somewhere this dict (takes the SSL* env variables and 
prints it) 

def yourcode():
.
debug_values = {}
for k, v in request.env.iteritems():
if k.lower().startswith('ssl'):
debug_values[k] = v
.
return dict(., debug_values=debug_values)

just to see if those gets indeed passed along.

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


[web2py] Re: IMPORTANT - DROPPING SUPPORT FOR PYTHON 2.5?

2015-03-10 Thread weheh
I should be OK. Got my fingers crossed.

On Saturday, March 7, 2015 at 11:18:17 AM UTC-8, Massimo Di Pierro wrote:

 Who is opposed? Why?


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


Re: [web2py] Re: PKI Authentication? How to grab users certificates httpd wsgi

2015-03-10 Thread Niphlod
debug it, debug it, debug it.

AFAICS, x509_auth.py requires:

ssl_client_raw_cert
optional ssl_client_serial

On Wednesday, March 11, 2015 at 12:04:51 AM UTC+1, LoveWeb2py wrote:

 so I did {{=request.env}} and I can see the SSL DATA certificate in 
 another app, but for some reason the app that requires the data isn't being 
 passed. Going to keep troubleshooting that app because I really want to use 
 the x509 authentication with web2py!!

 for some reason the x509 auth isn't working still. Going to keep pressing 
 and will post a fix when I find it. Thank you so much for your help 
 Niphlod. I hope this helps others in the future!



 On Tuesday, March 10, 2015 at 6:40:29 PM UTC-4, Niphlod wrote:

 what if you return somewhere this dict (takes the SSL* env variables 
 and prints it) 

 def yourcode():
 .
 debug_values = {}
 for k, v in request.env.iteritems():
 if k.lower().startswith('ssl'):
 debug_values[k] = v
 .
 return dict(., debug_values=debug_values)

 just to see if those gets indeed passed along.



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


[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread naveed


 Ok, I moved it to a stored procedure and it works. Thanks for your help.


It would be nice to be able to run multiple queries in one call - I prefer 
to keep my code in code, not in the database, but I'm probably asking for 
too much. 

 

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