[web2py] Coolpropgit Not WORKING

2019-04-25 Thread Prashant Dhakal
Why isn't Coolpropgit working ? Whenever I try to use it shows :Ticket 
issued: 
coolpropgit/130.74.132.69.2019-04-23.22-42-24.69a3990b-1414-4b55-85f8-013b80876c7c
 


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Error importing csv file in python3.6

2019-04-25 Thread nbacquet via web2py-users
I had a similar issue.
I solve it doing this:

f = request.vars.csvfile.file
import io
file = io.TextIOWrapper(f, encoding='utf-8')

El lunes, 11 de febrero de 2019, 14:34:18 (UTC-3), Maurice Waka escribió:
>
> I shifted to web2py/python3. In python2.7 I was able to upload csv files 
> but using the same code below I get an error.
> For example:
> def import_csv():
> form = FORM(INPUT(_type = 'file', _name = 'csv_file'),
>  INPUT(_type = 'submit', _value = T('Import')))
> return dict(form=form)
> @mobilize
> @auth.requires_login()
> def index1():
> if request.vars.csvfile != None:
> # set values
> table = db[request.vars.table]
> file = request.vars.csvfile.file
> # import csv file
> table.import_from_csv_file(file)
> # update who imported
> query = db.food_data.protein==""
> db(query).update(protein="")
> response.flash = 'Data uploaded'
> return dict()
>
> The error is this
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/mauricewaka/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File 
> "/home/mauricewaka/web2py/applications/Hestque_Wellness/controllers/default.py"
>  
> ,
>  line 479, in 
>   File "/home/mauricewaka/web2py/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/home/mauricewaka/web2py/gluon/contrib/user_agent_parser.py", line 
> 695, in __call__
> return self.func()
>   File "/home/mauricewaka/web2py/gluon/tools.py", line 3867, in f
> return action(*a, **b)
>   File 
> "/home/mauricewaka/web2py/applications/Hestque_Wellness/controllers/default.py"
>  
> ,
>  line 329, in index1
> table.import_from_csv_file(file)
>   File "/home/mauricewaka/web2py/gluon/packages/dal/pydal/objects.py", line 
> 980, in import_from_csv_file
> for lineno, line in enumerate(reader):
> _csv.Error: iterator should return strings, not bytes (did you open the file 
> in text mode?)
>
> How can I solve this
>
>
-- 


CONFIDENCIALIDAD La información
contenida en este mensaje y/o en los 
archivos adjuntos es de carácter
confidencial o privilegiada y está 
destinada al uso exclusivo del emisor y/o de
la persona o entidad a quien 
va dirigida. Si usted no es el destinatario,
cualquier almacenamiento, 
divulgación, distribución o copia de esta información
está estrictamente 
prohibido y sancionado por la ley. Si recibió este mensaje
por error, por 
favor infórmenos inmediatamente respondiendo este mismo mensaje
y borre 
éste y todos los archivos adjuntos. Gracias. 



CONFIDENTIAL NOTE The 
information transmitted in this message and/or
attachments is confidential 
and/or privileged and is intented only for use of
the person or entity to 
whom it is addressed. If you are not the intended
recipient, any retention, 
dissemination, distribution or copy of this
information is strictly 
prohibited and sanctioned by law. If you received this
messagge in error, 
please reply us this same message and delete this message
and all 
attachments. 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] bye bye T, welcome pluralize

2019-04-25 Thread Massimo Di Pierro
web3py now uses this:

https://pypi.org/project/pluralize/
https://github.com/web2py/pluralize

thoughts? comments?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Web2py Windows edition with 3.x Interpreter

2019-04-25 Thread rāma
I tested this just now. I can't seem to import pandas.

raise ImportError("No module named %s" % modules_prefix)
ImportError: No module named applications.dqma.modules.pandas


I have a previous web2py from source and have all module in my 
site-packages which I copied over to this 64-bit version. I used a conda 
environment running of pycharm in my original version and made sure all the 
site-packages modules or not preinstalled in the conda environment.

Please help.

On Friday, 26 April 2019 13:02:37 UTC+8, rāma wrote:
>
> This is wonderful. And, something I would love to be adopted to the 
> official repo.
>
> Thanks for this!
>
> On Sunday, 3 March 2019 19:24:38 UTC+8, Nico Zanferrari wrote:
>>
>> Good morning!
>>
>> I'm proud to say that I've succeeded in building the Windows 64 bit 
>> binary with python 3.7.2 using pyinstaller !  Grab it from 
>> https://github.com/nicozanf/web2py-pyinstaller 
>>
>> There are some little gothas, but it seems to work fine:
>> - in the console I've got many errors like 
>> 'ERROR:Rocket.Errors.Thread-2:Tried to send "500 Server Error" to client 
>> but received socket error'. They disappear as soon as I've disabled IPv6 
>> and rebooted. There are users that report also to fix similar problems by 
>> adding the hostname on the hosts file
>> - psycopg2 is placed in a folder by itself, instead than in the root 
>> folder
>> - in the currently official binary build (with pyhton 2.7) there are also 
>> two binaries: web2py_no_console.exe and web2py_on_gevent.exe. They don't 
>> run correctly, and don't seem to be so important for me so I've decided to 
>> skip their generation.
>> - Macintosh compatibility is needed, but I cannot work on it
>>
>> Please, help with testing it! I'll make a PR on the official web2py 
>> repository after some feedback.
>>
>> Cheers,
>> Nico
>>
>> Il giorno mer 27 feb 2019 alle ore 12:03 Nico Zanferrari <
>> nico...@gmail.com> ha scritto:
>>
>>> Hi,
>>>
>>> this is a big problem also from my point of view and I've already opened 
>>> issue 
>>> 2027  . However it's not 
>>> so easy to achieve this goal, because you've to switch to 3.x + go 64 bit + 
>>> change the *freezer* program (py2exe and bbfreeze do not work with 
>>> python >= 3.5). I'm playing with pyinstaller, but I'm not promising 
>>> anything. And also a binary Mac version is needed (I only have a Win box), 
>>> plus testing everything.
>>>
>>> Cheers,
>>> Nico 
>>>
>>> Il giorno mer 27 feb 2019 alle ore 11:45 elisha bere  
>>> ha scritto:
>>>
 Hie, 

 Is it possible to change from 2.7 to 3.x in my web2py app

 On 17 Feb 2019 20:57, "Jitun John"  wrote:

> "It requires Python 2.6 (no more supported), Python 2.7 (stable) or 
> Python 3.5+ (*recommended for new projects*) already installed on 
> your system. 
> There are also *binary packages for Windows* and Mac OS X.* They 
> include the Python 2.7 interpreter* so you do not need to have it 
> pre-installed."
>
> Sorry for my ignorance, I am assuming "Python 2.7 interpreter" as 
> "python27.dll" and "pywintypes27.dll" files.
>
> I recently moved my app from 2.x to 3.x using PyCharm IDE and the app 
> works fine when using IDE on 3.7 python.
> But when I try to compile it to .exe (using .iss file + hstart.exe), I 
> cant use the existing web2py_win.zip file.
>
> Gives me " unsupported pickle protocol: 
> 3"
>
> As we are recommending new projects on 3.x, Is it possible for the 
> next version to have a 3.x interpreter ?
> or if we have a workaround, I am happy to try it.
>
> Thanks.
>
> -- 
> 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 web...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
 -- 
 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 web...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>

-- 
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 

Re: [web2py] Web2py Windows edition with 3.x Interpreter

2019-04-25 Thread rāma
This is wonderful. And, something I would love to be adopted to the 
official repo.

Thanks for this!

On Sunday, 3 March 2019 19:24:38 UTC+8, Nico Zanferrari wrote:
>
> Good morning!
>
> I'm proud to say that I've succeeded in building the Windows 64 bit binary 
> with python 3.7.2 using pyinstaller !  Grab it from 
> https://github.com/nicozanf/web2py-pyinstaller 
>
> There are some little gothas, but it seems to work fine:
> - in the console I've got many errors like 
> 'ERROR:Rocket.Errors.Thread-2:Tried to send "500 Server Error" to client 
> but received socket error'. They disappear as soon as I've disabled IPv6 
> and rebooted. There are users that report also to fix similar problems by 
> adding the hostname on the hosts file
> - psycopg2 is placed in a folder by itself, instead than in the root folder
> - in the currently official binary build (with pyhton 2.7) there are also 
> two binaries: web2py_no_console.exe and web2py_on_gevent.exe. They don't 
> run correctly, and don't seem to be so important for me so I've decided to 
> skip their generation.
> - Macintosh compatibility is needed, but I cannot work on it
>
> Please, help with testing it! I'll make a PR on the official web2py 
> repository after some feedback.
>
> Cheers,
> Nico
>
> Il giorno mer 27 feb 2019 alle ore 12:03 Nico Zanferrari <
> nico...@gmail.com > ha scritto:
>
>> Hi,
>>
>> this is a big problem also from my point of view and I've already opened 
>> issue 
>> 2027  . However it's not 
>> so easy to achieve this goal, because you've to switch to 3.x + go 64 bit + 
>> change the *freezer* program (py2exe and bbfreeze do not work with 
>> python >= 3.5). I'm playing with pyinstaller, but I'm not promising 
>> anything. And also a binary Mac version is needed (I only have a Win box), 
>> plus testing everything.
>>
>> Cheers,
>> Nico 
>>
>> Il giorno mer 27 feb 2019 alle ore 11:45 elisha bere > > ha scritto:
>>
>>> Hie, 
>>>
>>> Is it possible to change from 2.7 to 3.x in my web2py app
>>>
>>> On 17 Feb 2019 20:57, "Jitun John" > 
>>> wrote:
>>>
 "It requires Python 2.6 (no more supported), Python 2.7 (stable) or 
 Python 3.5+ (*recommended for new projects*) already installed on your 
 system. 
 There are also *binary packages for Windows* and Mac OS X.* They 
 include the Python 2.7 interpreter* so you do not need to have it 
 pre-installed."

 Sorry for my ignorance, I am assuming "Python 2.7 interpreter" as 
 "python27.dll" and "pywintypes27.dll" files.

 I recently moved my app from 2.x to 3.x using PyCharm IDE and the app 
 works fine when using IDE on 3.7 python.
 But when I try to compile it to .exe (using .iss file + hstart.exe), I 
 cant use the existing web2py_win.zip file.

 Gives me " unsupported pickle protocol: 3"

 As we are recommending new projects on 3.x, Is it possible for the next 
 version to have a 3.x interpreter ?
 or if we have a workaround, I am happy to try it.

 Thanks.

 -- 
 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 web...@googlegroups.com .
 For more options, visit https://groups.google.com/d/optout.

>>> -- 
>>> 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 web...@googlegroups.com .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: custom search

2019-04-25 Thread João Matos
You don't have the standard buttons, but have a search button created by 
you?


quinta-feira, 25 de Abril de 2019 às 15:21:41 UTC+1, Andrea Fae' escreveu:
>
> I create a custom search, so not standard field with "Search" and "reset" 
> button standard. How to click the button "Search" programmatically?
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: datepicker preserve selecred date after postback

2019-04-25 Thread João Matos
Is the selected date in a db field? Then when editing the same field, the 
date picker should show the selected date.

If the date is still not saved to a db field but only in js, then you can 
send it using something similar to this







quinta-feira, 25 de Abril de 2019 às 20:40:25 UTC+1, Andrea Fae' escreveu:
>
> How to preserve datepicker selected date after postback using web2py in a 
> javascript view... I think it's a javascript problem but I don't know 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: 2.18.5 admin UnicodeDecodeError

2019-04-25 Thread João Matos
Did you change the Python version? Check your path.
Also, if clearing the sessions and errors doesn't work, try to delete all 
*.pyc in the web2py tree.

Another possible origin are the databases if using SQLite.


quinta-feira, 25 de Abril de 2019 às 10:00:49 UTC+1, Jacinto Parga escreveu:
>
> Hi, It suddenly appeared. Version downloaded from source web. The same 
> with github version.
>
> Error ticket for "admin" Ticket ID 
>
> 127.0.0.1.2019-04-25.10-45-30.ec4c021c-532a-46c7-a8cd-6f9356fc7ab7
>  'ascii' codec can't decode byte 0x8b in 
> position 1: ordinal not in range(128) Versión 
> web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
> Python Python 3.7.3: /usr/bin/python3.7 (prefix: /usr) Rastreo 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
>
> Traceback (most recent call last):
>   File "/home/jacinto/web2py2185/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 2021, 
> in 
>   File "/home/jacinto/web2py2185/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 1627, 
> in errors
> error = pickle.load(fullpath_file)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)
>
> Error snapshot [image: help] 
> 
>  
>
> UnicodeDecodeError('ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)) 
>
> inspeccionar atributos 
> Frames 
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/restricted.py in restricted at 
>line 219* código argumentos variables 
>Code listing 
>
>214.
>215.
>216.
>217.
>218.
>219.
>220.
>221.
>222.
>223.
>
>if environment is None:
>environment = {}
>environment['__file__'] = layer
>environment['__name__'] = '__restricted__'
>try:
>exec(ccode, environment)
>except HTTP:
>raise
>except RestrictedError:
># do not encapsulate (obfuscate) the original RestrictedError
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
> at line 2021* código argumentos variables 
>Code listing 
>
>2010.
>2011.
>2012.
>2013.
>2014.
>2015.
>2016.
>2017.
>2018.
>2019.
>
>else:
>filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
>if plugin_install(app, urlopen(source),
>  request, filename):
>session.flash = T('New plugin installed: %s', filename)
>else:
>session.flash = \
>T('unable to install plugin "%s"', filename)
>redirect(URL(f="plugins", args=[app, ]))
>return dict(form=form, app=app, plugin=plugin, source=source)
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/globals.py in  at line 
>421* código argumentos variables 
>Code listing 
>
>416.
>417.
>418.
>419.
>420.
>421.
>422.
>423.
>424.
>425.
>
>self.flash = ''# used by the default view layout
>self.meta = Storage()  # used by web2py_ajax.html
>self.menu = [] # used by the default view layout
>self.files = []# used by web2py_ajax.html
>self._vars = None
>self._caller = lambda f: f()
>self._view_environment = None
>self._custom_commit = None
>self._custom_rollback = None
>self.generic_patterns = ['*']
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
>errors at line 1627* código argumentos variables 
>Function argument list 
>
>()
>Code listing 
>
>1622.
>1623.
>1624.
>1625.
>1626.
>1627.
>1628.
>1629.
>1630.
>1631.
>
>if not os.path.isfile(fullpath):
>continue
>try:
>fullpath_file = safe_open(fullpath, 'rb')
>try:
>error = pickle.load(fullpath_file)
>finally:
>fullpath_file.close()
>except IOError:
>continue
>
>Variables
>
>

-- 
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 

[web2py] Re: How to build onvalidation routine for unique within location

2019-04-25 Thread João Matos
You shouldn't create a field called id. Check the recommendations on the 
docs. web2py creates an id (auto-increment) field automatically.

Anyway, form.vars.* are only available on onvalidation if the field is 
editable.

Check your grid config. Maybe adding field_id=db.brix_test.id would help.
Check request.vars.id.


quinta-feira, 25 de Abril de 2019 às 00:50:22 UTC+1, Jim S escreveu:
>
> Give the following table:
>
> db.define_table('brix_test',
> Field('id', 'id', readable=False),
> Field('site', 'reference site',
>   requires=IS_IN_DB(self.db, 'site',
> '%(siteNumber)s - %(name)s',
> zero='..')),
> Field('mixer_tech', 'reference mixerTech',
>   requires=IS_IN_DB(self.db, 'mixerTech', '%(name)s', zero='..')),
> Field('sampled', 'datetime', requires=IS_DATE('%m/%d/%Y %I:%M %p')),
> Field('sample_id', length=20, requires=IS_NOT_EMPTY()),
> Field('source', length=50, requires=IS_NOT_EMPTY()),
> Field('water_weight', 'integer', requires=IS_INT_IN_RANGE(100, 300)))
>
>
> I want to create an onvalidation function to be run when saving from by 
> SQLFORM.grid that will ensure that the 'source' field is unique within each 
> site.  
>
> Ex:
>
> A record for Site 1 can have a sample_id of 'Tank 1'
> A record for Site 2 can have a sample_id of 'Tank 1'
>
> But you cannot have more than 1 record for Site 1 where sample_id is 'Tank 
> 1'
>
> My problem is that I can't get my 'id' field to be recognized in my 
> onvalidation function:
>
> def validate_brix_test(form):
> brix_test_id = form.vars.id
> site_id = form.vars.site
> mixer_tech_id = form.vars.mixer_tech
> sample_id = form.vars.sample_id
>
>
> site = db.site(site_id)
>
>
> #  mixer tech must belong to the site specified
> mt = db.mixerTech(mixer_tech_id)
> if not mt:
> form.errors.mixer_tech = 'Mixer Tech was not found'
> else:
> if mt.siteId != site_id:
> form.errors.mixer_tech = 'Mixer Tech does not belong to %s.' % 
> site.name
>
>
> #  sample id must be unique within the site
> if brix_test_id and brix_test_id > 0:
> sample_id_count = db((db.brix_test.id != brix_test_id) &
>  (db.brix_test.sample_id == sample_id) &
>  (db.brix_test.site == site_id)).count()
> else:
> sample_id_count = db((db.brix_test.sample_id == sample_id) &
>  (db.brix_test.site == site_id)).count()
>
>
> if sample_id_count > 0:
> form.errors.sample_id = 'This sample ID has already been used at 
> %s.' % site.name
>
>
> return
>
> The problem is that form.vars.id is always None regardless of whether or 
> not I have db.brix_test.id.readable = db.brix_test.id.writable = True or 
> False
>
> Any idea how I can get the ID of the record in the form into the 
> onvalidation function?
>
> -Jim
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to create js function before web2py.js send data to server?

2019-04-25 Thread Dave S


On Wednesday, April 24, 2019 at 10:34:39 AM UTC-7, Константин Комков wrote:
>
> I use two validation (client and server). Web2py has good mechanism, which 
> block submit button and change text with considering translate another 
> languages.
> I need validate form when button was pushed and in that case I can't use 
> onblur, becouse web2py.js has own handler on that button. It's where I use 
> validation https://oas.timacad.ru/application/useCalc
>


I don't seem to have broken web2py by using onblur myself, but other 
triggers are available.  My only glitch is when I decide I'm not 
submitting, and click outside the form for a link to another page, then I 
have to click twice, but I have some ideas about fixing that.

/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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Radio Buttons basic inline editing in SQLFORM.grid

2019-04-25 Thread Dave S


On Wednesday, April 24, 2019 at 4:16:56 PM UTC-7, Jacob wrote:
>
> Hello I'm still new to web2py and I'm currently working on an a grid which 
> utilises basic inline editing using the example from 
> http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript
>  
>
> When I change the options widget to a radio widget for some reason only 
> one value for a whole set of seperate records can be selected rather than 
> each record having only 1 radio button field selected. In other words a 
> record has 4 possible values and they are displayed in a grid and can be 
> edited there is a field with a set which I'm trying to use radio buttons 
> for instead of a drop down menu. When I press a value for the first record 
> this is fine when I move onto the record beneath it the radio button value 
> is selected however the first one becomes empty and this carries on 
> throughout all the records on the grid only 1 field can be selected at a 
> time. If someone could help me please I would be very grateful.  
>

My first thought is that you've got a bunch of buttons with the same name.  
You can check this fairly easily by using your browser's inspect tool, and 
looking at the buttons for name=.  If that's the case, then you need to 
work out a way for each item's buttons to get a unique name; perhaps append 
item.id on the end of the name.

/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.
For more options, visit https://groups.google.com/d/optout.


[web2py] datepicker preserve selecred date after postback

2019-04-25 Thread Andrea Fae'
How to preserve datepicker selected date after postback using web2py in a 
javascript view... I think it's a javascript problem but I don't know 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] custom widget search form

2019-04-25 Thread Andrea Fae'
Can anyone help me giving me an example of custom widget search form? 
Better with default values and if is it possible to click "Search" 
programmatically. Thank you very much

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] custom search

2019-04-25 Thread Andrea Fae'
I create a custom search, so not standard field with "Search" and "reset" 
button standard. How to click the button "Search" programmatically?
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Connect to Sybase ASE 15.7

2019-04-25 Thread isi_jca
Using Python native module in SDK ASE 16, the connection is sucessful

 import sybpydb
 conn = sybpydb.connect(servername='TEST',user='Myuser', 
password='Pa$$w0rd')
 cur = conn.cursor()
 cur.execute("select succod, sucdesc from mydb..tsucursal")
 while True:
 row = cur.fetchone()
 if (not row):
break
print("%s: %s" % (row[0], row[1]))
 else:
 print('Sucursal',row[0],'Descripcion',row[1])
 cur.close()
conn.close()


/*==*/
>From web2py, I am using 'mssql' intead of 'sybase' because sybase has not 
DSN attribute.

db = DAL('mssql://DSN=SERVERTEST',check_reserved=['all'])
 
  ('42000', "[42000] [SAP][ASE ODBC 
Driver][Adaptive Server Enterprise]Incorrect syntax near '('.\n (102) 
(SQLExecDirectW)")
 Version
 web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
 Python Python 2.7.8: C:\Python27\python.exe (prefix: C:\Python27)
 Traceback
 
 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 219, in restricted
 exec(ccode, environment)
   File "C:\web2py\applications\StatusWeb\models\db.py", line 98, in 

 auth.define_tables(username=False, signature=False)
   File "C:\web2py\gluon\tools.py", line 2092, in define_tables
 super(Auth, self).define_tables(username, signature, migrate, 
fake_migrate)._table_signature_list
   File "C:\web2py\gluon\authapi.py", line 350, in define_tables
 format='%(first_name)s %(last_name)s (%(id)s)'))
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 592, in 
define_table
 table = self.lazy_define_table(tablename, *fields, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 626, in 
lazy_define_table
 polymodel=polymodel)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 798, in 
create_table
 return self.migrator.create_table(*args, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\migrator.py", line 281, in 
create_table
 self.adapter.create_sequence_and_triggers(query, table)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 881, in 
create_sequence_and_triggers
 self.execute(query)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\__init__.py", line 67, 
in wrap
 return f(*args, **kwargs)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 413, in 
execute
 rv = self.cursor.execute(command, *args[1:], **kwargs)
 ProgrammingError: ('42000', "[42000] [SAP][ASE ODBC Driver][Adaptive 
Server Enterprise]Incorrect syntax near '('.\n (102) (SQLExecDirectW)")
 
 Error snapshot help
 
 (('42000', "[42000] [SAP][ASE ODBC 
Driver][Adaptive Server Enterprise]Incorrect syntax near '('.\n (102) 
(SQLExecDirectW)"))
 
 inspect attributes
 Frames
 
 File C:\web2py\gluon\restricted.py in restricted at line 219 code 
arguments variables
 
 File C:\web2py\applications\StatusWeb\models\db.py in  at line 
98 code arguments variables
 
 File C:\web2py\gluon\tools.py in define_tables at line 2092 code 
arguments variables
 
 File C:\web2py\gluon\authapi.py in define_tables at line 350 code 
arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\base.py in define_table at 
line 592 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\base.py in lazy_define_table 
at line 626 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in 
create_table at line 798 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\migrator.py in create_table at 
line 281 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in 
create_sequence_and_triggers at line 881 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\adapters\__init__.py in wrap 
at line 67 code arguments variables
 
 File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in execute at 
line 413 code arguments variables
 Function argument list
 
 (self=, *args=('CREATE TABLE 
"auth_user"(\n "id" INT IDENTITY ... NULL,\n "registration_id" VARCHAR(512) 
NULL\n);',), **kwargs={})
 Code listing
 
 
 
 def execute(self, *args, **kwargs):
 command = self.filter_sql_command(args[0])
 handlers = self._build_handlers_for_execution()
 for handler in handlers:
 handler.before_execute(command)
 rv = self.cursor.execute(command, *args[1:], **kwargs)
 for handler in handlers:
 handler.after_execute(command)
 return rv
 
 Variables
 rv undefined
 self 
 args ('CREATE TABLE "auth_user"(\n "id" INT IDENTITY ... NULL,\n 
"registration_id" VARCHAR(512) NULL\n);',)
 self.cursor 
 command 'CREATE TABLE "auth_user"(\n "id" INT IDENTITY ... NULL,\n 
"registration_id" VARCHAR(512) NULL\n);'
 self.cursor.execute 
 kwargs {}
 
 
 

[web2py] MARKMIN - Sanitizing

2019-04-25 Thread Paul Ellis
I am using an editable span with some js to submit the input via ajax to 
the server. The span is only editable by admins. 

To give them some formatting options they can use MARKMIN in the span.

The problem is it only seems to be one directional. 
How can I take the processed HTML and turn it back into MARKMIN in order to 
allow editing?

or at least sanitize it that I can be sure no malicious code has been 
submitted so I can save the MARKMIN in the db.

 js that sends the span contents.
$("document").ready(function() {

// set the event listeners on the edit button
$("button[name='buttonedit']").click(function() {
var panel = $(this)[0].previousSibling
panel.innerText = panel.getAttribute("data-raw")
panel.setAttribute("contenteditable", "true")
// console.log(panel)
$(this).hide()
$(this)[0].nextSibling.setAttribute("style", "display:true")
})
$("button[name='buttonsave']").click(function() {
$(this).disabled = true
var xhttp = new XMLHttpRequest();
xhttp.open('POST', '/assist/update_info_panel', true);
xhttp.setRequestHeader("Content-type", 
"application/x-www-form-urlencoded");
var panel = $(this)[0].previousElementSibling.previousElementSibling
var body = {
'pid': panel.id, 
'body': panel.innerText,
};
// console.log(body);
xhttp.onreadystatechange = function() {
// debug code
// if (this.readyState == 4) {
// console.log(this);
// };
if (this.readyState == 4 && this.status == 200) {
var rObj = JSON.parse(this.responseText);
$("span#"+rObj.pid).replaceWith(rObj.body)
$("span#"+rObj.pid)
.next().attr("style", "display:true")
.next().attr("style", "display:None")
$("span#"+rObj.pid).find("a").attr("target", "_blank")

}
};
xhttp.send(JSON.stringify(body));
})
})

the controller function that receives the markmin (via json) and returns 
the HTML.

In order to allow editing the raw markmin is stored in a data attribute. I 
feel this is very unsafe which is why I am asking for help.
def update_info_panel():
if auth.has_membership('assistant_admin', cached=True):
raw_json = None
for key in request.vars.keys():
if len(key) > 10:
raw_json = key
inData = Storage(json.loads(raw_json))
pid = inData.pid[5:]
record = db.product[pid]
assist_info = inData.body
if record:
record.update_record(assist_info=assist_info)
body = {
'pid': inData.pid,
'body': SPAN(MARKMIN(assist_info),
_id=inData.pid,
_name='info_panel',
_contenteditable='false',
data = {'raw': assist_info}
).__str__()
}
return json.dumps(body) 
else:
pass

The section of the view which holds the span and edit buttons.

{{try:}}
{{for item in extra_info:}}
{{=DIV(
SPAN(MARKMIN(item['info']),
_id= 'info_{0}'.format(item['pid']),
_name= 'info_panel', 
_contenteditable= 'false',
_style="display:block",
data= {
'raw':item['info'] if 
auth.has_membership('assistant_admin') else '',
},
),
BUTTON(SPAN(_class="glyphicon glyphicon-pencil"), 
_class='btn btn-sm btn-default', 
_name='buttonedit')\
if auth.has_membership('assistant_admin') 
else '',
BUTTON(SPAN(_class='glyphicon 
glyphicon-floppy-disk'),
_class="btn btn-sm btn-primary", 
_name="buttonsave",
_style="display:none")\
if auth.has_membership('assistant_admin') 
else '',
_id= 'box_{0}'.format(item['id']),
_style='display:none', 
)}}
{{pass}}
{{except Exception as e:}}
{{print e}}
{{pass}}


The function looks and works great. Apart from the Italic formatting 
cutting the JSON string short, resulting in invalid JSON and me being very 
uneasy about saving raw user input into the db and then letting it back out 
again. 

As a side question. Is there different way to add the JSON string to the 
ajax request in js so that it is accessible from somwhere other than as a 
key in request.vars?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book 

[web2py] Re: 2.18.5 admin UnicodeDecodeError

2019-04-25 Thread Dave S


On Thursday, April 25, 2019 at 2:00:49 AM UTC-7, Jacinto Parga wrote:
>
> Hi, It suddenly appeared. Version downloaded from source web. The same 
> with github version.
>
> Error ticket for "admin" Ticket ID 
>
> 127.0.0.1.2019-04-25.10-45-30.ec4c021c-532a-46c7-a8cd-6f9356fc7ab7
>  'ascii' codec can't decode byte 0x8b in 
> position 1: ordinal not in range(128) Versión 
> web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
> Python Python 3.7.3: /usr/bin/python3.7 (prefix: /usr)
>

Are you updating an existing installation, or doing a new installation?

If updating, you may need to clear  old sessions (looks like you're okay on 
the errors directory, which sometimes gets pickle errors on updates).

/dps

Rastreo 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
>
> Traceback (most recent call last):
>   File "/home/jacinto/web2py2185/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 2021, 
> in 
>   File "/home/jacinto/web2py2185/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
> , line 1627, 
> in errors
> error = pickle.load(fullpath_file)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)
>
> Error snapshot [image: help] 
> 
>  
>
> UnicodeDecodeError('ascii' codec can't decode byte 0x8b in position 1: 
> ordinal not in range(128)) 
>
> inspeccionar atributos 
> Frames 
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/restricted.py in restricted at 
>line 219* código argumentos variables 
>Code listing 
>
>214.
>215.
>216.
>217.
>218.
>219.
>220.
>221.
>222.
>223.
>
>if environment is None:
>environment = {}
>environment['__file__'] = layer
>environment['__name__'] = '__restricted__'
>try:
>exec(ccode, environment)
>except HTTP:
>raise
>except RestrictedError:
># do not encapsulate (obfuscate) the original RestrictedError
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
> at line 2021* código argumentos variables 
>Code listing 
>
>2010.
>2011.
>2012.
>2013.
>2014.
>2015.
>2016.
>2017.
>2018.
>2019.
>
>else:
>filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
>if plugin_install(app, urlopen(source),
>  request, filename):
>session.flash = T('New plugin installed: %s', filename)
>else:
>session.flash = \
>T('unable to install plugin "%s"', filename)
>redirect(URL(f="plugins", args=[app, ]))
>return dict(form=form, app=app, plugin=plugin, source=source)
>
>- 
>
>*File /home/jacinto/web2py2185/gluon/globals.py in  at line 
>421* código argumentos variables 
>Code listing 
>
>416.
>417.
>418.
>419.
>420.
>421.
>422.
>423.
>424.
>425.
>
>self.flash = ''# used by the default view layout
>self.meta = Storage()  # used by web2py_ajax.html
>self.menu = [] # used by the default view layout
>self.files = []# used by web2py_ajax.html
>self._vars = None
>self._caller = lambda f: f()
>self._view_environment = None
>self._custom_commit = None
>self._custom_rollback = None
>self.generic_patterns = ['*']
>
>- 
>
>*File 
>/home/jacinto/web2py2185/applications/admin/controllers/default.py in 
>errors at line 1627* código argumentos variables 
>Function argument list 
>
>()
>Code listing 
>
>1622.
>1623.
>1624.
>1625.
>1626.
>1627.
>1628.
>1629.
>1630.
>1631.
>
>if not os.path.isfile(fullpath):
>continue
>try:
>fullpath_file = safe_open(fullpath, 'rb')
>try:
>error = pickle.load(fullpath_file)
>finally:
>fullpath_file.close()
>except IOError:
>continue
>
>Variables
>
>

-- 
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)
--- 

[web2py] 2.18.5 admin UnicodeDecodeError

2019-04-25 Thread Jacinto Parga
Hi, It suddenly appeared. Version downloaded from source web. The same with 
github version.

Error ticket for "admin" Ticket ID 

127.0.0.1.2019-04-25.10-45-30.ec4c021c-532a-46c7-a8cd-6f9356fc7ab7
 'ascii' codec can't decode byte 0x8b in 
position 1: ordinal not in range(128) Versión 
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
Python Python 3.7.3: /usr/bin/python3.7 (prefix: /usr) Rastreo 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File "/home/jacinto/web2py2185/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
, line 2021, in 

  File "/home/jacinto/web2py2185/gluon/globals.py", line 421, in 
self._caller = lambda f: f()
  File "/home/jacinto/web2py2185/applications/admin/controllers/default.py" 
, line 1627, in 
errors
error = pickle.load(fullpath_file)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal 
not in range(128)

Error snapshot [image: help] 

 

UnicodeDecodeError('ascii' codec can't decode byte 0x8b in position 1: 
ordinal not in range(128)) 

inspeccionar atributos 
Frames 
   
   - 
   
   *File /home/jacinto/web2py2185/gluon/restricted.py in restricted at line 
   219* código argumentos variables 
   Code listing 
   
   214.
   215.
   216.
   217.
   218.
   219.
   220.
   221.
   222.
   223.
   
   if environment is None:
   environment = {}
   environment['__file__'] = layer
   environment['__name__'] = '__restricted__'
   try:
   exec(ccode, environment)
   except HTTP:
   raise
   except RestrictedError:
   # do not encapsulate (obfuscate) the original RestrictedError
   
   - 
   
   *File /home/jacinto/web2py2185/applications/admin/controllers/default.py 
   in  at line 2021* código argumentos variables 
   Code listing 
   
   2010.
   2011.
   2012.
   2013.
   2014.
   2015.
   2016.
   2017.
   2018.
   2019.
   
   else:
   filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
   if plugin_install(app, urlopen(source),
 request, filename):
   session.flash = T('New plugin installed: %s', filename)
   else:
   session.flash = \
   T('unable to install plugin "%s"', filename)
   redirect(URL(f="plugins", args=[app, ]))
   return dict(form=form, app=app, plugin=plugin, source=source)
   
   - 
   
   *File /home/jacinto/web2py2185/gluon/globals.py in  at line 421* 
   código argumentos variables 
   Code listing 
   
   416.
   417.
   418.
   419.
   420.
   421.
   422.
   423.
   424.
   425.
   
   self.flash = ''# used by the default view layout
   self.meta = Storage()  # used by web2py_ajax.html
   self.menu = [] # used by the default view layout
   self.files = []# used by web2py_ajax.html
   self._vars = None
   self._caller = lambda f: f()
   self._view_environment = None
   self._custom_commit = None
   self._custom_rollback = None
   self.generic_patterns = ['*']
   
   - 
   
   *File /home/jacinto/web2py2185/applications/admin/controllers/default.py 
   in errors at line 1627* código argumentos variables 
   Function argument list 
   
   ()
   Code listing 
   
   1622.
   1623.
   1624.
   1625.
   1626.
   1627.
   1628.
   1629.
   1630.
   1631.
   
   if not os.path.isfile(fullpath):
   continue
   try:
   fullpath_file = safe_open(fullpath, 'rb')
   try:
   error = pickle.load(fullpath_file)
   finally:
   fullpath_file.close()
   except IOError:
   continue
   
   Variables
   

-- 
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.
For more options, visit https://groups.google.com/d/optout.