Modify

Opened 4 years ago

Closed 4 years ago

#7553 closed defect (fixed)

error with_transaction issue

Reported by: yoheeb@… Owned by: CuriousCurmudgeon
Priority: normal Component: BatchModifyPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

Hi,

I was excited to see batch modify has been improved and ported to 0.12, it's one of my favorite plugins.

Unfortunately it failed on me: details below will update if I find more info:

Python Traceback

Most recent call last:

    * File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 513, in _dispatch_request
      Code fragment:
      Line	
      508	try:
      509	if not env and env_error:
      510	raise HTTPInternalError(env_error)
      511	try:
      512	dispatcher = RequestDispatcher(env)
      513	dispatcher.dispatch(req)
      514	except RequestDone:
      515	pass
      516	resp = req._response or []
      517	 
      518	except HTTPException, e:
      Local variables:
      Name	Value
      dispatcher 	<trac.web.main.RequestDispatcher object at 0x010C4090>
      e 	NameError("global name 'with_transaction' is not defined",)
      env 	<trac.env.Environment object at 0x01452B30>
      env_error 	None
      req 	<Request "POST '/query'">
      resp 	[]
    * File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 200, in dispatch
      Code fragment:
      Line	
      195	if not req.path_info or req.path_info == '/':
      196	chosen_handler = self.default_handler
      197	# pre-process any incoming request, whether a handler
      198	# was found or not
      199	chosen_handler = self._pre_process_request(req,
      200	chosen_handler)
      201	except TracError, e:
      202	raise HTTPInternalError(e)
      203	if not chosen_handler:
      204	if req.path_info.endswith('/'):
      205	# Strip trailing / and redirect
      Local variables:
      Name	Value
      chosen_handler 	<trac.ticket.query.QueryModule object at 0x010C4510>
      chrome 	<trac.web.chrome.Chrome object at 0x010C4950>
      err 	(<type 'exceptions.NameError'>, NameError("global name 'with_transaction' ...
      handler 	<trac.ticket.query.QueryModule object at 0x010C4510>
      req 	<Request "POST '/query'">
      self 	<trac.web.main.RequestDispatcher object at 0x010C4090>
    * File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 346, in _pre_process_request
      Code fragment:
      Line	
      341	req.outcookie['trac_form_token']['secure'] = True
      342	return req.outcookie['trac_form_token'].value
      343	 
      344	def _pre_process_request(self, req, chosen_handler):
      345	for filter_ in self.filters:
      346	chosen_handler = filter_.pre_process_request(req, chosen_handler)
      347	return chosen_handler
      348	 
      349	def _post_process_request(self, req, *args):
      350	nbargs = len(args)
      351	resp = args
      Local variables:
      Name	Value
      chosen_handler 	<trac.ticket.query.QueryModule object at 0x010C4510>
      filter_ 	<batchmod.web_ui.BatchModifyModule object at 0x010C4750>
      req 	<Request "POST '/query'">
      self 	<trac.web.main.RequestDispatcher object at 0x010C4090>
    * File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 68, in pre_process_request
      Code fragment:
      Line	
      63	self.log.debug('BatchModifyModule: executing')
      64	
      65	batch_modifier = BatchModifier(self.fields_as_list,
      66	self.list_separator_regex,
      67	self.list_connector_string)
      68	batch_modifier.process_request(req, self.env, self.log)
      69	# redirect to original Query
      70	# TODO: need better way to fake QueryModule...
      71	req.redirect(req.args.get('query_href'))
      72	return handler
      73	 
      Local variables:
      Name	Value
      batch_modifier 	<batchmod.web_ui.BatchModifier instance at 0x015BC3C8>
      handler 	<trac.ticket.query.QueryModule object at 0x010C4510>
      req 	<Request "POST '/query'">
      self 	<batchmod.web_ui.BatchModifyModule object at 0x010C4750>
    * File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 150, in process_request
      Code fragment:
      Line	
      145	and selectedTickets or selectedTickets.split(',')
      146	if not selectedTickets:
      147	raise TracError, 'No tickets selected'
      148	
      149	self._save_ticket_changes(req, env, log, selectedTickets, tickets,
      150	values, comment, modify_changetime)
      151	 
      152	def _get_new_ticket_values(self, req, env):
      153	"""Pull all of the new values out of the post data."""
      154	values = {}
      155	for field in TicketSystem(env).get_ticket_fields():
      Local variables:
      Name	Value
      comment 	u''
      env 	<trac.env.Environment object at 0x01452B30>
      log 	<logging.Logger instance at 0x0124C788>
      modify_changetime 	False
      req 	<Request "POST '/query'">
      selectedTickets 	[u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13']
      self 	<batchmod.web_ui.BatchModifier instance at 0x015BC3C8>
      tickets 	[u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13']
      values 	{'type': u'HiLevel'}
    * File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 177, in _save_ticket_changes
      Code fragment:
      Line	
      172	if values.has_key('status') and values['status'] is not 'closed':
      173	values['resolution'] = ''
      174	 
      175	def _save_ticket_changes(self, req, env, log, selectedTickets, tickets,
      176	new_values, comment, modify_changetime):
      177	@with_transaction(self.env)
      178	def _implementation(db):
      179	for id in selectedTickets:
      180	if id in tickets:
      181	t = Ticket(env, int(id))
      182	
      Local variables:
      Name	Value
      comment 	u''
      env 	<trac.env.Environment object at 0x01452B30>
      log 	<logging.Logger instance at 0x0124C788>
      modify_changetime 	False
      new_values 	{'type': u'HiLevel'}
      req 	<Request "POST '/query'">
      selectedTickets 	[u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13']
      self 	<batchmod.web_ui.BatchModifier instance at 0x015BC3C8>
      tickets 	[u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13']

File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 513, in _dispatch_request
  dispatcher.dispatch(req)
File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 200, in dispatch
  chosen_handler)
File "C:/usr/bin/Python26/lib/site-packages/trac/web/main.py", line 346, in _pre_process_request
  chosen_handler = filter_.pre_process_request(req, chosen_handler)
File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 68, in pre_process_request
  batch_modifier.process_request(req, self.env, self.log)
File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 150, in process_request
  values, comment, modify_changetime)
File "C:/usr/bin/Python26/lib/site-packages/batchmodify-0.7.0_trac0.12-py2.6.egg/batchmod/web_ui.py", line 177, in _save_ticket_changes
  @with_transaction(self.env)

System Information:

User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8)[[BR]]

Gecko/20100722 Firefox/3.6.8

Trac 0.12
CustomFieldAdmin 0.2.2
FullBlog 0.1.1
Genshi 0.6
pysqlite 2.4.1
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
setuptools 0.6c11
SQLite 3.5.9
jQuery 1.4.2

Enabled Plugins:

batchmodify 0.7.0-trac0.12
estimationtools 0.4
iniadmin 0.2
timingandestimationplugin 0.9.5
tracchildtickets 1.0.2
traccustomfieldadmin 0.2.2
tracfullblogplugin 0.1.1
tractags 0.6
tracwysiwyg 0.12.0.2

Attachments (0)

Change History (11)

comment:1 Changed 4 years ago by CuriousCurmudgeon

(In [8444]) refs #7553

  • Forgot to import with_transaction.

comment:2 Changed 4 years ago by CuriousCurmudgeon

  • Trac Release changed from 0.11 to 0.12

It should work now. Trac 0.12 has a new transaction model and I forgot to import the method.

comment:3 Changed 4 years ago by CuriousCurmudgeon

  • Status changed from new to assigned

comment:4 Changed 4 years ago by CuriousCurmudgeon

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:5 Changed 4 years ago by yoheeb@…

Cool, glad I could help Just what you need more help right?

comment:6 Changed 4 years ago by gregmac

  • Resolution fixed deleted
  • Status changed from closed to reopened

I still have this problem.

2010-08-26 10:31:48,177 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 200, in dispatch
    chosen_handler)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 346, in _pre_process_request
    chosen_handler = filter_.pre_process_request(req, chosen_handler)
  File "build/bdist.linux-i686/egg/batchmod/web_ui.py", line 69, in pre_process_request
    batch_modifier.process_request(req, self.env, self.log)
  File "build/bdist.linux-i686/egg/batchmod/web_ui.py", line 151, in process_request
    values, comment, modify_changetime)
  File "build/bdist.linux-i686/egg/batchmod/web_ui.py", line 178, in _save_ticket_changes
    @with_transaction(self.env)
AttributeError: BatchModifier instance has no attribute 'env'
System Information:

User Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Trac 	0.12
CustomFieldAdmin 	0.2.2
Genshi 	0.6
mod_python 	3.3.1
Pygments 	1.0
pysqlite 	2.4.1
Python 	2.6.4 (r264:75706, Dec 7 2009, 19:02:09) [GCC 4.4.1]
pytz 	2009l
RPC 	1.0.6
setuptools 	0.6c9
SilverCity 	0.9.7
SQLite 	3.6.16
Subversion 	1.6.5 (r38866)
jQuery	1.4.2
Enabled Plugins:
AutocompleteUsers 	0.4.1 	/usr/local/lib/python2.6/dist-packages/AutocompleteUsers-0.4.1-py2.6.egg
BatchModify 	0.7.0-trac0.12 	/usr/local/lib/python2.6/dist-packages/BatchModify-0.7.0_trac0.12-py2.6.egg
BlackMagicTicketTweaks 	0.1 	/usr/local/lib/python2.6/dist-packages/BlackMagicTicketTweaks-0.1-py2.6.egg
ForceComment 	0.1 	/usr/local/lib/python2.6/dist-packages/ForceComment-0.1-py2.6.egg
IniAdmin 	0.2 	/usr/local/lib/python2.6/dist-packages/IniAdmin-0.2-py2.6.egg
NavAdd 	0.1 	/usr/local/lib/python2.6/dist-packages/NavAdd-0.1-py2.6.egg
nevernotifyupdaterplugin 	0.0.5 	/usr/local/lib/python2.6/dist-packages/nevernotifyupdaterplugin-0.0.5-py2.6.egg
PDFRedirector 	0.1 	/usr/local/lib/python2.6/dist-packages/PDFRedirector-0.1-py2.6.egg
TicketGuidelinesPlugin 	0.1-r0 	/usr/local/lib/python2.6/dist-packages/TicketGuidelinesPlugin-0.1_r0-py2.6.egg
ticketvalidator.admin 	N/A 	/usr/local/lib/python2.6/dist-packages/TicketValidator-0.1-py2.6.egg/ticketvalidator/admin.pyc
ticketvalidator.core 	N/A 	/usr/local/lib/python2.6/dist-packages/TicketValidator-0.1-py2.6.egg/ticketvalidator/core.pyc
Tracbacks 	0.1 	/usr/local/lib/python2.6/dist-packages/Tracbacks-0.1-py2.6.egg
TracCustomFieldAdmin 	0.2.2 	/usr/local/lib/python2.6/dist-packages/TracCustomFieldAdmin-0.2.2-py2.6.egg
TracMasterTickets 	3.0.1 	/usr/local/lib/python2.6/dist-packages/TracMasterTickets-3.0.1-py2.6.egg
TracProgressMeterMacro 	0.2 	/usr/local/lib/python2.6/dist-packages/TracProgressMeterMacro-0.2-py2.6.egg
TracTags 	0.6 	/usr/local/lib/python2.6/dist-packages/TracTags-0.6-py2.6.egg
TracTicketChange 	0.0.4 	/usr/local/lib/python2.6/dist-packages/TracTicketChange-0.0.4-py2.6.egg
TracTocMacro 	11.0.0.3 	/usr/local/lib/python2.6/dist-packages/TracTocMacro-11.0.0.3-py2.6.egg
TracWikiNotification 	0.2.1 	/usr/local/lib/python2.6/dist-packages/TracWikiNotification-0.2.1-py2.6.egg
TracWysiwyg 	0.12.0.2-r0 	/usr/local/lib/python2.6/dist-packages/TracWysiwyg-0.12.0.2_r0-py2.6.egg
TracXMLRPC 	1.0.6 	/usr/local/lib/python2.6/dist-packages/TracXMLRPC-1.0.6-py2.6.egg
WantedPages 	0.4dev 	/usr/local/lib/python2.6/dist-packages/WantedPages-0.4dev-py2.6.egg

Follow patch seems to fix:

  • batchmod/web_ui.py

     
    175175
    176176    def _save_ticket_changes(self, req, env, log, selectedTickets, tickets,
    177177                             new_values, comment, modify_changetime):
    178         @with_transaction(self.env)
     178        @with_transaction(env)
    179179        def _implementation(db):
    180180            for id in selectedTickets:
    181181                if id in tickets:
     
    185185                    if not modify_changetime:
    186186                        original_changetime = to_utimestamp(t.time_changed)
    187187
    188                     _values = values.copy()
    189                     for field in [f for f in values.keys() \
     188                    _values = new_values.copy()
     189                    for field in [f for f in new_values.keys() \
    190190                                  if f in self._fields_as_list]:
    191191                        _values[field] = self._merge_keywords(t.values[field],
    192192                                                              values[field],

comment:7 Changed 4 years ago by CuriousCurmudgeon

(In [8446]) refs #7553

  • with_transaction was passing in a bad reference to env. I'm not sure how this was working on my machine during testing.

comment:8 Changed 4 years ago by gregmac

values variable renamed to new_values seems to be causing a problem. I was getting an error on this, again, not sure how it works for you CuriousCurmudgeon ?

(updated patch for r8446)

  • batchmod/web_ui.py

     
    185185                    if not modify_changetime:
    186186                        original_changetime = to_utimestamp(t.time_changed)
    187187
    188                     _values = values.copy()
    189                     for field in [f for f in values.keys() \
     188                    _values = new_values.copy()
     189                    for field in [f for f in new_values.keys() \
    190190                                  if f in self._fields_as_list]:
    191191                        _values[field] = self._merge_keywords(t.values[field],
    192                                                               values[field],
     192                                                              new_values[field],
    193193                                                              log)
    194194
    195195                    t.populate(_values)

comment:9 Changed 4 years ago by CuriousCurmudgeon

(In [8448]) refs #7553

comment:10 Changed 4 years ago by CuriousCurmudgeon

Sorry about the confusion. I straightened out my testing problems so hopefully simple errors like this don't make it through anymore.

comment:11 Changed 4 years ago by CuriousCurmudgeon

  • Resolution set to fixed
  • Status changed from reopened to closed

Add Comment

Modify Ticket

Action
as closed The owner will remain CuriousCurmudgeon.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.