template problem

1 view
Skip to first unread message

eri x

unread,
Jun 12, 2009, 11:45:38 AM6/12/09
to trac...@googlegroups.com
Hi, i am developing a plugin but i have a problem, i have a variabile initialized at the default value on the load of the plugin and then it continues to be changed during it's use,but i have noticed that sometimes trac reload the plugin automatically and dhe value that i am using for the operations get reinitialized  and i loose all the changes made before.
Is there a way to conserve that value,or shuold i use the configuration file and insert a section anly for saving that value.
Regards Ermal

Erik Bray

unread,
Jun 12, 2009, 6:27:53 PM6/12/09
to trac...@googlegroups.com


What is this variable? Is it a class attribute of a Component? What
does it represent?

eri x

unread,
Jun 15, 2009, 3:28:34 AM6/15/09
to trac...@googlegroups.com
It's an attribute that i change from the template, but sometimes(usually when i don't use trac for some minutes) when i send a request to dhe admin pannel it takes the default value.Looking on request arguments i noticed that when this problem happens the request arguments are the same that are used when trac loads the plugin and there are none of the arguments that i have inserted in my code and are used when it works fine. Until now the only solution that i think can work is to use an outer file where to save this variable.
--------------------------------------------------------------------------------------------------
class WorkflowEditorAdmin(Component):

    tipo_ticket='default_workflow'

    def render_admin_panel(self, req, cat, page, path_info):
         req.perm.assert_permission('TRAC_ADMIN')

         if req.method == 'POST':
           if "select_ticket" and "flag" in req.args:
                    self.tipo_ticket=req.args['select_ticket']
  
            else:   
                    self._update_config(req,page_param)
---------------------------------------------------------------------------------------------
Regards ermal

Erik Bray

unread,
Jun 15, 2009, 1:18:12 PM6/15/09
to trac...@googlegroups.com

Right. Unless you've configured your system to only serve requests
one at a time from a single Python interpreter, this won't work. You
need to save your setting either in the config file or in the DB
somewhere.

eri x

unread,
Jun 16, 2009, 2:42:37 AM6/16/09
to trac...@googlegroups.com
Putting a counter in my  code and visualising it in the template i discovered that when i take a pause for some minutes and then began to work again  trac creates a new instance of the plugin and initialize the counter,when i take a pause again for some time and than began to work  trac uses the old istance of the plugin and  works with the old counter, and it continues to move between the instances every time i pause for some minutes,the only way for trac to don't change the instance that it use is to work on the plugin frequently.Is this a bug or is the way trac works.
Regards Ermal.

Erik Bray

unread,
Jun 16, 2009, 3:21:19 PM6/16/09
to trac...@googlegroups.com

Neither. It's the way Python works in a multiprocess web server, as
I've explained before.

Reply all
Reply to author
Forward
0 new messages