The TTFSearchPath changed at outside module is ignored

Bug #691442 reported by digitalsatori(Shine IT)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Invalid
Undecided
OpenERP's Framework R&D

Bug Description

There are 3 variable defined in report.render.rml2pdf.customfonts module: TTFSearchPath_Linux, TTFSearchPath_Windows, TTFSearchPath_Darwin, all refers to tuple object. They are refereed in the TTFSearchPathMap dict like below:
TTFSearchPathMap = {
    'Darwin': TTFSearchPath_Darwin,
    'Windows': TTFSearchPath_Windows,
    'Linux': TTFSearchPath_Linux,
}

If at later time I make 3 TTFSearchPath variable refers to other tuple object (eg. change the search path), these changes won't affect the TTFSearchPath* in TTFSearchPathMap dict, as they are still refered to the original tuple object.

I propose to replace immutable tuple to list, thus all changes to these variable will count in the later process.

patch is attached

Tags: report
Revision history for this message
digitalsatori(Shine IT) (digitalsatori) wrote :
Revision history for this message
xrg (xrg) wrote : Re: [Bug 691442] [NEW] The TTFSearchPath changed at outside module is ignored

On Friday 17 December 2010, you wrote:
> Public bug reported:
>
> There are 3 variable defined in report.render.rml2pdf.customfonts module:
> TTFSearchPath_Linux, TTFSearchPath_Windows, TTFSearchPath_Darwin, all
> refers to tuple object. They are refereed in the TTFSearchPathMap dict
> like below: TTFSearchPathMap = {
> 'Darwin': TTFSearchPath_Darwin,
> 'Windows': TTFSearchPath_Windows,
> 'Linux': TTFSearchPath_Linux,
> }
>
> If at later time I make 3 TTFSearchPath variable refers to other tuple
> object (eg. change the search path), these changes won't affect the
> TTFSearchPath* in TTFSearchPathMap dict, as they are still refered to
> the original tuple object.
>
> I propose to replace immutable tuple to list, thus all changes to these
> variable will count in the later process.
>
> patch is attached
>

Well, you may be right. If your module calls:
  from report.render.rml2pdf import customfonts as cfonts
  cfonts.TTFSearchPath_Linux = cfonts.TTFSearchPath_Linux + ( '/my/path',)
it wouldn't work.
However, I would still expect this to work:
  cfonts.TTFSearchPathMap['Linux'] = cfonts.TTFSearchPath_Linux + ( '/my/path',)

Note, however, that after any modification, you would better need to re-issue:
  cfonts.FindCustomFonts()
because there is a slight chance that this function had been called before your
module's code is executed, and then it wouldn't consult the paths again.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
status: New → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

As xrg pointed out, you can alter the TTFSearchPathMap directly, instead of trying to modify the tuples directly :-)
I'm closing this bug because the TTFSearchPath tuples were not meant to be extended in that way anyway (we'll try to have a minimal doc for this customfonts business online soon)

Thanks!

Changed in openobject-server:
status: Confirmed → Invalid
Changed in openobject-server:
importance: Low → Undecided
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.