[web2py] Como mostrar a imagem no HTML com web2py
olha eu aqui dnv :) Estou com um problema eu insiro uma imagem no banco mas na hr de mostrar no HTML não consigo de jeito nem um, eu nãoi to usando o template do web2py então td pra mim é mais dificil alguem teria algum jeito de fazer OBS : eu coloquei um campo extra_field no auth_user como foto e queria exibir essa foto, só que não utilizo quase nd do que o web2py tem pronto tipo sqlform grid essas coisas dai tenho que fazer mais manual a coisa alguem teria como me dar uma luz To tentando algo do genero tentei usar a função download que ta na default só que no meu controller só que ainda não funciona quando salvo a imagem ela upa a imagem no upload tipo auth_user.foto e uma hash só qe não consigo fazer funcionar msm alguem me ajuda :( -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/9131340d-6d7a-4d8f-bfa1-3fc0b0001ba7%40googlegroups.com.
[web2py] why Web2py doesn't compile all
I'm using web2py in python3.6. When running the app on the local machine, everything is fine. But when I compile and run it again, I get errors that a module does not exist. The module is not found in the compiled folder. How do I solve this?? Regards -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/da0c7209-0777-4f64-b04c-5ebf6d7fdcf6%40googlegroups.com.
[web2py] Re: Como mostrar a imagem no HTML com web2py
On Tuesday, August 6, 2019 at 8:21:57 AM UTC-7, Kimus wrote: > > olha eu aqui dnv :) > > Estou com um problema eu insiro uma imagem no banco mas na hr de mostrar > no HTML não consigo de jeito nem um, eu nãoi to usando o template do > web2py então td pra mim é mais dificil alguem teria algum jeito de fazer > > OBS : eu coloquei um campo extra_field no auth_user como foto e queria > exibir essa foto, só que não utilizo quase nd do que o web2py tem pronto > tipo sqlform grid essas coisas dai tenho que fazer mais manual a coisa > alguem teria como me dar uma luz > > To tentando algo do genero tentei usar a função download que ta na > default só que no meu controller só que ainda não funciona quando salvo a > imagem ela upa a imagem no upload tipo auth_user.foto e uma hash só qe não > consigo fazer funcionar msm alguem me ajuda :( > > > An upload field will store the original filename and an obfuscated filename (that is, a new name for the file that contains a unique portion and an encoding of the original name). The obfuscated filename, which looks rather like a hash, is the filename used by the filesystem. The user/download function in the controllers/default.py understands how to handle this. The URL to download an uploaded file is generated by A(" click to download", _href= URL("download", args=row.fdata) and looks like download/uploadf.fdata.81a339e105991c67.454e482d3570317670303956505530653369757a394d73484a64465f70657270657475616c5f5352562d48565f323031393038303631373237.txt Translating this to display an image, here's a controller function: def testimg(): row = db(db.uploadf.fname=="test1").select().first() return dict(img = row.fdata) using the model db.define_table('uploadf', Field('fname', 'string'), Field('fdata', 'upload'),migrate='uploadf.table') and the view testimg.html looks like {{extend 'layout.html'}} {{block header}} Blah! {{end}} {{=IMG(_src=URL("download", img), _alt="test image")}} After the page is loaded, if you use the browser tools to Inspect Element, you're shown To connect with your auth_user table, you may want to add an extra field that references the file uploaded image. For more on upload fields, see http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads> and http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth> or http://web2py.com/books/default/chapter/31/06/a-camada-de-abstracao-do-banco-de-dados#-Tipos-de-campo> http://web2py.com/books/default/chapter/31/06/a-camada-de-abstracao-do-banco-de-dados#-Mais-sobre-uploads> and http://web2py.com/books/default/chapter/31/09/controle-de-acesso#-Personalizando-Auth> for the Portuguese (Spanish is "41" instead of "31" or "29"). Good luck! Dave S /dps -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/d35b799d-87a1-4595-b150-68e06168158c%40googlegroups.com.
[web2py] Re: How can I insert image in HTML from database?
On Monday, August 5, 2019 at 11:28:43 PM UTC-7, Константин Комков wrote: > > *Val K*, it is my table.py file: > db.define_table( > 'recipes', > Field('NAME',length=512), > Field('IMAGE','upload'), > migrate=False > ) > It's code in my default.py file: > row = db().select(db.recipes.IMAGE).first() > > image = str(dir(row)) > >>> > row.keys() is more interesting than 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.file probably doesn't exist, because it would have to be row.keys() (it's not in the attributes, as you've shown), and then looking in a putative row.files for row key or attribute doesn't seem sensible. I don't have any experience with BLOBs, but I believe default/user/download is able to handle them. For a file-based upload field, the upload field is a string that default/user/download uses to locate the file. That is, it is the obfuscated file name, and the rest of the path is defined by the uploadfolder value (default, myapp/uploads), as well as uploadseparate and uploadfs. For BLOBs, you've instead set uploadfield to true. In my case, the file-base one, the attributes are those of a string, but I don't have to do much with it except return it in hrefs. default/users/download will use the path name or the blob field to figure out what to stream. There are times when it is desirable to set up the streaming in your code, and I thought this was one of those times, but Ramos and Val K have pointed out how to use the out-of-the-box tool to do this. /dps -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c14f5f36-3b83-44ca-9681-ad571bbabde7%40googlegroups.com.
[web2py] Re: py4web: how to import Template and change delimiters
it's port lte-2.4.15 to py4web https://github.com/ali96343/lteadmin-py4web четверг, 1 августа 2019 г., 10:48:02 UTC+3 пользователь Alex Beskopilny написал: > > Hi! > I put lte-2.4.15 to py4web and lte works with controllers.py : > > from py4web import action, request, abort, redirect, URL > from yatl.helpers import A > from . common import db, session, T, cache, auth > > @action('index') > @action.uses('index.html', ) > #@action.uses(Template('index.html', delimiters='[[ ]]')) > def index(): > message= "index.html" > user= "first second third" > return dict(message=message, user=user) > .. > but does not works with : > from py4web import action, request, abort, redirect, URL , Template > > > > error message: > WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.20ms > WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.55ms > WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 1.45ms > > how to fix it ? > > Is it possible to use some characters for delimiters, > for example delimiters='XXX ' ? > what is limits for delimiters ? > > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/340caf35-ba63-4255-a925-3be063ee7982%40googlegroups.com.