NOTE: This works fine on my local system just not on the live servers and the error message provided is impossible to find out where the problem exists. As Michele says I can debug at the postgres level however if there is an issue with secondary DB in web2py not throwing accurate error messages we should look into it right?
db.py: *# I noticed if something is invalid with this DB as it is the primary db for auth etc... then the system will throw exceptions* advertising_db = DAL('postgres://youadweb:1111@localhost /youad_advertisement') *# However if something is wrong with any secondary DB like for example DB was created however has no tables in it and all tables are set to migrate false, I just get the error I mentioned earlier.* db = DAL('postgres://youadweb:1111@localhost/youad') directory_db = DAL('postgres://youadweb:1111@localhost/youad_directory') from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(advertising_db, hmac_key=Auth.get_or_create_key()) crud, service, plugins = Crud(advertising_db), Service(), PluginManager() advertising_db.define_table( auth.settings.table_user_name, Field('first_name'), Field('last_name'), Field('referral_id'), Field('uad_id'), Field('email', length=128, default=''), Field('address'), Field('country', 'integer'), Field('province', 'integer'), Field('city', 'integer'), Field('postal_code'), Field('phone'), Field('department', notnull=False), Field('employee', 'boolean', default=False), Field('description','text', notnull=False), Field('status', 'boolean', default=True), Field('password', 'password', length=512, readable=False, label='Password'), Field('registration_key', length=512, writable=False, readable=False, default=''), Field('reset_password_key', length=512, writable=False, readable=False, default=''), Field('reset_security_key', length=512, writable=False, readable=False, default=''), Field('registration_id', length=512, writable=False, readable=False, default='') ) custom_auth_table = advertising_db[auth.settings.table_user_name] # get the custom_auth_table custom_auth_table.password.requires = [IS_STRONG(), CRYPT()] custom_auth_table.email.requires = [IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(advertising_db, custom_auth_table.email)] auth.settings.table_user = custom_auth_table auth.define_tables() # defined just for /union/details directory_db.define_table('directory_listing', Field('user_id'), Field('business_name'), Field('address'), Field('postal_code'), Field('country'), Field('province'), Field('city'), Field('location'), Field('website'), Field('phone'), Field('section'), Field('category'), Field('intro', 'text'), Field('accepted', 'boolean', default=False), Field('show_listing','boolean', default=True), Field('uad_union', 'boolean', default=False), Field('created_at', 'datetime', default=request.now), Field('business_id'), migrate = False ) directory_db.define_table('uad_union', Field('directory_listing', 'reference directory_listing'), Field('accepted', 'boolean', default=False), Field('managefee_pc'), Field('rating_results','text'), Field('total_ratings', 'integer', default=0), Field('added_date', 'datetime', default=request.now), Field('valid'), Field('business_id'), Field('business_name'), Field('country'), Field('province'), Field('city'), Field('location'), Field('address'), Field('postal_code'), Field('website'), Field('phone'), Field('fax'), Field('contact_person'), Field('intro'), Field('category'), Field('updated_at', 'datetime', default=request.now), Field('is_listed'), Field('waiting_no'), Field('end_cond'), Field('limit_hours'), Field('limit_views'), Field('total_views', default=0), Field('start_at'), Field('end_at'), Field('user_id'), migrate = False ) controllers/union.py def index(): page='listing' searchKeyword = request.vars.searchKeyword if "searchKeyword" in request.vars else '' searchCategory = request.vars.searchCategory if "searchCategory" in request.vars else 'business_name' categories = [(T('Business Name'), 'business_name'), (T('Accepted'), 'accepted'), (T('Owner ID'), 'user_id')] searchCategoryOptions = [OPTION(option[0], _value=option[1]) for option in categories] # set location box, change location box & form, and receive a tuple, location location = make_location_box(db, session, request, response, T) # make grid ================================================== query = ((directory_db.uad_union.valid==True) & (directory_db.uad_union.country == location['selected_country'])) if int(location['selected_province']) != 0: query &= directory_db.uad_union.province == location['selected_province'] if int(location['selected_city']) != 0: query &= directory_db.uad_union.city == location['selected_city'] if int(location['selected_location']) != 0: query &= directory_db.uad_union.location == location['selected_location'] if searchKeyword=='': query = query elif searchCategory=='business_name': query &= directory_db.uad_union.business_name.like('%'+searchKeyword+'%') elif searchCategory=='accepted': accepted = 'T' if searchKeyword.lower() == 'yes': accepted = 'T' elif searchKeyword.lower() == 'no': accepted = 'F' query &= directory_db.uad_union.accepted==accepted elif searchCategory=='user_id': try: id = "%07d" % int(searchKeyword) except: id = 0 query &= directory_db.uad_union.user_id== str(id) #from datetime import date import datetime directory_db.uad_union.added_date.represent = lambda added_date, r: type(r.added_date) is datetime.datetime and r.added_date.strftime('%Y.%m.%d') or '-' directory_db.uad_union.is_listed.represent = lambda value,r: value==False and SPAN(' ') \ or SPAN(_class="ui-icon ui-icon-check left", _style="margin: -2px 4px 0px 0px;") fields = [ directory_db.uad_union.id, # for the args in links, it should be included in the fields directory_db.uad_union.user_id, directory_db.uad_union.business_name, directory_db.uad_union.phone, directory_db.uad_union.is_listed, directory_db.uad_union.accepted, directory_db.uad_union.added_date ] # these two columns are only for arguments in links, so hide them directory_db.uad_union.id.readable = False default_sort_order = [directory_db.uad_union.business_name] links = [ lambda row: A(T('Details'),_href=URL("union","details",args=[row.id]), _class="gridlink-button details"), lambda row: A(T('Edit'),_href=URL("union","edit_union",args=[row.id], user_signature=False), _class="gridlink-button edit"), lambda row: A(T('DELETE'),_href=URL("union","update_union",args=[ row.id], vars={'type':'D'}, user_signature=True), _class="gridlink-button delete button-delete") ] # make search form ========================================== searchForm=FORM( LABEL(T('Search')), INPUT(_type='text', _name='searchKeyword', _id='search-keyword', _value=searchKeyword, _style="width: 280px;"), LABEL(T('By')), SELECT(searchCategoryOptions, value=searchCategory, _id = "search-category", _name="searchCategory"), INPUT(_type='submit', _class='submit-button search', _value=T('Search')), _action=URL('union','index'), _name='searchForm', _method="GET" ) grid = SQLFORM.grid(query, fields=fields, links=links, orderby=default_sort_order, sortable=True, # , sorter_icons=(' ^ ',' v ') create=False, csv=False, details=False, deletable=False, editable=False, # , selectable=True searchable=False, # , user_signature = True maxtextlength=64, paginate=defVal.PAGENATE, # , showbuttontext=False search_widget='default', formname='myform' ) # make a breadcrumbs ======================================================= return dict( pageTitle=make_page_title(T("Consumer Union"), pageIcon.UNION), pageBreadCrumbs=make_page_breadcrumbs([T('Union')]), page=page, grid=grid, #unionLocation=unionLocationForm, location = location, searchKeyword=searchKeyword, searchCategory=searchCategory, searchForm=searchForm, ) On Fri, Jun 15, 2012 at 7:53 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > can you show us some code? > > > On Friday, 15 June 2012 15:42:02 UTC-5, Bruce Wade wrote: >> >> I have just found if I have a secondary database with no tables and I try >> to use the database I get the following very unclear and very hard to debug >> error: >> >> <class 'psycopg2.InternalError'> current transaction is aborted, commands >> ignored until end of transaction block >> TRACEBACK >> >> 1. >> 2. >> 3. >> 4. >> 5. >> 6. >> 7. >> 8. >> 9. >> 10. >> 11. >> 12. >> 13. >> 14. >> 15. >> 16. >> 17. >> 18. >> 19. >> 20. >> 21. >> 22. >> 23. >> 24. >> 25. >> >> Traceback (most recent call last): >> >> File "/home/developer/projects/yaw/**gluon/restricted.py", line 205, in >> restricted >> >> exec ccode in environment >> File >> "/home/developer/projects/yaw/**applications/advertisement/**controllers/manage_customers.**py" >> >> <https://ad.youadworld.com/admin/edit/advertisement/controllers/manage_customers.py>, >> line 600, in <module> >> >> File "/home/developer/projects/yaw/**gluon/globals.py", line 173, in >> <lambda> >> >> self._caller = lambda f: f() >> >> File "/home/developer/projects/yaw/**gluon/tools.py", line 2575, in f >> >> return action(*a, **b) >> >> File >> "/home/developer/projects/yaw/**applications/advertisement/**controllers/manage_customers.**py" >> >> <https://ad.youadworld.com/admin/edit/advertisement/controllers/manage_customers.py>, >> line 147, in index >> >> formname='myform' >> File "/home/developer/projects/yaw/**gluon/sqlhtml.py", line 1769, in grid >> >> rows = >> dbset.select(left=left,orderby**=orderby,limitby=limitby,*tabl**e_fields) >> >> File "/home/developer/projects/yaw/**gluon/dal.py", line 7578, in select >> >> return adapter.select(self.query,fiel**ds,attributes) >> >> File "/home/developer/projects/yaw/**gluon/dal.py", line 1315, in select >> >> rows = response(sql) >> >> File "/home/developer/projects/yaw/**gluon/dal.py", line 1305, in response >> >> self.execute(sql) >> >> File "/home/developer/projects/yaw/**gluon/dal.py", line 1392, in execute >> >> return self.log_execute(*a, **b) >> >> File "/home/developer/projects/yaw/**gluon/dal.py", line 1386, in >> log_execute >> >> ret = self.cursor.execute(*a, **b) >> InternalError: current transaction is aborted, commands ignored until end of >> transaction block >> >> -- >> -- >> Regards, >> Bruce Wade >> http://ca.linkedin.com/in/**brucelwade<http://ca.linkedin.com/in/brucelwade> >> http://www.wadecybertech.com >> http://www.fittraineronline.**com <http://www.fittraineronline.com> - >> Fitness Personal Trainers Online >> http://www.warplydesigned.com >> >> -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com