[web2py] register and login - extra fields

2015-05-29 Thread Martin Weissenboeck
​

A proposal to extend the register form and the login form

The issue:

I want to have a register form with an extra field,* which should not be
part of auth_user*. The purpose: a new user can only register if this field
contrains (e.g.) some special code. This code can be checked by a
validation function, set by auth.settings.register_onvalidation

I have tried to change the form which is created by def user in default.py.
The result was a very long code which is hard to read and which needs some
additional statements for the error message. A better way would be a small
modification of gluon/tools.py. And the same could be done with the
login-form.

We need only 6 additional lines in gluon/tools.py

At the end of default_settings (line 1206) add:

​​
register_extra_fields=[],

​  ​
​  ​
login_extra_fields=[]


At the end of settings.update (line 1506) add:

​​
register_extra_fields = [],

​lo​
gin_extra_fields = []


​I​
n def login() add after line 2561ff:


   if settings.remember_me_form:

   extra_fields = [

   Field('remember_me', 'boolean', default=False,

 label = self.messages.label_remember_me)]

   else:

   extra_fields = []

   extra_fields += self.settings.login_extra_fields


In def register() add after line 2862 ff:

  if self.settings.register_verify_password:

   extra_fields = [

   Field("password_two", "password", requires=IS_EQUAL_TO(

   request.post_vars.get(passfield, None),

   error_message=self.messages.mismatched_password),

   label=current.T("Confirm Password"))]

   else:

  extra_fields = []

   extra_fields += self.settings.register_extra_fields

​How to use:​

Yes, it’s only a very simple check: the user has to write “VALID” into the
field “extracode”.

In db.py, before auth.define_tables:

def validate_registercode(form):

if form.vars.extracode != "VALID":

  form.errors.extracode=T("Invalid extra code")

auth.settings.register_extra_fields=

   [Field('extracode',

   label='My extracode',

   comment='This is the extracode')

   ]

auth.settings.register_onvalidation=[validate_registercode]

That’s all. Now we have a nice register form with an extra field labeled “My
extracode”. If the use
​r
 does not know the right answer “VALID” he could not register. All css
attributes are the same as in the remaining register form.


​
​Regards, Martin​

-- 
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: _before_insert / update question

2015-05-29 Thread Anthony
Possible bug. What does your bulk_insert code look like?

On Friday, May 29, 2015 at 1:32:35 AM UTC-4, Ian Ryder wrote:
>
> OK - I think I have the answer.
>
> I discovered it wasn't table-specific, it worked with this same method / 
> table elsewhere in the app. The place it was failing was using bulk_insert. 
> I changed to insert individually and all works fine.
>
> Bug?
>
> On Friday, May 29, 2015 at 6:39:56 AM UTC+2, Ian Ryder wrote:
>>
>> Hi, the key point is I'm not getting passed a dict, I'm getting passed a 
>> list. Here's a dump of what the _is_before handler gets passed:
>>
>>  [(, datetime.datetime(2015, 5
>> , 29, 6, 32, 27, 732420)), (, 
>> 1L), (, 8L), (> Field object at 0x1334a5390>, 2L), (> 0x11c2dfcd0>, 5.0), (, 14093L
>> ), (, 'APPEAL'), (> objects.Field object at 0x1334a5050>, 1L), (> at 0x1334a5410>, 358001L), (, 
>> datetime.datetime(2015, 5, 29, 6, 32, 27, 732420)), (> object at 0x1334a53d0>, 5.0), (> >, True), (, 1L)]
>>
>> I test it on a different table and it gets a dict as expected:
>> {'query_group': 1, 'name': 'asddasdasdasdsada', 'created_date': datetime.
>> datetime(2015, 5, 29, 6, 27, 37, 2291), 'run_order': 0, 'type': '', 
>> 'sum_description': '', 'created_by': 1L}
>>
>> I'll post again the definition for the one that isn't working:
>> db.income_line_item._before_insert.append(lambda f: 
>> trigger_ili_before_insert(f))
>>
>> Which is essentially the same for the one that is working:
>> db.query._before_insert.append(lambda f: query_before_test(f))
>>
>>
>>
>>
>> On Thursday, May 28, 2015 at 11:10:21 PM UTC+2, Niphlod wrote:
>>>
>>> the book shows how to print every argument passed to those functions 
>>> I dunno how to make the book clearer :°°°D
>>>
>>>
>>> before_insert 
>>>
>>>
>>> def this_is_before_insert(some_dict):
>>> if 'last_name' in some_dict:
>>>  some_dict['last_name'] = 'altering' + some_dict['last_name']
>>>
>>> db.auth_user._before_insert.append(lambda f: this_is_before_insert(f))
>>>
>>> >>>db.auth_user.insert(first_name='john')
>>> 1L
>>> >>> db.auth_user.insert(last_name='doe')
>>> 2L
>>> >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
>>> auth_user.last_name)
>>> >>> print str(rtn)
>>> auth_user.first_name,auth_user.last_name
>>> john,
>>> ,alteringdoe
>>>
>>> before_update ...
>>>
>>> def this_is_before_update(a_set, some_dict):
>>>   if 'last_name' in some_dict:
>>>   some_dict['last_name'] += 'was_updated'
>>>
>>> db.auth_user._before_update.append(lambda s,f: this_is_before_update(s,f
>>> ))
>>>
>>> >>> db.auth_user.insert(first_name='john', last_name='doe')
>>> 1L
>>> >>> db(db.auth_user.first_name=='john').update(last_name='white')
>>> 1
>>> >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
>>> auth_user.last_name)
>>> >>> print str(rtn)
>>> auth_user.first_name,auth_user.last_name
>>> john,whitewas_updated
>>>
>>>
>>>
>>>
>>>
>>>

-- 
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] web2py 2.11.1 is OUT

2015-05-29 Thread Massimo Di Pierro
This is strange. ANYWAY, a bug crept in so I reverted the posted "stable" 
version to 2.10.4 until the bug is fixed.

Massimo

On Friday, 29 May 2015 00:46:16 UTC-5, Gour wrote:
>
> Massimo Di Pierro writes: 
>
> > web2py 2.11.1 is OUT. 
>
> Heh, I pulled from the master yesterday and it was still alpha. :-) 
>
> > Just in time for the DePy conference tomorrow. 
>
> All the best promoting web2py!! 
>
>
> Sincerely, 
> Gour 
>
> p.s. I notice that your signature contains: 
>
> - https://code.google.com/p/web2py/issues/list (Report Issues) 
>
> which is linking to https://github.com/web2py/web2py/issues. Time to 
> update 
> your sig or it's by intention? 
>
> -- 
> As the embodied soul continuously passes, in this body, 
> from boyhood to youth to old age, the soul similarly passes 
> into another body at death. A sober person is not bewildered 
> by such a change. 
>
>

-- 
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: Strip Spaces

2015-05-29 Thread Niphlod
there are no functions in T-SQL accross backends that do what you ask, so 
you'll need to do it in python

for rec in db(db.table.id >0).select():
rec.update_record(field=rec.field.strip())

On Friday, May 29, 2015 at 6:33:28 AM UTC+2, Jerry Liu wrote:
>
> Hello, all
>
> I want to update all of records of a table. Basically, what I want to 
> update is just a string Field. I want to strip all spaces out of that Field.
>
> I have tried:
>
> db(db.table.id > 0).update(field = db.table.field.strip())
>
> But looks like Field object doesn't have a strip method.
>
> Any ideas?
>
>
>

-- 
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: Customizing registration fields for linkedin login

2015-05-29 Thread John Costantino
Just giving this a Bump. Would really love a resolution to this one. Thanks 
guys.

On Wednesday, May 13, 2015 at 10:28:43 AM UTC-4, John Costantino wrote:
>
> Yes, that is correct. I added extra fields using the 
> auth.settings.extra_fields['']. 
> So the table is able to support the extra ones I need. My issue is more so 
> with making sure that when logging with the linkedin API. I need to be sure 
> to get the rest of the information from the API, such as the public-url, 
> and then map those to the correct extra fields which where set by myself in 
> the auth.users table. 
>
> On Tuesday, May 12, 2015 at 5:56:58 PM UTC-4, 黄祥 wrote:
>>
>> had you modified the auth_users table?
>>
>> ref:
>>
>> http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth
>>
>> best regards,
>> stifan
>>
>

-- 
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: Strip Spaces

2015-05-29 Thread Derek
Yes there are, it's called the 'trim' function. It's part of SQL-92. 

http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt

Postgres, MSSQL, MySQL, SQLite, and Oracle all have rtrim, and ltrim.

I think it's widely supported and thus we should support it in DAL. It's 
easy enough to write a function that handles it if the database driver 
doesn't support it.



On Friday, May 29, 2015 at 5:54:46 AM UTC-7, Niphlod wrote:
>
> there are no functions in T-SQL accross backends that do what you ask, so 
> you'll need to do it in python
>
> for rec in db(db.table.id >0).select():
> rec.update_record(field=rec.field.strip())
>
> On Friday, May 29, 2015 at 6:33:28 AM UTC+2, Jerry Liu wrote:
>>
>> Hello, all
>>
>> I want to update all of records of a table. Basically, what I want to 
>> update is just a string Field. I want to strip all spaces out of that Field.
>>
>> I have tried:
>>
>> db(db.table.id > 0).update(field = db.table.field.strip())
>>
>> But looks like Field object doesn't have a strip method.
>>
>> Any ideas?
>>
>>
>>

-- 
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: Customizing registration fields for linkedin login

2015-05-29 Thread Derek
What don't you understand?

Step 2 - Retrieve basic profile data

Once you have obtained a valid access token for the user, you can use the 
following REST API call to retrieve basic profile data for the user:
GET

https://api.linkedin.com/v1/people/~?format=json

sample api response

{
  "firstName": "Frodo",
  "headline": "2nd Generation Adventurer",
  "id": "1R2RtA",
  "lastName": "Baggins",
  "siteStandardProfileRequest": {
"url": "https://www.linkedin.com/profile/view?id=…";
  }}



On Friday, May 29, 2015 at 7:56:35 AM UTC-7, John Costantino wrote:
>
> Just giving this a Bump. Would really love a resolution to this one. 
> Thanks guys.
>
> On Wednesday, May 13, 2015 at 10:28:43 AM UTC-4, John Costantino wrote:
>>
>> Yes, that is correct. I added extra fields using the 
>> auth.settings.extra_fields['']. 
>> So the table is able to support the extra ones I need. My issue is more so 
>> with making sure that when logging with the linkedin API. I need to be sure 
>> to get the rest of the information from the API, such as the public-url, 
>> and then map those to the correct extra fields which where set by myself in 
>> the auth.users table. 
>>
>> On Tuesday, May 12, 2015 at 5:56:58 PM UTC-4, 黄祥 wrote:
>>>
>>> had you modified the auth_users table?
>>>
>>> ref:
>>>
>>> http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth
>>>
>>> best regards,
>>> stifan
>>>
>>

-- 
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 field with function NOT lambda

2015-05-29 Thread goome
Hello
i need ta compute field, quite similar to that expesed in the book, but 
with a bit pre-verification before. So i need a function, not a lambda.
But what is the syntax in this case? Does the function need a row as input?
a need something like
Field('total', *compute*=lambda r: (float(r['preco'] * r['quantidade'])
But i need more process before
So ewhat should be the syntax?
def fun(r):
  process()
 r['preco'] * r['quantidade'])

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.


[web2py] Re: compute field with function NOT lambda

2015-05-29 Thread goome
i've done with
def func(row):
and calling row['preco'] etc in it.
Now the problem is that the filed is not shown in form, even if i put 
db.table.total.readable=True
I read there there was an issue about this in the past, but how is now the 
situation about this?
Thanks


Il giorno venerdì 29 maggio 2015 18:33:10 UTC+2, goome ha scritto:
>
> Hello
> i need ta compute field, quite similar to that expesed in the book, but 
> with a bit pre-verification before. So i need a function, not a lambda.
> But what is the syntax in this case? Does the function need a row as input?
> a need something like
> Field('total', *compute*=lambda r: (float(r['preco'] * r['quantidade'])
> But i need more process before
> So ewhat should be the syntax?
> def fun(r):
>   process()
>  r['preco'] * r['quantidade'])
>
> 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.


Re: [web2py] web2py 2.11.1 is OUT

2015-05-29 Thread José Ricardo Borba
@Massimo,

The web2py 2.11.1 still in the box or was released?

I need to test it out with my app, that use mongodb too. I'm experiencing
_id troubles, and wish that was only a minor problem with mongodb adapter
in the 2.10.4 release that I was updated from the pydal issue #170.

Best regards.
And congratulations for the very good work in w2p and pydal.


2015-05-29 9:12 GMT-03:00 Massimo Di Pierro :

> This is strange. ANYWAY, a bug crept in so I reverted the posted "stable"
> version to 2.10.4 until the bug is fixed.
>
> Massimo
>
> On Friday, 29 May 2015 00:46:16 UTC-5, Gour wrote:
>>
>> Massimo Di Pierro writes:
>>
>> > web2py 2.11.1 is OUT.
>>
>> Heh, I pulled from the master yesterday and it was still alpha. :-)
>>
>> > Just in time for the DePy conference tomorrow.
>>
>> All the best promoting web2py!!
>>
>>
>> Sincerely,
>> Gour
>>
>> p.s. I notice that your signature contains:
>>
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>
>> which is linking to https://github.com/web2py/web2py/issues. Time to
>> update
>> your sig or it's by intention?
>>
>> --
>> As the embodied soul continuously passes, in this body,
>> from boyhood to youth to old age, the soul similarly passes
>> into another body at death. A sober person is not bewildered
>> by such a change.
>>
>>  --
> 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.
>



-- 
José Ricardo Borba

-- 
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] getting " [Errno 13] Permission denied" over and over

2015-05-29 Thread Dave S


On Thursday, May 28, 2015 at 9:33:28 PM UTC-7, Gene wrote:
>
> Encountered the same ticket on windows 8.1, web2py 2.9. 'Fixed' by 
> uninstalling McAfee, no tickets thereafter.
>

You might not have to uninstall; McAfee, AIUI, does provide the ability to 
exclude certain directories from scanning.  This issue comes up in the 
Mercurial forums, too, and in general you don't want scanning (or the OS 
indexing) of repositories.

Thanks for the confirming experience, though.

/dps



> On Monday, September 15, 2014 at 11:22:15 PM UTC+8, Willoughby wrote:
>>
>> I'm late to this thread but one issue I always run into with web2py on 
>> Windows (well, anything with SQLite) are virus scanners randomly locking 
>> files.  Especially if they're corporate network machines.  That's another 
>> avenue you might look into.
>>
>> On Thursday, September 4, 2014 3:22:47 AM UTC-4, Johann Spies wrote:
>>>
>>> On 3 September 2014 23:31, JorgeH  wrote:
>>>
>>> I discovered that by cleaning errors, cache and sessions, its work 
 again. But now Im getting the error like every other time I test.

 Any hints??


>>> Which user owns web2py/applications//models?
>>>
>>> Regards
>>> Johann
>>>
>>> -- 
>>> 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.


[web2py] Re: _before_insert / update question

2015-05-29 Thread Ian Ryder
It was this:

new_ilis = []
...
new_ili = {
'income': this_rg.template_income,
'income_coding': rgli.income_coding,
'amount_item': rgli.amount_item,
'quantity': rgli.quantity,
'income_source': rgli.income_source,
'source_agency': rgli.source_agency,
'source_type': rgli.source_type
}
new_ilis.append(new_ili)
...
db.income_line_item.bulk_insert(new_ilis)



On Friday, May 29, 2015 at 1:43:37 PM UTC+2, Anthony wrote:
>
> Possible bug. What does your bulk_insert code look like?
>
> On Friday, May 29, 2015 at 1:32:35 AM UTC-4, Ian Ryder wrote:
>>
>> OK - I think I have the answer.
>>
>> I discovered it wasn't table-specific, it worked with this same method / 
>> table elsewhere in the app. The place it was failing was using bulk_insert. 
>> I changed to insert individually and all works fine.
>>
>> Bug?
>>
>> On Friday, May 29, 2015 at 6:39:56 AM UTC+2, Ian Ryder wrote:
>>>
>>> Hi, the key point is I'm not getting passed a dict, I'm getting passed a 
>>> list. Here's a dump of what the _is_before handler gets passed:
>>>
>>>  [(, datetime.datetime(2015, 
>>> 5, 29, 6, 32, 27, 732420)), (>> >, 1L), (, 8L), (>> objects.Field object at 0x1334a5390>, 2L), (>> at 0x11c2dfcd0>, 5.0), (, 
>>> 14093L), (, 'APPEAL'), (<
>>> pydal.objects.Field object at 0x1334a5050>, 1L), (>> object at 0x1334a5410>, 358001L), (>> 0x11eb9a4d0>, datetime.datetime(2015, 5, 29, 6, 32, 27, 732420)), (<
>>> pydal.objects.Field object at 0x1334a53d0>, 5.0), (>> object at 0x1334a5690>, True), (>> 0x1334a55d0>, 1L)]
>>>
>>> I test it on a different table and it gets a dict as expected:
>>> {'query_group': 1, 'name': 'asddasdasdasdsada', 'created_date': datetime
>>> .datetime(2015, 5, 29, 6, 27, 37, 2291), 'run_order': 0, 'type': '', 
>>> 'sum_description': '', 'created_by': 1L}
>>>
>>> I'll post again the definition for the one that isn't working:
>>> db.income_line_item._before_insert.append(lambda f: 
>>> trigger_ili_before_insert(f))
>>>
>>> Which is essentially the same for the one that is working:
>>> db.query._before_insert.append(lambda f: query_before_test(f))
>>>
>>>
>>>
>>>
>>> On Thursday, May 28, 2015 at 11:10:21 PM UTC+2, Niphlod wrote:

 the book shows how to print every argument passed to those 
 functions I dunno how to make the book clearer :°°°D


 before_insert 


 def this_is_before_insert(some_dict):
 if 'last_name' in some_dict:
  some_dict['last_name'] = 'altering' + some_dict['last_name']

 db.auth_user._before_insert.append(lambda f: this_is_before_insert(f))

 >>>db.auth_user.insert(first_name='john')
 1L
 >>> db.auth_user.insert(last_name='doe')
 2L
 >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
 auth_user.last_name)
 >>> print str(rtn)
 auth_user.first_name,auth_user.last_name
 john,
 ,alteringdoe

 before_update ...

 def this_is_before_update(a_set, some_dict):
   if 'last_name' in some_dict:
   some_dict['last_name'] += 'was_updated'

 db.auth_user._before_update.append(lambda s,f: this_is_before_update(s,
 f))

 >>> db.auth_user.insert(first_name='john', last_name='doe')
 1L
 >>> db(db.auth_user.first_name=='john').update(last_name='white')
 1
 >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
 auth_user.last_name)
 >>> print str(rtn)
 auth_user.first_name,auth_user.last_name
 john,whitewas_updated







-- 
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: _before_insert / update question

2015-05-29 Thread Ian Ryder
It was this:

new_ilis = []
...
new_ili = {
'income': this_rg.template_income,
'income_coding': rgli.income_coding,
'amount_item': rgli.amount_item,
'quantity': rgli.quantity,
'income_source': rgli.income_source,
'source_agency': rgli.source_agency,
'source_type': rgli.source_type
}
new_ilis.append(new_ili)
...
db.income_line_item.bulk_insert(new_ilis)



On Friday, May 29, 2015 at 1:43:37 PM UTC+2, Anthony wrote:
>
> Possible bug. What does your bulk_insert code look like?
>
> On Friday, May 29, 2015 at 1:32:35 AM UTC-4, Ian Ryder wrote:
>>
>> OK - I think I have the answer.
>>
>> I discovered it wasn't table-specific, it worked with this same method / 
>> table elsewhere in the app. The place it was failing was using bulk_insert. 
>> I changed to insert individually and all works fine.
>>
>> Bug?
>>
>> On Friday, May 29, 2015 at 6:39:56 AM UTC+2, Ian Ryder wrote:
>>>
>>> Hi, the key point is I'm not getting passed a dict, I'm getting passed a 
>>> list. Here's a dump of what the _is_before handler gets passed:
>>>
>>>  [(, datetime.datetime(2015, 
>>> 5, 29, 6, 32, 27, 732420)), (>> >, 1L), (, 8L), (>> objects.Field object at 0x1334a5390>, 2L), (>> at 0x11c2dfcd0>, 5.0), (, 
>>> 14093L), (, 'APPEAL'), (<
>>> pydal.objects.Field object at 0x1334a5050>, 1L), (>> object at 0x1334a5410>, 358001L), (>> 0x11eb9a4d0>, datetime.datetime(2015, 5, 29, 6, 32, 27, 732420)), (<
>>> pydal.objects.Field object at 0x1334a53d0>, 5.0), (>> object at 0x1334a5690>, True), (>> 0x1334a55d0>, 1L)]
>>>
>>> I test it on a different table and it gets a dict as expected:
>>> {'query_group': 1, 'name': 'asddasdasdasdsada', 'created_date': datetime
>>> .datetime(2015, 5, 29, 6, 27, 37, 2291), 'run_order': 0, 'type': '', 
>>> 'sum_description': '', 'created_by': 1L}
>>>
>>> I'll post again the definition for the one that isn't working:
>>> db.income_line_item._before_insert.append(lambda f: 
>>> trigger_ili_before_insert(f))
>>>
>>> Which is essentially the same for the one that is working:
>>> db.query._before_insert.append(lambda f: query_before_test(f))
>>>
>>>
>>>
>>>
>>> On Thursday, May 28, 2015 at 11:10:21 PM UTC+2, Niphlod wrote:

 the book shows how to print every argument passed to those 
 functions I dunno how to make the book clearer :°°°D


 before_insert 


 def this_is_before_insert(some_dict):
 if 'last_name' in some_dict:
  some_dict['last_name'] = 'altering' + some_dict['last_name']

 db.auth_user._before_insert.append(lambda f: this_is_before_insert(f))

 >>>db.auth_user.insert(first_name='john')
 1L
 >>> db.auth_user.insert(last_name='doe')
 2L
 >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
 auth_user.last_name)
 >>> print str(rtn)
 auth_user.first_name,auth_user.last_name
 john,
 ,alteringdoe

 before_update ...

 def this_is_before_update(a_set, some_dict):
   if 'last_name' in some_dict:
   some_dict['last_name'] += 'was_updated'

 db.auth_user._before_update.append(lambda s,f: this_is_before_update(s,
 f))

 >>> db.auth_user.insert(first_name='john', last_name='doe')
 1L
 >>> db(db.auth_user.first_name=='john').update(last_name='white')
 1
 >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
 auth_user.last_name)
 >>> print str(rtn)
 auth_user.first_name,auth_user.last_name
 john,whitewas_updated







-- 
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 field with function NOT lambda

2015-05-29 Thread Anthony
You need to set the "writable" attribute to True for forms.

-- 
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] web2py 2.11.1 is OUT

2015-05-29 Thread Ron Chatterjee
More I learn other framework more I appreciate web2py. Massimo truly 
deserves a gold medal if not a nobel prize.

On Friday, May 29, 2015 at 2:31:42 PM UTC-4, José Borba wrote:
>
> @Massimo,
>
> The web2py 2.11.1 still in the box or was released?
>
> I need to test it out with my app, that use mongodb too. I'm experiencing 
> _id troubles, and wish that was only a minor problem with mongodb adapter 
> in the 2.10.4 release that I was updated from the pydal issue #170.
>
> Best regards.
> And congratulations for the very good work in w2p and pydal.
>
>
> 2015-05-29 9:12 GMT-03:00 Massimo Di Pierro  >:
>
>> This is strange. ANYWAY, a bug crept in so I reverted the posted "stable" 
>> version to 2.10.4 until the bug is fixed.
>>
>> Massimo
>>
>> On Friday, 29 May 2015 00:46:16 UTC-5, Gour wrote:
>>>
>>> Massimo Di Pierro writes: 
>>>
>>> > web2py 2.11.1 is OUT. 
>>>
>>> Heh, I pulled from the master yesterday and it was still alpha. :-) 
>>>
>>> > Just in time for the DePy conference tomorrow. 
>>>
>>> All the best promoting web2py!! 
>>>
>>>
>>> Sincerely, 
>>> Gour 
>>>
>>> p.s. I notice that your signature contains: 
>>>
>>> - https://code.google.com/p/web2py/issues/list (Report Issues) 
>>>
>>> which is linking to https://github.com/web2py/web2py/issues. Time to 
>>> update 
>>> your sig or it's by intention? 
>>>
>>> -- 
>>> As the embodied soul continuously passes, in this body, 
>>> from boyhood to youth to old age, the soul similarly passes 
>>> into another body at death. A sober person is not bewildered 
>>> by such a change. 
>>>
>>>  -- 
>> 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.
>>
>
>
>
> -- 
> José Ricardo Borba
>
> 

-- 
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 field with function NOT lambda

2015-05-29 Thread goome


Il giorno venerdì 29 maggio 2015 21:40:27 UTC+2, Anthony ha scritto:
>
> You need to set the "writable" attribute to True for forms.


i put 
 legacy_db.ordinipo.total.readable = True
in the model (db.py).
Should i put it ont the form too? In this case, how?
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.


[web2py] Issues with _id in MongoDB

2015-05-29 Thread José Ricardo Borba
Hello all,

I'm experiencing some issues with web2py and MongoDB 3.0.3 _id field.

With web2py 2.10.4 the _id field (ObjectId) is showed in this way:

26418130264307745716389872944
26418130264307745716389872963
.
.


With Ipython 3.1.0 (with [python2.7.9 or 3.4.3 and pymongo] OR mongodb
shell 3.0.3) the _id field (ObjectId) is showed in this way:

555c90af47439f0958f10530
555c90af47439f0958f10543
.
.

I think that the last is the correct way to show the _id, because both
pymongo and mongoshell showed the same. But why the web2py is not showing
the correct _id? Maybe I'm doing something wrong?

The last record was imported from a CSV file, and the first was inserted
from web2py form (from SQLGRID).

Best regards,

-- 
José Ricardo Borba

-- 
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 field with function NOT lambda

2015-05-29 Thread Anthony
"writable", not "readable".

On Friday, May 29, 2015 at 5:11:39 PM UTC-4, goome wrote:
>
>
>
> Il giorno venerdì 29 maggio 2015 21:40:27 UTC+2, Anthony ha scritto:
>>
>> You need to set the "writable" attribute to True for forms.
>
>
> i put 
>  legacy_db.ordinipo.total.readable = True
> in the model (db.py).
> Should i put it ont the form too? In this case, how?
> 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.


[web2py] Re: _before_insert / update question

2015-05-29 Thread Anthony
Yes, this is a bug in bulk_insert -- it calls the _listify method *before* 
running the _before_insert callbacks instead of after (_listify changes the 
format from a dictionary to a list of (field, value) tuples). If you don't 
mind, please file a pydal github issue and reference this post.

Anthony

On Friday, May 29, 2015 at 3:21:33 PM UTC-4, Ian Ryder wrote:
>
> It was this:
>
> new_ilis = []
> ...
> new_ili = {
> 'income': this_rg.template_income,
> 'income_coding': rgli.income_coding,
> 'amount_item': rgli.amount_item,
> 'quantity': rgli.quantity,
> 'income_source': rgli.income_source,
> 'source_agency': rgli.source_agency,
> 'source_type': rgli.source_type
> }
> new_ilis.append(new_ili)
> ...
> db.income_line_item.bulk_insert(new_ilis)
>
>
>
> On Friday, May 29, 2015 at 1:43:37 PM UTC+2, Anthony wrote:
>>
>> Possible bug. What does your bulk_insert code look like?
>>
>> On Friday, May 29, 2015 at 1:32:35 AM UTC-4, Ian Ryder wrote:
>>>
>>> OK - I think I have the answer.
>>>
>>> I discovered it wasn't table-specific, it worked with this same method / 
>>> table elsewhere in the app. The place it was failing was using bulk_insert. 
>>> I changed to insert individually and all works fine.
>>>
>>> Bug?
>>>
>>> On Friday, May 29, 2015 at 6:39:56 AM UTC+2, Ian Ryder wrote:

 Hi, the key point is I'm not getting passed a dict, I'm getting passed 
 a list. Here's a dump of what the _is_before handler gets passed:

  [(, datetime.datetime(2015, 
 5, 29, 6, 32, 27, 732420)), (>>> >, 1L), (, 8L), (>>> objects.Field object at 0x1334a5390>, 2L), (>>> at 0x11c2dfcd0>, 5.0), (, 
 14093L), (, 'APPEAL'), (<
 pydal.objects.Field object at 0x1334a5050>, 1L), (>>> object at 0x1334a5410>, 358001L), (>>> 0x11eb9a4d0>, datetime.datetime(2015, 5, 29, 6, 32, 27, 732420)), (<
 pydal.objects.Field object at 0x1334a53d0>, 5.0), (>>> object at 0x1334a5690>, True), (>>> 0x1334a55d0>, 1L)]

 I test it on a different table and it gets a dict as expected:
 {'query_group': 1, 'name': 'asddasdasdasdsada', 'created_date': 
 datetime.datetime(2015, 5, 29, 6, 27, 37, 2291), 'run_order': 0, 'type'
 : '', 'sum_description': '', 'created_by': 1L}

 I'll post again the definition for the one that isn't working:
 db.income_line_item._before_insert.append(lambda f: 
 trigger_ili_before_insert(f))

 Which is essentially the same for the one that is working:
 db.query._before_insert.append(lambda f: query_before_test(f))




 On Thursday, May 28, 2015 at 11:10:21 PM UTC+2, Niphlod wrote:
>
> the book shows how to print every argument passed to those 
> functions I dunno how to make the book clearer :°°°D
>
>
> before_insert 
>
>
> def this_is_before_insert(some_dict):
> if 'last_name' in some_dict:
>  some_dict['last_name'] = 'altering' + some_dict['last_name']
>
> db.auth_user._before_insert.append(lambda f: this_is_before_insert(f))
>
> >>>db.auth_user.insert(first_name='john')
> 1L
> >>> db.auth_user.insert(last_name='doe')
> 2L
> >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
> auth_user.last_name)
> >>> print str(rtn)
> auth_user.first_name,auth_user.last_name
> john,
> ,alteringdoe
>
> before_update ...
>
> def this_is_before_update(a_set, some_dict):
>   if 'last_name' in some_dict:
>   some_dict['last_name'] += 'was_updated'
>
> db.auth_user._before_update.append(lambda s,f: this_is_before_update(s
> ,f))
>
> >>> db.auth_user.insert(first_name='john', last_name='doe')
> 1L
> >>> db(db.auth_user.first_name=='john').update(last_name='white')
> 1
> >>> rtn = db(db.auth_user.id>0).select(db.auth_user.first_name, db.
> auth_user.last_name)
> >>> print str(rtn)
> auth_user.first_name,auth_user.last_name
> john,whitewas_updated
>
>
>
>
>
>

-- 
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: Email invite users - peer review

2015-05-29 Thread Carlos Zenteno
Great idea.  My webapp needs something like this.  Not in bulk but I can 
modify it
to serve my needs

-- 
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] Select all fields with length > 0?

2015-05-29 Thread LoveWeb2py
db((db.table.field1.id>0)&(db.table.field2.length>0)).select()

This still returns the whole field. I'm thinking the length takes the 
length of the entire field. How can I bring back all records that aren't 
empty for a field

For example

db.table.field2

row1: has information
row2: 
row3: has information

in my query I only want to return row 1 & 3. I'm sure there is an easy way 
to do this?

-- 
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: Select all fields with length > 0?

2015-05-29 Thread LoveWeb2py
Sigh should have thought a little more before posting. Sorry about this

This works:
db((db.table.field1.id>0)&(db.table.field2!='')).select()

On Friday, May 29, 2015 at 6:19:44 PM UTC-4, LoveWeb2py wrote:
>
> db((db.table.field1.id>0)&(db.table.field2.length>0)).select()
>
> This still returns the whole field. I'm thinking the length takes the 
> length of the entire field. How can I bring back all records that aren't 
> empty for a field
>
> For example
>
> db.table.field2
>
> row1: has information
> row2: 
> row3: has information
>
> in my query I only want to return row 1 & 3. I'm sure there is an easy way 
> to do this?
>

-- 
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: _before_insert / update question

2015-05-29 Thread 黄祥
i face the same situation before, but because i use bulk_insert in 
controller install.py so that i put the conditional if on it.
e.g.
*models/db.py*
# after_insert_purchase_detail
def __after_insert_purchase_detail(f, id):
db(db.dvd.id == f.dvd).update(quantity = db.dvd(f.dvd).quantity + 
f.quantity)

# on_define_purchase_detail
def on_define_purchase_detail(table): 
# callbacks
if not 'install' in request.controller :
# _after_insert
table._after_insert.append(__after_insert_purchase_detail)

# create table : purchase_detail
db.define_table('purchase_detail', 
Field('purchase_no', 'reference purchase_header'), 
Field('dvd', 'reference dvd'), 
Field('quantity', 'integer'),
Field('price', 'integer'), 
on_define = on_define_purchase_detail, 
format = '%(purchase_no)s')

*controllers/install.py*
# purchase_detail
db.purchase_detail.bulk_insert([{"purchase_no" : 1, "dvd" : 1, "quantity" : 
1, 
 "price" : 15000}, 
{"purchase_no" : 2, "dvd" : 3, "quantity" : 1, 
 "price" : 15000}, 
{"purchase_no" : 2, "dvd" : 4, "quantity" : 1, 
 "price" : 15000}, ])

hopefully, after the bug is fixed i don't have to put the conditional if to 
check the controller again.

best regards,
stifan

-- 
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: Issues with _id in MongoDB

2015-05-29 Thread José Ricardo Borba
Hum...

Seems that web2py converts the hex _id of ObjectId to the Loong
integer that represent that number.

So, this is not an issue. I need to think again...

Best regards,

2015-05-29 18:22 GMT-03:00 José Ricardo Borba :

> Hello all,
>
> I'm experiencing some issues with web2py and MongoDB 3.0.3 _id field.
>
> With web2py 2.10.4 the _id field (ObjectId) is showed in this way:
>
> 26418130264307745716389872944
> 26418130264307745716389872963
> .
> .
>
>
> With Ipython 3.1.0 (with [python2.7.9 or 3.4.3 and pymongo] OR mongodb
> shell 3.0.3) the _id field (ObjectId) is showed in this way:
>
> 555c90af47439f0958f10530
> 555c90af47439f0958f10543
> .
> .
>
> I think that the last is the correct way to show the _id, because both
> pymongo and mongoshell showed the same. But why the web2py is not showing
> the correct _id? Maybe I'm doing something wrong?
>
> The last record was imported from a CSV file, and the first was inserted
> from web2py form (from SQLGRID).
>
> Best regards,
>
> --
> José Ricardo Borba
>
>


-- 
José Ricardo Borba

-- 
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: Email invite users - peer review

2015-05-29 Thread James Burke
I've submitted a pull request under the username Peregrinius.

As noted my initial code relies on register_bare, which seems to have since 
been removed.

On Thursday, May 28, 2015 at 5:19:07 PM UTC+12, Massimo Di Pierro wrote:
>
> think this is an excellent idea. Please submit a pull request.
>
> On Wednesday, 20 May 2015 03:12:24 UTC-5, James Burke wrote:
>>
>> Hi,
>>
>> I'm looking for a peer review of some code I put together for email 
>> inviting users to join an application. I couldn't find anything suitable 
>> looking around, hopefully I didn't overlook anything!
>>
>> The idea is, you enter in email addresses into a form, click submit and 
>> it will send an email to the email address with an invite to your 
>> application. The email will contain a link which the user clicks to take 
>> them to a form to fill in the rest of their required details, name etc.
>>
>> I've tested this and it works, but I would like to know what others 
>> thoughts are and there are any improvements that could be made.
>>
>> Thank you!
>>
>> *default.py controller*
>> def index():
>> form=FORM('Enter a comma separated list of emails to send invites:',
>>   BR(),
>>   INPUT(_id='emails', _value=''),
>>   INPUT(_type='submit'))
>>
>> if form.accepts(request,session):
>> # send the invitations
>> for email in form.vars.email.split(','):
>> auth.invite_user(email=email)
>> response.flash = 'Invitations sent'
>>
>> return dict(form=form)
>>
>> def confirm_registration():
>> return dict(form=auth.confirm_registration())
>>
>>
>>
>>
>> *gluon/tools.py*
>> def confirm_registration(
>> self,
>> next=DEFAULT,
>> onvalidation=DEFAULT,
>> onaccept=DEFAULT,
>> log=DEFAULT,
>> ):
>> """
>> Modified version of Auth.reset_password()
>> """
>>
>>
>> table_user = self.table_user()
>> request = current.request
>> # response = current.response
>> session = current.session
>>
>>
>> if next is DEFAULT:
>> next = self.get_vars_next() or self.settings.
>> reset_password_next
>>
>>
>> if self.settings.prevent_password_reset_attacks:
>> key = request.vars.key
>> if not key and len(request.args)>1:
>> key = request.args[-1]
>> if key:
>> session._reset_password_key = key
>> redirect(self.url('confirm_registration'))
>> else:
>> key = session._reset_password_key
>> else:
>> key = request.vars.key or getarg(-1)
>> try:
>> t0 = int(key.split('-')[0])
>> if time.time() - t0 > 60 * 60 * 24:
>> raise Exception
>> user = table_user(reset_password_key=key)
>> if not user:
>> raise Exception
>> except Exception as e:
>> session.flash = self.messages.invalid_reset_password
>> redirect(self.url('login', vars=dict(test=e)))
>> redirect(next, client_side=self.settings.client_side)
>> passfield = self.settings.password_field
>> form = SQLFORM.factory(
>> Field('first_name',
>>   label='First Name',
>>required=True),
>> Field('last_name',
>>   label='Last Name',
>>required=True),
>> Field('new_password', 'password',
>>   label=self.messages.new_password,
>>   requires=self.table_user()[passfield].requires),
>> Field('new_password2', 'password',
>>   label=self.messages.verify_password,
>>   requires=[IS_EXPR(
>>   'value==%s' % repr(request.vars.new_password),
>> self.messages.mismatched_password)]),
>> submit_button='Confirm Registration',
>> hidden=dict(_next=next),
>> formstyle=self.settings.formstyle,
>> separator=self.settings.label_separator
>> )
>> if form.accepts(request, session,
>> hideerror=self.settings.hideerror):
>> user.update_record(
>> **{passfield: str(form.vars.new_password),
>>'first_name': str(form.vars.first_name),
>>'last_name': str(form.vars.last_name),
>>'registration_key': '',
>>'reset_password_key': ''})
>> session.flash = self.messages.password_changed
>> if self.settings.login_after_password_change:
>> self.login_user(user)
>> redirect(next, client_side=self.settings.client_side)
>> return form
>>
>>
>> def email_registration(self, user):
>> """
>> Modified version of Auth.email_reset_password()
>> """
>> import
>> ...

[web2py] Re: Issues with _id in MongoDB

2015-05-29 Thread José Ricardo Borba
Closing with success

If more people need to import data from CSV files and need to reference
other collections in MongoDB, just prepare the file in the way described
below (recipe).

In a separate file (py) do this
- search your term in MongoDB collection of your choice;
- convert the _id in int from hex [ like  int('deadbeef',16) ];
- convert the int in str;
- save your csv with this string (shoul be the Looong integer above);
- import the file!

This is the code I've used to do this.
https://gist.github.com/jrborbars/63a82486bdddfc13e365

Best regards,


2015-05-29 22:12 GMT-03:00 José Ricardo Borba :

> Hum...
>
> Seems that web2py converts the hex _id of ObjectId to the Loong
> integer that represent that number.
>
> So, this is not an issue. I need to think again...
>
> Best regards,
>
> 2015-05-29 18:22 GMT-03:00 José Ricardo Borba :
>
>> Hello all,
>>
>> I'm experiencing some issues with web2py and MongoDB 3.0.3 _id field.
>>
>> With web2py 2.10.4 the _id field (ObjectId) is showed in this way:
>>
>> 26418130264307745716389872944
>> 26418130264307745716389872963
>> .
>> .
>>
>>
>> With Ipython 3.1.0 (with [python2.7.9 or 3.4.3 and pymongo] OR mongodb
>> shell 3.0.3) the _id field (ObjectId) is showed in this way:
>>
>> 555c90af47439f0958f10530
>> 555c90af47439f0958f10543
>> .
>> .
>>
>> I think that the last is the correct way to show the _id, because both
>> pymongo and mongoshell showed the same. But why the web2py is not showing
>> the correct _id? Maybe I'm doing something wrong?
>>
>> The last record was imported from a CSV file, and the first was inserted
>> from web2py form (from SQLGRID).
>>
>> Best regards,
>>
>> --
>> José Ricardo Borba
>>
>>
>
>
> --
> José Ricardo Borba
>
>


-- 
José Ricardo Borba

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