Ok thanks that makes things clear.

I am having another issue:

from gluon.dal import Field
from basemodel import BaseModel
from gluon.validators import IS_NOT_EMPTY, IS_NOT_IN_DB
from gluon import current

class Language(BaseModel):
    tablename = "languages"

    def set_properties(self):
        T = current.T

        self.fields = [
            Field('code'),
            Field('language')
        ]

        self.validators = {
            'code': [IS_NOT_EMPTY(), IS_NOT_IN_DB(self.db, 'Language.code')]
        }

        self.lables = {
            'code': T('code'),
            'language': T('Language')
        }

When saving I get the error the table languages does not exist. For the
validator I have tried: 'languages.code', 'Language.code',
self.db.languages.code, self.db.Language.code, self.entity.code. Tried
deleting the database but still same issue.

--
Regards,
Bruce

On Wed, Feb 1, 2012 at 9:37 AM, Bruno Rocha <rochacbr...@gmail.com> wrote:

> You can set visibility and other options, but you cant use
> self.auth.settings.table_user_
> name because at this point self.auth does not exist and it is a circular
> reference given the fact that User class is the base for the creation of
> Auth object in that example.
>
> But, in most cases you will name it "auth_user" so no problem to set it in
> tablename attribute.
>
>
> On Wed, Feb 1, 2012 at 3:12 PM, Bruce Wade <bruce.w...@gmail.com> wrote:
>
>> This is how I originally thought to do it. (Would have posted this last
>> night but code was at the office)
>>
>> class User(BaseAuth):
>>
>>     def set_properties(self):
>>         tablename = self.auth.settings.table_user_name
>>
>>         T = current.T
>>         # take a look in basemodel to see the options allowed here
>>         # self.widgets, self.fields, self.validators etc....
>>         # only extra fields are defined here
>>
>>         self.fields = [
>>             Field('username', length=128, default='0000000', unique=True),
>>             Field('account_id', self.db.user_account),
>>              Field('email', length=128, default=''),
>>             Field('password', 'password', length=512),
>>             Field('security', 'password', length=512),
>>             Field('registration_key', length=512),
>>             Field('reset_password_key', length=512),
>>             Field('reset_security_key', length=512),
>>             Field('registration_id', length=512)
>>         ]
>>
>>         self.visibility = {
>>             "password": (False, False),
>>             "security": (False, False),
>>             "registration_key": (False, False),
>>             "reset_password_key": (False, False),
>>             "reset_security_key": (False, False),
>>             "registration_id": (False, False)
>>         }
>>
>>         self.validators = {
>>             'password': [IS_STRONG(), CRYPT()],
>>             'security': [IS_STRONG(), CRYPT()],
>>             'email':
>> [IS_EMAIL(error_message=self.auth.messages.invalid_email)]
>>         }
>>
>>         self.labels = {
>>             "username": T("Username"),
>>             "email": T("Email"),
>>             "password": T("Your Password"),
>>             "security": T("Security Password")
>>         }
>>
>>         self.auth.settings.table_user = self
>>
>> --
>> Regards,
>> Bruce
>>
>> On Tue, Jan 31, 2012 at 9:33 PM, Bruce Wade <bruce.w...@gmail.com> wrote:
>>
>>> Thanks that will do it, I was close to that exact same approach when I
>>> was playing around today.
>>>
>>> --
>>> Regards,
>>> Bruce
>>>
>>>
>>> On Tue, Jan 31, 2012 at 7:54 PM, Bruno Rocha <rochacbr...@gmail.com>wrote:
>>>
>>>> Hi Bruce,
>>>>
>>>> delete the database if the sample app created one, then replace
>>>> modules/datamodel/user.py with this https://gist.github.com/1714979
>>>>
>>>>
>>>> --
>>>>
>>>> Bruno Rocha
>>>> [http://rochacbruno.com.br]
>>>>
>>>>
>>>
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/brucelwade
>>> http://www.wadecybertech.com
>>> http://www.warplydesigned.com
>>> http://www.fitnessfriendsfinder.com
>>>
>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>
>
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com

Reply via email to