Can page_attachments store uploads in database?

I know attachment_fu supports this, but I’m not sure if that means
page_attachments can work with it.

I wanted to see if anybody knows the answer to this before I spend the
time on trial-and-error.

Thanks,
Errol

Please don’t do that. It does two things: It means that every file
download has to hit your app server and it means that it has to pull
it from the db which will be exceedingly slow. I don’t know if it’s
possible with page_attachments, but it should be avoided.

Nate

In short, any backend that attachment_fu supports works with
page_attachments. The amount of poking around in page_attachments to
get it working will vary.

Nate: Thanks for the response. I agree that what you are saying is
true. I am trying to balance performance against maintainability of the
site. Perhaps you have a better suggestion for what I want to
accomplish. I want to be able to run multiple version of the site (one
for development and one for production). I understand that radiant has
dev and prod ‘modes’ but this is not really quite what I want. For
example I want to be able to edit a page (and its attachments) for
somebody to review without modifying the existing production version of
that page. I figured that if everything were stored in the database it
would make things easier. I would just need to dump the dev database
and import it into the prod database when I want to go live with
changes. Thanks in advance for any suggesions you might have.

John: Thanks – perhaps I will try this if nobody has a better idea for
managing content (based on what I wrote just above).

Write a capistrano task to clone from staging to production. In the
task clone both the database and static assets. It’s not much harder
than cloning the db. Tar up the assets, copy them to the new
location, then untar them. Remove old assets if necessary.

Nate

Errol,

If you add the appropriate database field(s) and tweak the model, you
should get it to work. I have no idea how one would get the image data
back out, however, since I’ve never done it.

Sean

There were dark times when we had like 200 000 images in the database,
because the initial developers thought it’s the easiest way to control
access to them for photo sharing and ordering website. So from that
experience I can tell you that it would be slow as hell (it’s kind of
obvious but still). For example Apache on my laptop can serve 1000+
static files per second and only like 15-20 request/sec for php. My
point is if you’re going to use this logic for production it will
totally kill your performance.

If I were in your place I’d go with the capistrano task thing

Just my 2 cents

On Thu, Oct 2, 2008 at 6:59 PM, Errol S. [email protected]
wrote:

Does anybody have any advice for how to go about this?

I’m pretty new to Capistrano. Is there a simple way to have Capistrano
tar up the files locally, upload them to the production server, then
replace the existing files with the uploaded files?

The last part seems easy enough – I get that I can use ‘run’ to run
commands on the remote server. I’m just not sure how to have it run
commands locally and upload files.

I too am curious about this. It would be great to have an entire copy of
the
production site on my laptop, but I have no idea which commands I would
run
to to make that happen. It was my impression, before looking into
import_export and super_export, that those extensions did that kind of
thing
(with or without Capistrano). I was mistaken, but I am still curious how
others are using those extensions on a daily basis to maintain some sort
of
parity between their dev and production sites.

~Nate

I think I agree that having a task sync those files is going to be the
best way to go.

Restricting access is not really an issue as (so far) I am just using
page_attachments for adding images to public pages.

Does anybody have any advice for how to go about this?

I’m pretty new to Capistrano. Is there a simple way to have Capistrano
tar up the files locally, upload them to the production server, then
replace the existing files with the uploaded files?

The last part seems easy enough – I get that I can use ‘run’ to run
commands on the remote server. I’m just not sure how to have it run
commands locally and upload files.

Nate:

Here is what I have picked up so far:

First, to answer one of my own questions, you can use ‘system’ in a
capistrano task to run local commands (as opposed to using ‘run’ to run
commands on remote servers).

Next, here are a couple of links to capistrano/rake tasks others have
created to pull down databases and/or files from the production
server(s) to the local dev machine:

http://www.artima.com/forums/flat.jsp?forum=123&thread=185948
http://nateclark.com/articles/tag/capistrano

I suppose the benefit of using import_export would be that in theory you
could use it to move data between a mysql production database to an
sqlite dev database (for example). The links above assume you are using
the same type of database in both environments (perhaps a reasonable
limitation for many people).