Re: Common files for a multi-app

2007-05-22 Thread Mike Orr

On 5/21/07, eneely [EMAIL PROTECTED] wrote:
 The apps are all dynamic apps hitting an mssql database through
 SqlAlchemy so I can't just use plain old Apache or any other server.

I think you may have misunderstood what Cliff was suggesting.  Have
Apache serve *only* the Javscript/CSS/images directly, and let Apache
forward dynamic requests to your dynamic applications.  To do this,
you'd normally put the static files under a distinct directory prefix
or virtual host; e.g.:

/static  : My shared static files

   /pylons-app1 :  A Pylons app served via ProxyPass, FastCGI, SCGI,
or your favorite handler.

  /cgi-app1 : An uncoverted CGI application served via CGI or FastCGI,
possibly using ScriptAlias or RewriteRule.

The trickiest part is if you want your static files to appear at a URL
underneath your Pylons application; e.g., if your Pylons app is / and
your static files are /static.  In this case you'd have to convince
Apache *not* to forward /static to the Pylons application.  Whether
you can override a handler in a subdirectory depends on the handler.
For ProxyPass, put ProxyPass /static ! before the other proxy
directives.  For mod_scgi, put   Location /staticSCGIHandler
Off/Location.

The main downside is if you want to limit access to the static files
to logged-in users.  In that case the request has to go through your
authorization routine, which is normally in your Pylons application.

 I've been down the symlink path and it just feels like a kludge to me
 to do it that way.

It makes sense in some applications but not others.  I have two
applications, one for uploading/managing attachments
(images/documents), the other that only displays them.  So my second
app has a symlink to the attachments directory.  That way I don't have
to hardcode an absolute path in the second app's config file, which I
share between different computers.

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Common files for a multi-app

2007-05-21 Thread eneely

Thanks, all. Some thoughts on the suggestions.

The apps are all dynamic apps hitting an mssql database through
SqlAlchemy so I can't just use plain old Apache or any other server.
The apps are currently implemented as Perl cgi scripts and the only
real commonality between them is the styling and some javascript bits.
I'm looking at switching to Pylons because I like the scalability and
flexibility of it.

I've been down the symlink path and it just feels like a kludge to me
to do it that way. I was hoping maybe I had missed something in the
documentation that would allow for a cleaner method of importing these
types of modules. I actually did try the url_for method, but then the
whole issue of what context is currently running comes up with regard
to where the files are.

Thanks again for the quick responses and giving me a couple of other
ideas to pursue in more depth. I'll keep poking around and maybe some
inspiration will strike.

- Eric

On May 19, 1:13 am, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 On 5/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

  I have been working with Pylons and have developed some standalone
  applications that are part of a larger site. I'm trying to find out
  what the best way is to reference common css/javascript files across
  all of the apps. Here is the setup in a nutshell:

  I have a home page and 3 sub-apps that all use the same css layout
  files and some of the same script files. I have so far been putting
  these files in each application's public directory. Bad idea, I know,
  but I was in a hurry. Anyway, the 3 apps really are separate apps and
  I therefore don't really want to put all of them in the same project.
  I currently use paste#urlmap to call out to each separate app.

  Just wondering if anyone has tried to do something similar and found a
  good way to share some of these files across multiple apps.

 I have a project called lookandfeel that defines the common look and
 feel for all the other Web applications.  In each of the other
 applications, in their websetup.py, it calls some setup function from
 lookandfeel that creates symlinks.  I use one symlink for the public
 directory, and one symlink for the templates directory.  Later, when I
 install the apps, I can run paster setup-app myapp, and it'll create
 the symlinks.  There's only one gotcha--make sure you create the eggs
 from a clean checkout.  Otherwise, the egg creation process will
 follow the symlinks, which isn't what you want.

 Happy Hacking!
 -jj

 --http://jjinux.blogspot.com/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Common files for a multi-app

2007-05-19 Thread Shannon -jj Behrens

On 5/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I have been working with Pylons and have developed some standalone
 applications that are part of a larger site. I'm trying to find out
 what the best way is to reference common css/javascript files across
 all of the apps. Here is the setup in a nutshell:

 I have a home page and 3 sub-apps that all use the same css layout
 files and some of the same script files. I have so far been putting
 these files in each application's public directory. Bad idea, I know,
 but I was in a hurry. Anyway, the 3 apps really are separate apps and
 I therefore don't really want to put all of them in the same project.
 I currently use paste#urlmap to call out to each separate app.

 Just wondering if anyone has tried to do something similar and found a
 good way to share some of these files across multiple apps.

I have a project called lookandfeel that defines the common look and
feel for all the other Web applications.  In each of the other
applications, in their websetup.py, it calls some setup function from
lookandfeel that creates symlinks.  I use one symlink for the public
directory, and one symlink for the templates directory.  Later, when I
install the apps, I can run paster setup-app myapp, and it'll create
the symlinks.  There's only one gotcha--make sure you create the eggs
from a clean checkout.  Otherwise, the egg creation process will
follow the symlinks, which isn't what you want.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Common files for a multi-app

2007-05-18 Thread Cliff Wells

On Fri, 2007-05-18 at 20:22 +, [EMAIL PROTECTED] wrote:
 I have been working with Pylons and have developed some standalone
 applications that are part of a larger site. I'm trying to find out
 what the best way is to reference common css/javascript files across
 all of the apps. Here is the setup in a nutshell:

I think what you'll find is that you don't want to have Pylons serve
these files anyway.  Simply define a common directory (outside any of
the application's directories) and let a real webserver (Nginx, Apache,
Lighttpd, etc) serve those files and leave Pylons for serving dynamic
content.  Hundreds of times faster and your problem becomes moot as a
side-effect.

Regards,
Cliff


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Common files for a multi-app

2007-05-18 Thread Ian Bicking

[EMAIL PROTECTED] wrote:
 I have been working with Pylons and have developed some standalone
 applications that are part of a larger site. I'm trying to find out
 what the best way is to reference common css/javascript files across
 all of the apps. Here is the setup in a nutshell:
 
 I have a home page and 3 sub-apps that all use the same css layout
 files and some of the same script files. I have so far been putting
 these files in each application's public directory. Bad idea, I know,
 but I was in a hurry. Anyway, the 3 apps really are separate apps and
 I therefore don't really want to put all of them in the same project.
 I currently use paste#urlmap to call out to each separate app.
 
 Just wondering if anyone has tried to do something similar and found a
 good way to share some of these files across multiple apps.

We've considered (but haven't implemented) something where each 
application would ask for a URL for a resource.  I suppose you could 
shoehorn this into url_for and Routes, though I probably wouldn't; I'd 
just do something like, um, my_url_for('PackageName', 'filename'), e.g., 
my_url_for('MochiKit', 'DOM.js').  Then unless configured it'd use the 
copies in public/, but with some extra configuration (probably taken 
from a common [DEFAULT] block or something) it'd return the URLs for 
some common location (e.g., http://static.mysite.com/PackageName/filename).

To go alongside this, I'd want some declarative way to indicate what 
files I have, what version they are, and what their package is.  E.g., 
something like (in setup.py):

   resource_files = 
   MochiKit-1.1 = mypackage/public/MochiKit/
   

Then some system might copy or symlink in those files into the static 
area on installation.  Or maybe I'd go all webby with it, as I have been 
inclined to do, and say that /application/.admin/resource-list should 
return some kind of links to all the resource files that might be 
needed, and I'd start up and grab all the files and copy them over, then 
somehow tell the app where they were.  But that's a little more fuzzy to 
me at this point.


-- 
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org
 | Write code, do good | http://topp.openplans.org/careers

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---