I am trying to create a column that stores sha1sums of content, and
allows easy programatic access of that content.  I would like my table
definition to look like this

class Picture(Base):
   content = sa.Column('content_sha1sum', DataColumn(se))

I would like to be able to create instances of pictures like this

p = Picture()
p.content(binary_image_string)

I only want to save the sha1sum to the database, DataColumn takes care
of computing the sha1sum, and actually saving the content to s3 or the
filesystem.  I also want DataColumn to be a deferred column, I can do
that with deferred

All good so far.

What I can't do, or can't do cleanly is figure out how to access the
sha1sum behind content

p = s.query(Picture).all().first()

p.content_sha1sum
p.content_direct_url

Where direct_url is a function of the sha1sum.  The problem with a
custom column is, I can't make sha1sum loading eager and the call to
s3/filesystem lazy, this means that every re-hydration of a Picture
requires a read from the filesystem.

There are a couple of ways that I could go.  First would be to store
the sha1sum directly as a regular String column, and create properties
of names "content" and "content_direct_url".  Another method would be
to use a mixin, but that is a bit ugly.

What I really want is a way to add all 3 properties with a single
line.  I'm willing to modify DeclarativeMeta .

Any thoughts?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/FH1NBMZj-mgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to