Well, I will try to explain myself better, because I'm from Argentina and my english is a mix between what I learned and what I hear in the movies :)
Basically, you've explained it for me. That's exactly what I'm going to do. But, instead of "auth.settings.register_onvalidation.append(...", I'm going to write a database trigger. I should mention that I don't use migrations; instead, I write an sql script that creates the database and the tables exactly in the way I want. That's because the same database is going to be accessed by desktop applications. So, when I define the tables in web2py and set required=True, that works fine with web2py forms. But if I try an insert directly, I can insert null values. And that's just the simple case; I need more complex restrictions (checks, constraints). PostgreSQL is a really great engine, with a lot of options to do that. So, I will create an after insert/update trigger on the auth_user table, and it will do what you explained, but at database level, so it will work when I try to insert or update via web2py or via a desktop application. I hope I be clear :P On 30 dic, 16:46, Marin Pranjic <[email protected]> wrote: > It's all in the book :) > Not sure what do you want to set by trigger. > First solution is to leave first_name and last_name empty. Just don't use > them, don't set them... ignore. > Second is to update those fields when your custom fields are updated. > Thats what i do. I added field 'username'. Field 'last_name' is always > empty, and 'first_name' is equal to 'username'. > Did it because first_name can be useful (auth.navbar uses first_name, > plugin_wiki uses first_name & last_name [i think], etc... i'm too lazy to > edit each one manually :P ). > > You can use: > > def sync_fields(form): > form.vars['first_name'] = form.vars['my_custom_first_name'] > form.vars['last_name'] = form.vars['my_custom_last_name'] > > auth.settings.register_onvalidation.append(sync_fields) > auth.settings.profile_onvalidation.append(sync_fields) > > This works for me. Not sure if that's what you want. > > Marin > > On Thu, Dec 30, 2010 at 8:28 PM, Lisandro <[email protected]>wrote: > > > Thanks for that tip! > > I thought something similar. I said "well, I just have to hide those > > fields, add the fields that I want, and then set the values for the > > hidden fields with a database trigger". As I'm using postgresql, I > > have lot of restrictions at database level, not at the DAL level > > (because required=True doesn't set "not null" to the field). So, I > > will keep the auth_user table as it is, and add the fields with other > > names. The only "problem" with this is that it isn't very elegant > > (values repeated in the database). But it will work. > > > Thanks for the help Marin. > > > On 29 dic, 18:39, Marin Pranjic <[email protected]> wrote: > > > You can "ignore" current first_name or last_name (or both) fields, and > > add > > > other fields, as you like. > > > > Add custom fields, and for current (first_name, last_name) set readable = > > > False and writable = False and just don't use them. > > > > More about customizing: > >http://www.web2py.com/book/default/chapter/08#Customizing-Auth > > > > hope this one helps > > > > Marin > > > > On Wed, Dec 29, 2010 at 9:02 PM, Lisandro > > > <[email protected]>wrote:> > > Thanks for the quickly answer. Though, I really need to rename the > > > > field, this is for keep backward compatibility and standards with an > > > > existing system. > > > > > On 29 dic, 11:03, Marin Pranjic <[email protected]> wrote: > > > > > Hi, > > > > > you can use *label* like described here: > > > >http://www.mail-archive.com/[email protected]/msg28123.html > > > > > > but you can still reference it only by its name ['first_name', > > > > 'last_name']. > > > > > > On Wed, Dec 29, 2010 at 2:44 PM, Lisandro < > > [email protected] > > > > >wrote: > > > > > > > Hi everyone. > > > > > > I'm customizing my authentication and access control system > > (following > > > > > > the instructions from the web2py website and some examples of this > > > > > > group). > > > > > > > I've renamed my auth_user table with the following: > > > > > > auth.settings.table_user_name = 'ciudadanos' > > > > > > > Then I renamed the fields "first_name" and "last_name", defining my > > > > > > custom table. But when I try to insert a record (from database > > > > > > administration interface), I receive an error. > > > > > > > ¿Is it possible to rename fields of auth_user table without having > > to > > > > > > change web2py source code? > > > > > > If it isn't possible, ¿is there a way to set an "alias" for a > > field, > > > > > > so it can be referenced by its name or by its alias? > > > > > > > Thanks in advance. > >

