[web2py] Re: Specifying onvalidation with auth.profile() prevents default onaccepts method

2013-09-05 Thread Mark Li
Thanks Massimo. However, using 
auth.settings.profile_onvalidation.append(reauthenticate_user)

has presented a problem of its own.

I insert an extra field ("confirm_password"), to recheck in the 
onvalidation method. However, the form.vars does not contain 
form.vars.confirm_password, which worked before when I was using form.
process(onvalidation=reauthenticate_user)


Here is the relevant code:

auth.settings.profile_onvalidation.append(reauthenticate_user)
form=auth.profile()
my_extra_element = TR(LABEL('Confirm Password'),INPUT(_type="password",_name
="confirm_password", _class="string"))
form[0].insert(-1,my_extra_element)


def reauthenticate_user(form):
#recheck the user password
plain_password = form.vars.confirm_password
if db.auth_user.password.validate(plain_password) != (db(db.auth_user.id
==auth.user.id).select().first().password, None):
form.errors.confirm_password = "Must enter correct password"


The form passed into reauthenticate_user does not contain 
form.vars.confirm_password variable. Any ideas on why this happens now, but 
not before?


On Thursday, September 5, 2013 4:46:11 PM UTC-7, Massimo Di Pierro wrote:
>
> This
>
> form = auth.profile()
> form.process(onvalidation=reauthenticate_user)
>
> is wrong because auth.profile() already calls process inside. Instead you 
> should do:
>
> auth.settings.profile_onvalidation.append(reauthenticate_user)
> form = auth.profile()
>
> On Thursday, 5 September 2013 17:42:18 UTC-5, Mark Li wrote:
>>
>> Currently I am creating a form with auth.profile()
>>
>> I have an onvalidation method to perform some extra checks.
>>
>> form = auth.profile()
>> if form.process(onvalidation=reauthenticate_user).accepted:
>>
>> response.flash = "Changes Saved"
>> elif form.errors:
>>
>> response.flash = "Errors found
>>
>>
>>
>> This prevented auth.user object from being updated, which auth.profile() 
>> usually takes care of.
>>
>> I also tried it with the following:
>>
>> form = auth.profile()
>> form.process(onvalidation=reauthenticate_user)
>>
>>
>>
>> but the default accepts method that usually updates auth.user doesn't 
>> work either
>>
>> For now, I've just added the following to the accepted method:
>> auth.user.update(db.auth_user._filter_fields(form.vars)) 
>>
>> But I'm interested in knowing if it's possible to specify an onvalidation 
>> method for auth.profile(), while still using the built-in accepts method.
>>
>

-- 

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


[web2py] web2py_win.zip redundant file during extracted

2013-09-05 Thread 黄祥
hi,

i've downloaded the latest web2py_win.zip during extracted the zip file, it 
tells that the file 
on web2py\applications\examples\static\epydoc\gluon.html__tag__-class.html 
is already there. the file size is different. is it okay to replace it or 
keep it?

thanks and best regards,
stifan

-- 

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

[web2py] Re: Force user to reenter password to save auth.profile() changes

2013-09-05 Thread 黄祥
done, Issue 1667 

thanks and best regards,
stifan

On Friday, September 6, 2013 7:32:57 AM UTC+7, Massimo Di Pierro wrote:
>
> I agree. Please open a ticket. This can be done easily.
>
> On Thursday, 5 September 2013 18:38:36 UTC-5, 黄祥 wrote:
>>
>> just an idea, why not put this as default feature in web2py, i mean 
>> in default/user/profile.
>>
>> best regards,
>> stifan
>>
>> On Saturday, August 10, 2013 3:18:59 PM UTC+7, Massimo Di Pierro wrote:
>>>
>>> This is what I would have done. Some caveats:
>>>
>>> 1) Use a SQLFORM.factory and not a SQLFORM because you do not want the 
>>> value of the password field to be stored in db
>>> 2) You can validate the password using validators (I think) 
>>>
>>>
>>> Field('password','passwrod',requires=(IS_CRYPT(),IS_EQUAL_TO((db.auth_user[user_id].password,None
>>>
>>>
>>> On Saturday, 10 August 2013 00:24:18 UTC-5, Mark Li wrote:

 For anyone else wondering how to do this, I decided to add a "password" 
 field and have onvalidation check the password.

 This link gave me the idea for checking the text password against the 
 encrypted pw: 
 https://groups.google.com/forum/#!msg/web2py/eqbXmseZ6XA/abnGIMevI6wJ

 On Wednesday, August 7, 2013 10:18:17 PM UTC-7, Mark Li wrote:
>
> I currently have a "settings" page, where a form created by 
> auth.profile() is displayed. I want to force the user to re-enter his/her 
> password in order to save any changes they make to their profile (such as 
> email, username, etc).
>
> Not really sure the best way to go about this, all the authentication 
> stuff I've dealt with involves logging the user in with both email and 
> pw. 
> In this case, the user is already logged in, but I just want them to 
> reenter their password before changing important profile information.
>


-- 

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


[web2py] Re: CAS consumer as CAS provider

2013-09-05 Thread Imran Ahmed
Previously, I have a state where I want third app to be CAS consumer of 
second app. Now I sorted it out.
Thanks for support. Now using same provider for third app also.

On Thursday, September 5, 2013 11:28:23 AM UTC+5:30, Imran Ahmed wrote:
>
> Can we use one CAS consumer as a CAS provider for other app?
>

-- 

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


[web2py] Re: Field value based on other field in Dal?

2013-09-05 Thread greenpoise
Thats exactly what I am looking! Thanks, will try and post Thanks Anthony



On Thursday, September 5, 2013 6:31:46 PM UTC-7, Anthony wrote:
>
> Does conversiontype need to be writable in forms? If not, you can use a 
> computed field. If you are just trying to change the default value, you 
> could do something like:
>
> Field('conversiontype','reference conversiontype',
>   default=5 if request.vars.tiluse == 5 else 2)
>
> Note, that will only change the default on submission, so it won't help 
> with pre-populating the form (but you can't know the value of tileuse at 
> the time the form is created anyway).
>
> Anthony
>
> On Thursday, September 5, 2013 7:32:04 PM UTC-4, greenpoise wrote:
>>
>> is it possible to have an if statement of some sort in Dal to 
>> validate/add a value based on other field?
>>
>> like:
>>
>> db.define_table('product',
>> Field('series', 'reference series'),
>> Field('suppliercode','reference supplier'),
>> Field('description'),
>> Field('tiluse','reference tileuse'),
>> Field('price'),
>> Field('cost'),
>> Field('picture', 'upload'),
>> Field('conversiontype','reference conversiontype',default=2))
>>
>>
>>
>> I need the conversiontype to be 1 if tiluse = '5' otherwise stay in 2. 
>>  How can I accomplish this in Dal?
>>
>> thanks
>>
>

-- 

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


[web2py] Re: Field value based on other field in Dal?

2013-09-05 Thread Anthony
Does conversiontype need to be writable in forms? If not, you can use a 
computed field. If you are just trying to change the default value, you 
could do something like:

Field('conversiontype','reference conversiontype',
  default=5 if request.vars.tiluse == 5 else 2)

Note, that will only change the default on submission, so it won't help 
with pre-populating the form (but you can't know the value of tileuse at 
the time the form is created anyway).

Anthony

On Thursday, September 5, 2013 7:32:04 PM UTC-4, greenpoise wrote:
>
> is it possible to have an if statement of some sort in Dal to validate/add 
> a value based on other field?
>
> like:
>
> db.define_table('product',
> Field('series', 'reference series'),
> Field('suppliercode','reference supplier'),
> Field('description'),
> Field('tiluse','reference tileuse'),
> Field('price'),
> Field('cost'),
> Field('picture', 'upload'),
> Field('conversiontype','reference conversiontype',default=2))
>
>
>
> I need the conversiontype to be 1 if tiluse = '5' otherwise stay in 2. 
>  How can I accomplish this in Dal?
>
> thanks
>

-- 

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


[web2py] Re: SQLFORM.factory requires explicit uploadfolder

2013-09-05 Thread Massimo Di Pierro
You can always define

def UploadField(*a,**b): 
 b['uploadfolder'] = request.folder
 return Field(*a,**b)

db.define_table( UploadField(...))

I often define

def HiddenField(*a,**b): 
 b['readable'] = b['writable'] = False
 return Field(*a,**b)

def ReadonlyField(*a,**b): 
 b['writable'] = False
 return Field(*a,**b)

def IntegerField(*a,**b): 
 b['type'] = 'integer'
 return Field(*a,**b)

etc.


On Thursday, 5 September 2013 19:22:58 UTC-5, Alan Etkin wrote:
>
> We could use current.request.folder but we would have to couple the dal 
>> code to current. that is something we avoided to far.
>>
>
> I don't think it is necessary to use current in dal just for this. I don't 
> mind adding uploadfolder on each Field(...) call, I just was curious why it 
> was needed. Maybe I would mind if I had a project with lots of code using 
> SQLFORM.factory plus upload fields, which I think is a corner case.
>
>

-- 

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


[web2py] Re: Force user to reenter password to save auth.profile() changes

2013-09-05 Thread Massimo Di Pierro
I agree. Please open a ticket. This can be done easily.

On Thursday, 5 September 2013 18:38:36 UTC-5, 黄祥 wrote:
>
> just an idea, why not put this as default feature in web2py, i mean 
> in default/user/profile.
>
> best regards,
> stifan
>
> On Saturday, August 10, 2013 3:18:59 PM UTC+7, Massimo Di Pierro wrote:
>>
>> This is what I would have done. Some caveats:
>>
>> 1) Use a SQLFORM.factory and not a SQLFORM because you do not want the 
>> value of the password field to be stored in db
>> 2) You can validate the password using validators (I think) 
>>
>>
>> Field('password','passwrod',requires=(IS_CRYPT(),IS_EQUAL_TO((db.auth_user[user_id].password,None
>>
>>
>> On Saturday, 10 August 2013 00:24:18 UTC-5, Mark Li wrote:
>>>
>>> For anyone else wondering how to do this, I decided to add a "password" 
>>> field and have onvalidation check the password.
>>>
>>> This link gave me the idea for checking the text password against the 
>>> encrypted pw: 
>>> https://groups.google.com/forum/#!msg/web2py/eqbXmseZ6XA/abnGIMevI6wJ
>>>
>>> On Wednesday, August 7, 2013 10:18:17 PM UTC-7, Mark Li wrote:

 I currently have a "settings" page, where a form created by 
 auth.profile() is displayed. I want to force the user to re-enter his/her 
 password in order to save any changes they make to their profile (such as 
 email, username, etc).

 Not really sure the best way to go about this, all the authentication 
 stuff I've dealt with involves logging the user in with both email and pw. 
 In this case, the user is already logged in, but I just want them to 
 reenter their password before changing important profile information.

>>>

-- 

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


[web2py] Re: SQLFORM.factory requires explicit uploadfolder

2013-09-05 Thread Alan Etkin

>
> We could use current.request.folder but we would have to couple the dal 
> code to current. that is something we avoided to far.
>

I don't think it is necessary to use current in dal just for this. I don't 
mind adding uploadfolder on each Field(...) call, I just was curious why it 
was needed. Maybe I would mind if I had a project with lots of code using 
SQLFORM.factory plus upload fields, which I think is a corner case.

-- 

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


[web2py] Adding jQuery effects back into a manual form

2013-09-05 Thread REM
I found it necessary to create a manual form, but I'd like to add back the 
cool default jQuery effects to report on validation errors for the one 
input field.

Is there a quick way to access and pass these jQuery effects back in to my 
manual form?

Here's the db definition:

db = DAL('mysql://user:password@localhost/1test', pool_size=2)
db.define_table('vendors',
Field('vendor_id', 'integer', length=4, required=True, unique=True,notnull
=True, label='Vendor ID', 
   requires=[IS_NOT_EMPTY(), 
 IS_INT_IN_RANGE(100,, error_message='Number Out Of 
Range')]),
Field('vendor_name', 'string', length=25, required=True, unique=True,notnull
=True, label='Vendor Name', 
   requires=[IS_NOT_EMPTY(), 
 IS_LENGTH(minsize=1,maxsize=25),
 IS_MATCH('^[a-zA-Z0-9\s]+$', error_message='Bad Vendor 
Name')]),
format='%(vendor_id)s %(vendor_name)s',
migrate=True)
db.vendors.id.readable = db.vendors.id.writable = False
db.vendors.vendor_id.readable = False




Here's the relevant controller:

def manual_form():
newid = db.executesql('select max(vendor_id) as last from vendors',as_dict
=True)
t = (newid[0]['last'] + 1)
form = SQLFORM(db.vendors)
if form.process(session=None, formname='manual').accepted:
redirect(URL('manual_form'))
response.flash = 'Manual Form Accepted'
elif form.errors:
response.flash = 'Manual Form Has Errors'
else:
response.flash = 'Please Enter A Vendor Name'
return locals()



And finally here's the manual_form.html:


{{extend 'layout.html'}}


New Vendor ID: {{=t}}
New Vendor Name: 







The reason I made the manual form is because I want the new vendor_id to 
always be the last vendor_id + 1. I'd use an autoincrement field for 
vendor_id, but I don't want to have gaps if any of them are ever deleted. 
Now that that part's working, I'd like to have the validators back, but I 
know very little about Javascript in general. Therefore, I was hoping that 
there's some easy web2py hooks to the jQuery effects that I can grab and 
put back into this or future forms.

Sincere thanks for any assistance.





-- 

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


[web2py] Re: Specifying onvalidation with auth.profile() prevents default onaccepts method

2013-09-05 Thread Massimo Di Pierro
This

form = auth.profile()
form.process(onvalidation=reauthenticate_user)

is wrong because auth.profile() already calls process inside. Instead you 
should do:

auth.settings.profile_onvalidation.append(reauthenticate_user)
form = auth.profile()

On Thursday, 5 September 2013 17:42:18 UTC-5, Mark Li wrote:
>
> Currently I am creating a form with auth.profile()
>
> I have an onvalidation method to perform some extra checks.
>
> form = auth.profile()
> if form.process(onvalidation=reauthenticate_user).accepted:
>
> response.flash = "Changes Saved"
> elif form.errors:
>
> response.flash = "Errors found
>
>
>
> This prevented auth.user object from being updated, which auth.profile() 
> usually takes care of.
>
> I also tried it with the following:
>
> form = auth.profile()
> form.process(onvalidation=reauthenticate_user)
>
>
>
> but the default accepts method that usually updates auth.user doesn't work 
> either
>
> For now, I've just added the following to the accepted method:
> auth.user.update(db.auth_user._filter_fields(form.vars)) 
>
> But I'm interested in knowing if it's possible to specify an onvalidation 
> method for auth.profile(), while still using the built-in accepts method.
>

-- 

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


[web2py] Re: glyphicon fonts served as text/html

2013-09-05 Thread Massimo Di Pierro
yes.

On Thursday, 5 September 2013 12:49:31 UTC-5, k0aun9 wrote:
>
> Oh, I found the problem. When I uploaded the files, all the hyphens in the 
> file names were converted to underscores automatically.
>
> Is it by design or bug?
>
> On Friday, September 6, 2013 1:44:08 AM UTC+8, k0aun9 wrote:
>>
>> I'm trying to come up with my own layout.html
>>
>> Instead of using web2py_bootstrap.css, I'm using the bootstrap.css (3.0) 
>> because I want to learn how things were built up and the differences.
>> I uploaded the glyphicon fonts and svg etc (which comes with bootstrap 
>> dist) to /[myapp]/static/fonts/ 
>>
>> In the bootstrap.css,
>>
>> @font-face {
>>   font-family: 'Glyphicons Halflings';
>>   src: url('../fonts/glyphicons-halflings-regular.eot');
>>   src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') 
>> format('embedded-opentype'), 
>> url('../fonts/glyphicons-halflings-regular.woff') format('woff'), 
>> url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
>> url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') 
>> format('svg');
>> }
>>
>> I'm seeing squares instead of icons. From the Chrome Developer Tools, I 
>> noticed that they're served as 'text/html' and getting HTTP 404.
>>
>>
>>
>> 
>>
>>
>> 
>>
>>
>> Am I doing something wrong?
>>
>>
>>

-- 

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


[web2py] Re: SQLFORM.factory requires explicit uploadfolder

2013-09-05 Thread Massimo Di Pierro
We could use current.request.folder but we would have to couple the dal 
code to current. that is something we avoided to far.

On Thursday, 5 September 2013 11:31:36 UTC-5, Alan Etkin wrote:
>
> > In that case, how will you determine the absolute folder path?
>
> It seems there's no way, unless the field class reads request.folder which 
> will be not always available.
>

-- 

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


[web2py] Re: wizard issue? (db.define_table settings for the "db.auth_user is missing)

2013-09-05 Thread Massimo Di Pierro
I think you want 
this: 
http://www.web2py.com/books/default/chapter/29/09/access-control?search=extra_fields

On Thursday, 5 September 2013 07:44:02 UTC-5, אבי אברמוביץ wrote:
>
>
> Thanks , not sure I understand. In order to add fields, or update fields 
> which were created, I need to add this to the wizard.db and edit from 
> there? (not all the fields I created with the wizard to that table were 
> created.)
> auth.define_tables('t_auth_user',
> Field('f_user_name', type='string', notnull=True,
>   label=T('User Name'
> etc"))
> ?
>
> On Thursday, September 5, 2013 2:18:28 PM UTC+3, אבי אברמוביץ wrote:
>>
>> Hi,
>> I created a new app using the wizard.
>> All looks good except for one thing:
>> On the models/db.wizard, I don't see the db.define_table settings for the 
>> "db.auth_user. Should it be somewhere else or should I add it?
>>
>> Thanks.
>>
>

-- 

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


[web2py] Re: CAS consumer as CAS provider

2013-09-05 Thread Massimo Di Pierro
I do not know. I never tried. But why? A consumer has a provider. Use the 
same provider for the third app.

On Thursday, 5 September 2013 00:58:23 UTC-5, Imran Ahmed wrote:
>
> Can we use one CAS consumer as a CAS provider for other app?
>

-- 

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


[web2py] Re: Force user to reenter password to save auth.profile() changes

2013-09-05 Thread 黄祥
just an idea, why not put this as default feature in web2py, i mean 
in default/user/profile.

best regards,
stifan

On Saturday, August 10, 2013 3:18:59 PM UTC+7, Massimo Di Pierro wrote:
>
> This is what I would have done. Some caveats:
>
> 1) Use a SQLFORM.factory and not a SQLFORM because you do not want the 
> value of the password field to be stored in db
> 2) You can validate the password using validators (I think) 
>
>
> Field('password','passwrod',requires=(IS_CRYPT(),IS_EQUAL_TO((db.auth_user[user_id].password,None
>
>
> On Saturday, 10 August 2013 00:24:18 UTC-5, Mark Li wrote:
>>
>> For anyone else wondering how to do this, I decided to add a "password" 
>> field and have onvalidation check the password.
>>
>> This link gave me the idea for checking the text password against the 
>> encrypted pw: 
>> https://groups.google.com/forum/#!msg/web2py/eqbXmseZ6XA/abnGIMevI6wJ
>>
>> On Wednesday, August 7, 2013 10:18:17 PM UTC-7, Mark Li wrote:
>>>
>>> I currently have a "settings" page, where a form created by 
>>> auth.profile() is displayed. I want to force the user to re-enter his/her 
>>> password in order to save any changes they make to their profile (such as 
>>> email, username, etc).
>>>
>>> Not really sure the best way to go about this, all the authentication 
>>> stuff I've dealt with involves logging the user in with both email and pw. 
>>> In this case, the user is already logged in, but I just want them to 
>>> reenter their password before changing important profile information.
>>>
>>

-- 

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


[web2py] How to change db servers (same underlying type)?

2013-09-05 Thread MichaelF
My application currently works fine, accessing a MySQL server on host H1 
("H1" is simply a name I've made up for this example.) I now want to start 
using MySQL on host H2 (hardware different from H1), same username and pwd. 
Once the tables/structure are created I'll just dump data from the server 
on H1 and restore (INSERTs) to the server on H2.

   1. Is there an easier way than what I've outlined?
   2. How do I go about getting web2py to create the structure on H2? I 
   assume the first step is to change the uri to point to the server on H2. Is 
   that it? Or do I delete all the files in the 'database' dir under the 
   application. Or something else entirely?

Thanks.

Michael

-- 

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


[web2py] Field value based on other field in Dal?

2013-09-05 Thread greenpoise
is it possible to have an if statement of some sort in Dal to validate/add 
a value based on other field?

like:

db.define_table('product',
Field('series', 'reference series'),
Field('suppliercode','reference supplier'),
Field('description'),
Field('tiluse','reference tileuse'),
Field('price'),
Field('cost'),
Field('picture', 'upload'),
Field('conversiontype','reference conversiontype',default=2))



I need the conversiontype to be 1 if tiluse = '5' otherwise stay in 2.  How 
can I accomplish this in Dal?

thanks

-- 

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


[web2py] Specifying onvalidation with auth.profile() prevents default onaccepts method

2013-09-05 Thread Mark Li
Currently I am creating a form with auth.profile()

I have an onvalidation method to perform some extra checks.

form = auth.profile()
if form.process(onvalidation=reauthenticate_user).accepted:

response.flash = "Changes Saved"
elif form.errors:

response.flash = "Errors found



This prevented auth.user object from being updated, which auth.profile() 
usually takes care of.

I also tried it with the following:

form = auth.profile()
form.process(onvalidation=reauthenticate_user)



but the default accepts method that usually updates auth.user doesn't work 
either

For now, I've just added the following to the accepted method:
auth.user.update(db.auth_user._filter_fields(form.vars)) 

But I'm interested in knowing if it's possible to specify an onvalidation 
method for auth.profile(), while still using the built-in accepts method.

-- 

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


[web2py] add another grid in edit form using sqlform.grid

2013-09-05 Thread 黄祥
hi,

i have a table invoice_header and invoice_detail, and i want to add 
invoice_detail grid in the invoice_header edit page.
actually i want to combile what i see in web2pyslices
http://www.web2pyslices.com/slice/show/1627/simple-online-invoices-with-invoice2py
with
http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-form
but my problem is i don't know how to add another grid in edit form using 
sqlform.grid
is there any way to achieve this?

many thanks and best regards,
stifan

-- 

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


Re: [web2py] Invalid request with special chars in URL

2013-09-05 Thread Wonton
Arrgh! I must be missing something, I'm very sorry :-(.

I've tried this:

- No changes. The site is working correctly except for the special chars.
- I've created in web2py root directory the routes.py file with this 
content:

routes_apps_raw=['myapp']

-I've restarted web2py.
- My app is not working anymore. All request are getting an "invalid 
request" error.
- I've edited routes.py, now it contains:

#!/usr/bin/python
# -*- coding: utf-8 -*-
routes_apps_raw=['myapp']

-I've restarted web2py.
- My app is not working yet, all request are invalid.
-I've deleted routes.py file.
-I've restarted web2py.
-My app is working correctly except for the special chars.

So, I'm sure I'm doing anythong very wrong. Besides creating the routes.py 
file, should I change any other thing in my controllers?

Thank you very much again!

On Thursday, September 5, 2013 4:45:11 PM UTC+2, Jonathan Lundell wrote:
>
> On 5 Sep 2013, at 12:11 AM, Wonton > 
> wrote:
>
> Hello Marcio,
>
> First of all, thank you so much for your answer, I haven thought on that 
> possibility and it's very interesting.
>
> However, I have a huge number of services and I often test them manually, 
> so I would like to maintain the URLs as readable as possible. I would like 
> to try first with the routes.py solution, disabling the args validation for 
> my app. But I will keep in mind your solution.
>
>
> Did you restart web2py after changing routes.py? routes_apps_raw ought to 
> do what you want.
>
> When your app is in the routes_apps_raw list, your args string (eg 
> 'json/public_function/...') is in request.raw_args (as usual) and 
> request.args is None. It's then the responsibility of your app (and you can 
> do this in your model if you like) to validate and parse request.raw_args, 
> and (if you want to) put the results in request.args as a List() object.
>
> Putting routes.py in the wrong place (it should be in the web2py root) or 
> changing it without restarting is the most common reason for trouble with 
> routes.py.
>
> (As an alternative you can use the parametric router and specify your own 
> validation regex for args: args_match.)
>
>
> Kind regards!
>
> On Thursday, September 5, 2013 3:50:17 AM UTC+2, Marcio Andrey Oliveira 
> wrote:
>>
>> Can't you send encoded parameters (say in Bas64 or hexadecimal) and 
>> decode them inside the methods?
>>
>> Regards.
>>
>> On Wednesday, September 4, 2013 8:24:26 PM UTC-3, Wonton wrote:
>>>
>>> Hello everyone!
>>>
>>> I've developed a web2py backend which is given me problems with special 
>>> chars in URLs. I'm a newbie with web2py so maybe I'm missing something very 
>>> easy, sorry if that is the case ;-).
>>>
>>> These are the details of my app.
>>>
>>> - I have no routes.py file.
>>>
>>> - In controllers/default.py I have this:
>>>
>>>
>>> ...
>>> public_services=Service()
>>> private_services=Service()
>>> ...
>>> def public_call(): 
>>> return public_services()
>>>
>>> @auth.requires_login()
>>> def private_call(): 
>>> return private_services()
>>> ...
>>> @public_services.json
>>> def public_function_1(var1, var2, var3):
>>> ...
>>> @private_services.json
>>> def private_function_1(var1, var2):
>>> ...
>>>
>>>
>>> - I call these methods this way:
>>>
>>> http://mydomain/myapp/default/public_call/json/
>>> public_function_1/var1/var2/var3
>>> http://mydomain/myapp/default/private_call/json/
>>> private_function_1/var1/var2
>>>
>>> - Everything is working except if my URL contains special chars, (var1, 
>>> var2 or var3 can contain 'ñ' or accents, coded with %...) then I get an 
>>> "invalid request" error.
>>>
>>> - After reading all posts related to this issue I'm a bit lost, sorry. 
>>> I've tried to create a routes.py and the only line inside it is this:
>>> routes_apps_raw=['myapp']
>>>
>>> But obviously this is not enough because I have the same problem yet.
>>>
>>> Besides this, I don't understand the "request.raw_args" thing, am I 
>>> supposed to do anything with that? I can't see any request.raw_args in my 
>>> code.
>>>
>>> Thank you very much and kind regards!
>>>
>>>
> -- 
>  
>
>
>
>
>

-- 

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


Re: [web2py] Re: Grid takes an awful long time to show result.

2013-09-05 Thread Anthony


> SELECT  rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id 
>
> FROM rresearch 
> WHERE (rresearch.id IS NOT NULL) 
> ORDER BY rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id;
>
> 2920.90ms
>
>
The above query is not used for the grid. Rather, it is used to generate a 
dropdown list for the db.isi_alt_countrynames.rsc_id field in the grid's 
search widget. The db.isi_alt_countrynames.rsc_id is a reference field that 
references db.rresearch, so it gets a default IS_IN_DB(db, 'rresearch.id', 
...) validator. In forms (including the grid search widget), that validator 
results in a  widget with an option for each item in 
db.rresearch.id (note, you won't see the select widget unless you first 
click in the grid's search box and then select the "rsc_id" field). Not 
only does the query take a long time to run and parse, but it also takes a 
long time to generate the  widget with all the options and send the 
HTML to the browser.

In general, if you create a reference field that references a table with a 
large number of records, you should avoid the default  widget for 
that field. You can do this by putting the validator in a list, which will 
prevent the  from being created:

db.isi_alt_countrynames.rsc_id.requires = [db.isi_alt_countrynames.rsc_id.
requires]

  

>
> and then one query for each of the rows in the result of the previous query 
> like this 
> (taking between 0.44ms and 0.72ms each):
>
>
>
> SELECT  rresearch.id, rresearch.cn, rresearch.nf, rresearch.nc, 
>
> rresearch.nd, rresearch.nn, rresearch.ny, rresearch.np, rresearch.nu, 
> rresearch.nz, rresearch.uuid 
> FROM rresearch WHERE (rresearch.id = 642117) LIMIT 1 OFFSET 0;
>
> 0.50ms
>

I think the above queries are due to an unnecessary select in the 
"represent" attribute of db.rresearch.id:

vars = dict(country = str(db.rresearch[id].nu))

Note, above, there is no reason to do db.rresearch[id].nu, which results in 
a select. Instead, just do:

vars = dict(country = str(row.nu))

Anthony

-- 

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


[web2py] Re: Is it possible to generate a file containing the update for book 4th to 5th?

2013-09-05 Thread Niphlod


>
> BTW: Another enhancement request: would it be possible to display changes 
> ordered by date/time?
>

I completely missed this post, sorry. Now its correctly ordered ^_^ 

-- 

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


Re: [web2py] LDAP with username=True can still login with email

2013-09-05 Thread Camille Roussel
Please excuse my ignorance on this as I am brand new to programming and 
web2py. For this issue what necessitates the need to store the bare 
username instead of potentially storing the full email or UPN? I know in 
our environment the sAMAccountName is not necessarily unique across the 
forest but the UPN is. In intial testing I have commented out line 255 from 
ldap_auth.py to resolve this issue but I am not sure what the full 
implications of that are elsewhere in the Auth module.

On Thursday, August 22, 2013 1:16:48 PM UTC-4, Massimo Di Pierro wrote:
>
> i agree
>
> On Thursday, 22 August 2013 11:16:20 UTC-5, Richard wrote:
>>
>> Hello,
>>
>> I just push these change in production, then face some exception... Some 
>> of our users have email as username some don't... So the fix I found is not 
>> the proper solution... I think we will have to improve ldap_auth logic to 
>> get out of the mud with this... I will look throught this a bit more see 
>> what I can come up with. What ldap_auth should do is to check user 
>> credentials, if the user log with email but he already have a user with the 
>> same username and password it should use this user instead of creating a 
>> new user with email as username and missing first_name and many other field 
>> empty...
>>
>> Richard
>>
>>
>> On Wed, Aug 21, 2013 at 9:34 AM, Richard Vézina wrote:
>>
>>> No problem, thank for the follow...
>>>
>>> Richard
>>>
>>>
>>> On Wed, Aug 21, 2013 at 4:51 AM, Massimo Di Pierro <
>>> massimo@gmail.com> wrote:
>>>
 I have not forgotten. I opened issue 1645.


 On Tuesday, 13 August 2013 15:13:30 UTC-5, Richard wrote:

> Massimo,
>
> If you are concern about possible backward compatibility issue that 
> this change could raise... Maybe we could find a way to let the ldap_auth 
> return validator error to form (to user)... I could live with that too... 
> I 
> just didn't find a easy way to make it works from ldap_auth (mean a lot 
> of 
> refactoring could be required and I don't want to screw up ldap_auth for 
> others, I am not equiped to test it properly over different ldap 
> implementation). I just have to change a single line in tools.py + add a 
> IS_NOT_EMAIL() validator, that was the easiest...
>
> :)
>
> Richard
>
>
> On Tue, Aug 13, 2013 at 10:19 AM, Richard Vézina <
> ml.richa...@gmail.com> wrote:
>
>> No problem!
>>
>> As long as there is a solution in the next version I will be happy... 
>> Curious to know what is bugging you though, adding a new validator? 
>> Maybe 
>> the IS_MAIL() could be hack in order that it usage could be reversed, 
>> something like this : IS_MAIL(..., complement=True), then it will return 
>> true if the string is not a email... So don't need a new validator.
>>  
>> Richard
>>
>>  
>>
>>
>> On Tue, Aug 13, 2013 at 10:04 AM, Massimo Di Pierro <
>> massimo@gmail.com> wrote:
>>
>>> I need to review this. I understand the problem but I am not 
>>> convinced by the solution. I will need one week.
>>>
>>>
>>> On Monday, 12 August 2013 08:46:31 UTC-5, Richard wrote:
>>>
 UP!



 On Fri, Aug 9, 2013 at 10:59 AM, Richard Vézina <
 ml.richa...@gmail.com> wrote:

> Here the patch!!
>
> I have not been able to use the IS_NOT_EMAIL() validator from 
> validators.py didn't understand how validators are import in 
> tools.py...
>
> NOTE :
> About my precedent mail... the "auth_table.username.requires = 
> IS_NOT_IN_DB(db, auth_table.username" from the book is not require if 
> the 
> user use the "auth.define_tables(username=**T**rue)" and the 
> recommended auth_tables customization mechanism. So, I think the book 
> should be revised this way :
>
> "In case you use old style customizing auth_tables. Make sure your 
> username field definition looks like that :
>  Field('username', 'string',
>   notnull=True,
>   required=True,
>requires=[IS_NOT_EMPTY(error_**m**
> essage=T(auth.messages.is_**empt**y)),
> IS_NOT_IN_DB(db, 'auth_user.username'), 
> IS_NOT_EMAIL()]
>   ),
>  
> Where you make sure you use these validators in order to make sure 
> email is not used as username and there is no duplicated username in 
> your 
> auth_user table."
>
> :)
>  
> Richard
>
>
>
>
> On Wed, Aug 7, 2013 at 1:48 PM, Richard Vézina <
> ml.richa...@gmail.com> wrote:
>
>> I would also add this :
>>
>> tmpvalidator = 
>> [IS_NOT_EMPTY(error_message=self.mes

[web2py] SQLFORM.factory field's type and default properties are not working as expected

2013-09-05 Thread Gliese 581 g
Hi,
 
I have a cutom form which I am displaying using SQLFORM.factory as given 
below:
 
searchform=SQLFORM.factory(
Field('uid', 'integer', requires=[IS_LENGTH(15,15)]),
Field('uaccount','unicode',default=None))
if searchform.accepts(request.vars):
result=__get_payments()
else:
response.flash = 'please fill the form' 
return dict(form=searchform)
 
I have 2 questions here which are given as follows:
 
1. I want *uid* must be an integer and form should not be accepted 
if string value is supplied.
But even if I enter string value in uid field, it still accepts the 
form.What do I do to achieve this?
 
2. If *uaccount *is not supplied, I want it to be None. But when I try to 
access it using request.vars.uaccount, I get empty string value. I think I 
should rather get None value. Please suggest.
 
Thank you.
 

-- 

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


[web2py] Re: SQLFORM.factory field's type and default properties are not working as expected

2013-09-05 Thread Niphlod


On Thursday, September 5, 2013 11:04:53 AM UTC+2, Gliese 581 g wrote:
>
> Hi,
>  
> I have a cutom form which I am displaying using SQLFORM.factory as given 
> below:
>  
> searchform=SQLFORM.factory(
> Field('uid', 'integer', requires=[IS_LENGTH(15,15)]),
> Field('uaccount','unicode',default=None))
> if searchform.accepts(request.vars):
> result=__get_payments()
> else:
> response.flash = 'please fill the form' 
> return dict(form=searchform)
>  
> I have 2 questions here which are given as follows:
>  
> 1. I want *uid* must be an integer and form should not be accepted 
> if string value is supplied.
> But even if I enter string value in uid field, it still accepts the 
> form.What do I do to achieve this?
>

Setting requires=IS_LENGTH() "killed" the IS_INT_IN_RANGE() default 
validator for integers. 
 

>  
> 2. If *uaccount *is not supplied, I want it to be None. But when I try to 
> access it using request.vars.uaccount, I get empty string value. I think I 
> should rather get None value. Please suggest.
>  
>

If you want a request.vars.something to be None, it should not exist in the 
list of the sent values (meaning, it shouldn't be included as an input in 
the form). In HTML there's no such thing as "Null" for an input value, you 
get the closest representation of that with an empty field, that gets sent 
with a value of '' . Use your own logic if you want "None" when the user 
leaves out the field.
 

> Thank you.
>  
>

-- 

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


[web2py] Odd behavior IS_UPPER()

2013-09-05 Thread greenpoise
I was tweaking my tables to change the INPUT to upper case. All the fields 
that I changed it to, worked except for one field. It has this:

Field('seriesname',requires=IS_UPPER())



and then at the end of the table it has this:


db.series.seriesname.requires = IS_NOT_IN_DB(db,db.series.seriesname)



If I remove the second one, IS_UPPER() works..if I have both, IS_UPPER() 
does not work. Very strange and it only happens with this table and field. 
I have IS_UPPER in more than 6 fields on different tables and they all 
work. Strange isnt?





-- 

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


[web2py] Re: Odd behavior IS_UPPER()

2013-09-05 Thread greenpoise
:)   thanks!



On Thursday, September 5, 2013 1:25:27 PM UTC-7, Niphlod wrote:
>
> what did you expect ? you are overwriting the requires attribute. requires 
> either takes a single validator or a list of them: just append to requires 
> instead of reassigning ^_^
>
> On Thursday, September 5, 2013 10:21:48 PM UTC+2, greenpoise wrote:
>>
>> I was tweaking my tables to change the INPUT to upper case. All the 
>> fields that I changed it to, worked except for one field. It has this:
>>
>> Field('seriesname',requires=IS_UPPER())
>>
>>
>>
>> and then at the end of the table it has this:
>>
>>
>> db.series.seriesname.requires = IS_NOT_IN_DB(db,db.series.seriesname)
>>
>>
>>
>> If I remove the second one, IS_UPPER() works..if I have both, IS_UPPER() 
>> does not work. Very strange and it only happens with this table and field. 
>> I have IS_UPPER in more than 6 fields on different tables and they all 
>> work. Strange isnt?
>>
>>
>>
>>
>>
>>

-- 

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


[web2py] Re: Odd behavior IS_UPPER()

2013-09-05 Thread Niphlod
what did you expect ? you are overwriting the requires attribute. requires 
either takes a single validator or a list of them: just append to requires 
instead of reassigning ^_^

On Thursday, September 5, 2013 10:21:48 PM UTC+2, greenpoise wrote:
>
> I was tweaking my tables to change the INPUT to upper case. All the fields 
> that I changed it to, worked except for one field. It has this:
>
> Field('seriesname',requires=IS_UPPER())
>
>
>
> and then at the end of the table it has this:
>
>
> db.series.seriesname.requires = IS_NOT_IN_DB(db,db.series.seriesname)
>
>
>
> If I remove the second one, IS_UPPER() works..if I have both, IS_UPPER() 
> does not work. Very strange and it only happens with this table and field. 
> I have IS_UPPER in more than 6 fields on different tables and they all 
> work. Strange isnt?
>
>
>
>
>
>

-- 

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


[web2py] Re: scheduler - Get task id for current task

2013-09-05 Thread Niphlod
whoopsie, sorry: I thought that was documented :D 
/me takes a note and adds to the todo-list 

On Thursday, September 5, 2013 12:46:39 PM UTC+2, Manoj Kumar M wrote:
>
> Well, after some digging into source code I found the solution. In 
> gluon/scheduler.py,
>
> def executor(queue, task, out):
>  W2P_TASK = Storage({'id' : task.task_id, 'uuid' : task.uuid})
> _env.update({'W2P_TASK' : W2P_TASK})
>
> W2P_TASK is an environment variable. So, to get the task id,
>
> task_id = W2P_TASK.id
>
>
> On Thursday, 29 August 2013 19:14:25 UTC+5:30, Manoj Kumar M wrote:
>>
>> Is it possible to get the task id of the current task from within the 
>> task?
>>
>> for example:
>> def task_add(a,b):
>> task_id = scheduler.my_id() # get current task id
>> return a+b
>>
>> scheduler = Scheduler(db, tasks=dict(demo1=task_add))
>>
>> scheduler.queue_task('demo1', pvars=dict(a=1,b=2),
>>  repeats = 0, period = 180)
>>
>

-- 

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


[web2py] how to create and or alter a rows object on the fly

2013-09-05 Thread keiser1080

Hi,

I need to use a smartgrid to show a mix of data comming from multiple 
source like database and webservices,
because it's very easy to search, filter ect... a smartgrid.

In my application i will first query my database, and then for each row i 
will query a a service and add some colums.

It is possible to  create and or alter a rows object on the fly ?

-- 

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


[web2py] Re: understanding problem - use models or classes?

2013-09-05 Thread Niphlod
let's take a different POV: even if you work with classes, where should you 
store your "objects", and with what ?
web2py ships with DAL that is not an ORM like in other frameworks. The 
"classes" paradigm can be adopted too but it's usually an extra step that 
can be beneficial only in huge apps with lots of business logic. If in the 
end you're going to store your "objects" in a table using DAL, you're just 
back to square one ^_^

On Thursday, September 5, 2013 9:30:38 AM UTC+2, Andreas Wienes wrote:
>
> Hello,
>
> I'm new to web2py and python and currently try to build a small 
> application just for learning purposes. Now I struggle because I don't know 
> if my solution is the right way doing it.
>
> I got three models called project, project_type and steps.
>
> A project belongs to a certain project_type and depending on what kind of 
> project it is, includes different steps. For example "writing a book" is a 
> project and belongs to the project_type "hobby project".
>  
> "making a plan", "do it" and "get feedback" are steps for a "hobby 
> project".  So the project "writing a book" should contain this steps.
>
> Is it correct to create three tables, one for each model, and work with 
> database reference or is this completly wrong and instead I should work 
> with classes?
>
> Sorry for the silly question, but I'm just a noob trying to code 
> something. ;-)
>
> This is my current database definition:
>
> db.define_table('project_type',
> Field('title', notnull=True, unique=True),
> Field('description', 'text', notnull=True),
> format='%(title)s')
>
> db.define_table('project',
> Field('name', notnull=True),
> Field('description', 'text', notnull=True),
> Field('project_type', db.project_type, notnull=True),
> format='%(name)s')
>
> db.define_table('step',
> Field('title',  notnull=True, unique=True),
> Field('description', 'text', notnull=True),
> Field('project_id', db.project),
> format='%(title)s')
>
>
> db.define_table('project_type_with_steps',
> Field('type_id', db.project_type),
> Field('step_id', db.step))
>
>
>
>
> All the best
> Andreas
>
>

-- 

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


[web2py] glyphicon fonts served as text/html

2013-09-05 Thread k0aun9
I'm trying to come up with my own layout.html

Instead of using web2py_bootstrap.css, I'm using the bootstrap.css (3.0) 
because I want to learn how things were built up and the differences.
I uploaded the glyphicon fonts and svg etc (which comes with bootstrap 
dist) to /[myapp]/static/fonts/ 

In the bootstrap.css,

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') 
format('embedded-opentype'), 
url('../fonts/glyphicons-halflings-regular.woff') format('woff'), 
url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') 
format('svg');
}

I'm seeing squares instead of icons. From the Chrome Developer Tools, I 
noticed that they're served as 'text/html' and getting HTTP 404.







Am I doing something wrong?


-- 

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


[web2py] Re: glyphicon fonts served as text/html

2013-09-05 Thread k0aun9
Oh, I found the problem. When I uploaded the files, all the hyphens in the 
file names were converted to underscores automatically.

Is it by design or bug?

On Friday, September 6, 2013 1:44:08 AM UTC+8, k0aun9 wrote:
>
> I'm trying to come up with my own layout.html
>
> Instead of using web2py_bootstrap.css, I'm using the bootstrap.css (3.0) 
> because I want to learn how things were built up and the differences.
> I uploaded the glyphicon fonts and svg etc (which comes with bootstrap 
> dist) to /[myapp]/static/fonts/ 
>
> In the bootstrap.css,
>
> @font-face {
>   font-family: 'Glyphicons Halflings';
>   src: url('../fonts/glyphicons-halflings-regular.eot');
>   src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') 
> format('embedded-opentype'), 
> url('../fonts/glyphicons-halflings-regular.woff') format('woff'), 
> url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
> url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') 
> format('svg');
> }
>
> I'm seeing squares instead of icons. From the Chrome Developer Tools, I 
> noticed that they're served as 'text/html' and getting HTTP 404.
>
>
>
> 
>
>
> 
>
>
> Am I doing something wrong?
>
>
>

-- 

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


[web2py] Re: SQLFORM.factory requires explicit uploadfolder

2013-09-05 Thread Alan Etkin
> In that case, how will you determine the absolute folder path?

It seems there's no way, unless the field class reads request.folder which 
will be not always available.

-- 

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


[web2py] understanding problem - use models or classes?

2013-09-05 Thread Andreas Wienes
Hello,

I'm new to web2py and python and currently try to build a small application 
just for learning purposes. Now I struggle because I don't know if my 
solution is the right way doing it.

I got three models called project, project_type and steps.

A project belongs to a certain project_type and depending on what kind of 
project it is, includes different steps. For example "writing a book" is a 
project and belongs to the project_type "hobby project".
 
"making a plan", "do it" and "get feedback" are steps for a "hobby 
project".  So the project "writing a book" should contain this steps.

Is it correct to create three tables, one for each model, and work with 
database reference or is this completly wrong and instead I should work 
with classes?

Sorry for the silly question, but I'm just a noob trying to code something. 
;-)

This is my current database definition:

db.define_table('project_type',
Field('title', notnull=True, unique=True),
Field('description', 'text', notnull=True),
format='%(title)s')

db.define_table('project',
Field('name', notnull=True),
Field('description', 'text', notnull=True),
Field('project_type', db.project_type, notnull=True),
format='%(name)s')

db.define_table('step',
Field('title',  notnull=True, unique=True),
Field('description', 'text', notnull=True),
Field('project_id', db.project),
format='%(title)s')


db.define_table('project_type_with_steps',
Field('type_id', db.project_type),
Field('step_id', db.step))




All the best
Andreas

-- 

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


[web2py] CAS consumer as CAS provider

2013-09-05 Thread Imran Ahmed
Can we use one CAS consumer as a CAS provider for other app?

-- 

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


Re: [web2py] Invalid request with special chars in URL

2013-09-05 Thread Jonathan Lundell
On 5 Sep 2013, at 12:11 AM, Wonton  wrote:
> Hello Marcio,
> 
> First of all, thank you so much for your answer, I haven thought on that 
> possibility and it's very interesting.
> 
> However, I have a huge number of services and I often test them manually, so 
> I would like to maintain the URLs as readable as possible. I would like to 
> try first with the routes.py solution, disabling the args validation for my 
> app. But I will keep in mind your solution.

Did you restart web2py after changing routes.py? routes_apps_raw ought to do 
what you want.

When your app is in the routes_apps_raw list, your args string (eg 
'json/public_function/...') is in request.raw_args (as usual) and request.args 
is None. It's then the responsibility of your app (and you can do this in your 
model if you like) to validate and parse request.raw_args, and (if you want to) 
put the results in request.args as a List() object.

Putting routes.py in the wrong place (it should be in the web2py root) or 
changing it without restarting is the most common reason for trouble with 
routes.py.

(As an alternative you can use the parametric router and specify your own 
validation regex for args: args_match.)

> 
> Kind regards!
> 
> On Thursday, September 5, 2013 3:50:17 AM UTC+2, Marcio Andrey Oliveira wrote:
> Can't you send encoded parameters (say in Bas64 or hexadecimal) and decode 
> them inside the methods?
> 
> Regards.
> 
> On Wednesday, September 4, 2013 8:24:26 PM UTC-3, Wonton wrote:
> Hello everyone!
> 
> I've developed a web2py backend which is given me problems with special chars 
> in URLs. I'm a newbie with web2py so maybe I'm missing something very easy, 
> sorry if that is the case ;-).
> 
> These are the details of my app.
> 
> - I have no routes.py file.
> 
> - In controllers/default.py I have this:
> 
> 
> ...
> public_services=Service()
> private_services=Service()
> ...
> def public_call(): 
> return public_services()
> 
> @auth.requires_login()
> def private_call(): 
> return private_services()
> ...
> @public_services.json
> def public_function_1(var1, var2, var3):
> ...
> @private_services.json
> def private_function_1(var1, var2):
> ...
> 
> 
> - I call these methods this way:
> 
> http://mydomain/myapp/default/public_call/json/public_function_1/var1/var2/var3
> http://mydomain/myapp/default/private_call/json/private_function_1/var1/var2
> 
> - Everything is working except if my URL contains special chars, (var1, var2 
> or var3 can contain 'ñ' or accents, coded with %...) then I get an "invalid 
> request" error.
> 
> - After reading all posts related to this issue I'm a bit lost, sorry. I've 
> tried to create a routes.py and the only line inside it is this:
> routes_apps_raw=['myapp']
> 
> But obviously this is not enough because I have the same problem yet.
> 
> Besides this, I don't understand the "request.raw_args" thing, am I supposed 
> to do anything with that? I can't see any request.raw_args in my code.
> 
> Thank you very much and kind regards!
> 
> 
> -- 
>  



-- 

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


Re: [web2py] sqlform.grid query question

2013-09-05 Thread Richard Vézina
Good!

Richard


On Thu, Sep 5, 2013 at 5:55 AM, António Ramos  wrote:

> Bingo!
> having =(count1 % 2* *==* *1)
>
>
> 2013/9/5 António Ramos 
>
>> Going with SQLTABLE i have my rows queried like
>>
>> count1=db.card_logs.id.count()
>>
>> (db.)select(db.trabalhador.nome,db.trabalhador.area,count1,groupby=db.trabalhador.nome,
>> *having =(count1 % 2 = 1)*)
>>
>>
>> the *having* clause is not accepted , how to do it to query only odd
>> counts?
>>
>>
>> I use sqlite!
>>
>>
>>
>>
>> 2013/9/4 Richard Vézina 
>>
>>> Ok, so you need to check against actual time which person are still in...
>>>
>>> If you really just want the persons/users that are still in a give time,
>>> I think you need a group by over user_id... So you could set a limit of 2
>>> records per user and if you have only one and it is a 'check in' stat value
>>> you know this user is still in...
>>>
>>> Though, SQLFORM.grid() doesn't support aggregation (
>>> https://groups.google.com/forum/#!topic/web2py-developers/0pEmptLdND8) since
>>> you pass it a query...
>>>
>>> So, maybe you should think of using the old SQLTABLE or build a custom
>>> table yourself with TABLE() and other helpers provide by web2py...
>>>
>>> First you should try to wrote the SQL query to make sure you can solve
>>> this with a single query, if you can, you may use SQLTABLE if you can't and
>>> have to iter over record your only remaning option will be a custom table I
>>> guess...
>>>
>>> I can help with the SQL if you need help, but I would need a dumy table
>>> with a data sample...
>>>
>>> :)
>>>
>>> Richard
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Sep 4, 2013 at 1:17 PM, António Ramos wrote:
>>>
 If the user checks his rfid tag within 5 minutes of the last check the
 log does not record "check in" or "check out" but "error"


 2013/9/4 António Ramos 

> yes , stat is a string with "chech in" or "check out" i also have a
> timestamp for the check in or check out.
>
> I dont want odd /even hours
>
> I want to know if the user is checked in
>
> I have an RFID app to check in /out outside workers via an rfid tag.
>
> when the user checks firstime, the app records "check in" , after that
> , checking again his rfid tag the app  logs "check out" .
>
> During the day the worker can go out to lunch and checks out, after
> lunck checks in again.
>
>
> so for a user i can have
>
> user a check in   (time...)
> user a check out (time...)
> user a check in (time...)
>
>
> I want to create a grid to show who is inside, so i need a query of
>  odd rfid checks for each user
>
>
>
> 2013/9/4 Richard Vézina 
>
>> Don't understand what you need exactly... Is stat a string type
>> containing 'check in' or 'check out' and you want just odd number of 
>> record
>> or you have an other field with timestamp or something and you want only
>> the odd hours to appear in the grid??
>>
>> Richard
>>
>>
>> On Wed, Sep 4, 2013 at 12:54 PM, António Ramos 
>> wrote:
>>
>>>
>>> hello i  need to use  the sqlform.grid(query,etc...   to show
>>> records
>>>
>>> *my problem*
>>> the query is not just like
>>> ((db.tab1.stat='check in')|(db.tab1.stat='check out'))
>>>
>>>
>>>
>>> i need to query only records that appear with stat='check in' or
>>> 'check out' odd times in tab1 and not even times
>>>
>>>
>>> For example , this should not be in the grid
>>>
>>> user a check in
>>> user a check out
>>> user a check in
>>> user a check out
>>>
>>>
>>> but this should
>>>
>>> user a check in
>>> user a check out
>>> user a check in
>>>
>>>
>>> how do i create a query for this? to use in sqlform.grid(query, 
>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
  --

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

>>>
>>>  --
>>>
>>> ---
>>> You re

[web2py] Re: wizard issue? (db.define_table settings for the "db.auth_user is missing)

2013-09-05 Thread אבי אברמוביץ

Thanks , not sure I understand. In order to add fields, or update fields 
which were created, I need to add this to the wizard.db and edit from 
there? (not all the fields I created with the wizard to that table were 
created.)
auth.define_tables('t_auth_user',
Field('f_user_name', type='string', notnull=True,
  label=T('User Name'
etc"))
?

On Thursday, September 5, 2013 2:18:28 PM UTC+3, אבי אברמוביץ wrote:
>
> Hi,
> I created a new app using the wizard.
> All looks good except for one thing:
> On the models/db.wizard, I don't see the db.define_table settings for the "
> db.auth_user. Should it be somewhere else or should I add it?
>
> Thanks.
>

-- 

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


[web2py] Re: wizard issue? (db.define_table settings for the "db.auth_user is missing)

2013-09-05 Thread Massimo Di Pierro
auth.define_tables() creates all the auth_* tables.

On Thursday, 5 September 2013 06:18:28 UTC-5, אבי אברמוביץ wrote:
>
> Hi,
> I created a new app using the wizard.
> All looks good except for one thing:
> On the models/db.wizard, I don't see the db.define_table settings for the "
> db.auth_user. Should it be somewhere else or should I add it?
>
> Thanks.
>

-- 

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


[web2py] Re: TypeError: %d format: a number is required, not dict

2013-09-05 Thread Massimo Di Pierro
Please try trunk or nightly build. I believe this is fixed.

On Thursday, 5 September 2013 00:42:04 UTC-5, Annet wrote:
>
>
>
> Version 2.5.1-stable+timestamp.2013.06.06.15.39.19
>
>
> Kind regards,
>
> Annet
>

-- 

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


Re: [web2py] Re: Grid takes an awful long time to show result.

2013-09-05 Thread villas
Hi Johann

I think this is related:  
https://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/2SjrZ3AHR1c

Using recursive queries which fetch the whole row (especially with very 
wide rows) is a huge DB hit.

My conclusion is that, ideally, web2py should use joins where necessary.  
However,  a join is only necessary where the foreign key table has a 
specified 'format',  and only the fields included in the 'format' should be 
selected.  All info could then be fetched in one select.  This would be a 
massive performance gain for SQL DBs.  

I guess No-SQL would still have to still work with recursive queries,  but 
their limitations shouldn't penalise the rest of us :)

Anthony's solution in the above mentioned thread goes part way to improving 
the situation,  but unless I misunderstood,  it doesn't deal with 
unnecessary recursion of the entire row.  It almost goes without saying 
that hidden performance hits (of that severity) undermine the value of 
built-in framework features.

In my case,  due to the above,  I rolled my own code which avoided 
recursive queries.  I found the toolbar brilliant for testing my queries!  

D


On Thursday, 5 September 2013 08:08:39 UTC+1, Johann Spies wrote:
>
> On 4 September 2013 15:34, Massimo Di Pierro 
> 
> > wrote:
>
>> Please check with the response.toolbar to see if there is are hidden 
>> recursive queries.
>>
>> Thanks!  I did not use the 'db stats'  function before when debugging and 
> it seems a useful tool!
>
> Interestingly the difference is the following:
>
> When using the grid, there are two queries:
>
> SELECT  rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id 
>
> FROM rresearch 
> WHERE (rresearch.id IS NOT NULL) 
> ORDER BY rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id;
>
> 2920.90ms
>
> SELECT  rresearch.nu, isi_alt_countrynames.code, isi_alt_countrynames.id, 
> rresearch.id 
>
> FROM rresearch, isi_alt_countrynames 
> WHERE (isi_alt_countrynames.rsc_id = rresearch.id) 
> ORDER BY rresearch.id, isi_alt_countrynames.id LIMIT 20 OFFSET 0;
>
> 325.16ms 
> and when using SQLTABLE there are a big one:
>
> SELECT  rresearch.nu, isi_alt_countrynames.code, isi_alt_countrynames.id, 
> rresearch.id
>
> FROM rresearch, isi_alt_countrynames 
> WHERE (isi_alt_countrynames.rsc_id = rresearch.id) 
> ORDER BY rresearch.nu LIMIT 21 OFFSET 0;  
>
> which took 185.42ms
>
> and then one query for each of the rows in the result of the previous query 
> like this 
> (taking between 0.44ms and 0.72ms each):
>
>
>
>
> SELECT  rresearch.id, rresearch.cn, rresearch.nf, rresearch.nc, 
>
> rresearch.nd, rresearch.nn, rresearch.ny, rresearch.np, rresearch.nu, 
> rresearch.nz, rresearch.uuid 
> FROM rresearch WHERE (rresearch.id = 642117) LIMIT 1 OFFSET 0;
>
> 0.50ms
>
> This leaves me with more questions about the efficiency of the translation 
> of the queries to the backend:
>
> *  In the case of the grid it will be totally impracticable to try and 
> load the whole rresearch table when working with table containing 80million 
> records.  Why was this necessary?
> *  In the case of the SQLTABLE why would each of those queries select all 
> the fields in stead of just those necessary in the original query?
>
>
>
> I am beginning to think of bypassing DAL in these queries and go straight 
> to the backend. 
>
> Regards
> Johann
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 

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


[web2py] wizard issue? (db.define_table settings for the "db.auth_user is missing)

2013-09-05 Thread אבי אברמוביץ
Hi,
I created a new app using the wizard.
All looks good except for one thing:
On the models/db.wizard, I don't see the db.define_table settings for the "
db.auth_user. Should it be somewhere else or should I add it?

Thanks.

-- 

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


[web2py] Re: scheduler - Get task id for current task

2013-09-05 Thread Manoj Kumar M


Well, after some digging into source code I found the solution. In 
gluon/scheduler.py,

def executor(queue, task, out):
 W2P_TASK = Storage({'id' : task.task_id, 'uuid' : task.uuid})
_env.update({'W2P_TASK' : W2P_TASK})

W2P_TASK is an environment variable. So, to get the task id,

task_id = W2P_TASK.id


On Thursday, 29 August 2013 19:14:25 UTC+5:30, Manoj Kumar M wrote:
>
> Is it possible to get the task id of the current task from within the task?
>
> for example:
> def task_add(a,b):
> task_id = scheduler.my_id() # get current task id
> return a+b
>
> scheduler = Scheduler(db, tasks=dict(demo1=task_add))
>
> scheduler.queue_task('demo1', pvars=dict(a=1,b=2),
>  repeats = 0, period = 180)
>

-- 

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


Re: [web2py] sqlform.grid query question

2013-09-05 Thread António Ramos
Bingo!
having =(count1 % 2* *==* *1)


2013/9/5 António Ramos 

> Going with SQLTABLE i have my rows queried like
>
> count1=db.card_logs.id.count()
>
> (db.)select(db.trabalhador.nome,db.trabalhador.area,count1,groupby=db.trabalhador.nome,
> *having =(count1 % 2 = 1)*)
>
>
> the *having* clause is not accepted , how to do it to query only odd
> counts?
>
>
> I use sqlite!
>
>
>
>
> 2013/9/4 Richard Vézina 
>
>> Ok, so you need to check against actual time which person are still in...
>>
>> If you really just want the persons/users that are still in a give time,
>> I think you need a group by over user_id... So you could set a limit of 2
>> records per user and if you have only one and it is a 'check in' stat value
>> you know this user is still in...
>>
>> Though, SQLFORM.grid() doesn't support aggregation (
>> https://groups.google.com/forum/#!topic/web2py-developers/0pEmptLdND8) since
>> you pass it a query...
>>
>> So, maybe you should think of using the old SQLTABLE or build a custom
>> table yourself with TABLE() and other helpers provide by web2py...
>>
>> First you should try to wrote the SQL query to make sure you can solve
>> this with a single query, if you can, you may use SQLTABLE if you can't and
>> have to iter over record your only remaning option will be a custom table I
>> guess...
>>
>> I can help with the SQL if you need help, but I would need a dumy table
>> with a data sample...
>>
>> :)
>>
>> Richard
>>
>>
>>
>>
>>
>>
>> On Wed, Sep 4, 2013 at 1:17 PM, António Ramos wrote:
>>
>>> If the user checks his rfid tag within 5 minutes of the last check the
>>> log does not record "check in" or "check out" but "error"
>>>
>>>
>>> 2013/9/4 António Ramos 
>>>
 yes , stat is a string with "chech in" or "check out" i also have a
 timestamp for the check in or check out.

 I dont want odd /even hours

 I want to know if the user is checked in

 I have an RFID app to check in /out outside workers via an rfid tag.

 when the user checks firstime, the app records "check in" , after that
 , checking again his rfid tag the app  logs "check out" .

 During the day the worker can go out to lunch and checks out, after
 lunck checks in again.


 so for a user i can have

 user a check in   (time...)
 user a check out (time...)
 user a check in (time...)


 I want to create a grid to show who is inside, so i need a query of
  odd rfid checks for each user



 2013/9/4 Richard Vézina 

> Don't understand what you need exactly... Is stat a string type
> containing 'check in' or 'check out' and you want just odd number of 
> record
> or you have an other field with timestamp or something and you want only
> the odd hours to appear in the grid??
>
> Richard
>
>
> On Wed, Sep 4, 2013 at 12:54 PM, António Ramos 
> wrote:
>
>>
>> hello i  need to use  the sqlform.grid(query,etc...   to show records
>>
>> *my problem*
>> the query is not just like
>> ((db.tab1.stat='check in')|(db.tab1.stat='check out'))
>>
>>
>>
>> i need to query only records that appear with stat='check in' or
>> 'check out' odd times in tab1 and not even times
>>
>>
>> For example , this should not be in the grid
>>
>> user a check in
>> user a check out
>> user a check in
>> user a check out
>>
>>
>> but this should
>>
>> user a check in
>> user a check out
>> user a check in
>>
>>
>> how do i create a query for this? to use in sqlform.grid(query, 
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>


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

Re: [web2py] sqlform.grid query question

2013-09-05 Thread António Ramos
Going with SQLTABLE i have my rows queried like

count1=db.card_logs.id.count()
(db.)select(db.trabalhador.nome,db.trabalhador.area,count1,groupby=db.trabalhador.nome,
*having =(count1 % 2 = 1)*)


the *having* clause is not accepted , how to do it to query only odd counts?


I use sqlite!




2013/9/4 Richard Vézina 

> Ok, so you need to check against actual time which person are still in...
>
> If you really just want the persons/users that are still in a give time, I
> think you need a group by over user_id... So you could set a limit of 2
> records per user and if you have only one and it is a 'check in' stat value
> you know this user is still in...
>
> Though, SQLFORM.grid() doesn't support aggregation (
> https://groups.google.com/forum/#!topic/web2py-developers/0pEmptLdND8) since
> you pass it a query...
>
> So, maybe you should think of using the old SQLTABLE or build a custom
> table yourself with TABLE() and other helpers provide by web2py...
>
> First you should try to wrote the SQL query to make sure you can solve
> this with a single query, if you can, you may use SQLTABLE if you can't and
> have to iter over record your only remaning option will be a custom table I
> guess...
>
> I can help with the SQL if you need help, but I would need a dumy table
> with a data sample...
>
> :)
>
> Richard
>
>
>
>
>
>
> On Wed, Sep 4, 2013 at 1:17 PM, António Ramos wrote:
>
>> If the user checks his rfid tag within 5 minutes of the last check the
>> log does not record "check in" or "check out" but "error"
>>
>>
>> 2013/9/4 António Ramos 
>>
>>> yes , stat is a string with "chech in" or "check out" i also have a
>>> timestamp for the check in or check out.
>>>
>>> I dont want odd /even hours
>>>
>>> I want to know if the user is checked in
>>>
>>> I have an RFID app to check in /out outside workers via an rfid tag.
>>>
>>> when the user checks firstime, the app records "check in" , after that ,
>>> checking again his rfid tag the app  logs "check out" .
>>>
>>> During the day the worker can go out to lunch and checks out, after
>>> lunck checks in again.
>>>
>>>
>>> so for a user i can have
>>>
>>> user a check in   (time...)
>>> user a check out (time...)
>>> user a check in (time...)
>>>
>>>
>>> I want to create a grid to show who is inside, so i need a query of  odd
>>> rfid checks for each user
>>>
>>>
>>>
>>> 2013/9/4 Richard Vézina 
>>>
 Don't understand what you need exactly... Is stat a string type
 containing 'check in' or 'check out' and you want just odd number of record
 or you have an other field with timestamp or something and you want only
 the odd hours to appear in the grid??

 Richard


 On Wed, Sep 4, 2013 at 12:54 PM, António Ramos wrote:

>
> hello i  need to use  the sqlform.grid(query,etc...   to show records
>
> *my problem*
> the query is not just like
> ((db.tab1.stat='check in')|(db.tab1.stat='check out'))
>
>
>
> i need to query only records that appear with stat='check in' or
> 'check out' odd times in tab1 and not even times
>
>
> For example , this should not be in the grid
>
> user a check in
> user a check out
> user a check in
> user a check out
>
>
> but this should
>
> user a check in
> user a check out
> user a check in
>
>
> how do i create a query for this? to use in sqlform.grid(query, 
>
>  --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

  --

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

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

-- 

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

[web2py] Re: Invalid request with special chars in URL

2013-09-05 Thread Wonton
Hello Marcio,

First of all, thank you so much for your answer, I haven thought on that 
possibility and it's very interesting.

However, I have a huge number of services and I often test them manually, 
so I would like to maintain the URLs as readable as possible. I would like 
to try first with the routes.py solution, disabling the args validation for 
my app. But I will keep in mind your solution.

Kind regards!

On Thursday, September 5, 2013 3:50:17 AM UTC+2, Marcio Andrey Oliveira 
wrote:
>
> Can't you send encoded parameters (say in Bas64 or hexadecimal) and decode 
> them inside the methods?
>
> Regards.
>
> On Wednesday, September 4, 2013 8:24:26 PM UTC-3, Wonton wrote:
>>
>> Hello everyone!
>>
>> I've developed a web2py backend which is given me problems with special 
>> chars in URLs. I'm a newbie with web2py so maybe I'm missing something very 
>> easy, sorry if that is the case ;-).
>>
>> These are the details of my app.
>>
>> - I have no routes.py file.
>>
>> - In controllers/default.py I have this:
>>
>>
>> ...
>> public_services=Service()
>> private_services=Service()
>> ...
>> def public_call(): 
>> return public_services()
>>
>> @auth.requires_login()
>> def private_call(): 
>> return private_services()
>> ...
>> @public_services.json
>> def public_function_1(var1, var2, var3):
>> ...
>> @private_services.json
>> def private_function_1(var1, var2):
>> ...
>>
>>
>> - I call these methods this way:
>>
>> http://mydomain/myapp/default/public_call/json/
>> public_function_1/var1/var2/var3
>> http://mydomain/myapp/default/private_call/json/
>> private_function_1/var1/var2
>>
>> - Everything is working except if my URL contains special chars, (var1, 
>> var2 or var3 can contain 'ñ' or accents, coded with %...) then I get an 
>> "invalid request" error.
>>
>> - After reading all posts related to this issue I'm a bit lost, sorry. 
>> I've tried to create a routes.py and the only line inside it is this:
>> routes_apps_raw=['myapp']
>>
>> But obviously this is not enough because I have the same problem yet.
>>
>> Besides this, I don't understand the "request.raw_args" thing, am I 
>> supposed to do anything with that? I can't see any request.raw_args in my 
>> code.
>>
>> Thank you very much and kind regards!
>>
>>

-- 

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


Re: [web2py] Re: Grid takes an awful long time to show result.

2013-09-05 Thread Johann Spies
On 4 September 2013 15:34, Massimo Di Pierro wrote:

> Please check with the response.toolbar to see if there is are hidden
> recursive queries.
>
> Thanks!  I did not use the 'db stats'  function before when debugging and
it seems a useful tool!

Interestingly the difference is the following:

When using the grid, there are two queries:

SELECT  rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id
FROM rresearch
WHERE (rresearch.id IS NOT NULL)
ORDER BY rresearch.nu, rresearch.ny, rresearch.nc, rresearch.id;

2920.90ms

SELECT  rresearch.nu, isi_alt_countrynames.code,
isi_alt_countrynames.id, rresearch.id
FROM rresearch, isi_alt_countrynames
WHERE (isi_alt_countrynames.rsc_id = rresearch.id)
ORDER BY rresearch.id, isi_alt_countrynames.id LIMIT 20 OFFSET 0;

325.16ms
and when using SQLTABLE there are a big one:

SELECT  rresearch.nu, isi_alt_countrynames.code,
isi_alt_countrynames.id, rresearch.id
FROM rresearch, isi_alt_countrynames
WHERE (isi_alt_countrynames.rsc_id = rresearch.id)
ORDER BY rresearch.nu LIMIT 21 OFFSET 0;

which took 185.42ms

and then one query for each of the rows in the result of the previous
query like this
(taking between 0.44ms and 0.72ms each):



SELECT  rresearch.id, rresearch.cn, rresearch.nf, rresearch.nc,
rresearch.nd, rresearch.nn, rresearch.ny, rresearch.np, rresearch.nu,
rresearch.nz, rresearch.uuid
FROM rresearch WHERE (rresearch.id = 642117) LIMIT 1 OFFSET 0;

0.50ms

This leaves me with more questions about the efficiency of the translation
of the queries to the backend:

*  In the case of the grid it will be totally impracticable to try and load
the whole rresearch table when working with table containing 80million
records.  Why was this necessary?
*  In the case of the SQLTABLE why would each of those queries select all
the fields in stead of just those necessary in the original query?



I am beginning to think of bypassing DAL in these queries and go straight
to the backend.

Regards
Johann

-- 

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