I'm doing something pretty routine in defining a db table in a class within
a file in modules, and later, attempting to display an image associated
with that table. The table is defined like so:
class Image:
def __init__(self, db, auth_signature, session, request, response):
...
if not 't_image' in db.tables:
self.db.define_table('t_image',
Field('f_user_id', type="reference auth_user", readable=
False, writable=False,
default=session.auth.user.id if session.auth else ''
),
Field('image',type="upload",
requires = (IS_EMPTY_OR(IS_IMAGE(
error_message = current.T('Error...'),
extensions = ('jpeg','jpg','png','bmp','gif'),
maxsize = (1200, 1200))),IS_LENGTH(524288)),
label = current.T('Image'), autodelete = True,
uploadseparate = True),
...
self.auth_signature)
In attempting to display the image, I'm doing something like this in a
non-default controller (I tried the equivalent in the default controller,
and that didn't change anything):
def show_user():
...
from user_custom import Image
cl__image = Image(db = db, auth_signature = auth.signature, session =
session,
request = request, response = response)
row__image = db(db.t_image.f_user_id == user_id).select('image').first()
image_filename = row__image['image'] if row__image else None
img = DIV(IMG(_src = URL('default', 'download/' + image_filename,
extension = False)))
...
return dict(img = img)
This produces a "NetworkError: 404 NOT FOUND" error. A blank image
container appears on the screen, and examining it, the url that shows up
looks reasonable, and seems to point to the appropriate file. Any ideas as
to what could be going on and how to fix it? Thank you.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.