コード例 #1
0
ファイル: FSPythonScript.py プロジェクト: goschtl/zope
 def _updateFromFS(self, force=0):
     if force or Globals.DevelopmentMode:
         fp = expandpath(self._filepath)
         try:    mtime=stat(fp)[8]
         except: mtime=0
         if force or mtime != self._file_mod_time:
             self._file_mod_time = mtime
             fp = expandpath(self._filepath)
             file = open(fp, 'rb')
             try: data = file.read()
             finally: file.close()
             self._write(data)
             self._makeFunction(1)
コード例 #2
0
ファイル: FSPageTemplate.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     if reparse:
         self.write(data)
コード例 #3
0
ファイル: FSImage.py プロジェクト: goschtl/zope
 def _readFile(self):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     (self.content_type, self.width, self.height) = getImageInfo(data)
     return data
コード例 #4
0
ファイル: FSImage.py プロジェクト: goschtl/zope
    def get_size(self):
        """Get the size of a file or image.

        Returns the size of the file or image.
        """
        fp = expandpath(self._filepath)
        return path.getsize(fp)
コード例 #5
0
ファイル: FSObject.py プロジェクト: goschtl/zope
 def _updateFromFS(self):
     if Globals.DevelopmentMode:
         fp = expandpath(self._filepath)
         try:    mtime=stat(fp)[8]
         except: mtime=0
         if mtime != self._file_mod_time:
             self._file_mod_time = mtime
             self._readFile(1)
コード例 #6
0
ファイル: FSDTMLMethod.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try:
         data = file.read()
     finally: file.close()
     self.raw = data
     if reparse:
         self.cook()
コード例 #7
0
ファイル: FSFile.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     if reparse or self.content_type == 'unknown/unknown':
         self.ZCacheable_invalidate()
         self.content_type=self._get_content_type(file, data, self.id)
     return data
コード例 #8
0
ファイル: FSPythonScript.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     """Read the data from the filesystem.
     
     Read the file (indicated by exandpath(self._filepath), and parse the
     data if necessary.
     """
     fp = expandpath(self._filepath)
     file = open(fp, 'r')
     try: data = file.read()
     finally: file.close()
     self._write(data)
コード例 #9
0
ファイル: FSImage.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     if reparse or self.content_type == 'unknown/unknown':
         ct, width, height = getImageInfo( data )
         self.content_type = ct
         self.width = width
         self.height = height
     return data
コード例 #10
0
ファイル: FSDTMLMethod.py プロジェクト: goschtl/zope
 def __init__(self, id, filepath, fullname=None, properties=None):
     if properties:
         # Since props come from the filesystem, this should be
         # safe.
         self.__dict__.update(properties)
     self._filepath = filepath
     data = self._readFile()
     fp = expandpath(filepath)
     try: self.file_mod_time = stat(fp)[8]
     except: pass
     HTML.__init__(self, data, __name__=id)
コード例 #11
0
ファイル: FSImage.py プロジェクト: goschtl/zope
 def __init__(self, id, filepath, fullname=None, properties=None):
     if properties:
         # Since props come from the filesystem, this should be
         # safe.
         self.__dict__.update(properties)
     self.__name__ = fullname or id  # Use the whole filename.
     self.title = ''
     self._filepath = filepath
     fp = expandpath(self._filepath)
     try: self.file_mod_time = stat(fp)[8]
     except: pass
     self._readFile()
コード例 #12
0
ファイル: FSSTXMethod.py プロジェクト: goschtl/zope
    def _readFile( self, reparse ):

        fp = expandpath( self._filepath )
        file = open( fp, 'r' )  # not binary, we want CRLF munging here.

        try:
            data = file.read()
        finally:
            file.close()

        self.raw = data

        if reparse:
            self.cook()
コード例 #13
0
ファイル: FSImage.py プロジェクト: bendavis78/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try:
         data = self._data = file.read()
     finally:
         file.close()
     if reparse or self.content_type == 'unknown/unknown':
         self.ZCacheable_invalidate()
         ct, width, height = getImageInfo(data)
         self.content_type = ct
         self.width = width
         self.height = height
     return data
コード例 #14
0
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'r')  # not 'rb', as this is a text file!
     try:
         data = file.read()
     finally:
         file.close()
     self.raw = data
     if reparse:
         self._reading = 1  # Avoid infinite recursion
         try:
             self.cook()
         finally:
             self._reading = 0
コード例 #15
0
ファイル: FSDTMLMethod.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'r')    # not 'rb', as this is a text file!
     try:
         data = file.read()
     finally:
         file.close()
     self.raw = data
     if reparse:
         self._reading = 1  # Avoid infinite recursion
         try:
             self.cook()
         finally:
             self._reading = 0
コード例 #16
0
ファイル: FSImage.py プロジェクト: bendavis78/zope
 def __init__(self, id, filepath, fullname=None, properties=None):
     if properties:
         # Since props come from the filesystem, this should be
         # safe.
         self.__dict__.update(properties)
     self.__name__ = fullname or id  # Use the whole filename.
     self.title = ''
     self._filepath = filepath
     fp = expandpath(self._filepath)
     try:
         self.file_mod_time = stat(fp)[8]
     except:
         pass
     self._readFile()
コード例 #17
0
    def _readFile( self, reparse ):

        fp = expandpath( self._filepath )
        file = open( fp, 'r' )  # not binary, we want CRLF munging here.

        try:
            data = file.read()
        finally:
            file.close()

        self.raw = data

        if reparse:
            self.cook()
コード例 #18
0
    def _readFile(self, reparse):
        """Read the data from the filesystem.

        Read the file (indicated by exandpath(self._filepath), and parse the
        data if necessary.
        """
        fp = expandpath(self._filepath)
        file = open(fp, 'r')
        try:
            data = file.read()
        finally:
            file.close()
        if reparse:
            self._write(data, reparse)
コード例 #19
0
    def _readFile(self, reparse):
        """Read the data from the filesystem.

        Read the file (indicated by exandpath(self._filepath), and parse the
        data if necessary.
        """

        fp = expandpath(self._filepath)

        file = open(fp, 'r')  # not 'rb', as this is a text file!
        try:
            lines = file.readlines()
        finally:
            file.close()

        map = []
        lino = 0

        for line in lines:

            lino = lino + 1
            line = line.strip()

            if not line or line[0] == '#':
                continue

            try:
                propname, proptv = line.split(':', 1)
                #XXX multi-line properties?
                proptype, propvstr = proptv.split('=', 1)
                propname = propname.strip()
                proptype = proptype.strip()
                propvstr = propvstr.strip()
                converter = get_converter(proptype, lambda x: x)
                propvalue = converter(propvstr)
                # Should be safe since we're loading from
                # the filesystem.
                setattr(self, propname, propvalue)
                map.append({
                    'id': propname,
                    'type': proptype,
                    'mode': '',
                    'default_value': propvalue,
                })
            except:
                raise ValueError, ('Error processing line %s of %s:\n%s' %
                                   (lino, fp, line))
        self._properties = tuple(map)
コード例 #20
0
ファイル: FSPropertiesObject.py プロジェクト: goschtl/zope
    def _readFile(self, reparse):
        """Read the data from the filesystem.
        
        Read the file (indicated by exandpath(self._filepath), and parse the
        data if necessary.
        """

        fp = expandpath(self._filepath)

        file = open(fp, 'rb')
        try:
            lines = file.readlines()
        finally:
            file.close()

        map = []
        lino=0

        for line in lines:

            lino = lino + 1
            line = strip( line )

            if not line or line[0] == '#':
                continue

            try:
                propname, proptv = split( line, ':' )
                #XXX multi-line properties?
                proptype, propvstr = proptv.split( '=', 1 )
                propname = strip(propname)
                proptype = strip(proptype)
                propvstr = strip(propvstr)
                converter = get_converter( proptype, lambda x: x )
                propvalue = converter( strip( propvstr ) )
                # Should be safe since we're loading from
                # the filesystem.
                setattr(self, propname, propvalue)
                map.append({'id':propname,
                            'type':proptype,
                            'mode':'',
                            'default_value':propvalue,
                            })
            except:
                raise ValueError, ( 'Error processing line %s of %s:\n%s'
                                  % (lino,fp,line) )
        self._properties = tuple(map)            
コード例 #21
0
ファイル: FSPageTemplate.py プロジェクト: goschtl/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'r')    # not 'rb', as this is a text file!
     try: 
         data = file.read()
     finally: 
         file.close()
     if reparse:
         if xml_detect_re.match(data):
             # Smells like xml
             self.content_type = 'text/xml'
         else:
             try:
                 del self.content_type
             except (AttributeError, KeyError):
                 pass
         self.write(data)
コード例 #22
0
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'r')  # not 'rb', as this is a text file!
     try:
         data = file.read()
     finally:
         file.close()
     if reparse:
         if xml_detect_re.match(data):
             # Smells like xml
             self.content_type = 'text/xml'
         else:
             try:
                 del self.content_type
             except (AttributeError, KeyError):
                 pass
         self.write(data)
コード例 #23
0
ファイル: FSPropertiesObject.py プロジェクト: goschtl/zope
 def _readFile(self):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: lines = file.readlines()
     finally: file.close()
     map = []
     for line in lines:
         propname, proptv = split( line, ':' )
         #XXX multi-line properties?
         proptype, propvstr = split( proptv, '=' )
         propname = strip(propname)
         proptv = strip(proptv)
         propvstr = strip(propvstr)
         converter = get_converter( proptype, lambda x: x )
         propvalue = converter( strip( propvstr ) )
         # Should be safe since we're loading from
         # the filesystem.
         setattr(self, propname, propvalue)
         map.append({'id':propname,
                     'type':proptype,
                     'mode':'',
                     'default_value':propvalue,
                     })
     self._properties = tuple(map)            
コード例 #24
0
    def _readFile( self, reparse ):

        fp = expandpath( self._filepath )
        file = open( fp, 'r' ) 
        parameters = {}
        
        try:
            for line in file.readlines():
                line = line.strip()
                if not line:
                    continue                    
                if line[0] == '#':
                    continue
                key, value = line.split(':')
                parameters[key.strip()] = value.strip()
                
        finally:
            file.close()

        for k in parameters.keys():
            if k not in self.allowed_params:
                del parameters[k]
        
        self.manage_edit(**parameters)
コード例 #25
0
 def get_size(self):
     """Get the size of the underlying file."""
     fp = expandpath(self._filepath)
     return path.getsize(fp)
コード例 #26
0
ファイル: FSPageTemplate.py プロジェクト: bendavis78/zope
 def _readFile(self, reparse):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     self.write(data)
コード例 #27
0
ファイル: FSDTMLMethod.py プロジェクト: goschtl/zope
 def _readFile(self):
     fp = expandpath(self._filepath)
     file = open(fp, 'rb')
     try: data = file.read()
     finally: file.close()
     return data