quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graham Dumpleton (JIRA)" <j...@apache.org>
Subject [jira] Updated: (MODPYTHON-128) Have assigning req.filename automatically update req.finfo.
Date Sun, 13 Aug 2006 11:14:14 GMT
     [ http://issues.apache.org/jira/browse/MODPYTHON-128?page=all ]

Graham Dumpleton updated MODPYTHON-128:

    Fix Version/s: 3.3

Another item which it would be nice to get resolved for mod_python 3.3.

My latest thinking on this is that we need an actual C based Python object which wraps an
instance of a apr_finfo_t structure. This object would be what is returned when req.finfo
is accessed. The Python object would need to preserve the existing means of accessing attributes
by assuming object is a tuple and accessing values by using special index keys defined in
mod_python.apache file. This means of access though would be seen as being obsolete and supported
for backward compatibility only. Instead, going forward code should be converted to use attribute
style access, thus we would have:

  OLD --> req.finfo[mod_python.apache.FINFO_FILETYPE] 
  NEW -->req.finfo.filetype

As much as makes sense of the apr_finfo_t object would be made accessible.

In respect of the original problem of how to update req.finfo when req.filename is changed,
two new functions would be added to mod_python.apache. This would be:

  mod_python.apache.stat(fname, wanted)
  mod_python.apache.lstat(fname, wanted)

The 'wanted' argument would be replaced with bitwise or of new global constants defined in
mod_python equivalent to:

#define 	APR_FINFO_LINK   0x00000001 /**< Stat the link not the file itself if it is a
link */
#define 	APR_FINFO_MTIME   0x00000010 /**< Modification Time */
#define 	APR_FINFO_CTIME   0x00000020 /**< Creation or inode-changed time */
#define 	APR_FINFO_ATIME   0x00000040 /**< Access Time */
#define 	APR_FINFO_SIZE   0x00000100 /**< Size of the file */
#define 	APR_FINFO_CSIZE   0x00000200 /**< Storage size consumed by the file */
#define 	APR_FINFO_DEV   0x00001000 /**< Device */
#define 	APR_FINFO_INODE   0x00002000 /**< Inode */
#define 	APR_FINFO_NLINK   0x00004000 /**< Number of links */
#define 	APR_FINFO_TYPE   0x00008000 /**< Type */
#define 	APR_FINFO_USER   0x00010000 /**< User */
#define 	APR_FINFO_GROUP   0x00020000 /**< Group */
#define 	APR_FINFO_UPROT   0x00100000 /**< User protection bits */
#define 	APR_FINFO_GPROT   0x00200000 /**< Group protection bits */
#define 	APR_FINFO_WPROT   0x00400000 /**< World protection bits */
#define 	APR_FINFO_ICASE   0x01000000 /**< if dev is case insensitive */
#define 	APR_FINFO_NAME   0x02000000 /**< ->name in proper case */
#define 	APR_FINFO_MIN   0x00008170 /**< type, mtime, ctime, atime, size */
#define 	APR_FINFO_IDENT   0x00003000 /**< dev and inode */
#define 	APR_FINFO_OWNER   0x00030000 /**< user and group */
#define 	APR_FINFO_PROT   0x00700000 /**< all protections */
#define 	APR_FINFO_NORM   0x0073b170 /**< an atomic unix apr_stat() */
#define 	APR_FINFO_DIRENT   0x02000000 /**< an atomic unix apr_dir_read() */

The result of the stat() and lstat() functions would be an instance of the Python object wrapping
the apr_finfo_t structure.

Finally, the req.finfo attribute would be made such that it could be assigned to by an instance
of the Python object wrapping an apr_finfo_t structure. Thus:

  req.filename = newfile
  req.finfo = mod_python.apache.stat(newfile, mod_python.apache.APR_FINFO_MIN)

The affect of the assignment would be that the finfo attribute in the underlying request_rec
structure would be updated from that held in the Python wrapper object for the apr_finfo_t
structure instance returned by the stat() call.

This should all be quite doable and the similarity to the Apache API is preserved.

> Have assigning req.filename automatically update req.finfo.
> -----------------------------------------------------------
>                 Key: MODPYTHON-128
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-128
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.3
>            Reporter: Graham Dumpleton
>         Assigned To: Graham Dumpleton
>             Fix For: 3.3
>         Attachments: MP128_20060423_grahamd_1.diff
> Although it is possible to assign a new value to "req.filename", it is not possible to
update "req.finfo" based on the new filename.
> Suggest that if "req.filename" is assigned a new value, that apr_stat() be automatically
called to update "req.finfo". Ie., internally mod_python would do something like:
>   apr_stat(&r->finfo, r->filename, APR_FINFO_MIN, r->pool);
> I believe that mod_perl supports a similar feature, but would need to confirm this.
> Related to "req.filename", the "req.canonical_filename" should also be writable as when
changing "req.filename" the latter should also by rights be updated as well.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message