vendor/tramline

changeset 2:dee3a43cd538 gracinet-fix-range

Moved filesystem path utils to a separate package for easy reference by svn externals
author gracinet
date Wed, 31 Dec 2008 12:48:37 +0000
parents 00f158ab38ae
children 5265ba1c57bd d17bf871c609
files CHANGES src/tramline/core.py src/tramline/path/__init__.py
diffstat 3 files changed, 23 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/CHANGES
     1.2 +++ b/CHANGES
     1.3 @@ -3,7 +3,8 @@
     1.4  -
     1.5  New features
     1.6  ~~~~~~~~~~~~
     1.7 --
     1.8 +- Moved filesystem path utils to a separate package for easy reference by
     1.9 +  svn externals
    1.10  Bug fixes
    1.11  ~~~~~~~~~
    1.12  -
     2.1 --- a/src/tramline/core.py
     2.2 +++ b/src/tramline/core.py
     2.3 @@ -4,6 +4,7 @@
     2.4  TRAMLINE_RANGE_HEADER = 'X-Tramline-Original-Range'
     2.5  
     2.6  from headers import parse_range
     2.7 +from path import id_to_path
     2.8  
     2.9  def pass_on(filter):
    2.10      try:
    2.11 @@ -45,20 +46,6 @@
    2.12                  # (set-group-ID-on-execution bit)
    2.13                  os.chmod(p, 02775)
    2.14  
    2.15 -def id_to_path(tramline_path, id, upload=False, create_intermediate=False):
    2.16 -    """Compute the path on filesystem of the file with given id.
    2.17 -
    2.18 -    tramline_path: the tramline base path, as extracted from request options.
    2.19 -    id: the tramline id, as a string.
    2.20 -    upload: if True, the computed path will be from the "upload" directory
    2.21 -            instead of the "repository"
    2.22 -    create_intermediate: if True, all necessary objects will be created, but
    2.23 -        the target file won't."""
    2.24 -    
    2.25 -    return os.path.join(tramline_path, upload and "upload" or "repository",
    2.26 -                        id)
    2.27 -    
    2.28 -
    2.29  FILE_CHUNKSIZE = 8 * 1024
    2.30  
    2.31  """
     3.1 new file mode 100644
     3.2 --- /dev/null
     3.3 +++ b/src/tramline/path/__init__.py
     3.4 @@ -0,0 +1,20 @@
     3.5 +# This package provides filesystem path utilities that are independent
     3.6 +# from the mod_python context.
     3.7 +#
     3.8 +# It takes the form of a package, in order to be, as any directory would, 
     3.9 +# embeddable as an svn external without the remainings of tramline code.
    3.10 +
    3.11 +import os
    3.12 +
    3.13 +def id_to_path(tramline_path, id, upload=False, create_intermediate=False):
    3.14 +    """Compute the path on filesystem of the file with given id.
    3.15 +
    3.16 +    tramline_path: the tramline base path, as extracted from request options.
    3.17 +    id: the tramline id, as a string.
    3.18 +    upload: if True, the computed path will be from the "upload" directory
    3.19 +            instead of the "repository"
    3.20 +    create_intermediate: if True, all necessary objects will be created, but
    3.21 +        the target file won't."""
    3.22 +    
    3.23 +    return os.path.join(tramline_path, upload and "upload" or "repository",
    3.24 +                        id)