[web2py] Re: Handling OPTIONS request in a web2py RESTful API

2019-11-27 Thread mcamel
I think you have to add code to handle OPTIONS the same way is described in the manual for GET, POST, PUT, DELETE. In my case it worked just adding this: def OPTIONS(*args, **vars): return dict() El viernes, 10 de mayo de 2013, 13:47:05 (UTC+2), Daniel Gonzalez escribió: > >

[web2py] Re: how to validate field that depend on each other in the model rather than form

2015-08-04 Thread mcamel
You are right. I planned to use validator for the "initial" state and then Ajax for "online changes", but it was too messy, so finally i'm using just Ajax. Thanks for the info links but I've written my own solution. Here it is, just in case it helps anyone: Moved db definition code to a model,

[web2py] Re: how to validate field that depend on each other in the model rather than form

2015-08-01 Thread mcamel
Hi Anthony, Thanks for your reply. What i want to acheive is to restrict IS_IN_DB validator depending on the value of another field. It can be done on controllers, but i couldn't do it on model. Here is an example: - We have 2 departments: Letters and Numbers - We have teachers assgined

[web2py] Re: how to validate field that depend on each other in the model rather than form

2015-07-31 Thread mcamel
I'm wondering just the same. How can this be done in model?. Particularly I want to use IS_IN_DB on a referenced field based on a query filtering by the value of another field of the table. I've tried this but didn't work: db.table1.field1.requires = lambda x,row: IS_IN_DB(db(db.table2.field2

[web2py] Re: can we have web2py groups with AD authentication ?

2015-02-13 Thread mcamel
Maybe you can delegate auth to Ldap and use auth.settings.login_onaccept.append(lambda form: my_postlogin_tasks(form. vars.username..)) to set a session variable that enables or disables admin access depending on who the user is. Then you could use auth decorators like @auth.requires(sessi

[web2py] Re: Force authentication to whole app

2015-02-13 Thread mcamel
Cool!. It works perfectlly on controllers files, but causes infinite recursion in auth model file. So if you want to apply it to your whole app, writing it once and in one place, this can be used in auth model, after defining auth: if request.url != auth.settings.login_url: auth.requires_l

[web2py] Re: Force authentication to whole app

2015-02-12 Thread mcamel
I basically agree you. I use auth decorators with my functions. This is just an extra security mechanism, set once in one single place. Then you forget about it. It only has sense in some kind of applications. It could be used instead of auth decorators only in extremelly simple apps where you

[web2py] Force authentication to whole app

2015-02-12 Thread mcamel
Hello, You can use @auth* decorators to force authentication to single functions, but how you can force authentication to your whole application?. I use this, just after defining auth: if not auth.is_logged_in(): # avoid infinite recursion if request.url != auth.settings.login_url:

[web2py] Re: auth_user table referenced table

2015-02-12 Thread mcamel
Hi, It seems wizard is returning id=0 instead of the actual organization id. Try removing the wizard from extra fields to guess more. Just in case, you can try this other syntax: auth.settings.register_onvalidation.append(lambda form: add_organization( form)) Regards. El jueves, 12 de f

Re: [web2py] Re: Please help us test the 2.9.12 binaries

2015-02-05 Thread mcamel
from gluon.dal import Row > > Regards, Martin > > 2015-01-16 21:33 GMT+01:00 mcamel >: > >> Hello, >> >> I make extensive use of DAL functionalities (filter in/out, common >> filter, callbacks...) and everything works fine on my apps with 2.9.12bet

[web2py] Re: Please help us test the 2.9.12 binaries

2015-01-16 Thread mcamel
Hello, I make extensive use of DAL functionalities (filter in/out, common filter, callbacks...) and everything works fine on my apps with 2.9.12beta at Ubuntu, except: from gluon.dal import Row ImportError: cannot import name Row I use it to guess if i'm working with a regular Dal Row or

[web2py] Re: datetime smart query

2014-12-24 Thread mcamel
Iso format like: day_and_time >= "2000-01-01 00:00:00" Must be ISO and UTC regardless you are using (and seeing) localized format and/or timezone (at least just now). Related question: https://groups.google.com/forum/?fromgroups=#!topic/web2py/fDP4mrIFdXg Regards. El martes, 20 de mayo de 201

[web2py] Re: adding html to SQLform.grid

2014-12-24 Thread mcamel
Hi, You can do DOM parsing at web2y level with something like: grid = SQLFORM.grid(...) table = grid.element("table") # or grid[1][0] table.insert(0, TR(LABEL('label1:'), INPUT(_name='_myname', _type= 'text', ))) 0 for the first, -1 for the last... More at http://ww

[web2py] how to use glyphicon

2014-12-24 Thread mcamel
Hi all, I've realized web2py uses 'app/static/images/glyphicons-halflings.png' (and the white version) in a CSS way. For example, the edit button on a grid is rendered to something like: I want to use those icons that way, so i'm begging to write things like: SPAN(_class="icon ok icon-ok gly

[web2py] Re: Datetime Grid Filtering ignores localized format and timezone

2014-12-23 Thread mcamel
h: event.day_and_time >= "2000-01-01 00:00:00" Regards. El martes, 23 de diciembre de 2014 08:35:28 UTC+1, Paolo Valleri escribió: > > Hi, > the issue is here > https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L1830 > can you try to replace that line with th

[web2py] Datetime Grid Filtering ignores localized format and timezone

2014-12-22 Thread mcamel
Hi all, I use frequently spanish localization, so dates are formated like day/month/year. Everything works fine if this is located at languages/es.py: '%Y-%m-%d %H:%M:%S': '%d/%m/%Y %H:%M:%S'. Represents, validators and widgets, follow this rule. But if you try to filter a grid by datetime wi

[web2py] How to deal with legacy data types at Mysql

2014-12-15 Thread mcamel
I mean, you have to access a preexisting database with boolean stored as tinyints, datetime stored as unixtime and so on. You cannot change that. Focusing on booleans, how to make a simple form work? At Mysql Test Instance: CREATE TABLE table1 ( `id` int unsigned NOT NULL AUTO_INCREME

[web2py] Re: Unexpected common filter behavior

2014-11-01 Thread mcamel
Just as a workaround for this common filter issue and for possible hidden similar problems, it could be created a WHERE clause like '1=1' when user does not specify any query at all. It's dirty, but it seems to me it has no side effects. Can we state 'WHERE 1=1' is identical to no WHERE at all?

[web2py] Re: Unexpected common filter behavior

2014-10-31 Thread mcamel
Book has plenty of examples like: db().select(db.person... To encourage people not to code that way they should be changed. Is this the way you encourage? db(db.person).select(db.person... Regards. El viernes, 31 de octubre de 2014 21:12:23 UTC+1, Niphlod escribió: > > +1: never code

[web2py] Re: Unexpected common filter behavior

2014-10-31 Thread mcamel
Ticket opened: https://code.google.com/p/web2py/issues/detail?id=2010 Regards. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message

[web2py] Re: Unexpected common filter behavior

2014-10-31 Thread mcamel
Sorry Leonel, for the sake of brevity i've just started where the book ends. You need to write this before: db.define_table('blog_post', Field('subject'), Field('post_text', 'text'), Field('is_public', 'boolean'), common_filter = lambda query: db.blog_post.is_public==True ) I append now both ful

[web2py] Unexpected common filter behavior

2014-10-31 Thread mcamel
Hi everybody, It seems common filters do nothing is there is no WHERE clause in the SQL. Following book example: db.blog_post.insert(subject='one', post_text=request.utcnow, is_public= True) db.blog_post.insert(subject='two', post_text=request.utcnow, is_public= False) this gives no WHE

[web2py] Re: Internationalization questions

2014-05-20 Thread mcamel
It's linux version. Ticket opened: http://code.google.com/p/web2py/issues/detail?id=1936 By the way, there's a message when you create a ticket at http://code.google.com/p/web2py/issues: "Issue attachment storage quota exceeded." It seems this disable posibility to attach files. I'd wanted

[web2py] Internationalization questions

2014-05-20 Thread mcamel
Hello, It is suppossed, T.is_writable=False, disables automatic writing to languages files. This doesn't seem to work for me (note i do not want to turn off translation completely with T.force(None)). In a controller (tested with Version 2.9.5-trunk+timestamp.2014.05.09.15.41.38): T.is_writab

[web2py] Re: Custom library function

2014-05-08 Thread mcamel
It sounds you are looking for a "module". You can place 'mylibrary.py' at the module folder of your app, and import its functions onto controllers or models, like: from mylibrary import my_custom_function You can add this to a model file to get changes at your modules without restarting web2py

[web2py] Re: after_update callback question

2014-04-04 Thread mcamel
> On Thursday, April 3, 2014 11:53:47 AM UTC-4, mcamel wrote: > >> Sorry, i wanted to say 'model' not 'module'. >> >> I've tried to pass data from a callback in a model to "its" function in a >> controller with 'current', but

[web2py] Re: after_update callback question

2014-04-03 Thread mcamel
for modules and not for models and/or controllers?. I'm sure the callback is called because all works if i replace 'current' with 'request.vars'. Thanks for your time. El jueves, 3 de abril de 2014 17:10:57 UTC+2, Anthony escribió: > > On Thursday, April 3, 2

[web2py] Re: after_update callback question

2014-04-03 Thread mcamel
> Be careful about storing something in request.vars, as some other code may >>> depend on request.vars and end up failing due to it being changed. >>> >> >> Any alternative you can suggest?. Session object seems error prone for >> this because of concurrency... >> > > You could just declare a

[web2py] Re: after_update callback question

2014-04-02 Thread mcamel
Hello, I've tried your suggestion and worked!. At 'before_update' stored old >> values in request.vars using Set object, then at 'after_update' access >> these values and compare to the new ones at f. >> > > Be careful about storing something in request.vars, as some other code may > depend on

[web2py] Re: after_update callback question

2014-04-02 Thread mcamel
d on the Set and store them in an object in the > global environment, and then have _after_update read the records you have > stored. What exactly does your _after_update do? > > Anthony > > On Tuesday, April 1, 2014 9:39:57 AM UTC-4, mcamel wrote: > >> Hello, >> &

[web2py] after_update callback question

2014-04-01 Thread mcamel
Hello, I'm trying to get a solid way of triggering an action, "after" an update, based on the data "before" the update. One approach is building an SQLFORM, inject the old values as hidden fields, validate it and do the update and triggers manually, but then you are limited to use this FORM (i

[web2py] Re: Date format and date picker

2014-03-05 Thread mcamel
Very strange. This works for me at Chromium Version 32.0.1700.107 Ubuntu 12.04: def test_date(): T.force('it') db = DAL('sqlite:memory:') db.define_table('test', Field('d', 'date')) form = SQLFORM(db.test) form.validate() return dict(form=form) At it.py (you can also t

[web2py] Re: SQLFORM.grid pagination and messed up URL

2014-03-03 Thread mcamel
Anthony, Would you mind to make a patch to the manual to clarify this thing?. Actual explanation is quite obscure and i'm not sure to understand completely what it means: the args argument of the grid specifies which request.args should be passed > along and ignored by the object Regards.

[web2py] Re: Date format and date picker

2014-03-03 Thread mcamel
I'm not sure to understand your problem, but just in case it helps: have you tried to use this in your language file: '%Y-%m-%d': '%d/%m/%Y', Default date validator will do inner convertions between both formats, so you'll have no problems with DAL and database backend. Regards. El sábado, 1

[web2py] Re: field inheritance

2014-03-03 Thread mcamel
passed as keyword args (e.g., the > above example changes the field name to "newname"). > > Anthony > > On Friday, February 28, 2014 4:04:59 AM UTC-5, mcamel wrote: >> >> Has field inheritance been implemented?. I'd swear it was, but i cannot >> f

[web2py] Re: field inheritance

2014-02-28 Thread mcamel
Has field inheritance been implemented?. I'd swear it was, but i cannot find it... Now i use dummy tables for this, but i have to define different dummies to get different combinations of names and amount of fields of these types on each table. Regards. El miércoles, 24 de agosto de 2011 17:

[web2py] Changing default datetime widget value in blank field

2014-02-27 Thread mcamel
Hello, Does anoybody knows how to alter the default value of the datetime widget in a blank datetime field?. I think it sets to the actual time in the timezone of the operating system. That's fine almost always, but no when the timezone of the application differs from the one of the system. A

[web2py] Re: Strange 'SQLTABLE linkto' behaviour

2014-02-27 Thread mcamel
Pull request done: https://github.com/mdipierro/web2py-book/pull/175 Thanks!. El miércoles, 26 de febrero de 2014 21:13:01 UTC+1, LightDot escribió: > > > > On Wednesday, February 26, 2014 10:44:21 AM UTC+1, mcamel wrote: >> >> ... >> If you agree you can close

[web2py] Re: Strange 'SQLTABLE linkto' behaviour

2014-02-26 Thread mcamel
Looking at gluon/sqltml.py code i think i realized how 'linkto' works: - is a lambda is passed, it's used to generate the href - if not, a string is concatenated: href = '%s/%s/%s' % (linkto, tablename, r_old) The manual says nothing about expecting a lambda, so i figured out you have

[web2py] Re: Strange 'SQLTABLE linkto' behaviour

2014-02-25 Thread mcamel
Just to point to the same function in order to make an autocontained example. I don't use empty string in my application. Anyway i've tested your suggestion and gives the same result. El martes, 25 de febrero de 2014 18:26:49 UTC+1, Massimo Di Pierro escribió: > > Why are you passing an empty

[web2py] Re: SQLCustomType bug with grids?

2014-02-25 Thread mcamel
Fixed in trunk: http://code.google.com/p/web2py/issues/detail?id=1871 -- 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 yo

[web2py] Re: Strange 'SQLTABLE linkto' behaviour

2014-02-25 Thread mcamel
Ticket opened: http://code.google.com/p/web2py/issues/detail?id=1881 -- 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

[web2py] Strange 'SQLTABLE linkto' behaviour

2014-02-20 Thread mcamel
Hi, I've seen an unexpected 'SQLTABLE linkto' behaviour (both at 2.8.2 and trunk version): In a controller: def sqltablelinkto(): db = DAL('sqlite:memory:') db.define_table('parent',Field('name')) db.parent.insert(name='Parent1') db.parent.insert(name='Parent2') l

[web2py] SQLCustomType bug with grids?

2014-02-12 Thread mcamel
Hi everybody, I've tried to use SQLCustomType with grids but always get this error (2.8.2 version): 'SQLCustomType' object has no attribute 'endswith' It works fine with SQLTABLE (as exposed below) but not with 'grid' neither 'smartgrid'. It also fails with MySQL backend. is there a way to

Re: [web2py] T() lack at welcome application?

2013-10-14 Thread mcamel
Hello, Just want to puntualize that problem 3, happens when you register a new user with Auth, not when you create a new application. Best regards. El lunes, 14 de octubre de 2013 12:09:28 UTC+2, mcamel escribió: > > Wow!, finally the four problems reported have four different >

Re: [web2py] T() lack at welcome application?

2013-10-14 Thread mcamel
in the manual. Best regards. El domingo, 13 de octubre de 2013 21:23:47 UTC+2, mcamel escribió: > > Hello, > > I've explained badly. The problem is in the core of the project (Auth) not > in the welcome application, except share.js that has different > consideration becau

Re: [web2py] T() lack at welcome application?

2013-10-13 Thread mcamel
't forget to update language files after change the app and then add > your translation to the file and update the files. > > If you feel confident you fix that, you can pull request here : > https://github.com/web2py/web2py/tree/master/applications/welcome > > :) > >

[web2py] T() lack at welcome application?

2013-10-11 Thread mcamel
Hello, There are a couple of things not being translated at the Welcome application, even after added to the language file. I think the reason is lack of T() at the code. Observed at: - Share: div at bottom-right to social networks - User Id: at user/impersonate - Group uniquely ass

Re: [web2py] Re: pluralization system problem

2013-09-23 Thread mcamel
El domingo, 22 de septiembre de 2013 12:59:23 UTC+2, dbdeveloper escribió: > > # This rule isn't perfect but covers many cases. Complete rules at > http://www.rae.es/dpd/srv/search?id=Iwao8PGQ8D6QkHPn4i. > construct_plural_form = lambda word, plural_id: (word + > ('es' if w

Re: [web2py] Re: pluralization system problem

2013-09-21 Thread mcamel
Ok. I did so and worked fine. I supposed words needed to be included in translation file once, but in fact, expressions including words has to be included also in the dictionary as if they were words itself. I propose this to be included in the manual: 1. expressions including words has to

Re: [web2py] pluralization system problem

2013-09-20 Thread mcamel
t;http://code.google.com/p/web2py/issues/detail?id=1684> ?. Thanks. El viernes, 20 de septiembre de 2013 03:33:17 UTC+2, Massimo Di Pierro escribió: > > Can I close the ticket? > > On Thursday, 19 September 2013 15:19:21 UTC-5, mcamel wrote: >> >> It works! >> &g

Re: [web2py] pluralization system problem

2013-09-19 Thread mcamel
It works! Thanks. El jueves, 19 de septiembre de 2013 22:05:31 UTC+2, dbdeveloper escribió: > > Use%%{word(%i)} to avoid printing the number: > > T('%%{object(%i)}', 2, language="es") or T('%%{object(%s)}', 2, > language="es") > -- Resources: - http://web2py.com - http://web2py.com/book

Re: [web2py] Re: pluralization system problem

2013-09-19 Thread mcamel
ct': ['objectos'],} > Please try to replace 'object' with 'objecto'. In plural-*.py must be > native language only. > > Vladyslav Kozlovskyy > > У ср, 2013-09-18 у 16:00 -0700, Massimo Di Pierro пише: > > Can you please open a ticket ab

Re: [web2py] pluralization system problem

2013-09-19 Thread mcamel
lp you. > > With the best regareds, > Vladyslav Kozlovskyy > > > У ср, 2013-09-18 у 12:54 -0700, mcamel пише: > > The second problem happens if you remove %s from index(): return > T('%%{object}', 2, language="es") > > Then you have an error:

[web2py] Re: pluralization system problem

2013-09-19 Thread mcamel
Nothing about pluralization, so i've opened Issue 1684 . El jueves, 19 de septiembre de 2013 12:03:00 UTC+2, LightDot escribió: > > Issues/tickets/bug reports are found here: > > http://code.google.com/p/web2py/issues/list > > Just search if

[web2py] Re: pluralization system problem

2013-09-19 Thread mcamel
Any guide to open a ticket?. Thanks. El jueves, 19 de septiembre de 2013 01:00:16 UTC+2, Massimo Di Pierro escribió: > > Can you please open a ticket about this and we will review it asap? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/

[web2py] pluralization system problem

2013-09-18 Thread mcamel
Hello, I've found two problems with Spanish pluralization. I think the first is a bug and the second is an unexpected behavior. Both happens with 2.51 and 2.6.3. How to repeat: 1. Create a sample app 2. Replace index() at default.py with: return T('%s %%{object}', 2, language="es")

Re: [web2py] Re: Defining stored procedures

2013-08-23 Thread mcamel
Hi, I've read this section on the manual several times ( http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#executesql), but wasn't able to understand its meaning. The reason is that the first three lines are missing, letting the text without the explanation of th

Re: [web2py] Re: DAL and schema

2013-06-28 Thread mcamel
Yes, the word ACROSS clarifies it. Besides, i've got another problem escaping SQL. I want to add this to the SQL sentence: WHERE b.type LIKE 'L''%' E.g. all types beggining with an L and following with an apostrophe. I've escaped the apostrophe writing it twice, but if filter is user input i

Re: [web2py] Re: DAL and schema

2013-06-27 Thread mcamel
Hi, I have the same problem with a legacy MySQL database. We have different Schemas and need to use plenty of JOINs of tables from different Schemas. I've couldn't find any solution for this in the documentation, so the only way i've found is writing the SQL of my own, like in: SELECT b.seria

Re: [web2py] Re: Help me to write SQL query in web2py

2012-08-22 Thread mcamel
Amit, Does it works if you use tbl.created_on.max() inside the select(), instead of max_created_on?. I mean, is it necessary to define max_created_on or just convenient for short. Thanks. On Wednesday, August 22, 2012 8:32:23 AM UTC+2, Amit wrote: > > Hi mcamel, > > Please fi

Re: [web2py] Re: Help me to write SQL query in web2py

2012-08-21 Thread mcamel
Hi Amit, Could you post the final code that works?. Thanks. --

[web2py] Re: Help me to write SQL query in web2py

2012-08-18 Thread mcamel
one who is yet learning. Best regards, mcamel. On Friday, August 17, 2012 4:26:39 PM UTC+2, Massimo Di Pierro wrote: > > You can try this: > > from gluon.dal import Expression > t = db.abc_tbl > max_created_on = t.max() > query = Expression(db,"date_sub(now(), i

[web2py] Re: web2py does not start as windows service

2012-08-17 Thread mcamel
I've just join the group today searching for the answer to the same problem as you. I've read dozens of post and will try some of this: - at the en of this post https://groups.google.com/forum/?fromgroups#!searchin/web2py/service$20windows/web2py/j-NT5gsMasE/SQV3g-kHHp8J[1-25]is describ