row = db().select(db.recipes.IMAGE).first()
image = '<img src="'+URL('default','download',args=row.file)+'"/>'
web2py™ | Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 |
---|---|
Python | Python 3.7.3: C:\Python\python.exe (prefix: C:\Python) |
1. | Traceback (most recent call last): |
AttributeError()
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\restricted.py in restricted at line 219 код аргументы переменные
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers\default.py in <module> at line 176 код аргументы переменные
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\globals.py in <lambda> at line 421 код аргументы переменные
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers\default.py in index at line 12 код аргументы переменные
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers\default.py in selectRecipes at line 111 код аргументы переменные
File C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\packages\dal\pydal\objects.py in __getattr__ at line 118 код аргументы переменные
(self=<Row {}>, k='file')
113. |
|
rows = db().select(db.recipes.ALL)
for row in rows:
if row.recipes.IMAGE is None:
image = ''
else:
image = '<img src="'+URL('default','download',args=row.recipes.IMAGE)+'"/>'
<img src="/Recipes/default/download/%3Cfdb.fbcore.BlobReader%20object%20at%200x04E09C50%3E"/>
--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/a782e7f9-ff3d-4d0c-affb-5f80bd94f480%40googlegroups.com.
db.define_table(
'recipes',
Field('NAME',length=512),
Field('IMAGE'),
migrate=False
)
db = DAL('firebird://sysdba:masterkey@localhost/C:/HR.fdb', ignore_field_case=True, entity_quoting=False, pool_size=1, migrate_enabled=False, db_codec='UTF-8')
maybe -> Field('IMAGE', 'upload'),
--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/3cf73bb8-3c63-47c3-88db-8f9c654798c7%40googlegroups.com.
def getmyblob():
import cStringIO
import os, shutil
# print request
if len(request.args) == 0 or not request.args[0]:
raise HTTP(404, "unknown file not found")
row = db(db.mypics.pname == request.args[0]).select().first()
blob = db[somethingsomething].[copyblobltotmpfile]
dst = os.path.join(request.env.web2py_path, "application", blob.tmpname)
if not os.access(dst, os.F_OK):
print dst
raise HTTP(404,"funny, that's not here")
imstat = os.stat(dst) filedata=open(dst,"rb").read()
response.headers['Content-Type']='image/jpeg'
response.headers['Content-Length']=imstat.st_size
return response.stream(cStringIO.StringIO(filedata))
<IMG src="getmyblob/{{=blobrowid}} alt="image file for {{=blobrowid"}} title="={{blobrowid}}">
blob = db[somethingsomething].[copyblobltotmpfile]
import codecs
base64_data = codecs.encode(row.recipes.IMAGE.read(), 'base64')
base64_text = codecs.decode(base64_data, 'ascii')
image = '<img src="data:image/png;base64, %s" />' % base64_text
db.define_table(
'recipes',
Field('NAME',length=512),
Field('IMAGE','upload'),
migrate=False
)
row = db().select(db.recipes.IMAGE).first()
image = str(dir(row))
image = str(dir(row.IMAGE))
Val K, it is my table.py file:It's code in my default.py file:
db.define_table(
'recipes',
Field('NAME',length=512),
Field('IMAGE','upload'),
migrate=False
)
row = db().select(db.recipes.IMAGE).first()
image = str(dir(row))>>>
>>>
image = str(dir(row.IMAGE))['_BlobReader__blob_get', '_BlobReader__blobid', '_BlobReader__bytes_read', '_BlobReader__charset', '_BlobReader__closed', '_BlobReader__db_handle', '_BlobReader__ensure_open', '_BlobReader__index', '_BlobReader__is_text', '_BlobReader__mode', '_BlobReader__open', '_BlobReader__opened', '_BlobReader__pos', '_BlobReader__python_charset', '_BlobReader__reset_buffer', '_BlobReader__tr_handle', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_blob_handle', '_isc_status', 'blob_charset', 'blob_id', 'charset', 'close', 'closed', 'flush', 'get_info', 'is_text', 'mode', 'next', 'read', 'readline', 'readlines', 'seek', 'tell']I can not do row.file.row.IMAGE
row = db().select(db.recipes.IMAGE).first()
image = '<img src="'+URL('default', 'download', args=row.IMAGE)+'"/>'
db.define_table(
'recipes',
Field('NAME',length=512),
Field('IMAGE','upload'),
migrate=False
)
<img src="/Recipes/default/download/%3Cfdb.fbcore.BlobReader%20object%20at%200x07E810D0%3E">
row = db().select(db.recipes.IMAGE).first()
stream = row.IMAGE
image = '<img src="'+URL('default', 'download', args=stream.read())+'"/>'
<img src="/Recipes/default/download/b%27%5Cxff%5Cxd8%5Cxff%5Cxe0%5Cx00%5Cx10JFIF%5Cx00%5Cx01%5Cx01...">
db.define_table(
'recipes',
Field('NAME',length=512),
Field('IMAGE','blob'),
migrate=False
)
db().select(db.recipes.IMAGE).first()
web2py™ | Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 |
---|---|
Python | Python 3.7.3: C:\Program Files (x86)\Python37-32\python.exe (prefix: C:\Program Files (x86)\Python37-32) |
1. |
24. |
Traceback (most recent call last |
): |
self._caller = lambda f: f |
() |
TypeError(Expected bytes)
File C:\web2py\gluon\restricted.py in restricted at line 219 код аргументы переменные
File C:\web2py\applications\test\controllers\default.py in <module> at line 61 код аргументы переменные
File C:\web2py\gluon\globals.py in <lambda> at line 421 код аргументы переменные
File C:\web2py\applications\test\controllers\default.py in index at line 9 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\objects.py in select at line 2395 код аргументы переменные
2390. | attributes.get('join', None), |
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in select at line 763 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in _select_aux at line 742 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in parse at line 306 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in <listcomp> at line 303 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in _parse at line 232 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in parse_value at line 199 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in parse at line 100 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in __call__ at line 75 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in _call at line 72 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\parsers\base.py in _blob at line 37 код аргументы переменные
File C:\web2py\gluon\packages\dal\pydal\_compat.py in to_bytes at line 131 код аргументы переменные
(obj=<fdb.fbcore.BlobReader object>, charset='utf-8', errors='strict')
126. | return None |
#default.py
def img():
row = db(<query based on request.args/vars>).select(db.recipes.IMAGE).first()
if row:
return response.stream(row.IMAGE)
def img():
row = db().select(db.recipes.IMAGE).first()
if row:
return response.stream(row.IMAGE)
image = '<img src="'+URL( 'default', 'img')+'"/>'
<img src="/Recipes/default/img"/>
def index():
row = db().select(db.recipes.IMAGE).first()
import codecs
base64_data = codecs.encode(row.IMAGE.read(), 'base64')
base64_text = codecs.decode(base64_data, 'ascii')
image = XML('<img src="data:image/png;base64, %s" class="card-img-top" alt="..."/>' % base64_text)
return dict(image=image)
def index():
image = XML('<img src="'+URL( 'default', 'img')+'" class="card-img-top" alt="..."/>')
return dict(image=image)
def img():
row = db().select(db.recipes.IMAGE).first()
if row:
return response.stream(row.IMAGE)
def index():
image = XML('<img src="'+URL( 'default', 'img')+'" class="card-img-top" alt="..."/>')
return dict(image=image)
def img():
row = db().select(db.recipes.IMAGE).first()
if row:
return row.IMAGE.read()
rows = db().select(db.recipes.IMAGE)
for row in rows:
def img():
id =request.args(0)
if id: row = db(
db.recipes.id == id).select(db.recipes.IMAGE).first()def index():
image = ''
rows = db().select(db.recipes.IMAGE)
for row in rows:
image += '<img src="'+URL( 'default', 'img', args = [row.recipes.IMAGE])+'" class="card-img-top" alt="..."/>'
image = XML(image)
return dict(image=image)
def img():
image = request.args(0)
if image:
return image.read()
def putRecipesInCache():
recipesCache = cache.ram('recipes', lambda: db().select(db.recipes.IMAGE), time_expire=60*60*24)
return recipesCache
def index():
rows = putRecipesInCache()
image = ''
for row in rows:
if row.IMAGE is None:
image += ''
else:
import codecs
base64_data = codecs.encode(row.IMAGE.read(), 'base64')
base64_text = codecs.decode(base64_data, 'ascii')
image += '<img src="data:image/png;base64, %s" class="card-img-top" alt="..."/>' % base64_text
return XML()
File C:\web2py\gluon\restricted.py in restricted at line 219 код аргументы переменные
File C:\web2py\applications\Recipes\controllers\default.py in <module> at line 226 код аргументы переменные
File C:\web2py\gluon\globals.py in <lambda> at line 421 код аргументы переменные
File C:\web2py\applications\Recipes\controllers\default.py in index at line 74 код аргументы переменные
File C:\web2py\applications\Recipes\controllers\default.py in selectRecipes at line 146 код аргументы переменные
File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in read at line 4764 код аргументы переменные
File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in __ensure_open at line 4658 код аргументы переменные
File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in __open at line 4667 код аргументы переменные
(self=<fdb.fbcore.BlobReader object>)
4662. | bs([ibase.isc_bpb_version1, ibase.isc_bpb_type, 1, |