Thank you. I got it. Best regards, Charlie Tian
-----Original Message----- From: Gary Martin [mailto:[email protected]] Sent: Monday, July 14, 2014 6:00 PM To: [email protected] Subject: Re: Questions about bloodhound BEP-0003 Hi, I assume that you meant this to go to [email protected] so I hope you don't mind if I send my reply there. My responses are inline: On 14/07/14 04:01, tianhongjie07 wrote: > Thanks for your reply. > > I can create option in database with command: > trac-admin path/to/environment product admin new_product config set > header_logo src "http://xxxxxxx.com/new_image.png". > But I can't get the value used method: > self.config.get('header_logo', 'src') > The method return value is empty string which in debug mode with breakpoint > in class[ProductAdminPanel] method[_render_admin_panel] Line[prod = > Product(self.env, keys)], > then add watch [self.config.get('header_logo', 'src')], the value is empty > string. Having set this, did you note whether new_product had the changed logo? As I understand it, whether self.config will pick up the config for global, @ or new_product will be dependant on which product is active (more about that below). > I also add > > imageurl = "http://xxxxxxx.com/new_image.png" > self.config.set('header_logo', 'src', imageurl) > self.config.save() > > in class[ProductAdminPanel] method[_render_admin_panel] below > Line[prod.update()]. > I find it has been modified in trac.ini file > > [header_logo] > src = http://xxxxxxx.com/new_image.png > > Not save it to database, I'm sure my understanding it's not correct. When you are not in a product context, self.config will be the global config and that does indeed get saved to the trac.ini file. I should probably have suggested guarding from making changes to any config other than the product you were interested in changing. So, while not useful in this form as production code: prod = "new_product" imageurl = "http://xxxxxxx.com/new_image.png" if self.env.product is not None and self.env.product.name == prod: self.config.set('header_logo', 'src', imageurl) self.config.save() this will at least make sure you don't change the header_logo for anything other than the hardcoded product. To get the match in admin pages you should use the select dropdown that is underneath the search tool. The selection defaults to "(Global settings)" and not specific products. Does that make a bit more sense? In the end the trac-admin command should be enough to insert the config you need though as far as I can tell. Cheers, Gary
