[web2py] Re: Web3py

2019-06-08 Thread 黄祥
test pip3 install web3py on ubuntu docker container, known work must 
install cython3 to ensure gevent source can be build by gcc, and the 
procedure must clone repo first then run python3 setup.py install, then you 
can successful pip3 install web3py (inefficient i think), detail steps on 
test 5 below
*error traceback*
Collecting web3py
  Downloading https:
//files.pythonhosted.org/packages/ee/a2/f57e1fefb0c62b4423fd76ea359d58d2363982054050b8c0ab54ed4b84c5/web3py-0.1.20190426.tar.gz
Complete output from command python setup.py egg_info:
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
  File "", line 1, in 
  File "/tmp/pip-build-fedj6ohs/web3py/setup.py", line 25, in 
long_description=__doc__ + ' (%s)' % get_hash(),
  File "/tmp/pip-build-fedj6ohs/web3py/setup.py", line 13, in get_hash
return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip
().decode('utf8')
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'rev-parse', 'HEAD']' 
returned non-zero exit status 128.

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-
build-fedj6ohs/web3py/

*test 1 steps : return error traceback above*
apt install -y git python3-pip cython3
pip3 install web3py

*test 2 steps : return error traceback above*
apt install -y git python3-pip cython3
cd
git init
pip3 install web3py

*test 3 steps : return error traceback above*
apt install -y git python3-pip cython3
cd
git clone https://github.com/web2py/web3py
cd web3py
pip3 install web3py

*test 4 steps : return error traceback above*
apt install -y git python3-pip cython3
cd
git clone https://github.com/web2py/web3py
cd web3py
pip3 install -U -r requirements.txt
pip3 install web3py

*test 5 steps : work*
apt install -y git python3-pip cython3 
cd
git clone https://github.com/web2py/web3py
cd web3py
python3 setup.py clean
python3 setup.py build
python3 setup.py install
pip3 install web3py
python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
touch apps/__init__.py
/usr/local/bin/web3py-start -p ./password.txt -a 0.0.0.0:8000 ./apps

best regards,
stifan

-- 
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/e130cce2-43de-44ec-bf9e-edbd267008cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-06-08 Thread 黄祥
tested latest commit 151 on docker ubuntu 
*problem*
dont have web3py/apps/__init__.py

*solution*
touch web3py/apps/__init__.py

*steps*
apt install -y git python3-pip
pip3 install git+https://github.com/web2py/web3py --upgrade
git clone https://github.com/web2py/web3py
python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
web3py-start -p ./password.txt -a 0.0.0.0:8000 /web3py/apps

*result (ended with web server not starting)*
Traceback (most recent call last):
  File "/usr/local/bin/web3py-start", line 11, in 
load_entry_point('web3py==0.1.20190426', 'console_scripts', 
'web3py-start')()
  File "/usr/local/lib/python3.6/dist-packages/web3py/core.py", line 717, in 
main
Reloader.import_apps()
  File "/usr/local/lib/python3.6/dist-packages/web3py/core.py", line 600, in 
import_apps
module = importlib.machinery.SourceFileLoader('apps', path).load_module
()
  File "", line 399, in 
_check_name_wrapper
  File "", line 823, in load_module
  File "", line 682, in load_module
  File "", line 265, in _load_module_shim
  File "", line 684, in _load
  File "", line 665, in _load_unlocked
  File "", line 674, in exec_module
  File "", line 780, in get_code
  File "", line 832, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 
'/web3py/apps/__init__.py'

best regards,
stifan

-- 
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/ea6371ac-d65f-4999-9417-9c800e998d7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-06-08 Thread 黄祥

>
> try a db.commit() after your define_table(s).
>

 already tried, same result (tested on different os), reported on previous 
message in this thread

best regards,
stifan

-- 
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/da7caa33-624e-4c94-a0cc-90e3e9463350%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Generating graph with chartjs

2019-06-08 Thread Massimo Di Pierro
Look into dashboard.js. It contains code like:

  var line = new Morris.Line({
element  : 'line-chart',
resize   : true,
data : [
  { y: '2011 Q1', item1: 2666 },
  { y: '2011 Q2', item1: 2778 },
  { y: '2011 Q3', item1: 4912 },
  { y: '2011 Q4', item1: 3767 },
  { y: '2012 Q1', item1: 6810 },
  { y: '2012 Q2', item1: 5670 },
  { y: '2012 Q3', item1: 4820 },
  { y: '2012 Q4', item1: 15073 },
  { y: '2013 Q1', item1: 10687 },
  { y: '2013 Q2', item1: 8432 }
],
xkey : 'y',
ykeys: ['item1'],
labels   : ['Item 1'],
lineColors   : ['#efefef'],
lineWidth: 2,
hideHover: 'auto',
gridTextColor: '#fff',
gridStrokeWidth  : 0.4,
pointSize: 4,
pointStrokeColors: ['#efefef'],
gridLineColor: '#efefef',
gridTextFamily   : 'Open Sans',
gridTextSize : 10
  });

What you have to do is replace input with something that you can pass from 
the server. There are many ways. I am going to suggestsimple solution 
without ajax which assume the html has been converted into a template

  var line = new Morris.Line({
element  : 'line-chart',
resize   : true,
data : MY_DATA_1,
xkey : 'y',
ykeys: ['item1'],
labels   : ['Item 1'],
lineColors   : ['#efefef'],
lineWidth: 2,
hideHover: 'auto',
gridTextColor: '#fff',
gridStrokeWidth  : 0.4,
pointSize: 4,
pointStrokeColors: ['#efefef'],
gridLineColor: '#efefef',
gridTextFamily   : 'Open Sans',
gridTextSize : 10
  });

Then in the controller that serves the page

def index():
 data = [
  { y: '2011 Q1', item1: 2666 },
  { y: '2011 Q2', item1: 2778 },
  { y: '2011 Q3', item1: 4912 },
  { y: '2011 Q4', item1: 3767 },
  { y: '2012 Q1', item1: 6810 },
  { y: '2012 Q2', item1: 5670 },
  { y: '2012 Q3', item1: 4820 },
  { y: '2012 Q4', item1: 15073 },
  { y: '2013 Q1', item1: 10687 },
  { y: '2013 Q2', item1: 8432 }
]
return dict(mydata1 = data)

and in the template, before  you add

{{=ASSIGNJS(MY_DATA_1 = mydata1)}}

This was the data is defined in python, passed to the template, stored in a 
js variable, and made it visible to the dashboard.js code.

On Saturday, 8 June 2019 12:25:41 UTC-7, Paul Arsenio Blanco Reyes wrote:
>
> Recently I found the theme "AdminLTE" (
> https://adminlte.io/themes/AdminLTE/index.html) 
> I have already implemented it in my application. I would like to generate 
> some graphics like those that appear in the preview but I don't know how yo 
> do it. Would any of you can help me with any example to understand how I 
> can generate them. I will thank you infinitely.

-- 
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/2f5fd918-9215-413d-8141-c9112b7a3c03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Editable Dropdown List in Web2py

2019-06-08 Thread 'LeChef' via web2py-users


I am new in Web2py.

I have the current requiment 

I need to create a Dropdownlist where in the user can select a value from 

the dropdownlist or type the value in. 

The Dropdownlist values are storedin a database table.

Examplee:

my Form looks like this one:

"Where do you come from?": Dropdown lists the available cities, if your 

city is not found type in your city.


I tried this code:

Field('City', requires = IS_IN_DB(db,db.city.id,'%(city)s')

With this code i can not enter a new city if it is missing in the 

database.

I can only select the available cities in the database. 


Full-Code:


*Model:*

db.define_table('city',Field('name',type='string',length=100,required=True
,notnull=True, ondelete='SET NULL',unique=True),format='%(name)s')

db.define_table('person',Field('name',type='string',length=100,required=Tr

ue,notnull=True, ondelete='SET NULL',unique=True),
Field('city_id','reference city',required=True,notnull=True,label='City'),

format='%(name)s')

db.person.city_id.requires=IS_IN_DB(db,'city.id' ,'%(city)s')

*Controller:*

def person():

 return 
dict(grid=sqlform.grid(db.person,create=True,editable=True,deletable=True))



*View:*{{extend 'layout.html'}}
...


  

 {{pass}}

{{=grid}}

  


-- 
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/643ad187-25e5-4241-8c0d-c4a5f0d3ad93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Generating graph with chartjs

2019-06-08 Thread Paul Arsenio Blanco Reyes
Recently I found the theme "AdminLTE" 
(https://adminlte.io/themes/AdminLTE/index.html)
I have already implemented it in my application. I would like to generate some 
graphics like those that appear in the preview but I don't know how yo do it. 
Would any of you can help me with any example to understand how I can generate 
them. I will thank you infinitely.

-- 
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/213e07a1-8992-4d07-b536-0f75c69982c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-06-08 Thread Massimo Di Pierro
thanks for this test. very useful. fixed.

On Saturday, 8 June 2019 01:06:07 UTC-7, 黄祥 wrote:
>
> *steps*
>> apt install -y git python3-pip
>> pip3 install git+https://github.com/web2py/web3py --upgrade
>> git clone https://github.com/web2py/web3py
>> python3 -c "from pydal.validators import CRYPT; 
>> open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
>> web3py-start -p ./password.txt -a 0.0.0.0:8000 /web3py/apps
>>
>> *result*
>> [FAILED] loading myapp
>> Traceback (most recent call last):
>>   File "/usr/local/lib/python3.6/dist-packages/web3py/core.py", line 607, 
>> in import_apps
>> module = importlib.machinery.SourceFileLoader(module_name, init).
>> load_module()
>>   File "", line 399, in 
>> _check_name_wrapper
>>   File "", line 823, in load_module
>>   File "", line 682, in load_module
>>   File "", line 265, in _load_module_shim
>>   File "", line 684, in _load
>>   File "", line 665, in _load_unlocked
>>   File "", line 678, in exec_module
>>   File "", line 219, in 
>> _call_with_frames_removed
>>   File "/root/web3py/apps/myapp/__init__.py", line 1, in 
>> from . import models
>> ModuleNotFoundError: No module named 'apps'
>>
>
> think error traceback is related with the path, but not sure, try it 
> different steps got the same result
> cd web3py/
> web3py-start -p /password.txt -a 0.0.0.0:8000 ./apps
>
> but when execute as written on github readme.md, it can work (notice it 
> execute the one ship with git, not the one installed on 
> /usr/local/bin/web3py-start)
> cd web3py/
> *./*web3py-start -p /password.txt -a 0.0.0.0:8000 ./apps
>
> best regards,
> stifan
>
>
>
>

-- 
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/dfa6e461-ab3d-49ff-bc51-930c9e37e6bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-06-08 Thread 黄祥

>
> *steps*
> apt install -y git python3-pip
> pip3 install git+https://github.com/web2py/web3py --upgrade
> git clone https://github.com/web2py/web3py
> python3 -c "from pydal.validators import CRYPT; 
> open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
> web3py-start -p ./password.txt -a 0.0.0.0:8000 /web3py/apps
>
> *result*
> [FAILED] loading myapp
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.6/dist-packages/web3py/core.py", line 607, 
> in import_apps
> module = importlib.machinery.SourceFileLoader(module_name, init).
> load_module()
>   File "", line 399, in 
> _check_name_wrapper
>   File "", line 823, in load_module
>   File "", line 682, in load_module
>   File "", line 265, in _load_module_shim
>   File "", line 684, in _load
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in 
> _call_with_frames_removed
>   File "/root/web3py/apps/myapp/__init__.py", line 1, in 
> from . import models
> ModuleNotFoundError: No module named 'apps'
>

think error traceback is related with the path, but not sure, try it 
different steps got the same result
cd web3py/
web3py-start -p /password.txt -a 0.0.0.0:8000 ./apps

but when execute as written on github readme.md, it can work (notice it 
execute the one ship with git, not the one installed on 
/usr/local/bin/web3py-start)
cd web3py/
*./*web3py-start -p /password.txt -a 0.0.0.0:8000 ./apps

best regards,
stifan



-- 
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/cedbbb4d-e76b-4467-be75-5f18371c3d0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.