AttributeError: 'Environment' object has no attribute 'get_db_cnx'

196 views
Skip to first unread message

Mike Dewhirst

unread,
Oct 9, 2017, 4:22:42 AM10/9/17
to Trac Users
How can I deal with this?

There seem to be a number of tickets discussing this error and my
interpretation is it should be fixed in 1.2. However, I have recently
upgraded from 1.0 to 1.2 as indicated below in the Trac version.
However, when I click on the Plugins page Trac 1.0 appears instead of
1.2.2. Maybe that is evidence I did it badly. An earlier thread "[Trac]
Re: multiple projects transition from a single project​" finishing on 28
September covers Ryan's valiant and eventually successful effort to get
me going again a couple of weeks ago.

It is reproducible by clicking [Save changes] at the /General\ tab on
the Preferences page. All the other tabs with [Save changes] work
without error.

It is also reproducible by clicking [Restart] on the Accounts |
Configuration | Password Refresh section (at .../admin/accounts/config)
whether Silently update password hashes ... is ticked or not

It is also reproducible by clicking the Accounts | Users link on the
same page (at .../admin/accounts/config)

I couldn't find the error elsewhere. But in trying things, I did
discover a Custom Fields KeyError: 'width' which I'll now write up in a
separate thread.

I have all the _ADMIN permissions including ACCTMGR_ADMIN,
ACCTMGR_CONFIG_ADMIN and ACCTMGR_USER_ADMIN

Thanks for any hints.

Mike


Oops…

*Trac detected an internal error:*

AttributeError: 'Environment' object has no attribute 'get_db_cnx'

This is probably a local installation issue.


Found a bug in Trac?

If you think this should work and you can reproduce the problem, you
should consider creating a bug report.

Note that the following plugins seem to be involved: TracAccountManager,
TracVote*Please report this issue to the plugin maintainer.*

Before you do that, though, please first try*searching
<http://trac-hacks.org/search?ticket=yes&noquickjump=1&q=AttributeError%3A+%27Environment%27+object+has+no+attribute+%27get_db_cnx%27>for
similar issues*, as it is quite likely that this problem has been
reported before. For questions about installation and configuration of
Trac or its plugins, please try themailing list
<http://trac.edgewall.org/wiki/MailingList>instead of creating a ticket.

Otherwise, pleasea new bug report describing the problem and explain how
to reproduce it.


Python Traceback

Most recent call last:

File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 623, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 206, in dispatch
chosen_handler = self._pre_process_request(req, chosen_handler)
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 431, in _pre_process_request
chosen_handler = filter_.pre_process_request(req, chosen_handler)
File "/usr/local/lib/python2.7/dist-packages/acct_mgr/register.py", line 485, in pre_process_request
EmailCheck(self.env).validate_registration(req)
File "/usr/local/lib/python2.7/dist-packages/acct_mgr/register.py", line 254, in validate_registration
elif email_associated(self.env, email):
File "/usr/local/lib/python2.7/dist-packages/acct_mgr/model.py", line 25, in email_associated
db = _get_db(env, db)
File "/usr/local/lib/python2.7/dist-packages/acct_mgr/model.py", line 292, in _get_db
return db or env.get_db_cnx()

------------------------------------------------------------------------


System Information

Package Version
Trac 1.2.2
Babel 0.9.6
Docutils 0.9.1
Genshi 0.7 (without speedups)
mod_wsgi 4.3.0 (WSGIProcessGroup WSGIApplicationGroup %(GLOBAL))
Pygments 2.1
pysqlite 2.6.0
Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
pytz 2012d
setuptools 36.5.0
SQLite 3.11.0
Subversion 1.9.3 (r1718519)


Installed Plugins

Name Version Location
TracAccountManager <http://trac-hacks.org/wiki/AccountManagerPlugin>
0.4.4 /usr/local/lib/python2.7/dist-packages
<https://trac.climate.com.au/ssds/prefs#frame0>
TracCustomFieldAdmin <http://trac-hacks.org/wiki/CustomFieldAdminPlugin>
0.2.8.post13289
/usr/local/lib/python2.7/dist-packages/TracCustomFieldAdmin-0.2.8_r13289-py2.7.egg

TracVote <https://trac-hacks.org/wiki/VotePlugin> 0.6.0
/usr/local/lib/python2.7/dist-packages
<https://trac.climate.com.au/ssds/prefs#frame0>


Interface Customization

Site templates site.html
Shared templates
Site static resources
Shared static resources

Ryan Ollos

unread,
Oct 9, 2017, 4:28:48 AM10/9/17
to Trac Users
You need to install version 0.5dev of TracAccountManager. Suggested steps:

$ pip uninstall TracAccountManager


- Ryan

David S

unread,
Feb 19, 2018, 1:18:06 PM2/19/18
to Trac Users
Tried:

$ pip uninstall TracAccountManager

But no succuss.

RjOllos

unread,
Feb 19, 2018, 5:31:52 PM2/19/18
to Trac Users


On Monday, February 19, 2018 at 10:18:06 AM UTC-8, David S wrote:
Tried:

$ pip uninstall TracAccountManager

But no succuss.

Repeat the "uninstall" command until it reports "not installed". It's common to have eggs installed for multiple versions if you haven't been using pip previously, since setuptools does not provide an uninstall tool.

- Ryan

David S

unread,
Feb 19, 2018, 11:22:36 PM2/19/18
to Trac Users
Thanks for your quick response! This must be being caused by a different issue, although the error message is the same. The error is occuring while trying to enable the Agilo trac plugin. Maybe it is better to head over to Agilo to fix this?

trac-admin /home/user/Development/TracEnv/TracProject/ upgrade
The upgrade failed. Please fix the issue and try again.
AttributeError: 'Environment' object has no attribute 'get_db_cnx'
Using mysql database connection and a new trac project. Trac is installed in a virtualenv. Trac project installs okay. Then added agilo.* = enable to conf/trac.ini. Finally, running trac-admin upgrade results in the above error.

David S

unread,
Feb 19, 2018, 11:23:21 PM2/19/18
to Trac Users
But yes, multiple uninstalls of TracAccountManager did not prove successful.

Ryan Ollos

unread,
Feb 19, 2018, 11:25:52 PM2/19/18
to trac-...@googlegroups.com


From: David S
Sent: Monday, February 19, 20:23
Subject: Re: [Trac] AttributeError: 'Environment' object has no attribute 'get_db_cnx'
To: Trac Users


But yes, multiple uninstalls of TracAccountManager did not prove successful.

On Monday, February 19, 2018 at 11:22:36 PM UTC-5, David S wrote:
Thanks for your quick response! This must be being caused by a different issue, although the error message is the same. The error is occuring while trying to enable the Agilo trac plugin. Maybe it is better to head over to Agilo to fix this?




Please share the full tracelog from the exception.

Ryan

RjOllos

unread,
Feb 19, 2018, 11:28:18 PM2/19/18
to Trac Users
Please share the full traceback associated with the exception.

Ryan

David S

unread,
Feb 20, 2018, 12:10:22 AM2/20/18
to Trac Users
traceback?

Ryan Ollos

unread,
Feb 20, 2018, 12:17:11 AM2/20/18
to trac-...@googlegroups.com
From: David S
Sent: Monday, February 19, 21:10
Subject: Re: [Trac] AttributeError: 'Environment' object has no attribute 'get_db_cnx'
To: Trac Users


traceback?


Excerpt from log showing error trace.


davids...@gmail.com

unread,
Feb 20, 2018, 12:42:56 AM2/20/18
to trac-...@googlegroups.com
Hm.  Directory ./log is empty. Is it somewhere else?


-----Original message-----
From: Ryan Ollos <rjo...@gmail.com>
To:
"trac-...@googlegroups.com" <trac-...@googlegroups.com>
Sent:
Tue, Feb 20, 2018 05:17:11 GMT+00:00
Subject:
Re: [Trac] AttributeError: 'Environment' object has no attribute 'get_db_cnx'



From: David S
Sent: Monday, February 19, 21:10
Subject: Re: [Trac] AttributeError: 'Environment' object has no attribute 'get_db_cnx'
To: Trac Users


traceback?


Excerpt from log showing error trace.


--
You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/KtuRDCN60us/unsubscribe.
To unsubscribe from this group and all its topics, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

RjOllos

unread,
Feb 20, 2018, 1:22:39 AM2/20/18
to Trac Users
Let's start over. Where did you see the error "AttributeError: 'Environment' object has no attribute 'get_db_cnx'"? If you saw it on page while navigating Trac, please send a screen capture.

- Ryan

David S

unread,
Feb 20, 2018, 1:16:27 PM2/20/18
to Trac Users
Error is occurring on the command line when trying to upgrade the database, after enabling Agilo plug-in in trac.ini (agilo.* = enabled). Trac is installed in a virtualenv. After a new project is created, Agilo installation requires adding to trac.ini. Agilo's docs state only to add "agilo.* = enabled". Adding only this line and running upgrade results in the output: "Database is up to date, no upgrade necessary." This is invalid because elsewhere it is stated that this command ought to produce updates to the database. However, on trac installation for plug-ins, it states to add plug-ins under a section titled "[component]". Adding this section to trac.ini, then adding "agilo.* = enabled" below this, results in the error below:

$ uname -a
Linux localhost.localdomain 4.14.14-200.fc26.x86_64 #1 SMP Fri Jan 19 13:27:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ trac-admin /home/user/Development/TracEnv/TracProject/ upgrade

The upgrade failed. Please fix the issue and try again.
AttributeError: 'Environment' object has no attribute 'get_db_cnx'

Ryan Ollos

unread,
Feb 20, 2018, 1:25:39 PM2/20/18
to Trac Users
On Tue, Feb 20, 2018 at 10:16 AM, David S <davids...@gmail.com> wrote:
Error is occurring on the command line when trying to upgrade the database, after enabling Agilo plug-in in trac.ini (agilo.* = enabled). Trac is installed in a virtualenv. After a new project is created, Agilo installation requires adding to trac.ini. Agilo's docs state only to add "agilo.* = enabled". Adding only this line and running upgrade results in the output: "Database is up to date, no upgrade necessary." This is invalid because elsewhere it is stated that this command ought to produce updates to the database. However, on trac installation for plug-ins, it states to add plug-ins under a section titled "[component]". Adding this section to trac.ini, then adding "agilo.* = enabled" below this, results in the error below:

$ uname -a
Linux localhost.localdomain 4.14.14-200.fc26.x86_64 #1 SMP Fri Jan 19 13:27:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ trac-admin /home/user/Development/TracEnv/TracProject/ upgrade
The upgrade failed. Please fix the issue and try again.
AttributeError: 'Environment' object has no attribute 'get_db_cnx'

I'm pretty sure Agilo doesn't yet support Trac 1.2.

You can get more information on the AttributeError from the log file, which will be at:
 /home/user/Development/TracEnv/TracProject/log/trac.log

In the log file there should be a traceback showing leading up to the exception "AttributeError". The traceback shows where the exception originated, and propagation up the call stack.

- Ryan

David Shumway

unread,
Feb 20, 2018, 1:32:13 PM2/20/18
to trac-...@googlegroups.com
Ah, okay. Oops, did not consider a version issue. Thanks. Will start
over with a trac version compatible with aglio :)
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Trac Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/trac-users/KtuRDCN60us/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> trac-users+...@googlegroups.com
> <mailto:trac-users+...@googlegroups.com>.
> To post to this group, send email to trac-...@googlegroups.com
> <mailto:trac-...@googlegroups.com>.

David S

unread,
Feb 20, 2018, 3:03:08 PM2/20/18
to Trac Users
Okay, it works now. Just to clarify from previous post, in trac.ini it is "[components]" not "[component]". And adding under "[components]" was still necessary before upgrade processed. Thanks again ;)
> To post to this group, send email to trac-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages