Changeset 149

Show
Ignore:
Timestamp:
03/23/06 19:00:10 (6 years ago)
Author:
sdeibel
Message:

Updates to work w/ cpy scripts in the latest CMF. The key fix is
making sure filepath is a full path before compiling the code object.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • WingDBG/trunk/ScriptDebugging.py

    r91 r149  
    1515Wingware to support debugging of file system scripts running under Zope''' 
    1616 
    17 __version__='1.0.3' 
    18  
    19 import sys, marshal 
     17__version__='1.0.4' 
     18 
     19import os, sys, marshal 
    2020from zLOG import LOG, ERROR 
    2121 
     
    2323from Products.PythonScripts.PythonScript import PythonScript, Python_magic, \ 
    2424    Script_magic, _nonempty_line, _first_indent, _nice_bind_names 
     25 
     26# Copy of code from CMFCore utils so we can expand the partial 
     27# paths used for products to full path 
     28import Products 
     29ProductsPath = [ os.path.abspath(ppath) for ppath in Products.__path__ ] 
     30def expandpath(p): 
     31    p = os.path.normpath(p) 
     32    if os.path.isabs(p): 
     33        return p 
     34 
     35    for ppath in ProductsPath: 
     36        abs = os.path.join(ppath, p) 
     37        if os.path.exists(abs): 
     38            return abs 
     39 
     40    # We're hosed 
     41    return p 
    2542 
    2643# Add support for storing a path to the file. 
     
    3653def PythonScript_compile(self): 
    3754     
    38     fp = getattr(self, '_filepath', self.meta_type) 
     55    fp = getattr(self, '_filepath', None) 
     56    if fp is not None: 
     57        fp = expandpath(fp) 
     58    else: 
     59        fp = self.meta_type 
    3960    bind_names = self.getBindingAssignments().getAssignedNamesInOrder() 
    4061    r = self._compiler(self._params, self._body or 'pass', 
     
    189210try: 
    190211    from Products.CMFCore.FSPythonScript import FSPythonScript 
    191     from Products.CMFCore.DirectoryView import expandpath 
    192212except ImportError: 
    193213    FSPythonScript = None 
     
    253273    if CMFPythonScript is not None: 
    254274        CMFPythonScript.write = PythonScriptwrite 
    255      
     275         
    256276def unpatch(): 
    257277    PythonScript.__init__ = savedPythonScript__init__