Actually just tested the same problem happens with all datamodels I created
and try to save from using appadmin.
appadmin.py:
from myapp import MyApp
app = MyApp()
auth = app.auth
#from datamodel.post import Post as PostModel
from datamodel.user import UserAccount
from datamodel.dist import Distributor
from datamodel.lang import Language
db = app.db([UserAccount, Distributor, Language])

Traceback (most recent call last):
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
line 204, in restricted
    exec ccode in environment
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/appadmin.py"
<http://127.0.0.1:8000/admin/edit/welcome/controllers/appadmin.py>,
line 444, in <module>
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py",
line 172, in <lambda>
    self._caller = lambda f: f()
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/appadmin.py"
<http://127.0.0.1:8000/admin/edit/welcome/controllers/appadmin.py>,
line 139, in insert
    if form.accepts(request.vars, session):
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/sqlhtml.py",
line 1267, in accepts
    self.vars.id = self.table.insert(**fields)
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py",
line 5597, in insert
    return self._db._adapter.insert(self,self._listify(fields))
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py",
line 914, in insert
    raise e
OperationalError: no such table: user_account


On Wed, Feb 1, 2012 at 10:08 AM, Bruce Wade <[email protected]> wrote:

> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]>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 <[email protected]>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
>



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