ProductImage model extend to save images in sub directories

7 views
Skip to first unread message

davidl

unread,
Jan 24, 2011, 5:55:24 PM1/24/11
to Satchmo users
Hello,

I plan to upload about 200 products to start with and more in the near
future. Each product has 5-10 images, shot from different angles. That
equates to 1000 - 2000 images for the first 200 products.

I read somewhere that having more than a thousand images in a single
directory is a bad idea, because all the common filing system has a
linear search( need to look up every single file until it finds the
match) and slows down the system.

If that is true, I want to create a subdirectory system. Possibly
create subdirectories based on the first or second letter of the
product name and put images. Also, save the name of the image with the
path. To do this, I would need to change "def _get_filename(self):" in
ProductImage model

Any recommendation on how I should change the behavior of that
function?
I read about custom product module http://www.satchmoproject.com/docs/dev/custom-product.html,
but not sure if it's for changing how model saves its items.

Thank you.
David L.

Cristian Ciupitu

unread,
Jan 25, 2011, 2:24:07 AM1/25/11
to satchm...@googlegroups.com
On Tue, Jan 25, 2011 at 12:55 AM, davidl <david...@gmail.com> wrote:
>
> I read somewhere that having more than a thousand images in a single
> directory is a bad idea, because all the common filing system has a
> linear search( need to look up every single file until it finds the
> match) and slows down the system.

That was ages ago. Modern filesystems don't have this problem, they
use data structures better than a list. For example ext3 has the
following feature:

dir_index
Use hashed b-trees to speed up lookups in large
directories.

Cheers,
Cristian

hynekcer

unread,
Jan 25, 2011, 10:51:53 AM1/25/11
to Satchmo users
If you have really big number of images, you may need my patch which I
sent to Chris some time ago.
https://bitbucket.org/hynekcer/satchmo-outgoing/changeset/5478f6ced325

It is especially usefull if you have many images and also many
products without any image.

In contrary - Hundred thousand images in one directory are not problem
for Satchmo, nevertheles I upload only little number of images
manually by admin to the default directory and big number of products
I import in bulk by a script. Then it is easy to divide thousands
images from every mass upload to its own subdirectory. The result of
both is the same for Satchmo.

Hynek

On 25 led, 08:24, Cristian Ciupitu <cristian.ciup...@gmail.com> wrote:

david lee

unread,
Jan 25, 2011, 12:44:40 PM1/25/11
to satchm...@googlegroups.com
>> That was ages ago. Modern filesystems don't have this problem

>> In contrary - Hundred thousand images in one directory are not problem
for Satchmo,


Cool~ Thank you Christian and Hynek for tips.

Hynek, thanks for the patch also, and probably will implement it on the new site.

DL


--
You received this message because you are subscribed to the Google Groups "Satchmo users" group.
To post to this group, send email to satchm...@googlegroups.com.
To unsubscribe from this group, send email to satchmo-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.


Reply all
Reply to author
Forward
0 new messages