[web2py] Re: Using parse_as_rest: problem with cross joins?

2019-05-17 Thread Massimo Di Pierro
Hello David,

I recommend moving the the new DBAPI (other thread). Do not know the 
parse_as_rest will be supported very much in the near future. Got very 
little traction.

On Friday, 17 May 2019 08:24:13 UTC-7, David Orme wrote:
>
> Hi,
>
> I'm looking at parse_as_rest() to provide an API and can't get it to work 
> as expected. I have two table: datasets and fields, with a 1 to N 
> relationship and I want to create an API that returns datasets that have a 
> field name matching a pattern so (using the tuple version of patterns to 
> provide a pattern, base query and exposed fields).
>
> patterns = [
> ("/field_name/{fields.field_name.contains}/data[datasets.id]", 
> None, None),
> ]
>
> I thought this was fine, but now I want to restrict results to the latest 
> version of datasets either through:
>
> patterns = [
> ("/field_name/{fields.field_name.contains}/data[datasets.id]",  (
> db.datasets.latest == True), None),
> ]
>
> or:
>   
>   parser = db.parse_as_rest(patterns, args, vars, queries=(db.datasets.latest 
> == True))
>
> That was returning datasets that are not the latest version. I stuck a 
> print(dbset._select()) into pydal/helpers/rest.py to try and figure it out. 
> I think that the example in the manual goes from 1 to N (people to pets), 
> whereas here I am going from N to 1 (fields to datasets) and the underlying 
> SQL from that select is performing a cross join:
>
> SELECT * 
> FROM "datasets" 
> WHERE ("datasets"."id" IN (
> SELECT "fields"."dataset_id" 
> FROM "fields", "datasets" 
> WHERE (("fields"."field_name" ILIKE '%search_text%') 
> AND ("datasets"."latest" = 'T') ESCAPE '\'))); 
>
> That cross join is breaking the link between the two tables. If I edit 
> that by hand to check:
>
> SELECT * 
> FROM "datasets" 
> WHERE ("datasets"."id" IN (
> SELECT "datasets"."latest", "datasets"."id", "fields"."dataset_id" 
> FROM "fields", "datasets" 
> WHERE (("fields"."field_name" ILIKE '%search_text%') 
> AND ("datasets"."latest" = 'T') ESCAPE '\')));
>
> then I get rows like this:
>
>  latest  | id  | dataset_id 
> -+-+
>  T   | 134 |177
>  T   | 134 |177
>  T   | 134 |177
>  T   | 134 |180
>  T   | 134 |180
>  T   | 134 |180
>  T   | 158 |177
>  T   | 158 |177
>  T   | 158 |177
>
> What am I doing wrong?
>
> Cheers,
> David
>
>
>  From looking at the code, it seems like the current options are:
>
> 1. If parse_at_rest() gets a queries object that isn't a dict, the is 
> applied 
>

-- 
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/2ac3a57b-ad0e-463d-845d-6d3d09494802%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Massimo Di Pierro
How about restapi or friendlyql?

I do not want to tie this to web3py or dal too much. there is no reason 
this syntax cannot be ported to other ORMs

On Friday, 17 May 2019 10:02:24 UTC-7, John Bannister wrote:
>
> As you are da man I would suggest DaQL .. DALQL is a bit of a mouth full J
>
>  
>
> *From:* web2py@googlegroups.com [mailto:web2py@googlegroups.com] *On 
> Behalf Of *Massimiliano
> *Sent:* 17 May 2019 18:56
> *To:* web2py@googlegroups.com
> *Subject:* Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py
>
>  
>
> DALQL
>
>  
>
>  
>
> On Fri, May 17, 2019 at 5:42 PM Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
> I am embarrassed I have forgotten all about latin. :-(
>
>  
>
> The italian equivalent would be "accesso" but does not sound nice to me.
>
>  
>
> I am not too concerned about naming conflicts as long as the name is 
> simple to remember and conveys what it does.
>
> After all it is the name of a file and a class, not a package.
>
>  
>
> I do not think Gate/ Bus, etc convey it. {something}QL would be nice but 
> {anything simple}QL appears to be taken.
>
> Also this is not just a QL as it supports all rest methods with policies.
>
>  
>
> Massimo
>
>  
>
>  
>
> -- 
> 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/059b32ee-e5f0-45d4-800f-cfee8d353202%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  
>
> -- 
>
> Massimiliano
>
> -- 
> 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/CANPTPxJumAdQ3veA%3Dw76xbrAD-aFLDZoyrzhTQJ9Nu88HzZt9Q%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/72fb08a9-7345-4daf-8fec-831f4095ed03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread Massimo Di Pierro
Also, web3py uses this: 
https://pypi.org/project/reloader/
The docs have an example. Does this module work for you?


On Friday, 17 May 2019 22:12:39 UTC-7, Massimo Di Pierro wrote:
>
> Does it print this when you press [reload]?
>
> [OK] reloaded _dashboard 
> [OK] reloaded myapp 
> [OK] reloaded todo 
> [OK] reloaded superheroes 
> [OK] reloaded examples 
> [OK] reloaded _scaffold
>
> On Friday, 17 May 2019 16:03:18 UTC-7, John Bannister wrote:
>>
>> For me I have not installed any npm or other. Clean python 3 virtual 
>> environment into which I installed web3py on Ubuntu. Base install on 
>> windows 10 as well same. All works fine apart from the reloading. I can try 
>> to set up on one of my Centos 7 servers later tomorrow but am pretty sure 
>> its gonna be the same.
>>
>> Best Regards
>> John
>>
>>
>> On Friday, 17 May 2019 23:47:38 UTC+2, 黄祥 wrote:
>>>
>>> Editing apps and reloading forks for me. Please try again and let's try 
 figure out why does not work for you.

>>>
>>> after tried latest commit (110), guess when it's work on you, but not 
>>> work on us, perhaps related with module installed (python or js via npm) on 
>>> your side, but not installed on us. not sure just guess.
>>>
>>> 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/456b6c96-fac7-456f-bcdb-8df87464af31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread Massimo Di Pierro
Does it print this when you press [reload]?

[OK] reloaded _dashboard 
[OK] reloaded myapp 
[OK] reloaded todo 
[OK] reloaded superheroes 
[OK] reloaded examples 
[OK] reloaded _scaffold

On Friday, 17 May 2019 16:03:18 UTC-7, John Bannister wrote:
>
> For me I have not installed any npm or other. Clean python 3 virtual 
> environment into which I installed web3py on Ubuntu. Base install on 
> windows 10 as well same. All works fine apart from the reloading. I can try 
> to set up on one of my Centos 7 servers later tomorrow but am pretty sure 
> its gonna be the same.
>
> Best Regards
> John
>
>
> On Friday, 17 May 2019 23:47:38 UTC+2, 黄祥 wrote:
>>
>> Editing apps and reloading forks for me. Please try again and let's try 
>>> figure out why does not work for you.
>>>
>>
>> after tried latest commit (110), guess when it's work on you, but not 
>> work on us, perhaps related with module installed (python or js via npm) on 
>> your side, but not installed on us. not sure just guess.
>>
>> 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/193c5899-0629-4140-8484-05f2c8178468%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: I can not import module in app

2019-05-17 Thread Dave S


On Friday, May 17, 2019 at 2:49:45 PM UTC-7, Константин Комков wrote:
>
> Check line 8 in error, it already contain import mytest, in another 
> project i can import that module. 
>

The working application has a modules/_init__.py file; does the  excepting 
app have that?

/dps


> пт, 17 мая 2019 г., 18:59 Leonel Câmara 
> >:
>
>> Inside the application which has the module in its modules folder all you 
>> need is "import mytest"
>>
>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/vdwfLThWz0U/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/dd1443ec-704f-48af-af0a-d66988d9281a%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4a3f7f28-cf62-47eb-a1c8-ddbdc9f81a65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: why am I getting "duplicate key value violates unique contraint"?

2019-05-17 Thread Dave S


On Friday, May 17, 2019 at 3:57:39 PM UTC-7, Dave S wrote:
>
> As mentioned in another thread, I recently moved one of my tables from 
> sqlite to postgres.  Importing data all went well.  For a while, inserts 
> went well, also.  But then I started getting ERROR 23505  (dup key).  Can I 
> blame this on pg8000?  [I have an open question on getting hooked up to 
> psycopg2]
> [...] 
>
Any ideas of what I screwed up?
>


Okay, stuckoverflux led me to the SELECT setval() answer.  My BP reading 
should now be back in range.

Note 1: the sequence is a separate thing in postgres ('updreq_y_id_seq' in 
this case).
Note 2: ALTER SEQUENCE ... RESTART WITH ... is also possible, but doesn't 
allow a SELECT subquery to provide the values.

/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/79e43d54-bc42-4807-9a24-3f13da5455f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>
> Also, I think it would be nice if URL helper would have ability to handle 
> this, without a need to figure out the encoding/decoding subject... 
>

You don't need the encoding -- just put the values in the query string.

Anthony

-- 
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/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread John Bannister
For me I have not installed any npm or other. Clean python 3 virtual 
environment into which I installed web3py on Ubuntu. Base install on 
windows 10 as well same. All works fine apart from the reloading. I can try 
to set up on one of my Centos 7 servers later tomorrow but am pretty sure 
its gonna be the same.

Best Regards
John


On Friday, 17 May 2019 23:47:38 UTC+2, 黄祥 wrote:
>
> Editing apps and reloading forks for me. Please try again and let's try 
>> figure out why does not work for you.
>>
>
> after tried latest commit (110), guess when it's work on you, but not work 
> on us, perhaps related with module installed (python or js via npm) on your 
> side, but not installed on us. not sure just guess.
>
> 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/3b2a4b86-330c-4cf5-a883-83068d3626f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] why am I getting "duplicate key value violates unique contraint"?

2019-05-17 Thread Dave S
As mentioned in another thread, I recently moved one of my tables from 
sqlite to postgres.  Importing data all went well.  For a while, inserts 
went well, also.  But then I started getting ERROR 23505  (dup key).  Can I 
blame this on pg8000?  [I have an open question on getting hooked up to 
psycopg2]

The table def:

db.define_table('updreq_y',
Field('unitaddr', 'string'),
Field("unitname", 'string', requires=IS_LENGTH(60)),
Field("unitid", 'string', default = "", requires=IS_LENGTH(
60)),
Field('country', 'string', requires=IS_LENGTH(2)),
Field("reqtime", "datetime"),
Field("firsttime", "datetime", default = request.now),
Field("upcount", "integer", default=1)
) 

There's also a before_update hook to bump upcount, but no additional 
constraints.

Looking at the table from psql:
postgres=# \d+ updreq_y
 Table 
"public.updreq_y"
  Column  |Type |   
Modifiers  
 | Storage  | Stats target | Description 
---+-+--
-+--+--+-
 id   | integer | not null default nextval(
'updreq_y_id
_seq'::regclass) | plain|  | 
 unitaddr | character varying(512)  |   
   
 | extended |  | 
 unitname | character varying(512)  |   
   
 | extended |  | 
 unitid   | character varying(512)  |   
   
 | extended |  | 
 country  | character varying(512)  |   
   
 | extended |  | 
 reqtime  | timestamp without time zone |   
   
 | plain|  | 
 firsttime| timestamp without time zone |   
   
 | plain|  | 
 upcount   | integer | 
 
 | plain|  | 
Indexes:
"updreq_y_pkey" PRIMARY KEY, btree (id)
Has OIDs: no


The imported data (a CSV dump from sqlite) had gaps in the id number, and 
when I turned the postgres on, the inserts that happened for a while were 
filling in those gaps.  Then I started getting errors on insert attempts.  
I was using update_or_insert(), and I thought maybe pg8000 didn't handle 
that correctly, so I did my own select, and if no matching rows do a 
regular insert().  Still getting errors.  The value of max(id) hasn't 
changed yet.

The field unitid represents data that's being phased in; in the interim, 
I'm using unitaddr and unitname for the select conditions.  Neither is 
unique by themselves, but together seem to avoid conflicts.

The insert looks like:
k = dby.updreq_y.insert(
   unitid = request.client,
   unitname   = varkeys[0],
   unitid = varkeys[1],
   country= country,
   reqtime= request.now,
   firsttime  = request.now)


and the traceback like
Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File 
"/home/ec2-user/web2py/web2py-2.15.4/web2py/applications/updater/controllers/default.py"
, line 556, in 
  File "/home/www-data/web2py/gluon/globals.py", line 414, in
self._caller = lambda f: f()
  File "/home/www-data/web2py/gluon/tools.py", line 3981, in f
return action(*a, **b)
  File 
"/home/ec2-user/web2py/web2py-2.15.4/web2py/applications/updater/controllers/default.py"
, line 149, in getXML
firsttime = request.now)
  File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 734
, in insert
ret = self._db._adapter.insert(self, row.op_values())
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 486, in insert
raise e
ProgrammingError: (\'ERROR\', \'23505\', \'duplicate key value violates 
unique constraint "updreq_y_pkey"\')'

Oh, and 2.15.4 on python 2.7.16, AWS Linux.

Any ideas of what I screwed up?

/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/c97c07f9-49be-45a0-b1cd-aefa3d18f803%40googlegroups.com.
For more options, visit 

Re: [web2py] Re: I can not import module in app

2019-05-17 Thread Константин Комков
Check line 8 in error, it already contain import mytest, in another project
i can import that module.

пт, 17 мая 2019 г., 18:59 Leonel Câmara :

> Inside the application which has the module in its modules folder all you
> need is "import mytest"
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/vdwfLThWz0U/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/dd1443ec-704f-48af-af0a-d66988d9281a%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAM7z-Vm-a_tzNsyV1uXUmiDzVt%2B63Fy6QZRpLB5QUwKxBBixiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread 黄祥

>
> Editing apps and reloading forks for me. Please try again and let's try 
> figure out why does not work for you.
>

after tried latest commit (110), guess when it's work on you, but not work 
on us, perhaps related with module installed (python or js via npm) on your 
side, but not installed on us. not sure just guess.

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/45c78276-aeb9-42f9-99f3-4c169579670c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Also, I think it would be nice if URL helper would have ability to handle
this, without a need to figure out the encoding/decoding subject...

On Fri, May 17, 2019, 5:03 PM Eliezer (Vlad) Tseytkin <
westgate6...@gmail.com> wrote:

> Okay, I got it :)
>
> Very embarrassing. There were some prior entries in the database that
> weren't converted to begin with, so when they were pulled over, the
> exception was raised. I totally forgot about them, and on top of that the
> one that caused the trouble was just one character different from the one I
> was testing against, with 49 characters being the same, so it was almost
> unnoticeable visually...
>
> I thought that the conversion malfunctioned, while in fact it simply
> pulled back something else, without me realizing what was going on...
>
> I took a deep breath and patiently went through the whole thing step by
> step and, of course, found it. It's now just perfect. Ended up using atob
> and btoa.
>
> Just a quick question: are atob and btoa consistent and give the same
> results across browsers and operating systems? (If not, I'll use that uri
> thing, if that's hopefully consistent)
>
> On Fri, May 17, 2019, 12:42 PM Anthony  wrote:
>
>> On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>>>
>>> It works almost, but not 100% :)
>>>
>>> with encodeURIComponent :
>>>
>>> abc def (test)
>>> comes back as
>>> abc_def__test_
>>>
>>
>> Please show your exact code. Doesn't sound like you are using the query
>> string.
>>
>> Anthony
>>
>> --
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCAPxd0rUGsKHer0n_VRxqWb0Xu0-3vWDWGJr-UrV44eQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Okay, I got it :)

Very embarrassing. There were some prior entries in the database that
weren't converted to begin with, so when they were pulled over, the
exception was raised. I totally forgot about them, and on top of that the
one that caused the trouble was just one character different from the one I
was testing against, with 49 characters being the same, so it was almost
unnoticeable visually...

I thought that the conversion malfunctioned, while in fact it simply pulled
back something else, without me realizing what was going on...

I took a deep breath and patiently went through the whole thing step by
step and, of course, found it. It's now just perfect. Ended up using atob
and btoa.

Just a quick question: are atob and btoa consistent and give the same
results across browsers and operating systems? (If not, I'll use that uri
thing, if that's hopefully consistent)

On Fri, May 17, 2019, 12:42 PM Anthony  wrote:

> On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>>
>> It works almost, but not 100% :)
>>
>> with encodeURIComponent :
>>
>> abc def (test)
>> comes back as
>> abc_def__test_
>>
>
> Please show your exact code. Doesn't sound like you are using the query
> string.
>
> Anthony
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCBW2M%3DsRyFq5CqxK6sYEc9pco2qOA9tnpWcACLw_WGAwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread John Bannister
Update on this :-

Just tried it on native windows10  python3.7 and same results. New 
functions return error 404 until server restart.

BR
John

On Friday, 17 May 2019 18:49:28 UTC+2, 黄祥 wrote:
>
> problem still exist (in commits 110) only superheroes app traceback error 
> is gone when hit 'reload apps':
> 1. 'routes for ' disappears after hit 'reload apps' for : 
> - scaffold
> - myapp
> but for _dashboard, example, todo still exist (appears as expected)
> 2. editing and adding new function in controller apps/myapp/controller.py
> @action('helloworld') # exposes http://127.0.0.1:8000/myapp/helloworld
> @action.uses(db, 'helloworld.html')
> def helloworld(): return dict(name=request.forms.get('name', 'visitoras'))
>
> @action('helloworld1') # exposes http://127.0.0.1:8000/myapp/helloworld
> @action.uses(db, 'helloworld.html')
> def helloworld1(): return dict(name=request.forms.get('name', 'visitorasd'
> ))
>
> *result (not expected) when hit : *http://localhost:8000/myapp/helloworld
> Hello Dear visitor
>
> *result (not expected) when hit : *http://localhost:8000/myapp/helloworld1
> 404
> not found
>
> *steps*
> rm -rf web3py
> git clone https://github.com/web2py/web3py
> cd web3py
> source activate python3_test
> pip install -U -r requirements.txt
> ./web3py-start apps
>
> also seen you've had mailer.py, is still not tested yet, no example or no 
> doc available
>
> 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/5755e5bb-cd53-41e8-a014-cfe33cf3e0aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread John Bannister
As you are da man I would suggest DaQL .. DALQL is a bit of a mouth full J

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Massimiliano
Sent: 17 May 2019 18:56
To: web2py@googlegroups.com
Subject: Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py

 

DALQL

 

 

On Fri, May 17, 2019 at 5:42 PM Massimo Di Pierro  
wrote:

I am embarrassed I have forgotten all about latin. :-(

 

The italian equivalent would be "accesso" but does not sound nice to me.

 

I am not too concerned about naming conflicts as long as the name is simple to 
remember and conveys what it does.

After all it is the name of a file and a class, not a package.

 

I do not think Gate/ Bus, etc convey it. {something}QL would be nice but 
{anything simple}QL appears to be taken.

Also this is not just a QL as it supports all rest methods with policies.

 

Massimo

 

 

-- 
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/059b32ee-e5f0-45d4-800f-cfee8d353202%40googlegroups.com
 

 .
For more options, visit https://groups.google.com/d/optout.




 

-- 

Massimiliano

-- 
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/CANPTPxJumAdQ3veA%3Dw76xbrAD-aFLDZoyrzhTQJ9Nu88HzZt9Q%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/008001d50cd2%2449f92d70%24ddeb8850%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Massimiliano
DALQL


On Fri, May 17, 2019 at 5:42 PM Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I am embarrassed I have forgotten all about latin. :-(
>
> The italian equivalent would be "accesso" but does not sound nice to me.
>
> I am not too concerned about naming conflicts as long as the name is
> simple to remember and conveys what it does.
> After all it is the name of a file and a class, not a package.
>
> I do not think Gate/ Bus, etc convey it. {something}QL would be nice but
> {anything simple}QL appears to be taken.
> Also this is not just a QL as it supports all rest methods with policies.
>
> Massimo
>
>
> --
> 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/059b32ee-e5f0-45d4-800f-cfee8d353202%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Massimiliano

-- 
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/CANPTPxJumAdQ3veA%3Dw76xbrAD-aFLDZoyrzhTQJ9Nu88HzZt9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread 黄祥
problem still exist (in commits 110) only superheroes app traceback error 
is gone when hit 'reload apps':
1. 'routes for ' disappears after hit 'reload apps' for : 
- scaffold
- myapp
but for _dashboard, example, todo still exist (appears as expected)
2. editing and adding new function in controller apps/myapp/controller.py
@action('helloworld') # exposes http://127.0.0.1:8000/myapp/helloworld
@action.uses(db, 'helloworld.html')
def helloworld(): return dict(name=request.forms.get('name', 'visitoras'))

@action('helloworld1') # exposes http://127.0.0.1:8000/myapp/helloworld
@action.uses(db, 'helloworld.html')
def helloworld1(): return dict(name=request.forms.get('name', 'visitorasd'))

*result (not expected) when hit : *http://localhost:8000/myapp/helloworld
Hello Dear visitor

*result (not expected) when hit : *http://localhost:8000/myapp/helloworld1
404
not found

*steps*
rm -rf web3py
git clone https://github.com/web2py/web3py
cd web3py
source activate python3_test
pip install -U -r requirements.txt
./web3py-start apps

also seen you've had mailer.py, is still not tested yet, no example or no 
doc available

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/997ba379-3a3f-42d9-95fc-b3ace6f82b30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>
> It works almost, but not 100% :) 
>
> with encodeURIComponent :
>
> abc def (test)
> comes back as
> abc_def__test_
>

Please show your exact code. Doesn't sound like you are using the query 
string.

Anthony

-- 
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/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [web2py] Re: Web3py

2019-05-17 Thread John Bannister
Hi Massimo,

 

I have downloaded latest web3py and same thing is happening. I can see in the 
console that it is reloading all the apps but for me updates are not happening 
until I restart the server.

 

I am running web3py in a python3 venv  on windows/linux (Ubuntu 18) python 3.6.

 

Myapp/controller.py

 

from web3py import action, request, redirect, abort

from . models import db

 

@action('helloworld') # exposes http://127.0.0.1:8000/myapp/helloworld

@action.uses(db, 'helloworld.html')

def helloworld(): return dict(name=request.forms.get('name', 'visitor'))

 

@action('helloworld1') # exposes http://127.0.0.1:8000/myapp/helloworld1

@action.uses(db, 'helloworld.html')

def helloworld1(): return dict(name=' 1 '+ request.forms.get('name', 'visitor'))

 

@action('helloworld2') # exposes http://127.0.0.1:8000/myapp/helloworld2

@action.uses(db, 'helloworld.html')

def helloworld2(): return dict(name=' 2 ' +request.forms.get('name', 'visitor'))

 

@action('helloworld3') # exposes http://127.0.0.1:8000/myapp/helloworld3

@action.uses(db, 'helloworld.html')

def helloworld3(): return dict(name=' 3 ' + request.forms.get('name', 
'visitor'))  

 

After reload apps only helloworld accessible. After server restart all are.

 

BR

John

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Massimo Di Pierro
Sent: 17 May 2019 17:12
To: web2py-users
Subject: Re: [web2py] Re: Web3py

 

I fixed the database locking problem. missing db.commit()

Editing apps and reloading forks for me. Please try again and let's try figure 
out why does not work for you.

It is intentionally reloading all apps but this can easily be changed. I will 
change it.

 

Massimo

 


On Friday, 17 May 2019 02:10:27 UTC-7, John Bannister wrote:

Hi Massimo,

 

I have tried that but it has no effect. It seems to be doing something for a 
while but the only way I can get changes to appear is to restart the server.

 

Basically what I did was to copy and rename the helloworld action a few times 
so helloworld1 …….helloworld7 (all in same controller.py)  giving appropriate 
return messages.

 

If I reload using the dashboard button I still only see helloworld (the rest 
give me 404 errors) but if I restart the server I can access myapp/helloworld1 
to myapp/helloworld7.

 

Also it seems that the reload apps button is reloading all the apps in the 
applications directory. Is this intentional or is there a way to just reload 
the app currently being developed?

 

BR

John 

 

 

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Massimo Di Pierro
Sent: 17 May 2019 09:36
To: web2py-users
Subject: [web2py] Re: Web3py

 

yes. There is a button on the top/right of the dashboard "reload apps"

On Thursday, 16 May 2019 08:15:44 UTC-7, John Bannister wrote:

Hi All,

 

Had a first real 'play' with web3py' today and have a few questions the biggest 
of which I am hoping the gurus will be able to answer:-

 

1: Is there any way to not to have to restart the app every time changes are 
made to actions in the controller or new actions added etc? I understand that 
controllers are basically being imported when the app fires up but is any there 
any way to occasionally reload instead of having to restart the app? This is a 
fairly big one for me as sometimes tweaks will need to be made in production 
and restarting the web server is not really an option so hopefully I am missing 
something really simple.

 

Thanks in advance

John

 

 

 

 

 

 

  

-- 
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/c33707df-ec41-4574-a6a6-54c2905ff10e%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/84b51eaa-209e-45fa-88a3-d4f986f7a441%40googlegroups.com
 

 .
For more options, visit 

[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I'll try to simplify it, hoping that I'll figure it out, but it's really 
very puzzling: 

this works perfect: 

var encodedDescription = $("#CurrentCartDescription").text();
$("#CurrentCartDescription").html(atob(encodedDescription));

it decodes it back just exactly from what it was encoded. 
However, the following is messed up: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

throws an exception, even for the same very value! 

Will simplify it all now, let's see what comes out...

On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>
> It works almost, but not 100% :) 
>
> with encodeURIComponent :
>
> abc def (test)
> comes back as
> abc_def__test_
>
> a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
> comes back as
> a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=
>
> This wouldn't help me, because I want it to be exactly whatever they enter 
> - 
>
> In contrast, atob and btoa work just perfect, except that in one 
> particular situation is gets messed up by that exception... 
>
> On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>>
>> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>>
>>> I have the following javascript in the view: 
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>
>> How about putting the variables in the query string:
>>
>> const id = $('#CurrentCartId').text();
>> const description = $(this).text();
>> const url='{{=URL('cart','description')}}';
>> ajax(
>> `${url}?id=${encodeURIComponent(id)}=${encodeURIComponent(description)}`
>> , [], ':eval');
>>
>> Then in the controller, access request.vars.id and 
>> request.vars.description.
>>
>> Anthony
>>
>

-- 
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/4fc90afb-1e30-439d-b5ba-730df5bb1a34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
It works almost, but not 100% :) 

with encodeURIComponent :

abc def (test)
comes back as
abc_def__test_

a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
comes back as
a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=

This wouldn't help me, because I want it to be exactly whatever they enter 
- 

In contrast, atob and btoa work just perfect, except that in one particular 
situation is gets messed up by that exception... 

On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>
> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>
> How about putting the variables in the query string:
>
> const id = $('#CurrentCartId').text();
> const description = $(this).text();
> const url='{{=URL('cart','description')}}';
> ajax(
> `${url}?id=${encodeURIComponent(id)}=${encodeURIComponent(description)}`
> , [], ':eval');
>
> Then in the controller, access request.vars.id and 
> request.vars.description.
>
> Anthony
>

-- 
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/1e9addff-674e-471b-a570-c07d05df96af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread John Bannister
How about Despresso (for database express O ).  J

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Massimo Di Pierro
Sent: 17 May 2019 17:43
To: web2py-users
Subject: [web2py] Re: new DBAPI in pydal for both web2py and web3py

 

I am embarrassed I have forgotten all about latin. :-(

 

The italian equivalent would be "accesso" but does not sound nice to me.

 

I am not too concerned about naming conflicts as long as the name is simple to 
remember and conveys what it does.

After all it is the name of a file and a class, not a package.

 

I do not think Gate/ Bus, etc convey it. {something}QL would be nice but 
{anything simple}QL appears to be taken.

Also this is not just a QL as it supports all rest methods with policies.

 

Massimo

 

 

-- 
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/059b32ee-e5f0-45d4-800f-cfee8d353202%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/001801d50ccb%24a9f72b20%24fde58160%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I can not import module in app

2019-05-17 Thread Leonel Câmara
Inside the application which has the module in its modules folder all you 
need is "import mytest"

-- 
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/dd1443ec-704f-48af-af0a-d66988d9281a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Massimo Di Pierro
I am embarrassed I have forgotten all about latin. :-(

The italian equivalent would be "accesso" but does not sound nice to me.

I am not too concerned about naming conflicts as long as the name is simple 
to remember and conveys what it does.
After all it is the name of a file and a class, not a package.

I do not think Gate/ Bus, etc convey it. {something}QL would be nice but 
{anything simple}QL appears to be taken.
Also this is not just a QL as it supports all rest methods with policies.

Massimo


-- 
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/059b32ee-e5f0-45d4-800f-cfee8d353202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL warning

2019-05-17 Thread Joel Samuelsson
Hi,

Thanks for your input Dave. It is indeed from Auth. If I change lines 
(1867-1869) in gluon/tools.py:
Field('registration_id', length=512,
writable=False, readable=False, default='',
label=self.messages.label_registration_id),
to
Field('registration_id', length=512,
writable=False, readable=False, default=123,
label=self.messages.label_registration_id), 
the warning goes away. It all stems from a call to db.auth_user.insert where 
registration_id is not specified. What is the column for? 

Den fredag 17 maj 2019 kl. 03:35:03 UTC+2 skrev Dave S:
>
>
>
> On Thursday, May 16, 2019 at 2:26:21 AM UTC-7, Joel Samuelsson wrote:
>>
>> It is not my table but something builtin I'm guessing. I have no column 
>> with name registration_id.
>>
>
> That name sounds like it is from Auth (auth_user, probably).  Please show 
> your model file where Auth is instantiated;  did you make any changes in 
> the lines above that?
>
> What flavor of Docker?  (OS, OS version, Python version; we have 2.17.1 
> from your first message,
>
> You might also consider using a newer version of web2py; 2.18.5 came out 
> on April 7th, and there have been a bunch of bug fixes since 2.17.1.
>
> /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/03e810f6-e954-44dd-a070-fb74a94a826b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using parse_as_rest: problem with cross joins?

2019-05-17 Thread David Orme
Hi,

I'm looking at parse_as_rest() to provide an API and can't get it to work 
as expected. I have two table: datasets and fields, with a 1 to N 
relationship and I want to create an API that returns datasets that have a 
field name matching a pattern so (using the tuple version of patterns to 
provide a pattern, base query and exposed fields).

patterns = [
("/field_name/{fields.field_name.contains}/data[datasets.id]", 
None, None),
]

I thought this was fine, but now I want to restrict results to the latest 
version of datasets either through:

patterns = [
("/field_name/{fields.field_name.contains}/data[datasets.id]",  (db.
datasets.latest == True), None),
]

or:
  
  parser = db.parse_as_rest(patterns, args, vars, queries=(db.datasets.latest 
== True))

That was returning datasets that are not the latest version. I stuck a 
print(dbset._select()) into pydal/helpers/rest.py to try and figure it out. 
I think that the example in the manual goes from 1 to N (people to pets), 
whereas here I am going from N to 1 (fields to datasets) and the underlying 
SQL from that select is performing a cross join:

SELECT * 
FROM "datasets" 
WHERE ("datasets"."id" IN (
SELECT "fields"."dataset_id" 
FROM "fields", "datasets" 
WHERE (("fields"."field_name" ILIKE '%search_text%') 
AND ("datasets"."latest" = 'T') ESCAPE '\'))); 

That cross join is breaking the link between the two tables. If I edit that 
by hand to check:

SELECT * 
FROM "datasets" 
WHERE ("datasets"."id" IN (
SELECT "datasets"."latest", "datasets"."id", "fields"."dataset_id" 
FROM "fields", "datasets" 
WHERE (("fields"."field_name" ILIKE '%search_text%') 
AND ("datasets"."latest" = 'T') ESCAPE '\')));

then I get rows like this:

 latest  | id  | dataset_id 
-+-+
 T   | 134 |177
 T   | 134 |177
 T   | 134 |177
 T   | 134 |180
 T   | 134 |180
 T   | 134 |180
 T   | 158 |177
 T   | 158 |177
 T   | 158 |177

What am I doing wrong?

Cheers,
David


 From looking at the code, it seems like the current options are:

1. If parse_at_rest() gets a queries object that isn't a dict, the is 
applied 

-- 
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/982e6d3f-a03e-4347-b23c-0860d3846a68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web3py

2019-05-17 Thread Massimo Di Pierro
I fixed the database locking problem. missing db.commit()
Editing apps and reloading forks for me. Please try again and let's try 
figure out why does not work for you.
It is intentionally reloading all apps but this can easily be changed. I 
will change it.

Massimo


On Friday, 17 May 2019 02:10:27 UTC-7, John Bannister wrote:
>
> Hi Massimo,
>
>  
>
> I have tried that but it has no effect. It seems to be doing something for 
> a while but the only way I can get changes to appear is to restart the 
> server.
>
>  
>
> Basically what I did was to copy and rename the helloworld action a few 
> times so helloworld1 …….helloworld7 (all in same controller.py)  giving 
> appropriate return messages.
>
>  
>
> If I reload using the dashboard button I still only see helloworld (the 
> rest give me 404 errors) but if I restart the server I can access 
> myapp/helloworld1 to myapp/helloworld7.
>
>  
>
> Also it seems that the reload apps button is reloading all the apps in the 
> applications directory. Is this intentional or is there a way to just 
> reload the app currently being developed?
>
>  
>
> BR
>
> John 
>
>  
>
>  
>
>  
>
> *From:* web2py@googlegroups.com [mailto:web2py@googlegroups.com] *On 
> Behalf Of *Massimo Di Pierro
> *Sent:* 17 May 2019 09:36
> *To:* web2py-users
> *Subject:* [web2py] Re: Web3py
>
>  
>
> yes. There is a button on the top/right of the dashboard "reload apps"
>
> On Thursday, 16 May 2019 08:15:44 UTC-7, John Bannister wrote:
>
> Hi All,
>
>  
>
> Had a first real 'play' with web3py' today and have a few questions the 
> biggest of which I am hoping the gurus will be able to answer:-
>
>  
>
> 1: Is there any way to not to have to restart the app every time changes 
> are made to actions in the controller or new actions added etc? I 
> understand that controllers are basically being imported when the app fires 
> up but is any there any way to occasionally reload instead of having to 
> restart the app? This is a fairly big one for me as sometimes tweaks will 
> need to be made in production and restarting the web server is not really 
> an option so hopefully I am missing something really simple.
>
>  
>
> Thanks in advance
>
> John
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>   
>
> -- 
> 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/c33707df-ec41-4574-a6a6-54c2905ff10e%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/84b51eaa-209e-45fa-88a3-d4f986f7a441%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Carlos Costa
I liked it, sounds Italian.
Sometimes when you have a restriction it inspires creativity.
For example, if we would have a rule to give only Italian (Massimo origin
is the reason here) names to Web2py stuff (web2py itself included) we could
come up with more natural and interesting names.
Like Django. It sounds natural and cool. But I don't like the framework.
But I believe it's one thing the helps spread the word and make it
well known.
I love web2py and I am already loving web3py but surely do not love these
names, neither the fact web2py is little known these days.
I really hope that web3py will be the next top fullstack web framework, and
will contribute for that. But this name does not help.

Em sex, 17 de mai de 2019 às 10:03, António Ramos 
escreveu:

> there we go again about naming something ...
>
> Jut call it Gluino! to glue data to the app..
>
> Em sex, 17 de mai de 2019 às 11:37, villas  escreveu:
>
>> acquisAPI
>>
>> acquis Shortened from acquis communautaire: French acquis (“that which
>> has been acquired or obtained”) + communautaire (“of the community”).
>>
>>
>>
>>
>> On Thursday, 16 May 2019 07:33:21 UTC+1, Massimo Di Pierro wrote:
>>>
>>> how about we simply call it "Access"?
>>>
>>> On Wednesday, 15 May 2019 06:58:37 UTC-7, Anthony wrote:

 On Wednesday, May 15, 2019 at 12:53:27 AM UTC-4, Massimo Di Pierro
 wrote:
>
> We can change the name but api is too ambiguous. Any other idea?
>

 Not sure. RESTAPI? HTTPAPI?

>>> --
>> 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/b89a5a76-8692-40f9-b797-4eebfec67cca%40googlegroups.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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CAEM0BxM9zSuGORmypOr2Tw6BCnYpidNZegG%3DP0J2EpMO0DCBaA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
At.

Carlos J. Costa
--
Cientista da Computação - Esp. Gestão em Telecom

-- 
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/CAGsD4Nz6mgPmkVaL-mW94KCxbp5%3Dmif5b%2BSopFPRLpk3Dk3cmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>

How about putting the variables in the query string:

const id = $('#CurrentCartId').text();
const description = $(this).text();
const url='{{=URL('cart','description')}}';
ajax(
`${url}?id=${encodeURIComponent(id)}=${encodeURIComponent(description)}`
, [], ':eval');

Then in the controller, access request.vars.id and request.vars.description.

Anthony

-- 
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/e574b961-7bc2-4dba-86d4-1f231da4d008%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread António Ramos
there we go again about naming something ...

Jut call it Gluino! to glue data to the app..

Em sex, 17 de mai de 2019 às 11:37, villas  escreveu:

> acquisAPI
>
> acquis Shortened from acquis communautaire: French acquis (“that which has
> been acquired or obtained”) + communautaire (“of the community”).
>
>
>
>
> On Thursday, 16 May 2019 07:33:21 UTC+1, Massimo Di Pierro wrote:
>>
>> how about we simply call it "Access"?
>>
>> On Wednesday, 15 May 2019 06:58:37 UTC-7, Anthony wrote:
>>>
>>> On Wednesday, May 15, 2019 at 12:53:27 AM UTC-4, Massimo Di Pierro wrote:

 We can change the name but api is too ambiguous. Any other idea?

>>>
>>> Not sure. RESTAPI? HTTPAPI?
>>>
>> --
> 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/b89a5a76-8692-40f9-b797-4eebfec67cca%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAEM0BxM9zSuGORmypOr2Tw6BCnYpidNZegG%3DP0J2EpMO0DCBaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: !web2py, but i'm asking someone's help with aws-sdk-js.

2019-05-17 Thread lucas
actually Dave S, 

your indirect answer led me to a place of where not to go at all, which was 
the server-side node.js.  believe it or not.  because it led me to a place 
where i actually needed to be.  and i conjured the final code after about 
44 hours of toil.  it works freaking great, pure client-side and progress 
also.  so, i'll post my code snippets for anyone else in the future.  

so here is most of the snippet from the view:
{{block head}}


 

var fileChoose, fileChooseUploadButton, fileChooseSpan, fileETag;

function local_file_upload(event) {
event.preventDefault();
var submit = jQuery('form#item_edit > div#submit_record__row > 
div.col-sm-9 > input[type="submit"]');
var file = fileChoose.prop('files')[0];
console.log('uploading file: '+file.name);
fileETag.prop('readonly', false).val('').prop('readonly', true);
fileChooseUploadButton.val('Uploading...').prop('disabled', true);
submit.prop('disabled', true);
jQuery.get({url:"{{=URL(c='default', f='ajaxAws')}}", async:false}).done
(function(t) {
if (t.response) {
console.log('rtn t.response: '+t.response);
//console.log('rtn t: '+JSON.stringify(t));
AWS.config.update({
"accessKeyId": t.accessKeyId,
"secretAccessKey": t.secretAccessKey, //.replace('K', '9'),
"region": "us-west-1"
});
}
});
var s3 = new AWS.S3();
var params = {
Bucket: 'happyBucketDays',
Key: '{{=professor_folder}}/'+jQuery('form#item_edit > 
div#lecture_items_filename__row > div.col-sm-9 > 
input#lecture_items_filename').val(),
ContentType: file.type,
Body: file,
ACL: 'public-read'
};
s3.upload(params, function (error, results) {
if (error) {
fileETag.prop('readonly', false).val('').prop('readonly', true);
fileChooseSpan.html(error.message);
return jQuery.alert({title:"Error Uploading Data: ", content:
error});
} else {
var etg = results.ETag.replace('"', '').replace('"', '');
fileChooseSpan.html('Sucessfull Upload Confirmed.  Be sure to 
click Submit below.');
fileETag.prop('readonly', false).val(etg).prop('readonly', true
);
console.log('file uploaded with result: '+JSON.stringify(results
));
submit.prop('disabled', false);
return jQuery.alert({title:"Successfully Uploaded File", content
:""});
}
}).on('httpUploadProgress', function(progress) {
fileChooseSpan.html('Uploaded: '+parseInt((progress.loaded * 100)/
progress.total)+'%');
});
}

function local_filename_change() {
var e = jQuery('input[type="file"]');
console.log('local file name: '+e.prop('files')[0].name);
jQuery('input#lecture_items_filename').val(e.prop('files')[0].name);
fileChooseUploadButton.css('display', "inline").val('Upload File').prop(
'disabled', false);
console.log(fileChooseUploadButton.prop('type')+" ___ "+
fileChooseUploadButton.prop('id'));
fileChooseSpan.html('Make sure the "Server Filename" is correct.');
jQuery('form#item_edit > div#lecture_items_filename__row > div.col-sm-9 
> input#lecture_items_filename').focus();
}

jQuery(document).ready(function() {
var sx = "jQuery.version: "+jQuery.fn.jquery;
console.log("jQuery.document.ready begin..."+sx);
jQuery('form#item_edit > div#lecture_items_text_before__row').after('
'); fileChoose = jQuery('form#item_edit > div#lecture_items_local_filename__row > div.col-sm-9 > input#lecture_items_file'); fileChooseUploadButton = jQuery('form#item_edit > div#lecture_items_local_filename__row > div.col-sm-9 > input#lecture_items_file_upload'); fileChooseSpan = jQuery('form#item_edit > div#lecture_items_local_filename__row > div.col-sm-9 > span.help-block'); fileETag = jQuery('form#item_edit > div#lecture_items_fileetag__row > div.col-sm-9 > input#lecture_items_fileetag'); fileETag.prop('readonly', true); console.log("jQuery.document.ready end..."); }); {{end}} {{if ('body' in globals()) and (body is not None): =body pass}} where the "body" is passed as an SQLFORM from the controller, where the referenced fields in the

Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Make sure that your jQuery loading and browser up to date...

Simplify the page to something like below.  Get that working.  Add back 
your complexity afterwards:

Q29va2llcyBvbmU=


$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 alert(hereWeAre);
 var decodedString = atob(hereWeAre);
 console.log(decodedString); 
});



On Friday, 17 May 2019 13:24:57 UTC+1, Vlad wrote:
>
> Typo: I meant atob
>
> On Fri, May 17, 2019, 8:21 AM Eliezer (Vlad) Tseytkin  > wrote:
>
>> Those are span elements inside  inside in a table. 
>>
>> But the values themselves are fine - I can print them out, and they are 
>> correct. It's only a problem when I try to apply btoa function to it. 
>>
>> On Fri, May 17, 2019, 8:09 AM villas > 
>> wrote:
>>
>>> Hmm, not sure.  
>>> Are you getting the values from  elements?
>>> Try:  
>>>
>>> var hereWeAre = $(this).val();
>>>
>>>
>>> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:

 I thought so and tried: 

 $(".EncodedDescriptionField").each( function(index, element ){
  var hereWeAre = $(this).text();
  var decodedString = atob(hereWeAre);
  console.error(hereWeAre);
  console.error(decodedString); 
 });

 this brings up an exception: 

 Uncaught DOMException: Failed to execute 'atob' on 'Window': The string 
 to be decoded is not correctly encoded.

 I've also double-checked the values - they are correct. For example, 
 when I replace with the following: 

  var decodedString = atob("Q29va2llcyBvbmU=");

 it decodes just fine, and the string itself I pick right from there - 
 that's the value it has when it throws exception. 

 Have no slightest clue what could possibly go wrong. 


 On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>
> Maybe you need to iterate through the class elements.  See this:
>
> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>
>
>
> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>
>> Just to clarify: 
>>
>> the following works perfect  for one field by ID (decrypts it back):
>> var encodedDescription = $("#CurrentCartDescription").text()
>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>
>> However, when I try to do it for a bunch of fields at once using 
>> class (instead of id), it doesn't work - doesn't touch the values: 
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> I am sure I am missing something basic... Greatly appreciate 
>> suggestions - 
>>
>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>>
>>> I had no clue about it - I mean never heard the terms :)
>>>
>>> Thank you very much for point to the direction. After some googling, 
>>> it is almost working. 
>>>
>>> Encoding is just fine (using btoa). 
>>>
>>> When I read it back and want to decode - it's not yet behaving 
>>> right. I'm suspecting my javascript is a problem. 
>>>
>>> There is a bunch of fields which now have encrypted values (class 
>>> 'EncodedDescriptionField'), and I am trying to use the following to 
>>> reclaim 
>>> the original values: 
>>>
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> What am I doing wrong? (It doesn't change the values - they remain 
>>> as they are, encrypted)
>>>
>>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:

 Have you considered base64 encoding/decoding?

 quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in 
> the URL helper is because the parameters are coming from the html 
> itself - 
> they are not known in the controller py. 
>
> now the problem is that it changes the description and I have no 
> way to recover its original value. for example, when description is 
> "askjdf 
> d   dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed 
> string 
> in this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
> Obviously, it 

Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Typo: I meant atob

On Fri, May 17, 2019, 8:21 AM Eliezer (Vlad) Tseytkin <
westgate6...@gmail.com> wrote:

> Those are span elements inside  inside in a table.
>
> But the values themselves are fine - I can print them out, and they are
> correct. It's only a problem when I try to apply btoa function to it.
>
> On Fri, May 17, 2019, 8:09 AM villas  wrote:
>
>> Hmm, not sure.
>> Are you getting the values from  elements?
>> Try:
>>
>> var hereWeAre = $(this).val();
>>
>>
>> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>>>
>>> I thought so and tried:
>>>
>>> $(".EncodedDescriptionField").each( function(index, element ){
>>>  var hereWeAre = $(this).text();
>>>  var decodedString = atob(hereWeAre);
>>>  console.error(hereWeAre);
>>>  console.error(decodedString);
>>> });
>>>
>>> this brings up an exception:
>>>
>>> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string
>>> to be decoded is not correctly encoded.
>>>
>>> I've also double-checked the values - they are correct. For example,
>>> when I replace with the following:
>>>
>>>  var decodedString = atob("Q29va2llcyBvbmU=");
>>>
>>> it decodes just fine, and the string itself I pick right from there -
>>> that's the value it has when it throws exception.
>>>
>>> Have no slightest clue what could possibly go wrong.
>>>
>>>
>>> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:

 Maybe you need to iterate through the class elements.  See this:

 https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class



 On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>
> Just to clarify:
>
> the following works perfect  for one field by ID (decrypts it back):
> var encodedDescription = $("#CurrentCartDescription").text()
> $("#CurrentCartDescription").html(atob(encodedDescription));
>
> However, when I try to do it for a bunch of fields at once using class
> (instead of id), it doesn't work - doesn't touch the values:
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> I am sure I am missing something basic... Greatly appreciate
> suggestions -
>
> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>
>> I had no clue about it - I mean never heard the terms :)
>>
>> Thank you very much for point to the direction. After some googling,
>> it is almost working.
>>
>> Encoding is just fine (using btoa).
>>
>> When I read it back and want to decode - it's not yet behaving right.
>> I'm suspecting my javascript is a problem.
>>
>> There is a bunch of fields which now have encrypted values (class
>> 'EncodedDescriptionField'), and I am trying to use the following to 
>> reclaim
>> the original values:
>>
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> What am I doing wrong? (It doesn't change the values - they remain as
>> they are, encrypted)
>>
>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>
>>> Have you considered base64 encoding/decoding?
>>>
>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:

 I have the following javascript in the view:

 var id = $('#CurrentCartId').text();
 var description = $(this).text();
 var url='{{=URL('cart','description')}}';
 url += '/' + id + '/';
 url += description;
 ajax(url,[],':eval');

 the reason I use url+= to pass parameters instead of using args in
 the URL helper is because the parameters are coming from the html 
 itself -
 they are not known in the controller py.

 now the problem is that it changes the description and I have no
 way to recover its original value. for example, when description is 
 "askjdf
 d   dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed 
 string
 in this case), it comes out as "askjdf_d___dka_lskdj__3838_".
 Obviously, it needs to do this conversion in order to pass  the 
 parameter,
 but I need to be able to recreate the original string, entered by the 
 user.

 Is there a better way of doing this? I.e. a better way of passing a
 parameter in  a way that it could be "recreated" and stored in the 
 database
 exactly as typed by the user?

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

[web2py] Re: Answer from database empty list, list with tuple

2019-05-17 Thread villas
1. Note that this will fail if no email var is passed.
request.vars.email.strip() 

2. For the second query,  print the SQL to the console using ._select()
Are you getting the SQL you expected?

-- 
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/97317180-a0ff-4afc-931d-228ae13b8898%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Those are span elements inside  inside in a table.

But the values themselves are fine - I can print them out, and they are
correct. It's only a problem when I try to apply btoa function to it.

On Fri, May 17, 2019, 8:09 AM villas  wrote:

> Hmm, not sure.
> Are you getting the values from  elements?
> Try:
>
> var hereWeAre = $(this).val();
>
>
> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>>
>> I thought so and tried:
>>
>> $(".EncodedDescriptionField").each( function(index, element ){
>>  var hereWeAre = $(this).text();
>>  var decodedString = atob(hereWeAre);
>>  console.error(hereWeAre);
>>  console.error(decodedString);
>> });
>>
>> this brings up an exception:
>>
>> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string
>> to be decoded is not correctly encoded.
>>
>> I've also double-checked the values - they are correct. For example, when
>> I replace with the following:
>>
>>  var decodedString = atob("Q29va2llcyBvbmU=");
>>
>> it decodes just fine, and the string itself I pick right from there -
>> that's the value it has when it throws exception.
>>
>> Have no slightest clue what could possibly go wrong.
>>
>>
>> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>>>
>>> Maybe you need to iterate through the class elements.  See this:
>>>
>>> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>>>
>>>
>>>
>>> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:

 Just to clarify:

 the following works perfect  for one field by ID (decrypts it back):
 var encodedDescription = $("#CurrentCartDescription").text()
 $("#CurrentCartDescription").html(atob(encodedDescription));

 However, when I try to do it for a bunch of fields at once using class
 (instead of id), it doesn't work - doesn't touch the values:

 $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

 I am sure I am missing something basic... Greatly appreciate
 suggestions -

 On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>
> I had no clue about it - I mean never heard the terms :)
>
> Thank you very much for point to the direction. After some googling,
> it is almost working.
>
> Encoding is just fine (using btoa).
>
> When I read it back and want to decode - it's not yet behaving right.
> I'm suspecting my javascript is a problem.
>
> There is a bunch of fields which now have encrypted values (class
> 'EncodedDescriptionField'), and I am trying to use the following to 
> reclaim
> the original values:
>
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> What am I doing wrong? (It doesn't change the values - they remain as
> they are, encrypted)
>
> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>
>> Have you considered base64 encoding/decoding?
>>
>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>
>>> I have the following javascript in the view:
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>> the reason I use url+= to pass parameters instead of using args in
>>> the URL helper is because the parameters are coming from the html 
>>> itself -
>>> they are not known in the controller py.
>>>
>>> now the problem is that it changes the description and I have no way
>>> to recover its original value. for example, when description is "askjdf 
>>> d
>>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
>>> in
>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
>>> Obviously,
>>> it needs to do this conversion in order to pass  the parameter, but I 
>>> need
>>> to be able to recreate the original string, entered by the user.
>>>
>>> Is there a better way of doing this? I.e. a better way of passing a
>>> parameter in  a way that it could be "recreated" and stored in the 
>>> database
>>> exactly as typed by the user?
>>>
>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> 

[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Hmm, not sure.  
Are you getting the values from  elements?
Try:  

var hereWeAre = $(this).val();


On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>
> I thought so and tried: 
>
> $(".EncodedDescriptionField").each( function(index, element ){
>  var hereWeAre = $(this).text();
>  var decodedString = atob(hereWeAre);
>  console.error(hereWeAre);
>  console.error(decodedString); 
> });
>
> this brings up an exception: 
>
> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to 
> be decoded is not correctly encoded.
>
> I've also double-checked the values - they are correct. For example, when 
> I replace with the following: 
>
>  var decodedString = atob("Q29va2llcyBvbmU=");
>
> it decodes just fine, and the string itself I pick right from there - 
> that's the value it has when it throws exception. 
>
> Have no slightest clue what could possibly go wrong. 
>
>
> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>>
>> Maybe you need to iterate through the class elements.  See this:
>>
>> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>>
>>
>>
>> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>>
>>> Just to clarify: 
>>>
>>> the following works perfect  for one field by ID (decrypts it back):
>>> var encodedDescription = $("#CurrentCartDescription").text()
>>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>>
>>> However, when I try to do it for a bunch of fields at once using class 
>>> (instead of id), it doesn't work - doesn't touch the values: 
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> I am sure I am missing something basic... Greatly appreciate suggestions 
>>> - 
>>>
>>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:

 I had no clue about it - I mean never heard the terms :)

 Thank you very much for point to the direction. After some googling, it 
 is almost working. 

 Encoding is just fine (using btoa). 

 When I read it back and want to decode - it's not yet behaving right. 
 I'm suspecting my javascript is a problem. 

 There is a bunch of fields which now have encrypted values (class 
 'EncodedDescriptionField'), and I am trying to use the following to 
 reclaim 
 the original values: 


 $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

 What am I doing wrong? (It doesn't change the values - they remain as 
 they are, encrypted)

 On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>
> Have you considered base64 encoding/decoding?
>
> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>> the reason I use url+= to pass parameters instead of using args in 
>> the URL helper is because the parameters are coming from the html itself 
>> - 
>> they are not known in the controller py. 
>>
>> now the problem is that it changes the description and I have no way 
>> to recover its original value. for example, when description is "askjdf 
>> d  
>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
>> in 
>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
>> Obviously, 
>> it needs to do this conversion in order to pass  the parameter, but I 
>> need 
>> to be able to recreate the original string, entered by the user. 
>>
>> Is there a better way of doing this? I.e. a better way of passing a 
>> parameter in  a way that it could be "recreated" and stored in the 
>> database 
>> exactly as typed by the user? 
>>
>

-- 
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/a20934f0-54a3-4bd9-95ff-0d3b60cbcfa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: updating menu without reloading the page

2019-05-17 Thread villas
Wow thanks Vlad!  I didn't hope for such a full explanation, but this will 
be appreciated by anyone following the thread.
All the best.


On Thursday, 16 May 2019 17:04:13 UTC+1, Vlad wrote:
>
> Yes sure: 
>
> My issue was the menu item with "Cart (X)" menu item where X indicated how 
> many items were currently in the cart. Since the cart was updated with ajax 
> calls - I needed to update that menu item. 
>
> This is what I've changed in the menu construction in the layout.html :
>
>   
>   {{if _item[0].startswith('Cart ('):}}
>href="{{=_item[2]}}">{{=_item[0]}}
>   {{else:}}
>href="{{=_item[2]}}">{{=_item[0]}}
>   {{pass}}
>   
>
> This if-else logic takes care of giving a proper ID to the element I need 
> to update. 
>
> The menu.py got a small addition to its response.menu += part:
>
> ('Cart (' + str(howManyItemsInCart()) + ")", False, URL('cart','show'), 
> []),
>
> Where howManyItemsInCart() is communicating with the database and is 
> located in the model file.
>
> The catalog view got the following in the table of products:
>
>  onclick="var url='{{=URL('cart','plus',args=[item['product.id
> '],1],vars={'price':item['product.price'],'target':'Item'+str(item['
> product.id'])})}}';ajax(url,[],':eval');">Add/Remove
> {{=isInCartRep(aBunch,item['
> product.id'])}}
>
> Clicking Add/Remove adds an item to the cart when it's not there 
> beforehand, and removes it if it's already there. 
>
> The function plus() which is ajax-called from the view (on Add/Remove 
> click) returns some javascript to be executed (this allows to update 
> multiple targets - the beauty of :eval option in ajax function):
>
> final_result = 
> "document.getElementById('CartMenuItem').innerHTML='Cart (" + \
>str(CartCount())+ \
>")';document.getElementById('" + \
>target + \
>"').innerHTML='"+result+"';"
>
> So this updates the status (eiher 'added' or 'removed') and also the menu 
> item text to the current cart quantity. 
>
> It's pretty straightforward, but somehow it took me time to figure out how 
> to address that menu item as it's created dynamically... 
>
> This kind of stuff makes our work enjoyable :)
>
> Thank you for the inquiry! 
>
> On Thursday, May 16, 2019 at 7:24:45 AM UTC-4, villas wrote:
>>
>> Hi Vlad,
>> It is great that you resolved this problem.  
>> Many of us use this group to search and learn from each other's 
>> experiences, and it can be frustrating to read a thread of messages and 
>> then simply see 'resolved' at the bottom. 
>> If you have time, it would be interesting and helpful to know briefly 
>> what you did.  I mean just an executive summary.  
>> Many thanks!
>>
>>
>> On Thursday, 16 May 2019 01:58:26 UTC+1, Vlad wrote:
>>>
>>> Never mind,
>>> Resolved...
>>>
>>> On Wednesday, May 15, 2019 at 8:43:44 PM UTC-4, Vlad wrote:

 I didn't say it precisely. By web2py controlling it I meant that it's 
 dynamic and changes all the time - it's not static that I could assign 
 certain id to some item... 

 On Wednesday, May 15, 2019 at 7:55:26 PM UTC-4, Vlad wrote:
>
> Sometimes I need to change the menu without reloading the page. 
>
> More specifically: 
>
> response.menu = [
> .
> .
> ('Cart (' + str(howManyItemsInCart()) + ")", False, 
> URL('catalog','cart'), []),
> ]
>
> I do control the event when the cart content changes (without 
> reloading the page), so javascript can be inserted there; I just don't 
> know 
> how to "address" that menu item, as I don't manage it - web2py does - 
>
> How would I accomplish this? ... 
>


-- 
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/dc5693a2-ba77-4886-b221-b1618aa31a07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I thought so and tried: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

this brings up an exception: 

Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to 
be decoded is not correctly encoded.

I've also double-checked the values - they are correct. For example, when I 
replace with the following: 

 var decodedString = atob("Q29va2llcyBvbmU=");

it decodes just fine, and the string itself I pick right from there - 
that's the value it has when it throws exception. 

Have no slightest clue what could possibly go wrong. 


On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>
> Maybe you need to iterate through the class elements.  See this:
>
> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>
>
>
> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>
>> Just to clarify: 
>>
>> the following works perfect  for one field by ID (decrypts it back):
>> var encodedDescription = $("#CurrentCartDescription").text()
>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>
>> However, when I try to do it for a bunch of fields at once using class 
>> (instead of id), it doesn't work - doesn't touch the values: 
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> I am sure I am missing something basic... Greatly appreciate suggestions 
>> - 
>>
>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>>
>>> I had no clue about it - I mean never heard the terms :)
>>>
>>> Thank you very much for point to the direction. After some googling, it 
>>> is almost working. 
>>>
>>> Encoding is just fine (using btoa). 
>>>
>>> When I read it back and want to decode - it's not yet behaving right. 
>>> I'm suspecting my javascript is a problem. 
>>>
>>> There is a bunch of fields which now have encrypted values (class 
>>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
>>> the original values: 
>>>
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> What am I doing wrong? (It doesn't change the values - they remain as 
>>> they are, encrypted)
>>>
>>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:

 Have you considered base64 encoding/decoding?

 quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in the 
> URL helper is because the parameters are coming from the html itself - 
> they 
> are not known in the controller py. 
>
> now the problem is that it changes the description and I have no way 
> to recover its original value. for example, when description is "askjdf d 
>  
>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
> in 
> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
> it needs to do this conversion in order to pass  the parameter, but I 
> need 
> to be able to recreate the original string, entered by the user. 
>
> Is there a better way of doing this? I.e. a better way of passing a 
> parameter in  a way that it could be "recreated" and stored in the 
> database 
> exactly as typed by the user? 
>


-- 
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/298b3f3d-a5fe-4fdf-80a0-b0455e094744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Maybe you need to iterate through the class elements.  See this:
https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class



On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>
> Just to clarify: 
>
> the following works perfect  for one field by ID (decrypts it back):
> var encodedDescription = $("#CurrentCartDescription").text()
> $("#CurrentCartDescription").html(atob(encodedDescription));
>
> However, when I try to do it for a bunch of fields at once using class 
> (instead of id), it doesn't work - doesn't touch the values: 
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> I am sure I am missing something basic... Greatly appreciate suggestions - 
>
> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>
>> I had no clue about it - I mean never heard the terms :)
>>
>> Thank you very much for point to the direction. After some googling, it 
>> is almost working. 
>>
>> Encoding is just fine (using btoa). 
>>
>> When I read it back and want to decode - it's not yet behaving right. I'm 
>> suspecting my javascript is a problem. 
>>
>> There is a bunch of fields which now have encrypted values (class 
>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
>> the original values: 
>>
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> What am I doing wrong? (It doesn't change the values - they remain as 
>> they are, encrypted)
>>
>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>
>>> Have you considered base64 encoding/decoding?
>>>
>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:

 I have the following javascript in the view: 

 var id = $('#CurrentCartId').text();
 var description = $(this).text();
 var url='{{=URL('cart','description')}}';
 url += '/' + id + '/';
 url += description;
 ajax(url,[],':eval');

 the reason I use url+= to pass parameters instead of using args in the 
 URL helper is because the parameters are coming from the html itself - 
 they 
 are not known in the controller py. 

 now the problem is that it changes the description and I have no way to 
 recover its original value. for example, when description is "askjdf d  
  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
 this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
 it needs to do this conversion in order to pass  the parameter, but I need 
 to be able to recreate the original string, entered by the user. 

 Is there a better way of doing this? I.e. a better way of passing a 
 parameter in  a way that it could be "recreated" and stored in the 
 database 
 exactly as typed by the user? 

>>>

-- 
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/d0d5cc0b-1a55-45ad-a8c3-caeefa695d3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread villas
acquisAPI

acquis Shortened from acquis communautaire: French acquis (“that which has 
been acquired or obtained”) + communautaire (“of the community”).




On Thursday, 16 May 2019 07:33:21 UTC+1, Massimo Di Pierro wrote:
>
> how about we simply call it "Access"?
>
> On Wednesday, 15 May 2019 06:58:37 UTC-7, Anthony wrote:
>>
>> On Wednesday, May 15, 2019 at 12:53:27 AM UTC-4, Massimo Di Pierro wrote:
>>>
>>> We can change the name but api is too ambiguous. Any other idea?
>>>
>>
>> Not sure. RESTAPI? HTTPAPI? 
>>
>

-- 
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/b89a5a76-8692-40f9-b797-4eebfec67cca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Answer from database empty list, list with tuple

2019-05-17 Thread Константин Комков
Version 2 can return



-- 
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/a0c86adb-313a-4ced-b6bf-15d458c8ca78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Answer from database empty list, list with tuple

2019-05-17 Thread Константин Комков
I want to have answer which contain *id* or *None*, but now in my query I 
have answer as empty list or list with tuple.
It's my query (version 1):
row = db_xml.executesql("SELECT FIRST 1 CASE WHEN V_CODE={0} THEN ID ELSE 
NULL END AS ID FROM ABIT_VALIDATION_CODES WHERE A_EMAIL='{1}' AND 
SESSION_DATE>DATEADD(-2 MINUTE TO CURRENT_TIMESTAMP) ORDER BY SESSION_DATE 
DESC".format(db._adapter.dialect.quote(request.vars.code),db._adapter.
dialect.quote(request.vars.email.strip(
It's my query (version 2):
cutoff_time = datetime.datetime.now() - datetime.timedelta(minutes=2)
condition = db_xml.abit_validation_codes.V_CODE==request.vars.code
typeOfAnswer = condition.case(db_xml.abit_validation_codes.id,None)
row = 
db_xml((db_xml.abit_validation_codes.A_EMAIL==request.vars.email.strip()) & 
(db_xml.abit_validation_codes.SESSION_DATE>cutoff_time)).select(typeOfAnswer,orderby=~db_xml.abit_validation_codes.SESSION_DATE).first()
Both of them do not work correct.


-- 
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/a10f776a-d446-4679-8ff2-27146092962b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Val K
Maybe 'Gate' or 'Gateway'

-- 
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/bb68428a-94fe-475b-babd-3a9b0829710f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Daniel Guilhermino
I feel like noob ... I suggested because Aditus in Latin is "Access".

And my google search (Brazilian) don't show anything like this on 2 firsts 
pages.

:(

mirimQL

mirim = small in "Tupi language"


*Old Tupi* or *classical Tupi* is an extinct Tupian language 
 which was spoken by the 
native Tupi people  of Brazil 
, mostly those who inhabited coastal 
regions in South  and Southeast 
Brazil .

https://en.wikipedia.org/wiki/Tupi_language

Em sexta-feira, 17 de maio de 2019 04:40:22 UTC-3, Massimo Di Pierro 
escreveu:
>
> I feel like I am missing something. This is the first entry from google: 
> https://en.wikipedia.org/wiki/Aditus_to_mastoid_antrum
>
> On Thursday, 16 May 2019 22:25:58 UTC-7, Daniel Guilhermino wrote:
>>
>> My 20 cents...  Why not Aditus?
>>
>> Em terça-feira, 14 de maio de 2019 03:18:42 UTC-3, Massimo Di Pierro 
>> escreveu:
>>>
>>> You may have missed this but there is a new functionality in PyDAL that 
>>> allows you to create very powerful APIs. It is called DBAPI.
>>> It is still not 100% stable but it is working and I could use some help 
>>> testing it.
>>> web3py's equivalent of appadmin will be called dbadmin (90% done) and it 
>>> is based on DBAPI.
>>> Even if primarily designed for web3py it works for web2py too and you 
>>> can find some preliminary examples below.
>>> Hope it is self-explanatory.
>>>
>>> DBAPI EXAMPLES 
>>>
>>> Inspired by GraphQL but not quite the same
>>>
>>> Less powerful but simpler to use
>>>
>>> Self descriptive (@model=True) and policy based (policy set serverside)
>>>
>>> Support complex queries like: 
>>>
>>>- name.eq=Clark Kent
>>>- name.ne=Clark Kent
>>>- name.gt=Clark Kent
>>>- name.lt=Clark Kent
>>>- name.ge=Clark Kent
>>>- name.le=Clark Kent
>>>- name.startswith=Clark
>>>- name.contains=Kent
>>>- not.real_identity.name.contains=Wayne
>>>- not.superhero.tag.superpower.description.eq=Flight
>>>
>>> Support de-normalization: 
>>>
>>>- @lookup=real_identity
>>>- @lookup=real_identity[name]
>>>- @lookup=real_identity[name,job]
>>>- @lookup=identity:real_identity[name,job]
>>>- @lookup=identity!:real_identity[name,job]
>>>- @lookup=superhero.tag
>>>- @lookup=superhero.tag[strength]
>>>- @lookup=superhero.tag[strength].superpower
>>>- @lookup=superhero.tag[strength].superpower.description
>>>
>>> Fast. Even the most complex query is implemented with at most 2 selects 
>>> + 1 select for each denormalized link table
>>> Example Model 
>>>
>>> db.define_table(
>>> 'person',
>>> Field('name'),
>>> Field('job'))
>>>
>>> db.define_table(
>>> 'superhero',
>>> Field('name'),
>>> Field('real_identity', 'reference person'))
>>>
>>> db.define_table(
>>> 'superpower',
>>> Field('description'))
>>>
>>> db.define_table(
>>> 'tag',
>>> Field('superhero', 'reference superhero'),
>>> Field('superpower', 'reference superpower'),
>>> Field('strength', 'integer'))
>>>
>>> Example Controller 
>>>
>>> from pydal.dbapi import DBAPI, Policy
>>> policy = Policy()
>>> policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
>>> post_vars:True, allowed_patterns=['*'])
>>> policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
>>> post_vars:False)
>>> policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
>>> post_vars:False)
>>> policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
>>> post_vars:False)
>>>
>>> def api():
>>> return DBAPI(db, policy)(request.method, request.args(0), 
>>> request.args(1),
>>>  request.get_vars, request.post_vars)
>>>
>>> Example GET URLs 
>>> /superheroes/default/api.json/superhero 
>>>
>>> {
>>> "count": 3,
>>> "status": "success",
>>> "code": 200,
>>> "items": [
>>> {
>>> "real_identity": 1,
>>> "name": "Superman",
>>> "id": 1
>>> },
>>> {
>>> "real_identity": 2,
>>> "name": "Spiderman",
>>> "id": 2
>>> },
>>> {
>>> "real_identity": 3,
>>> "name": "Batman",
>>> "id": 3
>>> }
>>> ],
>>> "timestamp": "2019-05-14T06:14:06.764966",
>>> "api_version": "0.1"
>>> }
>>>
>>> /superheroes/default/api.json/superhero&@model=true 
>>>
>>> {
>>> "status": "error",
>>> "timestamp": "2019-05-14T06:14:06.997662",
>>> "message": "Invalid table name: superhero_amp_@model=true",
>>> "code": 400,
>>> "api_version": "0.1"
>>> }
>>>
>>> /superheroes/default/api.json/superhero?@lookup=real_identity 
>>>
>>> {
>>> "count": 3,
>>> "status": "success",
>>> "code": 200,
>>> "items": [
>>> {
>>> "real_identity": {

[web2py] Re: Web3py

2019-05-17 Thread 黄祥
test 'reload apps' on http://localhost:8000/_dashboard return an error on 
terminal and also on browser http://localhost:8000/_dashboard when click 
superheroes installed applications
[FAILED] loading superheroes 
Traceback (most recent call last):
  File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 577, in 
import_apps
reloader.reload(module)
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/reloader.py"
, line 147, in reload
_reload(m, set())
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/reloader.py"
, line 135, in _reload
imp.reload(m)
  File "/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/imp.py"
, line 314, in reload
return importlib.reload(module)
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/importlib/__init__.py"
, line 169, in reload
_bootstrap._exec(spec, module)
  File "", line 630, in _exec
  File "", line 728, in 
exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "/Users/sugizo/learn/python/web3py/apps/superheroes/__init__.py", 
line 28, in 
db.person.insert(name='Clark Kent', job='Journalist')
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/objects.py"
, line 762, in insert
ret = self._db._adapter.insert(self, row.op_values())
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/adapters/base.py"
, line 487, in insert
raise e
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/adapters/base.py"
, line 482, in insert
self.execute(query)
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/adapters/__init__.py"
, line 67, in wrap
return f(*args, **kwargs)
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/adapters/base.py"
, line 413, in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
sqlite3.OperationalError: database is locked

the strange things also occured
1st. when first run server the route for apps : _scaffold and myapp are 
appears on http://localhost:8000/_dashboard, after hit 'reload apps' the 
route for apps are disappears. yet that still have the route for apps are 
_dashboard, examples, todo
2nd. yet the edited apps didn't take an effect
*e.g.*
1. ./web3py-start apps
2. edit apps/myapp/controllers.py
*change* 
def helloworld(): return dict(name=request.forms.get('name', '*visitor*'))
*into*
def helloworld(): return dict(name=request.forms.get('name', '*visitorsadf*'
))
3. hit 'reload apps' on http://localhost:8000/_dashboard
4. refresh http://localhost:8000/myapp/helloworld
*expected result on browser:*
Hello Dear visitorsadf
*got result** on browser**:*
Hello Dear visitor

expected result 'Hello Dear visitorsadf' can be achieved after stop and 
start the server again

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/df94734c-ec34-426c-8a4a-f761f4832e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [web2py] Re: Web3py

2019-05-17 Thread John Bannister
Hi Massimo,

 

I have tried that but it has no effect. It seems to be doing something for a 
while but the only way I can get changes to appear is to restart the server.

 

Basically what I did was to copy and rename the helloworld action a few times 
so helloworld1 …….helloworld7 (all in same controller.py)  giving appropriate 
return messages.

 

If I reload using the dashboard button I still only see helloworld (the rest 
give me 404 errors) but if I restart the server I can access myapp/helloworld1 
to myapp/helloworld7.

 

Also it seems that the reload apps button is reloading all the apps in the 
applications directory. Is this intentional or is there a way to just reload 
the app currently being developed?

 

BR

John 

 

 

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Massimo Di Pierro
Sent: 17 May 2019 09:36
To: web2py-users
Subject: [web2py] Re: Web3py

 

yes. There is a button on the top/right of the dashboard "reload apps"

On Thursday, 16 May 2019 08:15:44 UTC-7, John Bannister wrote:

Hi All,

 

Had a first real 'play' with web3py' today and have a few questions the biggest 
of which I am hoping the gurus will be able to answer:-

 

1: Is there any way to not to have to restart the app every time changes are 
made to actions in the controller or new actions added etc? I understand that 
controllers are basically being imported when the app fires up but is any there 
any way to occasionally reload instead of having to restart the app? This is a 
fairly big one for me as sometimes tweaks will need to be made in production 
and restarting the web server is not really an option so hopefully I am missing 
something really simple.

 

Thanks in advance

John

 

 

 

 

 

 

  

-- 
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/c33707df-ec41-4574-a6a6-54c2905ff10e%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/02ab01d50c90%245b5be270%241213a750%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] I can not import module in app

2019-05-17 Thread Константин Комков
I want import module. I create module mytest like in book, but after import 
I heve error. I tried to import mytest in another app and it work. What is 
reason of it? I tried import module like that : from applications.
application.modules import mytest but error the same.
Error ticket for "application"Ticket ID

192.168.20.177.2019-05-17.10-35-07.293afb38-6e29-461b-8ccb-46092d983b29
 No module named application.modulesВерсия
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
Python Python 2.7.10: C:\Python27\python.exe (prefix: C:\Python27)Traceback

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

Traceback (most recent call last):
  File ".\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:\inetpub\wwwroot\applications\application\controllers/default.py", 
line 2, in 
import datetime, calendar, mytest
  File ".\gluon\custom_import.py", line 74, in custom_importer
modules_prefix, globals, locals, (itemname,), level)
ImportError: No module named application.modules

-- 
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/d3672bde-65a0-4408-acff-2437bf01980e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-17 Thread Massimo Di Pierro
I feel like I am missing something. This is the first entry from google: 
https://en.wikipedia.org/wiki/Aditus_to_mastoid_antrum

On Thursday, 16 May 2019 22:25:58 UTC-7, Daniel Guilhermino wrote:
>
> My 20 cents...  Why not Aditus?
>
> Em terça-feira, 14 de maio de 2019 03:18:42 UTC-3, Massimo Di Pierro 
> escreveu:
>>
>> You may have missed this but there is a new functionality in PyDAL that 
>> allows you to create very powerful APIs. It is called DBAPI.
>> It is still not 100% stable but it is working and I could use some help 
>> testing it.
>> web3py's equivalent of appadmin will be called dbadmin (90% done) and it 
>> is based on DBAPI.
>> Even if primarily designed for web3py it works for web2py too and you can 
>> find some preliminary examples below.
>> Hope it is self-explanatory.
>>
>> DBAPI EXAMPLES 
>>
>> Inspired by GraphQL but not quite the same
>>
>> Less powerful but simpler to use
>>
>> Self descriptive (@model=True) and policy based (policy set serverside)
>>
>> Support complex queries like: 
>>
>>- name.eq=Clark Kent
>>- name.ne=Clark Kent
>>- name.gt=Clark Kent
>>- name.lt=Clark Kent
>>- name.ge=Clark Kent
>>- name.le=Clark Kent
>>- name.startswith=Clark
>>- name.contains=Kent
>>- not.real_identity.name.contains=Wayne
>>- not.superhero.tag.superpower.description.eq=Flight
>>
>> Support de-normalization: 
>>
>>- @lookup=real_identity
>>- @lookup=real_identity[name]
>>- @lookup=real_identity[name,job]
>>- @lookup=identity:real_identity[name,job]
>>- @lookup=identity!:real_identity[name,job]
>>- @lookup=superhero.tag
>>- @lookup=superhero.tag[strength]
>>- @lookup=superhero.tag[strength].superpower
>>- @lookup=superhero.tag[strength].superpower.description
>>
>> Fast. Even the most complex query is implemented with at most 2 selects + 
>> 1 select for each denormalized link table
>> Example Model 
>>
>> db.define_table(
>> 'person',
>> Field('name'),
>> Field('job'))
>>
>> db.define_table(
>> 'superhero',
>> Field('name'),
>> Field('real_identity', 'reference person'))
>>
>> db.define_table(
>> 'superpower',
>> Field('description'))
>>
>> db.define_table(
>> 'tag',
>> Field('superhero', 'reference superhero'),
>> Field('superpower', 'reference superpower'),
>> Field('strength', 'integer'))
>>
>> Example Controller 
>>
>> from pydal.dbapi import DBAPI, Policy
>> policy = Policy()
>> policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
>> post_vars:True, allowed_patterns=['*'])
>> policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>> policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>> policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>>
>> def api():
>> return DBAPI(db, policy)(request.method, request.args(0), 
>> request.args(1),
>>  request.get_vars, request.post_vars)
>>
>> Example GET URLs 
>> /superheroes/default/api.json/superhero 
>>
>> {
>> "count": 3,
>> "status": "success",
>> "code": 200,
>> "items": [
>> {
>> "real_identity": 1,
>> "name": "Superman",
>> "id": 1
>> },
>> {
>> "real_identity": 2,
>> "name": "Spiderman",
>> "id": 2
>> },
>> {
>> "real_identity": 3,
>> "name": "Batman",
>> "id": 3
>> }
>> ],
>> "timestamp": "2019-05-14T06:14:06.764966",
>> "api_version": "0.1"
>> }
>>
>> /superheroes/default/api.json/superhero&@model=true 
>>
>> {
>> "status": "error",
>> "timestamp": "2019-05-14T06:14:06.997662",
>> "message": "Invalid table name: superhero_amp_@model=true",
>> "code": 400,
>> "api_version": "0.1"
>> }
>>
>> /superheroes/default/api.json/superhero?@lookup=real_identity 
>>
>> {
>> "count": 3,
>> "status": "success",
>> "code": 200,
>> "items": [
>> {
>> "real_identity": {
>> "name": "Clark Kent",
>> "job": "Journalist",
>> "id": 1
>> },
>> "name": "Superman",
>> "id": 1
>> },
>> {
>> "real_identity": {
>> "name": "Peter Park",
>> "job": "Photographer",
>> "id": 2
>> },
>> "name": "Spiderman",
>> "id": 2
>> },
>> {
>> "real_identity": {
>> "name": "Bruce Wayne",
>> "job": "CEO",
>> "id": 3
>> },
>> "name": "Batman",
>> "id": 3
>> }
>> ],
>> "timestamp": "2019-05-14T06:14:06.931746",
>> "api_version": "0.1"
>> }
>>
>> /superheroes/default/api.json/superhero?@lookup=identity:real_identity 
>>
>> {
>> "count": 3,
>> "status": 

Re: [web2py] Web3Py equivalent of SQLFORM.grid

2019-05-17 Thread Massimo Di Pierro
Please consider that it is not finished. As soon as done I will write some 
documentation. But basically you include utils.js, vue.min.js, 
axios.min.js, components/mtable.js and the you embed it







as a vue component.

On Thursday, 16 May 2019 08:31:23 UTC-7, John Bannister wrote:
>
> Hi Massimo,
>
> Had a quick look at the mtable prototype in the _dashboad/dbadmin and 
> re-visiting datatables as well. Will need to spend a bit more time on both 
> before I can come to any sort of solution but thanks very much for the 
> input. 
>
> On Thursday, 16 May 2019 16:50:48 UTC+2, Massimo Di Pierro wrote:
>>
>> Web3py will have a replacement for smartgrid based on vue. You can look 
>> at the mtable component already in there as a prototype. Anyway, nothing 
>> wrong with datatables.
>
>

-- 
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/1e07a734-6039-45b7-a351-0ae313a366c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-17 Thread Massimo Di Pierro
yes. There is a button on the top/right of the dashboard "reload apps"

On Thursday, 16 May 2019 08:15:44 UTC-7, John Bannister wrote:
>
> Hi All,
>
> Had a first real 'play' with web3py' today and have a few questions the 
> biggest of which I am hoping the gurus will be able to answer:-
>
> 1: Is there any way to not to have to restart the app every time changes 
> are made to actions in the controller or new actions added etc? I 
> understand that controllers are basically being imported when the app fires 
> up but is any there any way to occasionally reload instead of having to 
> restart the app? This is a fairly big one for me as sometimes tweaks will 
> need to be made in production and restarting the web server is not really 
> an option so hopefully I am missing something really simple.
>
> Thanks in advance
> John
>
>
>
>
>
>
>   
>

-- 
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/c33707df-ec41-4574-a6a6-54c2905ff10e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.