Traceback (most recent call last):
File "C:\dev\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
File "C:/dev/web2py/applications/infocenter/models/db.py", line 152, in <module>
format='%(name)s')
File "C:\dev\web2py\gluon\dal.py", line 7047, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "C:\dev\web2py\gluon\dal.py", line 7078, in lazy_define_table
polymodel=polymodel)
File "C:\dev\web2py\gluon\dal.py", line 920, in create_table
fake_migrate=fake_migrate)
File "C:\dev\web2py\gluon\dal.py", line 988, in migrate_table
and not isinstance(table[key].type, SQLCustomType) \
File "C:\dev\web2py\gluon\dal.py", line 7559, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'permissionid'
link = db.define_table('link',
Field('linkId', 'id', readable=False),
Field('name', length=50, required=True, unique=True),
Field('parentLinkId', 'reference link', required=True,
label='Parent Link'),
Field('controller', length=512, required=True),
Field('method', length=512, required=True),
Field('picture', length=512, required=False),
Field('permissionId', db.auth_permission, label='Rqd Permission'),
Field('groupId', db.auth_group, label='Rqd Group'),
Field('description', 'text', required=True),
format='%(name)s')
link = db.define_table('link',
Field('linkId', 'id', readable=False),
Field('name', length=50, required=True, unique=True),
Field('parentLinkId', 'reference link', required=True,
label='Parent Link'),
Field('controller', length=512, required=True),
Field('method', length=512, required=True),
Field('picture', length=512, required=False),
Field('permissionId', db.auth_permission.id, label='Rqd Permission'),
Field('groupId', db.auth_group, label='Rqd Group'),
Field('description', 'text', required=True),
format='%(name)s')Traceback (most recent call last):
File "C:\dev\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
File "C:/dev/web2py/applications/infocenter/models/db.py", line 152, in <module>
format='%(name)s')
File "C:\dev\web2py\gluon\dal.py", line 7047, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "C:\dev\web2py\gluon\dal.py", line 7078, in lazy_define_table
polymodel=polymodel)
File "C:\dev\web2py\gluon\dal.py", line 721, in create_table
elif field_type.startswith('reference'):
File "C:\dev\web2py\gluon\dal.py", line 8122, in startswith
raise SyntaxError, "startswith used with incompatible field type"
SyntaxError: startswith used with incompatible field type
did you turned lazy_tables to True on your db definition?
Bruno Rocha
http://rochacbruno.com.br
mobile
--
--
from gluon.custom_import import track_changes
track_changes()
import icUtil
import infoCenterUtil
import logging
from dateutil.relativedelta import *
from dateutil.parser import *
import datetime
import os
from plugin_suggest_widget import suggest_widget
log = logging.getLogger('InfoCenter')
if len(log.handlers) == 0:
log = icUtil.getLog(loggerName='InfoCenter', level='INFO', echo=True)
if infoCenterUtil.migrate():
db = DAL(infoCenterUtil.getDalString(), bigint_id=True)
else:
db = DAL(infoCenterUtil.getDalString(), migrate=False,
migrate_enabled=False, bigint_id=True)
# by default give a view/generic.extension to all actions from localhost
# none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []
#print request.env.path_info
#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - crud actions
## (more options discussed in gluon/tools.py)
#########################################################################
from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate
mail = Mail() # mailer
auth = Auth(db) # authentication/authorization
crud = Crud(db) # for CRUD helpers using auth
service = Service() # for json, xml, jsonrpc, xmlrpc, amfrpc
plugins = PluginManager()
from gluon.contrib.login_methods.email_auth import email_auth
#auth.settings.login_methods.append((email_auth('smtp.sdfgsdg.com:321, '@sdfgs.com')))
auth.settings.login_methods.append((email_auth('mail.sdfgsd.com:6548, '@sdfg.com')))
mail.settings.server = 'mail.sdfgsd.com:9875 # your SMTP server
mail.settings.sender = 'i...@sdfgs.com' # your email
mail.settings.login = sdfgs:dfgsdg # your credentials or None
auth.settings.hmac_key = 'sha512:9d8d83af-4769-6546-9cf5-e01a163b498d' # before define_tables()
auth_user = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default='', required=True),
Field('last_name', length=128, default='', required=True),
Field('email', length=128, unique=True, required=True),
Field('password', 'password', length=512,
readable=True, writable=True, label='Password'),
Field('registration_key', length=512,
writable=False, readable=False, default=''),
Field('reset_password_key', length=512,
writable=False, readable=False, default=''),
Field('registration_id', length=512,
writable=False, readable=False, default=''),
Field('brillLogon', length=10, default='', label='Brill Logon'),
Field('technician', 'boolean', default=False),
Field('dispatcher', 'boolean', default=False),
Field('lastFirst', compute=lambda u: '%s, %s' % (u['last_name'], u['first_name']), label='Name'),
Field('firstLast', compute=lambda u: '%s %s' % (u['first_name'], u['last_name']), label='Name'),
format='%(last_name)s, %(first_name)s')
auth_user.first_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_user.last_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_user.password.requires = [CRYPT()]
auth_user.email.requires = [IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, auth_user.email),
IS_NOT_EMPTY(error_message=auth.messages.is_empty)]
auth_user.id.readable = False
auth_user._plural = 'Users'
auth.settings.table_user = auth_user
auth.define_tables() # creates all needed tables
auth.settings.mailer = mail # for user email verification
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.messages.verify_email = 'Click on the link http://'+request.env.http_host+URL('default','user',args=['verify_email'])+'/%(key)s to verify your email'
auth.settings.reset_password_requires_verification = True
auth.messages.reset_password = 'Click on the link http://'+request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s to reset your password'
#########################################################################
## If you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, uncomment and customize following
# from gluon.contrib.login_methods.rpx_account import RPXAccount
# auth.settings.actions_disabled = \
# ['register','change_password','request_reset_password']
# auth.settings.login_form = RPXAccount(request, api_key='...',domain='...',
# url = "http://localhost:8000/%s/default/user/login" % request.application)
## other login methods are in gluon/contrib/login_methods
#########################################################################
crud.settings.auth = None # =auth to enforce authorization on crud
#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
## 'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
##
## >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield
#########################################################################
warehouse = db.define_table('warehouse',
Field('warehouseId', 'id'),
Field('warehouseNumber', 'integer', required=True, unique=True, label='Warehouse #'),
Field('name', length=50, required=True, unique=True),
Field('allowPricesToFall', 'boolean', default=False,
label='Allow Prices to Fall'),
Field('hin', length=10),
Field('active', 'boolean', default=True),
format='%(warehouseNumber)s - %(name)s')
warehouse.warehouseNumber.requires = [IS_NOT_EMPTY(error_message=auth.messages.is_empty),
IS_NOT_IN_DB(db, warehouse.warehouseNumber)]
warehouse.name.requires = [IS_NOT_IN_DB(db, warehouse.name),
IS_NOT_EMPTY(error_message=auth.messages.is_empty)]
warehouse._plural = 'Warehouses'
link = db.define_table('link',
Field('linkId', 'id', readable=False),
Field('name', length=50, required=True, unique=True),
Field('parentLinkId', 'reference link', required=True,
label='Parent Link'),
Field('controller', length=512, required=True),
Field('method', length=512, required=True),
Field('picture', length=512, required=False),
Field('permissionId', db.auth_permission, label='Rqd Permission'),
Field('groupId', db.auth_group, label='Rqd Group'),
Field('description', 'text', required=True),
format='%(name)s')
CREATE TABLE link(
linkId BIGINT AUTO_INCREMENT NOT NULL,
NAME VARCHAR(50) UNIQUE,
parentLinkId BIGINT, INDEX parentLinkId__idx (parentLinkId), FOREIGN KEY (parentLinkId) REFERENCES link (id) ON DELETE CASCADE,
controller VARCHAR(255),
method VARCHAR(255),
picture VARCHAR(255),
permissionId BIGINT, INDEX permissionId__idx (permissionId), FOREIGN KEY (permissionId) REFERENCES auth_permission (id) ON DELETE CASCADE,
groupId BIGINT, INDEX groupId__idx (groupId), FOREIGN KEY (groupId) REFERENCES auth_group (id) ON DELETE CASCADE,
description LONGTEXT,
PRIMARY KEY(linkId)
) ENGINE=INNODB CHARACTER SET utf8;
Traceback (most recent call last):
File "C:\dev\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
File "C:/dev/web2py/applications/infocenter/models/db.py", line 152, in <module>
format='%(name)s'
)
File "C:\dev\web2py\gluon\dal.py", line 7052, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "C:\dev\web2py\gluon\dal.py", line 7083, in lazy_define_table
polymodel=polymodel)
File "C:\dev\web2py\gluon\dal.py", line 925, in create_table
fake_migrate=fake_migrate)
File "C:\dev\web2py\gluon\dal.py", line 993, in migrate_table
and not isinstance(table[key].type, SQLCustomType) \
File "C:\dev\web2py\gluon\dal.py", line 7564, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'permissionid'
--