From: Chuck E. <ec...@mi...> - 2001-01-24 18:58:33
|
WEP: serverSidePath() Date: 01/24/00 This WEP replaces the "serverSidePath() & serverSideDir()" WEP from 1/20/01. DESCRIPTION Dynamic web sites must often deal with the file system on the server side. Several WebKit classes provide a method to return the server-side path of an object and build relative paths from it. def serverSidePath(self, path=None): ''' Returns the absolute server-side path containing the object. If the optional path is passed in, then it is joined with the server side directory to form a path relative to the object. You can use this to build relative paths. For example: filename = app.serverSidePath('configs/fields.csv') Since os.path.join() is used, if the path argument is absolute, it will be returned as-is. ''' Classes that implement this method include: AppServer Application Servlet HTTPRequest PlugIn In WebKit 0.4.1, Servlet and HTTPRequest have a serverSideDir(), but this method is used almost exclusively like so: os.path.join(req.serverSideDir(), 'somePath') Which is more succinctly done as: req.serverSidePath('somePath') serverSideDir() should be deprecated and then removed in a later version. Also, the existing serverPath() method should be replaced with serverSidePath(). In addition, none of the code implementing WebKit should rely on the current directory being the location of WebKit/, but instead, use the serverSidePath() of the appropriate object instead. |
From: Jay L. <js...@js...> - 2001-02-06 04:29:19
|
Chuck, it looks to me like serverSidePath() is returning the FULL path, including the filename. Is this your intended behavior? If so, how do I get the serverSideDir? Can we add an optional keyword arg? Jay On 24 Jan 2001 13:56:59 -0500, Chuck Esterbrook wrote: > WEP: serverSidePath() > Date: 01/24/00 > > This WEP replaces the "serverSidePath() & serverSideDir()" WEP from 1/20/01. > > > DESCRIPTION > > Dynamic web sites must often deal with the file system on the server side. > Several WebKit classes provide a method to return the server-side path of > an object and build relative paths from it. > > def serverSidePath(self, path=None): > ''' > Returns the absolute server-side path containing the object. > If the optional path is passed in, then it is joined with the server side > directory to form a path relative to the object. You can use this to build > relative paths. For example: > > filename = app.serverSidePath('configs/fields.csv') > > Since os.path.join() is used, if the path argument is absolute, it will be > returned as-is. > ''' > > Classes that implement this method include: > AppServer > Application > Servlet > HTTPRequest > PlugIn > > > In WebKit 0.4.1, Servlet and HTTPRequest have a serverSideDir(), but this > method is used almost exclusively like so: > > os.path.join(req.serverSideDir(), 'somePath') > > Which is more succinctly done as: > > req.serverSidePath('somePath') > > serverSideDir() should be deprecated and then removed in a later version. > > Also, the existing serverPath() method should be replaced with > serverSidePath(). > > In addition, none of the code implementing WebKit should rely on the > current directory being the location of WebKit/, but instead, use the > serverSidePath() of the appropriate object instead. > > > _______________________________________________ > Webware-discuss mailing list > Web...@li... > http://lists.sourceforge.net/lists/listinfo/webware-discuss |
From: Chuck E. <ec...@mi...> - 2001-02-06 04:52:26
|
BTW Which object are we talking about? Probably Request and Servlet? Upon reviewing the pre-existing code that was using serverSidePath() and serverSideDir() I noticed that serverSideDir() was always being used for an os.path.join. We also had a relativePath() method that did both in one call. So I combined this into serverSidePath(): The current optional arg for serverSidePath is a relative path to join to. So for example: if serverSidePath() ==> '/a/b/c.py' then serverSidePath('config.csv') ==> '/a/b/config.csv'. And you can always do an os.path.dirname(req.serverSidePath()) if you have to, but don't bother with that approach if you're just going to do an os.path.join(). What are you doing with the dirname? -Chuck At 11:39 PM 2/5/2001 -0500, Jay Love wrote: >Chuck, it looks to me like serverSidePath() is returning the FULL path, >including the filename. Is this your intended behavior? If so, how do >I get the serverSideDir? Can we add an optional keyword arg? > >Jay > > > >On 24 Jan 2001 13:56:59 -0500, Chuck Esterbrook wrote: > > WEP: serverSidePath() > > Date: 01/24/00 > > > > This WEP replaces the "serverSidePath() & serverSideDir()" WEP from > 1/20/01. > > > > > > DESCRIPTION > > > > Dynamic web sites must often deal with the file system on the server side. > > Several WebKit classes provide a method to return the server-side path of > > an object and build relative paths from it. > > > > def serverSidePath(self, path=None): > > ''' > > Returns the absolute server-side path containing the object. > > If the optional path is passed in, then it is joined with the > server side > > directory to form a path relative to the object. You can use this to build > > relative paths. For example: > > > > filename = app.serverSidePath('configs/fields.csv') > > > > Since os.path.join() is used, if the path argument is absolute, > it will be > > returned as-is. > > ''' > > > > Classes that implement this method include: > > AppServer > > Application > > Servlet > > HTTPRequest > > PlugIn > > > > > > In WebKit 0.4.1, Servlet and HTTPRequest have a serverSideDir(), but this > > method is used almost exclusively like so: > > > > os.path.join(req.serverSideDir(), 'somePath') > > > > Which is more succinctly done as: > > > > req.serverSidePath('somePath') > > > > serverSideDir() should be deprecated and then removed in a later version. > > > > Also, the existing serverPath() method should be replaced with > > serverSidePath(). > > > > In addition, none of the code implementing WebKit should rely on the > > current directory being the location of WebKit/, but instead, use the > > serverSidePath() of the appropriate object instead. > > > > > > _______________________________________________ > > Webware-discuss mailing list > > Web...@li... > > http://lists.sourceforge.net/lists/listinfo/webware-discuss |
From: Jay L. <js...@js...> - 2001-02-06 04:55:14
|
I'm globing the files in the servlet's directory. OK, do want to add an optional kw arg to serverSidePath that specifis that you want the directory, ie serverSidePath(dir=1), or should we just keep serverSideDir()? Jay > > And you can always do an os.path.dirname(req.serverSidePath()) if you have > to, but don't bother with that approach if you're just going to do an > os.path.join(). > > What are you doing with the dirname? > > -Chuck > > > > At 11:39 PM 2/5/2001 -0500, Jay Love wrote: > > >Chuck, it looks to me like serverSidePath() is returning the FULL path, > >including the filename. Is this your intended behavior? If so, how do > >I get the serverSideDir? Can we add an optional keyword arg? > > > >Jay > > > > > > > >On 24 Jan 2001 13:56:59 -0500, Chuck Esterbrook wrote: > > > WEP: serverSidePath() > > > Date: 01/24/00 > > > > > > This WEP replaces the "serverSidePath() & serverSideDir()" WEP from > > 1/20/01. > > > > > > > > > DESCRIPTION > > > > > > Dynamic web sites must often deal with the file system on the server side. > > > Several WebKit classes provide a method to return the server-side path of > > > an object and build relative paths from it. > > > > > > def serverSidePath(self, path=None): > > > ''' > > > Returns the absolute server-side path containing the object. > > > If the optional path is passed in, then it is joined with the > > server side > > > directory to form a path relative to the object. You can use this to build > > > relative paths. For example: > > > > > > filename = app.serverSidePath('configs/fields.csv') > > > > > > Since os.path.join() is used, if the path argument is absolute, > > it will be > > > returned as-is. > > > ''' > > > > > > Classes that implement this method include: > > > AppServer > > > Application > > > Servlet > > > HTTPRequest > > > PlugIn > > > > > > > > > In WebKit 0.4.1, Servlet and HTTPRequest have a serverSideDir(), but this > > > method is used almost exclusively like so: > > > > > > os.path.join(req.serverSideDir(), 'somePath') > > > > > > Which is more succinctly done as: > > > > > > req.serverSidePath('somePath') > > > > > > serverSideDir() should be deprecated and then removed in a later version. > > > > > > Also, the existing serverPath() method should be replaced with > > > serverSidePath(). > > > > > > In addition, none of the code implementing WebKit should rely on the > > > current directory being the location of WebKit/, but instead, use the > > > serverSidePath() of the appropriate object instead. > > > > > > > > > _______________________________________________ > > > Webware-discuss mailing list > > > Web...@li... > > > http://lists.sourceforge.net/lists/listinfo/webware-discuss |
From: Chuck E. <ec...@mi...> - 2001-02-06 05:01:02
|
serverSidePath() already exists for 5 classes. I'm not enthused about adding a serverSideDir() each place there is a path. I think the dir thing is fairly rare so I'd rather just use os.path.dirname(obj.serverSidePath()) which is what serverSideDir() would do anyway. -Chuck At 12:05 AM 2/6/2001 -0500, Jay Love wrote: >I'm globing the files in the servlet's directory. > > >OK, do want to add an optional kw arg to serverSidePath that specifis >that you want the directory, ie serverSidePath(dir=1), or should we just >keep serverSideDir()? > >Jay > > > > > > > And you can always do an os.path.dirname(req.serverSidePath()) if you have > > to, but don't bother with that approach if you're just going to do an > > os.path.join(). > > > > What are you doing with the dirname? > > > > -Chuck > > > > > > > > At 11:39 PM 2/5/2001 -0500, Jay Love wrote: > > > > >Chuck, it looks to me like serverSidePath() is returning the FULL path, > > >including the filename. Is this your intended behavior? If so, how do > > >I get the serverSideDir? Can we add an optional keyword arg? > > > > > >Jay > > > > > > > > > > > >On 24 Jan 2001 13:56:59 -0500, Chuck Esterbrook wrote: > > > > WEP: serverSidePath() > > > > Date: 01/24/00 > > > > > > > > This WEP replaces the "serverSidePath() & serverSideDir()" WEP from > > > 1/20/01. > > > > > > > > > > > > DESCRIPTION > > > > > > > > Dynamic web sites must often deal with the file system on the > server side. > > > > Several WebKit classes provide a method to return the server-side > path of > > > > an object and build relative paths from it. > > > > > > > > def serverSidePath(self, path=None): > > > > ''' > > > > Returns the absolute server-side path containing the object. > > > > If the optional path is passed in, then it is joined with the > > > server side > > > > directory to form a path relative to the object. You can use this > to build > > > > relative paths. For example: > > > > > > > > filename = app.serverSidePath('configs/fields.csv') > > > > > > > > Since os.path.join() is used, if the path argument is absolute, > > > it will be > > > > returned as-is. > > > > ''' > > > > > > > > Classes that implement this method include: > > > > AppServer > > > > Application > > > > Servlet > > > > HTTPRequest > > > > PlugIn > > > > > > > > > > > > In WebKit 0.4.1, Servlet and HTTPRequest have a serverSideDir(), > but this > > > > method is used almost exclusively like so: > > > > > > > > os.path.join(req.serverSideDir(), 'somePath') > > > > > > > > Which is more succinctly done as: > > > > > > > > req.serverSidePath('somePath') > > > > > > > > serverSideDir() should be deprecated and then removed in a later > version. > > > > > > > > Also, the existing serverPath() method should be replaced with > > > > serverSidePath(). > > > > > > > > In addition, none of the code implementing WebKit should rely on the > > > > current directory being the location of WebKit/, but instead, use the > > > > serverSidePath() of the appropriate object instead. > > > > > > > > > > > > _______________________________________________ > > > > Webware-discuss mailing list > > > > Web...@li... > > > > http://lists.sourceforge.net/lists/listinfo/webware-discuss > > >_______________________________________________ >Webware-discuss mailing list >Web...@li... >http://lists.sourceforge.net/lists/listinfo/webware-discuss |
From: Jay L. <js...@js...> - 2001-02-06 05:03:43
|
Then you have to go import os, etc. Would it drive you crazy to offer the dir kw arg? (Though I must admit, I'd prefer serverSideDir. it's cleaner) Jay Chuck Esterbrook wrote: > serverSidePath() already exists for 5 classes. I'm not enthused about > adding a serverSideDir() each place there is a path. > > I think the dir thing is fairly rare so I'd rather just use > os.path.dirname(obj.serverSidePath()) which is what serverSideDir() would > do anyway. |
From: Chuck E. <ec...@mi...> - 2001-02-06 14:51:24
|
At 12:13 AM 2/6/2001 -0500, Jay Love wrote: >Then you have to go import os, etc. Would it drive you crazy to offer the >dir kw >arg? (Though I must admit, I'd prefer serverSideDir. it's cleaner) There's no "etc." it's just import os, os.path.dirname(). The case is so rare, I want to stick with that approach. -Chuck |