Re: [web2py] VSCODE with linter + debugging in WEB2PY

2022-11-27 Thread Alex Glaros
vscode is not understanding where web2py syntax is defined. I get following 
error

Exception has occurred: NameError
name 'request' is not defined
File "
C:\alex\alt_w2p_06_source\web2py\applications\lower_case_8\models\db.py", 
line 8, in  if request.global_settings.web2py_version < "2.14.1":

I have windows 10, install Web2py from source.

launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: web2py",
    "type": "python",
"request": "launch",
"program": "C:/alex/alt_w2p_06_source/web2py/web2py.py",
"console": "integratedTerminal",
"justMyCode": true
}
]
}

settings.json
{
"python.pythonPath": "C:\Users\alex_\venv\Scripts\python.exe",
"debug.allowBreakpointsEverywhere": true
}
On Saturday, September 18, 2021 at 4:07:20 PM UTC-7 yamand...@gmail.com 
wrote:

> Hi, I have a video teaching how to setup web2py launch and debug in vs 
> code.
> It is in Portuguese, but you can activate english subtitles, and it is 
> also to see what I do in the video.
> https://www.youtube.com/watch?v=4LSy5VuLqCQ
>
> Em sexta-feira, 17 de setembro de 2021 às 05:21:04 UTC-3, 
> muratkas...@gmail.com escreveu:
>
>> Hi Monir,
>>
>> I have to explain my env in other words. Before start, you can finish 
>> vscode and python setup:
>>
>> my pc environment is 
>> win10/pro, 
>> python :3.8.5  (not virtual env)
>> vscode 1.60.0
>>
>> steps:
>>
>> 1. download web2py *source *code and  extract it to the desired folder.
>> 2. open the vscode
>> 3. open the folder you extracted web2py source.
>> 4. create a *.vscode* folder and copy these files:
>>
>> *launch.json*
>> {
>> "version": "0.2.0",
>> "configurations": [
>> {
>> "name": "Python: Current File",
>> "type": "python",
>> "request": "launch",
>> "program": "${file}",
>> "console": "integratedTerminal"
>> }
>> ]
>> }
>>
>> *settings.json  *
>> {
>> "python.pythonPath": "C:\\your_python_folder\\python.exe",
>> "debug.allowBreakpointsEverywhere": true
>> }
>>
>> 6. Press F5 or select link from Menu>Run>Start Debugging
>>
>> I think it will start. Whenever select any row on the code for debug, it 
>> will stop.
>>
>> Can you try and inform me whether the info is working.
>>
>> Regards,
>> Murat.
>>
>>
>>
>> K P , 17 Eyl 2021 Cum, 03:06 tarihinde şunu yazdı:
>>
>>> Hi Murat
>>>
>>> I need some help setting up web2py in vs code also. I tried what you 
>>> said (and many other things) but none worked. Please help. 
>>> (Yardim Edibilur)
>>>
>>> On Tuesday, September 10, 2019 at 3:03:55 AM UTC-4 muratkas...@gmail.com 
>>> wrote:
>>>
>>>> Hi,
>>>> I work with VSCODE like this:
>>>> - Open folder includes web2py.py file.
>>>> - Insert some debug point to desired lines
>>>> - Press F5 
>>>>
>>>> Also my environment: 
>>>> Windows 10 Pro
>>>> Web2py Python 2.7
>>>> (maybe Py 3> works same.)
>>>>
>>>> Best.
>>>>
>>>> ---
>>>> Murat KAŞIKÇIOĞLU
>>>> +90 (533) 745-1400 <+90%20533%20745%2014%2000>
>>>>
>>>>
>>>>
>>>> Monir , 4 Eyl 2019 Çar, 18:55 tarihinde şunu 
>>>> yazdı:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I'm new on Python and also on Web2py. I've been searching some sort of 
>>>>> info or step by step about how to config web2py in VS CODE to Debug, 
>>>>> Lint, 
>>>>> Intelisense, etc... would be nice!
>>>>>
>>>>> But unfortunately, all resources I have found so far seems to be 
>>>>> deprecated. Even here in the group, this seems to be not relevant topic. 
>>>>> Am 
>>>>> I wright ?
>>>>>
>>>>> I had downloaded Don Jaimanne extension, Pylint, etc without success.
>>>>>
>>>>> I would b

[web2py] Re: where is the path specified that points to python.exe

2022-11-27 Thread Alex Glaros
I mean where in the  Web2py source code or settings can I tell web2py which 
instance of python to use.   Where can I type the path?

On Saturday, November 26, 2022 at 2:24:32 PM UTC-8 Arglanir wrote:

> sys.executable should be your friend.
>
> Le samedi 26 novembre 2022 à 08:42:52 UTC+1, alexg...@gmail.com a écrit :
>
>> where is the path specified that points to python.exe?
>>
>> Am using Windows source code for For Python 3.7
>>
>

-- 
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/76bc3bc5-247d-449e-b277-da2e2486fa11n%40googlegroups.com.


[web2py] where is the path specified that points to python.exe

2022-11-25 Thread Alex Glaros
where is the path specified that points to python.exe?

Am using Windows source code for For Python 3.7

-- 
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/12c9193d-54bf-4647-a248-42de3a05ef06n%40googlegroups.com.


[web2py] Re: Slider example

2022-08-31 Thread Alex Beskopilny
unfortunately, I don't have the code.

I once made such a form from a book
web2py Application Development Cookbook
(I remember that there were errors in the book, 
but the code that came with the book worked 
after obvious changes)

On Tuesday, August 30, 2022 at 11:04:41 AM UTC+3 Kenneth wrote:

> Hello everybody,
>
> does anyone have an example on creating a form with sliders. Selecting a 
> value of lets say 1-10. 
>
> I tried using the example on web2pyslices but can't get it working. 
>
>
> Kenneth
>
>

-- 
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/1bfdda50-729f-4e56-b685-8de17a635d1cn%40googlegroups.com.


[web2py] How to measure performance?

2022-01-15 Thread Alex Glaros
I put start-time capture at top of view, and end time-capture at bottom of 
view. Start and end time are always result in identical values but seems 
that end time should be different.

In view I have:

{{startTime = request.now}}  [this is a top of view]
{{for a in 
...takes a few seconds to run through a bunch of computations and 
data:}}
{{endTime = request.now}} [this is at bottom of view]

Result is:

Start Time: 2022-01-15 16:04:28.066000   End Time: 2022-01-15 
16:04:28.066000 [This should be different]
Time Spent Checking: 0:00:00 [It should have some minor value in it, right?]

-- 
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/0e662dc4-1dce-4830-a3c5-a163bae9031cn%40googlegroups.com.


[web2py] Re: rendering rows as a generator and displaying via SQLTABLE

2020-12-24 Thread Alex Beskopilny
Hi! 

You can create a table in memory and use grid
working example:

def pro_report1():
# https://web2py.wordpress.com/category/web2py-and-databases/
# 
https://stackoverflow.com/questions/33674532/web2py-sqlform-grid-with-executesql
tbl = 'proverka'

#f_short_proverka = [  'f' + str(e) for e in short_proverka ]

l = [e for e in db[tbl].fields if e in f_short_proverka ]
memf = [ Field('oid', 'integer', label='П id', default= 0) ] + \
   [ Field(db[tbl][e].name, db[tbl][e].type, label = 
db[tbl][e].label,
 length= db[tbl][e].length, represent= db[tbl][e].represent  )
 for e in l ]

dbmem = DAL('sqlite:memory')
dbmem.define_table('mem_table',*memf)

records = db(db[tbl].id>0).select().as_list()
for r in records:
r['oid'] = r['id']
dbmem.mem_table.insert(**dbmem.mem_table._filter_fields(r))

#dbmem.commit()

flds= [ db[tbl][e] for e in f_short_proverka ]
rows=db(db[tbl].id>0 ).select( *flds  )

exportclasses=dict(
csv_with_hidden_cols=False,
csv=False,
xml=False,
json=False,
tsv_with_hidden_cols=False,
tsv= False,
)

dbmem.mem_table.id.readable = False
grid = SQLFORM.grid(dbmem.mem_table, create=False, editable=False, 
exportclasses= exportclasses,
deletable=False, buttons_placement = 'left', 
showbuttontext=False)
return dict(rows=rows, l=l, records=records, grid=grid)

On Thursday, December 24, 2020 at 12:32:51 AM UTC+3 Vlad wrote:

> I'm getting the rows as a result of the select:
> *rows = db(query).select(*fields)*
> and want to display as 
> *table = SQLTABLE(rows, _class='table')*
> but before displaying need to reformat based on field representation, so 
> rendering first: 
> *rendered_rows = rows.render()*
> now I simply want to display the rendered_rows, like this: 
> *table = SQLTABLE(rendered_rows, _class='table')* 
> which is impossible because rendered_rows is a generator. I can iterate 
> row by row, but don't know how to use it with SQLTABLE. 
>
> Is there an easy way to transform the generator into the format that 
> SQLTABLE understands? 
>  
>

-- 
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/23e730b8-6522-4400-b034-7f9b912c345an%40googlegroups.com.


[web2py] Re: How to add another field to select clause?

2020-11-28 Thread Alex Glaros
It worked Jim.   Thanks!

On Friday, November 27, 2020 at 11:18:32 AM UTC-8 Jim S wrote:

> If your groupby is a list of fields then it needs list brackers [ ] around 
> it.
>
> Can you add that and report back?
>
> -Jim
>
> On Friday, November 27, 2020 at 2:01:17 AM UTC-6 alexg...@gmail.com wrote:
>
>> using Postgres 
>>
>> On Thursday, November 26, 2020 at 11:18:00 PM UTC-8 Alex Glaros wrote:
>>
>>> How to add db.role_member.id within select clause as highlighted below?
>>>
>>> If I leave it out, it runs fine. If I add it, I get error: 
>>> class 'psycopg2.errors.GroupingError'> column "role_member.id" must 
>>> appear in the GROUP BY
>>>
>>> and if I make it appear in the group by section as suggested by the 
>>> error message, I get error:
>>> SyntaxError: non-keyword arg after keyword arg
>>>
>>> Here is the code:
>>>
>>> distinctCount = 
>>> db.object_super_object.super_object_fk.count().with_alias('distinctCount')
>>> 
>>> distinctSet = db((db.role_member_status_instance.role_member_fk == 
>>> db.role_member.id) & (db.role_member.role_fk == specificRoleID) & 
>>> (db.role_member.object_super_object_fk == db.object_super_object.id) & 
>>> (db.role_member.is_active == True) &  
>>> (db.role_member.member_super_object_fk == db.super_object.id) & 
>>> (specificOrganizationID == 
>>> db.object_super_object.role_owner_organization_fk)).select(db.role_member.member_super_object_fk,
>>>  
>>> db.role_member.id, distinctCount, groupby = 
>>> db.role_member.member_super_object_fk, db.role_member.id)
>>>
>>

-- 
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/03fd1332-1dab-47a9-9dd5-4ac0212e2fddn%40googlegroups.com.


[web2py] Re: How to add another field to select clause?

2020-11-27 Thread Alex Glaros
using Postgres 

On Thursday, November 26, 2020 at 11:18:00 PM UTC-8 Alex Glaros wrote:

> How to add db.role_member.id within select clause as highlighted below?
>
> If I leave it out, it runs fine. If I add it, I get error: 
> class 'psycopg2.errors.GroupingError'> column "role_member.id" must 
> appear in the GROUP BY
>
> and if I make it appear in the group by section as suggested by the error 
> message, I get error:
> SyntaxError: non-keyword arg after keyword arg
>
> Here is the code:
>
> distinctCount = 
> db.object_super_object.super_object_fk.count().with_alias('distinctCount')
> 
> distinctSet = db((db.role_member_status_instance.role_member_fk == 
> db.role_member.id) & (db.role_member.role_fk == specificRoleID) & 
> (db.role_member.object_super_object_fk == db.object_super_object.id) & 
> (db.role_member.is_active == True) &  
> (db.role_member.member_super_object_fk == db.super_object.id) & 
> (specificOrganizationID == 
> db.object_super_object.role_owner_organization_fk)).select(db.role_member.member_super_object_fk,
>  
> db.role_member.id, distinctCount, groupby = 
> db.role_member.member_super_object_fk, db.role_member.id)
>

-- 
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/ce8d209b-75fb-44c8-895d-5ef117426edan%40googlegroups.com.


[web2py] How to add another field to select clause?

2020-11-26 Thread Alex Glaros
How to add db.role_member.id within select clause as highlighted below?

If I leave it out, it runs fine. If I add it, I get error: 
class 'psycopg2.errors.GroupingError'> column "role_member.id" must appear 
in the GROUP BY

and if I make it appear in the group by section as suggested by the error 
message, I get error:
SyntaxError: non-keyword arg after keyword arg

Here is the code:

distinctCount = 
db.object_super_object.super_object_fk.count().with_alias('distinctCount')

distinctSet = db((db.role_member_status_instance.role_member_fk == 
db.role_member.id) & (db.role_member.role_fk == specificRoleID) & 
(db.role_member.object_super_object_fk == db.object_super_object.id) & 
(db.role_member.is_active == True) &  
(db.role_member.member_super_object_fk == db.super_object.id) & 
(specificOrganizationID == 
db.object_super_object.role_owner_organization_fk)).select(db.role_member.member_super_object_fk,
 
db.role_member.id, distinctCount, groupby = 
db.role_member.member_super_object_fk, db.role_member.id)

-- 
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/e5599300-316f-4377-a432-f1b0d88b343dn%40googlegroups.com.


[web2py] Re: How to sort a join by count

2020-11-20 Thread Alex Glaros
Thanks for detailed responses Val, I appreciate it.

On Saturday, November 14, 2020 at 4:51:06 PM UTC-8 valq...@gmail.com wrote:

> I made even CTE+recursive:  
> https://github.com/web2py/pydal/issues/627
>
> But have no time to make a PR
>
> воскресенье, 15 ноября 2020 г. в 03:41:24 UTC+3, valq...@gmail.com: 
>
>> for example,  you can use window function to get  records with count  in 
>> one query:
>> db(...).select( ... ,  'count(id) OVER() AS cnt' )
>>
>>
>> воскресенье, 15 ноября 2020 г. в 03:35:34 UTC+3, valq...@gmail.com: 
>>
>>> It was in 2017
>>> Now you can pass to select raw-sql-strings with any expression, just end 
>>> with  ' ... *AS* some_name'  (*AS* must be in uppercase )
>>>
>>> воскресенье, 15 ноября 2020 г. в 02:54:53 UTC+3, alexg...@gmail.com: 
>>>
>>>> looks like need executeSQL needed for string_agg: 
>>>> Is it possible to do more advanced queries (like using string_agg) with 
>>>> DAL in the meantime?
>>>> Massimo Di Pierro
>>>> Apr 12, 2017, 4:21:36 AM
>>>> to web...@googlegroups.com
>>>> You have to use db.executesql for that. Sorry.
>>>>
>>>> On Saturday, November 14, 2020 at 3:28:06 PM UTC-8 valq...@gmail.com 
>>>> wrote:
>>>>
>>>>>   just replace *GROUP_CONCAT* with *string_agg * 
>>>>>
>>>>> воскресенье, 15 ноября 2020 г. в 02:19:52 UTC+3, alexg...@gmail.com: 
>>>>>
>>>>>> I have postgres. How would it look for that?
>>>>>>
>>>>>> On Saturday, November 14, 2020 at 9:03:13 AM UTC-8 valq...@gmail.com 
>>>>>> wrote:
>>>>>>
>>>>>>> Just in case : pydal doesnt support backend specific aggregate 
>>>>>>> functions
>>>>>>>
>>>>>>>
>>>>>>> суббота, 14 ноября 2020 г. в 19:54:35 UTC+3, valq...@gmail.com: 
>>>>>>>
>>>>>>>> There is no db.executesql
>>>>>>>>
>>>>>>>> суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: 
>>>>>>>>
>>>>>>>>> sorry, did not mean direct SQL through db.executesql , meant 
>>>>>>>>> through DAL
>>>>>>>>>
>>>>>>>>> On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 
>>>>>>>>> valq...@gmail.com wrote:
>>>>>>>>>
>>>>>>>>>> Assuming sqlite:
>>>>>>>>>> person_cnt = 
>>>>>>>>>> db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt')
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> prioritySet = db((db.PERSON.id <http://db.person.id/> == 
>>>>>>>>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>>>>>>>>> PERSON-PROJECT-PRIORITY.project_fk)).select(
>>>>>>>>>> ...,
>>>>>>>>>> person_cnt, 
>>>>>>>>>> 'GROUP_CONCAT(person.person_name,",") AS person_list'
>>>>>>>>>> groupby = db.PERSON-PROJECT-PRIORITY.project_fk, 
>>>>>>>>>> )
>>>>>>>>>>
>>>>>>>>>> суббота, 14 ноября 2020 г. в 09:40:17 UTC+3, alexg...@gmail.com: 
>>>>>>>>>>
>>>>>>>>>>> How to write a statement that counts which projects are the 
>>>>>>>>>>> priority of most people
>>>>>>>>>>>
>>>>>>>>>>> PROJECT
>>>>>>>>>>> id
>>>>>>>>>>> project_name
>>>>>>>>>>>
>>>>>>>>>>> PERSON
>>>>>>>>>>> id
>>>>>>>>>>> person_name
>>>>>>>>>>>
>>>>>>>>>>> PERSON_PROJECT_PRIORITY
>>>>>>>>>>> person_fk
>>>>>>>>>>> project_fk
>>>>>>>>>>>
>>>>>>>>>>> prioritySet = db((db.PERSON.id == 
>>>>>>>>>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>>>>>>>>>> PERSON-PROJECT-PRIORITY.project_fk)).select()
>>>>>>>>>>>
>>>>>>>>>>> How to sort by count of projects which have priority in order of 
>>>>>>>>>>> the most persons' priority?
>>>>>>>>>>>
>>>>>>>>>>> Output looks like this:
>>>>>>>>>>>
>>>>>>>>>>> Paint-the-house (10)  [Means is the top priority for 10 people]
>>>>>>>>>>> Plant-a-garden (5)
>>>>>>>>>>> Clean-out-garage (2)
>>>>>>>>>>>
>>>>>>>>>>> If you have additional time, how to write so output looks like:
>>>>>>>>>>>
>>>>>>>>>>> Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, 
>>>>>>>>>>> Chris, Ed, Sally
>>>>>>>>>>> Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
>>>>>>>>>>> Clean-out-garage (2) Clyde, Jane
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>>
>>>>>>>>>>> Alex Glaros
>>>>>>>>>>>
>>>>>>>>>>

-- 
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/b1bc83f0-f737-4d01-96f5-d5192f496957n%40googlegroups.com.


[web2py] Re: How to pass variables to db.executesql?

2020-11-20 Thread Alex Beskopilny
myid = 10L
sql_str = "xxx  where id=%s;" % (str(myid))
db.executesql( sql_str )

examples:  https://web2py.wordpress.com/tag/db-executesql/

On Friday, November 20, 2020 at 7:56:07 AM UTC+3 alexg...@gmail.com wrote:

> for example 
>
> where mytable.id = someWeb2PyVariable
>
> thanks,
>
> Alex Glaros 
>

-- 
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/1888eac3-dab9-4182-97a6-dc5bb3caa84fn%40googlegroups.com.


[web2py] How to pass variables to db.executesql?

2020-11-19 Thread Alex Glaros
for example 

where mytable.id = someWeb2PyVariable

thanks,

Alex Glaros 

-- 
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/fa1cf04c-a01c-40fa-8e00-20295fa46113n%40googlegroups.com.


[web2py] Re: Dashboard library for Web2py performance/recommendation python vs. js

2020-11-18 Thread Alex Beskopilny
dasjboards for web2py https://github.com/ali96343/facew2p
dashboards  for py4web https://github.com/ali96343/facep4w
charts Highcharts.js 
On Tuesday, November 17, 2020 at 11:47:04 AM UTC+3 Jonsubs wrote:

> Hi everyone,
> I need to implement a dashboard and some charts in my webapp. And honestly 
> I'm a little bit lost and overwhelmed.
>
> From a Web2py perspective which is the best approach?
> a) a python based solution (e.g. plotly)
> b) a JS based solution
>
> My app is hosted in Pythonanywhere.
>
> Is there any recommended dashboard and chart library for web2py?
> Thanks, Jon.
>
>
> 
>  Libre 
> de virus. www.avast.com 
> 
>  
> <#m_-2958339010838646051_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

-- 
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/b33a4e69-68f9-4607-aa3f-99f1f661fb34n%40googlegroups.com.


[web2py] Re: How to sort a join by count

2020-11-14 Thread Alex Glaros
looks like need executeSQL needed for string_agg: 
Is it possible to do more advanced queries (like using string_agg) with DAL 
in the meantime?
Massimo Di Pierro
Apr 12, 2017, 4:21:36 AM
to web...@googlegroups.com
You have to use db.executesql for that. Sorry.

On Saturday, November 14, 2020 at 3:28:06 PM UTC-8 valq...@gmail.com wrote:

>   just replace *GROUP_CONCAT* with *string_agg * 
>
> воскресенье, 15 ноября 2020 г. в 02:19:52 UTC+3, alexg...@gmail.com: 
>
>> I have postgres. How would it look for that?
>>
>> On Saturday, November 14, 2020 at 9:03:13 AM UTC-8 valq...@gmail.com 
>> wrote:
>>
>>> Just in case : pydal doesnt support backend specific aggregate functions
>>>
>>>
>>> суббота, 14 ноября 2020 г. в 19:54:35 UTC+3, valq...@gmail.com: 
>>>
>>>> There is no db.executesql
>>>>
>>>> суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: 
>>>>
>>>>> sorry, did not mean direct SQL through db.executesql , meant through 
>>>>> DAL
>>>>>
>>>>> On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 valq...@gmail.com 
>>>>> wrote:
>>>>>
>>>>>> Assuming sqlite:
>>>>>> person_cnt = 
>>>>>> db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt')
>>>>>>
>>>>>>
>>>>>> prioritySet = db((db.PERSON.id <http://db.person.id/> == 
>>>>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>>>>> PERSON-PROJECT-PRIORITY.project_fk)).select(
>>>>>> ...,
>>>>>> person_cnt, 
>>>>>> 'GROUP_CONCAT(person.person_name,",") AS person_list'
>>>>>> groupby = db.PERSON-PROJECT-PRIORITY.project_fk, 
>>>>>> )
>>>>>>
>>>>>> суббота, 14 ноября 2020 г. в 09:40:17 UTC+3, alexg...@gmail.com: 
>>>>>>
>>>>>>> How to write a statement that counts which projects are the priority 
>>>>>>> of most people
>>>>>>>
>>>>>>> PROJECT
>>>>>>> id
>>>>>>> project_name
>>>>>>>
>>>>>>> PERSON
>>>>>>> id
>>>>>>> person_name
>>>>>>>
>>>>>>> PERSON_PROJECT_PRIORITY
>>>>>>> person_fk
>>>>>>> project_fk
>>>>>>>
>>>>>>> prioritySet = db((db.PERSON.id == 
>>>>>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>>>>>> PERSON-PROJECT-PRIORITY.project_fk)).select()
>>>>>>>
>>>>>>> How to sort by count of projects which have priority in order of the 
>>>>>>> most persons' priority?
>>>>>>>
>>>>>>> Output looks like this:
>>>>>>>
>>>>>>> Paint-the-house (10)  [Means is the top priority for 10 people]
>>>>>>> Plant-a-garden (5)
>>>>>>> Clean-out-garage (2)
>>>>>>>
>>>>>>> If you have additional time, how to write so output looks like:
>>>>>>>
>>>>>>> Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, Chris, 
>>>>>>> Ed, Sally
>>>>>>> Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
>>>>>>> Clean-out-garage (2) Clyde, Jane
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Alex Glaros
>>>>>>>
>>>>>>

-- 
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/a7831526-8b95-4b3c-a48b-4f8d3a0f2923n%40googlegroups.com.


[web2py] Re: How to sort a join by count

2020-11-14 Thread Alex Glaros
I have postgres. How would it look for that?

On Saturday, November 14, 2020 at 9:03:13 AM UTC-8 valq...@gmail.com wrote:

> Just in case : pydal doesnt support backend specific aggregate functions
>
>
> суббота, 14 ноября 2020 г. в 19:54:35 UTC+3, valq...@gmail.com: 
>
>> There is no db.executesql
>>
>> суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: 
>>
>>> sorry, did not mean direct SQL through db.executesql , meant through DAL
>>>
>>> On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 valq...@gmail.com 
>>> wrote:
>>>
>>>> Assuming sqlite:
>>>> person_cnt = 
>>>> db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt')
>>>>
>>>>
>>>> prioritySet = db((db.PERSON.id <http://db.person.id/> == 
>>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>>> PERSON-PROJECT-PRIORITY.project_fk)).select(
>>>> ...,
>>>> person_cnt, 
>>>> 'GROUP_CONCAT(person.person_name,",") AS person_list'
>>>> groupby = db.PERSON-PROJECT-PRIORITY.project_fk, 
>>>> )
>>>>
>>>> суббота, 14 ноября 2020 г. в 09:40:17 UTC+3, alexg...@gmail.com: 
>>>>
>>>>> How to write a statement that counts which projects are the priority 
>>>>> of most people
>>>>>
>>>>> PROJECT
>>>>> id
>>>>> project_name
>>>>>
>>>>> PERSON
>>>>> id
>>>>> person_name
>>>>>
>>>>> PERSON_PROJECT_PRIORITY
>>>>> person_fk
>>>>> project_fk
>>>>>
>>>>> prioritySet = db((db.PERSON.id == PERSON-PROJECT-PRIORITY.person_fk) 
>>>>> & (PROJECT.id == PERSON-PROJECT-PRIORITY.project_fk)).select()
>>>>>
>>>>> How to sort by count of projects which have priority in order of the 
>>>>> most persons' priority?
>>>>>
>>>>> Output looks like this:
>>>>>
>>>>> Paint-the-house (10)  [Means is the top priority for 10 people]
>>>>> Plant-a-garden (5)
>>>>> Clean-out-garage (2)
>>>>>
>>>>> If you have additional time, how to write so output looks like:
>>>>>
>>>>> Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, Chris, Ed, 
>>>>> Sally
>>>>> Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
>>>>> Clean-out-garage (2) Clyde, Jane
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Alex Glaros
>>>>>
>>>>

-- 
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/13fb5728-3a9a-45e1-aae8-3f467d4fa9b8n%40googlegroups.com.


[web2py] Re: How to sort a join by count

2020-11-14 Thread Alex Glaros
sorry, did not mean direct SQL through db.executesql , meant through DAL

On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 valq...@gmail.com wrote:

> Assuming sqlite:
> person_cnt = 
> db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt')
>
>
> prioritySet = db((db.PERSON.id <http://db.person.id/> == 
> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
> PERSON-PROJECT-PRIORITY.project_fk)).select(
> ...,
> person_cnt, 
> 'GROUP_CONCAT(person.person_name,",") AS person_list'
> groupby = db.PERSON-PROJECT-PRIORITY.project_fk, 
> )
>
> суббота, 14 ноября 2020 г. в 09:40:17 UTC+3, alexg...@gmail.com: 
>
>> How to write a statement that counts which projects are the priority of 
>> most people
>>
>> PROJECT
>> id
>> project_name
>>
>> PERSON
>> id
>> person_name
>>
>> PERSON_PROJECT_PRIORITY
>> person_fk
>> project_fk
>>
>> prioritySet = db((db.PERSON.id == PERSON-PROJECT-PRIORITY.person_fk) & 
>> (PROJECT.id == PERSON-PROJECT-PRIORITY.project_fk)).select()
>>
>> How to sort by count of projects which have priority in order of the most 
>> persons' priority?
>>
>> Output looks like this:
>>
>> Paint-the-house (10)  [Means is the top priority for 10 people]
>> Plant-a-garden (5)
>> Clean-out-garage (2)
>>
>> If you have additional time, how to write so output looks like:
>>
>> Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, Chris, Ed, 
>> Sally
>> Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
>> Clean-out-garage (2) Clyde, Jane
>>
>> Thanks,
>>
>> Alex Glaros
>>
>

-- 
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/7c8aea14-a3d7-40c9-a7a2-c342f872329bn%40googlegroups.com.


[web2py] How to sort a join by count

2020-11-13 Thread Alex Glaros
How to write a statement that counts which projects are the priority of 
most people

PROJECT
id
project_name

PERSON
id
person_name

PERSON_PROJECT_PRIORITY
person_fk
project_fk

prioritySet = db((db.PERSON.id == PERSON-PROJECT-PRIORITY.person_fk) & 
(PROJECT.id == PERSON-PROJECT-PRIORITY.project_fk)).select()

How to sort by count of projects which have priority in order of the most 
persons' priority?

Output looks like this:

Paint-the-house (10)  [Means is the top priority for 10 people]
Plant-a-garden (5)
Clean-out-garage (2)

If you have additional time, how to write so output looks like:

Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, Chris, Ed, Sally
Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
Clean-out-garage (2) Clyde, Jane

Thanks,

Alex Glaros

-- 
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/493ef6e9-1218-47ee-9498-7b4e185ead70n%40googlegroups.com.


[web2py] Re: SQLFLORMGRID

2020-10-08 Thread Alex Beskopilny
maybe you could do this

def art_manage():

if  len(request.args) >= 2 and ('new' == request.args[0]):
   # some code
   return ' create '


records= SQLFORM.grid(query=db.t_art,maxtextlength = 
40,deletable=False,create=True, fields=[db.t_art.f_name, db.t_art.f_team, 
db.t_art.f_tit])
return dict(records=records)

-- 
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/0f266063-c05b-4edd-9a2e-b76a8144bc89o%40googlegroups.com.


[web2py] Re: Streaming pdf in a browser

2020-09-28 Thread Alex Beskopilny
1 create new app and mkdir docfiles in it

# models/db1.py
db.define_table( 'zurina',
  Field('jenka_fnm', requires=IS_NOT_EMPTY(), 
label='orig_file_name'  ),
  Field("fld",label="Remark", length=3500,),
  Field('new_image_file', requires=IS_NOT_EMPTY(), 
label='w2p_file_name'  ),
  )
# controllers/default.py

# -*- coding: utf-8 -*-

def error(message="auth ?!!!error!!!"):
session.flash = message
redirect(URL('index'))


def zurina():
import os

jenka_fnm=''
l_id = 0

new_image_file_path=''
# mkdir docfiles in app dir !
upfolder= os.path.join(request.folder, 'docfiles')

form=SQLFORM.factory( Field('new_image_file', 'upload',uploadfolder= 
upfolder, requires=IS_NOT_EMPTY(),
label='orig_file_name'  ),
  Field("fld", 'text', label="Remark:", requires = 
IS_NOT_EMPTY(error_message='emplty field is bad!') ),
  )

form.element('textarea[name=fld]')['_rows']='2'


if form.process().accepted:
  jenka_fnm = request.vars.new_image_file.filename # origin file 
name
  new_image_file_path = os.path.join(upfolder, 
form.vars.new_image_file)
  piece = dict( jenka_fnm = jenka_fnm, new_image_file = 
new_image_file_path  , fld = form.vars.fld  )
  l_id=db.zurina.insert(**db.zurina._filter_fields( piece  ))
  request.flash='Ok!!!'
  session.flash= 'ok! ok!'
  #redirect(URL('zurina_grid'))
elif form.errors:
response.flash = 'Please correct the error(s).'


return locals()

def doc2user():
import os
prn_id = request.args(0,cast=int)
task = db.zurina(prn_id) or error()
qu=db.zurina.id == prn_id
res= db(qu).select().first()
file_path = res.new_image_file
ext = os.path.splitext( res.jenka_fnm  )
with open(file_path, 'rb') as f:
file_text= f.read()

from gluon.contenttype import contenttype
tru_ext=''
if len(ext) and len(ext[1]):
  tru_ext = ext[1].lower()

if len(tru_ext) :
response.headers['Content-Type'] = contenttype(tru_ext)
else:
response.headers['Content-Type'] = 
contenttype('application/octet-stream')

if len(tru_ext) and  tru_ext.endswith(('pdf','jpeg', 'jpg', 'png', 
'bmp')):
  response.headers['Content-disposition'] = 'inline; 
filename=\"%s"' % ( res.jenka_fnm)
else:
  response.headers['Content-disposition'] = 'attachment; 
filename=\"%s"' % ( res.jenka_fnm)

#return "{}".format( file_path  )
return file_text

def zurina_grid():

  query = db.zurina.id > 0

  grid=SQLFORM.grid( query, maxtextlength=200,user_signature=False, 
csv=False, buttons_placement = 'left',
   orderby =~ db.zurina.id,

   links=[ lambda row: A('Save',_href=URL('doc2user',args=row.id),  
_class="btn btn-default" , _title="save file to disk"  ), ],

   deletable = True, create=False, 
editable=False,showbuttontext=False)
  return locals()
---
# views/default/zurina.html
{{extend 'layout.html'}}

{{=A('Go to grid',_href=URL('zurina_grid'),_class="btn btn-primary 
btn-space", _title="View files list")}}

{{=form}}
# -- views/default/zurina_grid.html
{{extend 'layout.html'}}
{{=grid}}




четверг, 24 сентября 2020 г., 17:54:53 UTC+3 пользователь 
lcham...@gmail.com написал:
>
> Hi,
> i have a controller with this :
> response.headers['Content-Disposition'] = 'inline; filename=%s' % 
> request.vars.filename   
>
> to force streaming the pdf file , and i do not why it does not work ..
> any idea ?
>
> Thank you 
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/08b25ff4-796b-4495-9215-b99a86182eb9o%40googlegroups.com.


[web2py] Re: Streaming pdf in a browser

2020-09-28 Thread Alex Beskopilny

it's work with web2py
inline for pdf, jpeg, png ...
save file fot other file types

def doc2user():
  
# read from db.table orig file name and path to file in upfolder
import os
prn_id = request.args(0,cast=int)
task = db.zurina(prn_id) or error()
qu=db.zurina.id == prn_id
res= db(qu).select().first()
upfolder= os.path.join(request.folder, 'docfiles')
   
#  path to file content
file_path = os.path.join( upfolder, res.new_image_file)
 
# orig file name 
ext = os.path.splitext( res.jenka_fnm  )
with open(file_path, 'rb') as f:
file_text= f.read()

from gluon.contenttype import contenttype
tru_ext=''
if len(ext) and len(ext[1]):
  tru_ext = ext[1].lower()

if len(tru_ext) :
response.headers['Content-Type'] = contenttype(tru_ext)
else:
response.headers['Content-Type'] = 
contenttype('application/octet-stream')

if len(tru_ext) and  tru_ext.endswith(('pdf','jpeg', 'jpg', 'png', 
'bmp')):
  response.headers['Content-disposition'] = 'inline; 
filename=\"%s"' % ( res.jenka_fnm)
else:
  response.headers['Content-disposition'] = 'attachment; 
filename=\"%s"' % ( res.jenka_fnm)

   # some debug string, you can view it in browser
#return "{}".format( file_path  )
return file_text

Also, we need the quotes   'attachment; filename=\"%s"' % ( res.jenka_fnm)

^^^

четверг, 24 сентября 2020 г., 17:54:53 UTC+3 пользователь 
lcham...@gmail.com написал:
>
> Hi,
> i have a controller with this :
> response.headers['Content-Disposition'] = 'inline; filename=%s' % 
> request.vars.filename   
>
> to force streaming the pdf file , and i do not why it does not work ..
> any idea ?
>
> Thank you 
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7db8b3d8-b6e0-4759-ab52-6491b229e0b6o%40googlegroups.com.


[web2py] Re: Streaming pdf in a browser

2020-09-25 Thread Alex Beskopilny
only pdf to browser - inline

def doc2user():
import os
prn_id = request.args(0,cast=int)
task = db.zurina(prn_id) or error()
qu=db.zurina.id == prn_id
res= db(qu).select().first()
upfolder= os.path.join(request.folder, 'docfiles')
file_path = os.path.join( upfolder, res.new_image_file)
ext = os.path.splitext( res.jenka_fnm  )
with open(file_path, 'rb') as f:
file_text= f.read()

from gluon.contenttype import contenttype

if len(ext) and len(ext[1]):
response.headers['Content-Type'] = contenttype(ext[1])
else:
response.headers['Content-Type'] = 
contenttype('application/octet-stream')

if len(ext) and len(ext[1]) and ext[1].endswith('pdf'):

  response.headers['Content-disposition'] = 'inline; 
filename=\"%s"' % ( res.jenka_fnm)
else:
  response.headers['Content-disposition'] = 'attachment; 
filename=\"%s"' % ( res.jenka_fnm)



четверг, 24 сентября 2020 г., 17:54:53 UTC+3 пользователь 
lcham...@gmail.com написал:
>
> Hi,
> i have a controller with this :
> response.headers['Content-Disposition'] = 'inline; filename=%s' % 
> request.vars.filename   
>
> to force streaming the pdf file , and i do not why it does not work ..
> any idea ?
>
> Thank you 
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f388deff-6ab2-42ab-91a4-08ae69a7828co%40googlegroups.com.


[web2py] Re: Streaming pdf in a browser

2020-09-25 Thread Alex Beskopilny
Hi! 
solution
 
https://stackoverflow.com/questions/20508788/do-i-need-content-type-application-octet-stream-for-file-download

web2py func
 
def doc2user():
import os
prn_id = request.args(0,cast=int)
task = db.zurina(prn_id) or error()
qu=db.zurina.id == prn_id
res= db(qu).select().first()
upfolder= os.path.join(request.folder, 'docfiles')
file_path = os.path.join( upfolder, res.new_image_file)
ext = os.path.splitext( res.jenka_fnm  )
with open(file_path, 'rb') as f:
file_text= f.read()

from gluon.contenttype import contenttype

if len(ext) and len(ext[1]):
response.headers['Content-Type'] = contenttype(ext[1])
else:
response.headers['Content-Type'] = 
contenttype('application/octet-stream')
response.headers['Content-disposition'] = 'attachment; filename=\"%s"' 
% ( res.jenka_fnm)

return file_text


четверг, 24 сентября 2020 г., 17:54:53 UTC+3 пользователь 
lcham...@gmail.com написал:
>
> Hi,
> i have a controller with this :
> response.headers['Content-Disposition'] = 'inline; filename=%s' % 
> request.vars.filename   
>
> to force streaming the pdf file , and i do not why it does not work ..
> any idea ?
>
> Thank you 
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/06ba613b-9d45-4767-9a47-d76362406579o%40googlegroups.com.


[web2py] Re: How to sort a smartgrid with your own custom sorted id list

2020-07-03 Thread Alex Beskopilny
smartgrid sort with three one to many tables

def uvidomlen_all():
table=db.operacia

gqu = lambda tnm : (tnm.id>0) if auth.user.is_admin else 
(tnm.created_by == me)
oqu = lambda tnm : ~db[tnm].id

constraints = {'operacia':gqu(db.operacia), 'os1doc':gqu(db.os1doc), 
'os2doc':gqu(db.os2doc), 'os3doc':gqu(db.os3doc)}
orderby = {'operacia':oqu('operacia'), 'os1doc':oqu('os1doc'), 
'os2doc':oqu('os2doc'), 'os3doc':oqu('os3doc')}

return dict(grid=SQLFORM.smartgrid(db.operacia,
   deletable = False, #constraints = dict(povidomlen=query),
   editable = auth.user.is_admin,
   orderby= orderby,
   constraints= constraints,
   linked_tables= ['os1doc','os2doc','os3doc'] ,
   buttons_placement = 'left', 
user_signature=False,searchable=True, create=False, 
csv=False,showbuttontext=False,   ))


четверг, 18 июня 2020 г., 18:38:39 UTC+3 пользователь rāma написал:
>
> Hi all,
>
> How to sort a smartgrid with your own custom sorted id list?
>
> Say I have a id list after executing the query and I have a sorting 
> functions that returns a sorted id list, how would I make smartgrid to 
> commit to the ordering instead of sorting by ids by default?
>
> Thanks,
> rama
>

-- 
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/100b80be-4842-4bab-96c0-c00df0d75349o%40googlegroups.com.


[web2py] Re: How to sort a smartgrid with your own custom sorted id list

2020-07-03 Thread Alex Beskopilny
 Hi! 
some working solution

1 build a sqlite-table in memory, as required
2 insert data in the table
3 show table in smartgird

def pro_report1():

tbl = 'proverka'
l = [e for e in db[tbl].fields if e in f_short_proverka ]
memf = [ Field('oid', 'integer', label='П id', default= 0) ] + \
   [ Field(db[tbl][e].name, db[tbl][e].type, label = 
db[tbl][e].label,
 length= db[tbl][e].length, represent= db[tbl][e].represent  )
 for e in l ]

dbmem = DAL('sqlite:memory')
dbmem.define_table('mem_table',*memf)

records = db(db[tbl].id>0).select().as_list()
for r in records:
r['oid'] = r['id']
dbmem.mem_table.insert(**dbmem.mem_table._filter_fields(r))
flds= [ db[tbl][e] for e in f_short_proverka ]
rows=db(db[tbl].id>0 ).select( *flds  )

exportclasses=dict(
csv_with_hidden_cols=False,
csv=False,
xml=False,
json=False,
tsv_with_hidden_cols=False,
tsv= False,
)

dbmem.mem_table.id.readable = False
grid = SQLFORM.grid(dbmem.mem_table, create=False, editable=False, 
exportclasses= exportclasses,
deletable=False, buttons_placement = 'left', 
showbuttontext=False)
return dict(rows=rows, l=l, records=records, grid=grid)


четверг, 18 июня 2020 г., 18:38:39 UTC+3 пользователь rāma написал:
>
> Hi all,
>
> How to sort a smartgrid with your own custom sorted id list?
>
> Say I have a id list after executing the query and I have a sorting 
> functions that returns a sorted id list, how would I make smartgrid to 
> commit to the ordering instead of sorting by ids by default?
>
> Thanks,
> rama
>

-- 
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/63853b58-756c-4623-be23-1fd0872a08f3o%40googlegroups.com.


[web2py] Re: Standard way of removing X-Powered-By: web2py http header?

2020-04-12 Thread Alex Beskopilny
cd web2py/gluon
grep -r X-Powered-By
./globals.py:self.headers['X-Powered-By'] = 'xping'


воскресенье, 12 апреля 2020 г., 16:02:13 UTC+3 пользователь Yan Wong 
написал:
>
> I'm a bit disappointed that web2py by default sets `X-Powered-By: web2py` 
> in the http header, thus making it easier for web-scanning tools to detect 
> the software running behind a web site, and allow more targetted attacks. 
> Is there an easy config option to efficiently turn this off for all pages / 
> json responses etc served by web2py? Also, are there other ways to obscure 
> the fact that it is web2py / python running on a web server, and reduce 
> information disclosure? For example, can anyone detect what python version 
> I'm running by using web queries: I see that rocket server puts the python 
> version in the `Server:` header, which seems bad to me, although my 
> production machine simply returns `Server: nginx` which is a little better, 
> I suppose. I suspect it will never be possible to obscure the software 
> entirely, but anything that makes it harder for the script kiddies seems 
> like an easy win to me.
>

-- 
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/568d754e-316b-4cfb-abba-312bd83d549f%40googlegroups.com.


[web2py] Re: Web2py, react, typescript, visual studio code setup

2020-03-13 Thread Alex Beskopilny

Thanks Larry!  great example.

maybe in  *webpack.config.js*

*- app: './static/reactsrc/index.tsx'*
+ app: './static/src/index.tsx'

среда, 11 марта 2020 г., 18:59:40 UTC+3 пользователь Larry Weinberg написал:
>
> Several people have asked about how to set up web2py to work with React 
> (and Typescript) on the front end. Others have asked how to use an IDE like 
> Visual Studio Code with web2py. I have a setup that I've posted to github 
> that has the basics in place for doing this with a pre-configured Visual 
> Studio Code workspace and instructions on how to get it up and running.  
>  Web2py running inside VSCode is really easy to work with and debug!
>
> https://github.com/larrywberg/web2py-react-ts-vscode
>
> I am not an expert on Visual Studio Code, or React, or Typescript, or 
> web2py so I would be happy to get feedback to improve it.  I hope this is 
> useful for others.  It is using React with React Hooks for state 
> management.  There is a sample REST call set up.
>
> I hooked in a webpack dev server in addition to the web2py server so that 
> the react sample code can be iterated on quickly if you so choose.  You can 
> debug the python server and the Typescript client at the same time in 
> VSCode if you launch them both from the preconfigured launch tasks. You can 
> also use the Web2py admin interface to edit files in parallel with editing 
> them in VS Code when running locally.  There are other preconfigured 
> scripts set up and you can also trigger the compile of the react code from 
> a menu item in the sample code.
>
>
>
>
>
>

-- 
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/84d8d415-944f-46d9-aa8f-aa90d9c311ff%40googlegroups.com.


[web2py] Re: About menu and current page

2020-03-04 Thread Alex Beskopilny
items_sub_menu= []
menu_item = [ (chr( 0x0001f534 ), False, URL('default', 'index'), 
items_sub_menu) ]

save_orig_menu= response.menu
response.menu = menu_item
response.menu += save_orig_menu
items_sub_menu.append( (T('home'), False, URL(_app, 'default', 'index') ),)
items_sub_menu.append( (T('appadmin'), False, URL(_app, 'appadmin', 
'index') ),)


items_sub_menu.append( (T('ctrlnm1'), False, URL('ctrlnm1','index') ), )

items_sub_menu.append( (T('ctrlnm2'), False, URL('ctrlnm2','index') ), )


среда, 4 марта 2020 г., 14:13:26 UTC+3 пользователь Константин Комков 
написал:
>
> Hello, are somebody know how create link in menu empty if current page 
> like link in menu, but not empty if page is not like in link.
> I do like that:
>
> response.menu.insert(0, (T('Editor'), False, '#', [
> (T('Edit timetable'), False, '#' if (request.controller == 'default' and 
> request.function == 'selectTimetable') else URL('default', 
> 'selectTimetable')),
> ]))
>
> If there is more elegant way share it please.
>
>

-- 
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/b313a0e9-0f17-4850-a82b-7cb69246b492%40googlegroups.com.


[web2py] Re: Searching by date using SQLFORM.factory

2020-02-19 Thread Alex Beskopilny
import cPickle, os
def put_on_disk(file_name, data):

uploadfolder=os.path.join(request.folder, 'uploads')
fn = os.path.join(uploadfolder, file_name)
out_file = open(fn, 'w')
cPickle.dump(data, out_file)
out_file.close()


def get_from_disk(file_name):

uploadfolder=os.path.join(request.folder, 'uploads')
fn = os.path.join(uploadfolder, file_name)
in_file = open(fn, 'r')
data = cPickle.load(in_file)
in_file .close()
return data

save data on disk, add user.id to file name


четверг, 20 февраля 2020 г., 0:49:11 UTC+3 пользователь mostwanted написал:
>
> I'm trying to use SQLFORM.factory to search by date but its failing, it is 
> somehow possible to that & i'm missing something?? If so where can i 
> rectify my code to give me results?
>
> *MY FUNCTION*
> def search():
> form=SQLFORM.factory(Field('SEARCH', 'date')
> if form.accepts(request):
> tokens=form.vars.SEARCH.split()
> query=reduce(lambda a,b:a&b, [db.birthdays.contains(k) for k in 
> tokens])
> people=db(query).select(orderby=db.birthdays.Person)
> else:
> people=[]
> return locals()
>
> Regards;
>
> Mostwanted
>

-- 
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/24aed2dc-75c6-49e3-b6b5-b8b1cf5603bf%40googlegroups.com.


[web2py] py4web Form customization

2020-02-12 Thread Alex Beskopilny
is that possible? 

similar to the web2py

{{=form.custom.begin}}Name: 
{{=form.custom.widget.name}}{{=form.custom.submit}}{{=form.custom.end}}

 form.element('input[name=name]')['_id']='myid'
 form.element('input[name=name]')['_class']='myclass'


Thanks
Alex

-- 
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/12c5163a-651d-4761-900a-70e9edc80fb7%40googlegroups.com.


[web2py] Re: py4web nw version and new example

2020-02-10 Thread Alex Beskopilny

[X] loaded _dashboard
[FAILED] loading myfeed
..
FileNotFoundError: [Errno 2] No such file or directory: 
'apps/myfeed/databases/sql.log'

-
mkdir apps/myfeed/databases

and restart

понедельник, 10 февраля 2020 г., 9:13:46 UTC+3 пользователь Massimo Di 
Pierro написал:
>
> A new py4web version is out 0.1.20200209.2:
>
> - better reload mechanism should avoid come pitfalls and inconsistent state
> - includes a new example app, a minimalist facebook clone called myfeed 
> (feel free to suggest improvements)
> - includes a new page "/_dashboard/gitlog/{app_name}" which, for apps that 
> are git projects, allow to check commit history, checkout a commit, and 
> show commits. It is designed more as an educational tool and not as a 
> replacement of normal git commands. Needs documentation.
>
>
>

-- 
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/736eac61-c620-4232-9d3a-b723c4724926%40googlegroups.com.


[web2py] Re: SQLFORMGRID - CSS - LAYOUT

2019-12-07 Thread Alex Beskopilny
Hi! 
Here is the script and working examples for sqlform and customform
https://github.com/ali96343/facew2p
http://alibsk.pythonanywhere.com


среда, 4 декабря 2019 г., 18:47:26 UTC+3 пользователь L c написал:
>
> Hi,
> Soory but i do not find answer:
>
> I did that  :
>
>1. Create a subfolder of static (example "css_template")
>2. Move template files to static/css_template
>3. Move static/css_template/index.html to views/layout.html
>4. Edit views/layout.html to fix *href* and *src* to static files 
>using {{=URL('static','css_template/style.css')}}
>5. add these to views/layout.html where you want them to appear
>
> I have created a static html page with css like  ( href="../static/css_template/assets/css/main.css" />)
> inside this page html i have {{=list}}  (From controler : list= 
> SQLFORM.grid(query=query,maxtextlength=20,orderby=~db.t_news.id
> ,deletable=False,editable=False,create=False,advanced_search=False,csv=False)
>
> When i want to edit a record , the css ... are not taken ! where can i 
> change this ?
>
> thank you
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a007f400-bcfc-4177-89bf-cded5cf60056%40googlegroups.com.


[web2py] Re: language file overwritten

2019-10-24 Thread Alex
anyone? this is a huge issue causing us serious trouble on our production 
site.

So far it seems that this only happens on startup when the threads are 
initialized. There must be some kind of race condition during 
initialization. It seems to be related to multiple simultaneous requests 
which are triggered on our pages containing many images. The browser will 
start many requests at the same time to fetch all the images so this is 
probably related.

I also experienced this issue a few times locally using the integrated 
web2py webserver. So this has nothing to do with Apache or mod_wsgi.


On Monday, October 14, 2019 at 3:28:31 PM UTC+2, Alex wrote:
>
> We have upgraded to the latest web2py version 2.18.5 (from a very old 
> 2.12.3) and also changed from Python 2 to 3.
>
> Most things are working fine but we have one major issue: from time to 
> time a language file gets overwritten. We did not experience this problem 
> before.
>
> In a model file we explicitly set T.is_writable to False. After 
> determining the used language we set the flag:
>
> T.force(session_language)
> T.is_writable = False
>
>
> When the language file is overwritten usually only one or two labels are 
> added to the file. But sometimes it happens that the language file only 
> contains the new label and then all translations are lost.
>
> How is it possible that web2py overwrites the language file when we set 
> the is_writable flag? are there any possible race conditions as this 
> problem only occurs very rarely?
>
> For now we changed the file owner of the language files to root so web2py 
> cannot corrupt our translation files but of course this is only a temporary 
> workaround. Any ideas?
>
> Alex
>

-- 
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/fb3bb70c-4ef0-4d59-a1a6-e5141c892e81%40googlegroups.com.


[web2py] Re: How to easily implement another CSS-Framework

2019-10-14 Thread Alex Beskopilny
1:
views/default/myindex.html


Mysite


  myown unique  page with my_css
{{=message}}



2:
def index():
response.view = 'default/myindex.html'
return dict(message=T('Welcome to web2py!'))


пятница, 11 октября 2019 г., 8:38:52 UTC+3 пользователь Jay B написал:
>
> Hello guys,
>
> I'm trying to figure out how to include another CSS framework instead of 
> bootstrap. But the fact that the layout.html and other files point to the 
> bootstrap files makes it harder than I thought. 
>
> I would like to test other CSS frameworks like Semantic UI or Bulma 
> instead of Bootstrap and wonder how to do it best. Or am I forced to delete 
> all CSS files and standard views?
>
> I would be happy if you could help me and thank you in advance for all the 
> tips.
>
> Greetz
> Jay
>

-- 
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/f16e2867-0c61-48d4-b2ee-5dff0b731914%40googlegroups.com.


[web2py] Re: Vue2pyj - alternative web IDE

2019-09-30 Thread Alex Beskopilny


суббота, 11 мая 2019 г., 5:12:26 UTC+3 пользователь Val K написал:
>
> As result of experimenting with Rapydscript I want to present my 
> alternative web IDE for web2py, 
> (that could be easily ported to web3py as well)
> https://github.com/valq7711/vue2pyj
>
> Any feedback is appreciated
>
> 2) 
> def safe_read(fp):
> with open(fp, 'rb') as f:
>   ^^^
> ret = f.read()
> return to_str(ret)
>^^
>

-- 
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/546e44ad-cf84-4a7b-bf70-d56abac9d2e8%40googlegroups.com.


[web2py] Re: Vue2pyj - alternative web IDE

2019-09-30 Thread Alex Beskopilny


суббота, 11 мая 2019 г., 5:12:26 UTC+3 пользователь Val K написал:
>
> As result of experimenting with Rapydscript I want to present my 
> alternative web IDE for web2py, 
> (that could be easily ported to web3py as well)
> https://github.com/valq7711/vue2pyj
>
> Any feedback is appreciated
>

  Hi! 

very interesting program, thanks !

to run it on localhost with python 3.7.3 (web2py Version 
2.18.5-stable+timestamp.2019.04.08.04.22.03)
I added to the file  vue2pyj/modules/fs2json.py

two func:

def to_bytes(data, enc="utf8"):
if data is None:
return b""
if isinstance(data, str):
return bytes(data, enc)  # data.encode('utf8')
if isinstance(data, dict):
return dict(map(to_bytes, data.items()))
if isinstance(data, tuple):
return map(to_bytes, data)
if isinstance(data, list):
return list(map(to_bytes, data))
return data


def to_str(data, enc="utf8", err="strict"):  # bytes to str
if data is None:
return str("")
if isinstance(data, bytes):
return data.decode(enc, err)
if isinstance(data, dict):
return dict(map(to_str, data.items()))
if isinstance(data, tuple):
return map(to_str, data)
if isinstance(data, list):
return list(map(to_str, data))
return data

and was changed lines
1)
ctime = stat.st_ctime * 1000,
mtime = stat.st_mtime * 1000,
#ctime = long(stat.st_ctime * 1000),
#mtime = long(stat.st_mtime * 1000),
2)
ret = f.read()
return to_str(ret)
3)
content =  to_bytes( fdata.get('content', '') )
#content =  unicode.encode(fdata.get('content', ''), 'utf8')


vue2pyj works, unfortunately web2py reports

ERROR:Rocket.Errors.Thread-5:Traceback (most recent call last):

  File "/home/w3p/web2py/gluon/rocket.py", line 1288, in run
self.run_app(conn)

  File "/home/w3p/web2py/gluon/rocket.py", line 1781, in run_app
self.environ = environ = self.build_environ(sock_file, conn)

  File "/home/w3p/web2py/gluon/rocket.py", line 1601, in build_environ
request = self.read_request_line(sock_file)

  File "/home/w3p/web2py/gluon/rocket.py", line 1339, in read_request_line
d = sock_file.readline()

  File "/home/w3p/anaconda3/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)

ConnectionResetError: [Errno 104] Connection reset by peer

ERROR:Rocket.Errors.Thread-5:Tried to send "500 Server Error" to client but 
received socket error



Alex

-- 
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/d96bad10-4e57-4049-a6da-ac828a010649%40googlegroups.com.


[web2py] big data "out of memory" error

2019-08-12 Thread Alex Glaros
Not sure if I'm qualified to give tips here, but I had a one-time job that 
timed out with out-of-memory error. To fix that, I cloned a copy of my site 
(admin-console, manage, pack all), keeping the same database, then in db.py 
replaced every instance of 'reference my_big_tables' with 'integer' in the 
clone. It ran quickly and I then discarded the clone. If this helps anyone, 
then good.

Questions: 

Is it generally accepted that with big data tables, it's best to achieve 
referential integrity in the controller at the record-creation stage, and 
not add any rules into the database? 

My clone kept the requires statements: requires = IS_IN_DB(db, 
'my_big_tables.id'  ... and still ran fast so can the "reference 
my_big_tables" statement be safely, and completely eliminated from db.py? 
The "reference" statement really slows things down.

thanks,

Alex Glaros

-- 
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/8833de76-2fc7-4c3e-a6f6-b57e79d3bd05%40googlegroups.com.


[web2py] Re: py4web: how to import Template and change delimiters

2019-08-06 Thread Alex Beskopilny
it's port lte-2.4.15 to py4web

https://github.com/ali96343/lteadmin-py4web

четверг, 1 августа 2019 г., 10:48:02 UTC+3 пользователь Alex Beskopilny 
написал:
>
> Hi! 
> I put lte-2.4.15  to py4web  and lte works  with controllers.py :
>
> from py4web import action, request, abort, redirect, URL
> from yatl.helpers import A
> from . common import db, session, T, cache, auth
>
> @action('index')
> @action.uses('index.html', )
> #@action.uses(Template('index.html', delimiters='[[ ]]'))
> def index():
> message= "index.html"
> user= "first second third"
> return dict(message=message, user=user)
> ..
> but does not works with :
> from py4web import action, request, abort, redirect, URL , Template
>   
>  
> 
> error message:
> WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.20ms
> WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.55ms
> WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 1.45ms
>
> how to fix it ?
>
> Is it possible to use some characters for delimiters, 
> for example  delimiters='XXX ' ?
> what is limits for delimiters ?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/340caf35-ba63-4255-a925-3be063ee7982%40googlegroups.com.


[web2py] Re: py4web: how to import Template and change delimiters

2019-08-01 Thread Alex Beskopilny

Thanks Massimo! 

it works: deliniters="X0X0X0 Y1Y1Y1"
and delimiters="[Z[ ]]"

py4web was tested with   urls  lte-2.14.15 
and ThreadPoolExecutor(max_workers=10)

results:
execution time: 98.3 sec, data_size=  3794965000, urls= 56000
 bytes/sec= 38596744.13, req/sec= 569.54




четверг, 1 августа 2019 г., 10:48:02 UTC+3 пользователь Alex Beskopilny 
написал:
>
> Hi! 
> I put lte-2.4.15  to py4web  and lte works  with controllers.py :
>
> from py4web import action, request, abort, redirect, URL
> from yatl.helpers import A
> from . common import db, session, T, cache, auth
>
> @action('index')
> @action.uses('index.html', )
> #@action.uses(Template('index.html', delimiters='[[ ]]'))
> def index():
> message= "index.html"
> user= "first second third"
> return dict(message=message, user=user)
> ..
> but does not works with :
> from py4web import action, request, abort, redirect, URL , Template
>   
>  
> 
> error message:
> WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.20ms
> WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.55ms
> WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 1.45ms
>
> how to fix it ?
>
> Is it possible to use some characters for delimiters, 
> for example  delimiters='XXX ' ?
> what is limits for delimiters ?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/caaf1e92-773b-496c-9bf9-d87884d53ece%40googlegroups.com.


[web2py] py4web: how to import Template and change delimiters

2019-08-01 Thread Alex Beskopilny
Hi! 
I put lte-2.4.15  to py4web  and lte works  with controllers.py :

from py4web import action, request, abort, redirect, URL
from yatl.helpers import A
from . common import db, session, T, cache, auth

@action('index')
@action.uses('index.html', )
#@action.uses(Template('index.html', delimiters='[[ ]]'))
def index():
message= "index.html"
user= "first second third"
return dict(message=message, user=user)
..
but does not works with :
from py4web import action, request, abort, redirect, URL , Template

   

error message:
WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.20ms
WARNING:tornado.access:404 GET /lte2 (127.0.0.1) 1.55ms
WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 1.45ms

how to fix it ?

Is it possible to use some characters for delimiters, 
for example  delimiters='XXX ' ?
what is limits for delimiters ?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1a809bdf-2659-42ef-a3ab-11350da79bbb%40googlegroups.com.


[web2py] Re: web2py multiple domains on nginx + gunicorn

2019-07-01 Thread Alex Beskopilny
 

start second guicorn 
You have to run your projects on different ports like firsrone on 8000 and 
secondone on 8001. Then in nginx conf, in place of location /, you have to 
write location /firstone/ and proxy pass this to port 8000 and then write 
same location object for second one as location /secondone/ and proxy pass 
it to port 8001.


some example 
http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/


понедельник, 1 июля 2019 г., 16:23:30 UTC+3 пользователь Áureo Dias Neto 
написал:
>
> Good morning group,
>
> I'm using web2py on nginx + gunicorn, I currently have two applications 
> with two different domains, one for each web2py application ..
>
> Each domain points to my ip in AWS and nginx, each domain has a file in 
> nginx with its settings and server_name corresponding to its domain with 
> location pointing to / web2py / applications
>
> My routes.py file follows the pattern:
>
> routers = dict (
> BASE = dict (
> domains = {
> 'exampleapp.com': 'exampleapp',
> 'anotherexample.com': 'anotherexample',
> }
> ),
> )
>
> however, whenever you access exampleapp.com or any other domain listed 
> there, I'm redirected to exampleapp.com/welcome
>
> I can only run an app with the following configuration in the routes.py 
> file
>
> routers = dict (
> BASE = dict (
> default_application = 'exampleapp',
> domains = {
> 'exampleapp.com': 'exampleapp',
> 'anotherexample.com': 'anotherexample',
> }
> ),
> )
>
> so both exampleapp.com and anotherexample.com redirect to exampleapp.
>
> How to proceed?
> Hugs
>

-- 
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/31ee98f9-04c9-48a5-966e-52ce19439fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py multiple domains on nginx + gunicorn

2019-07-01 Thread Alex Beskopilny


понедельник, 1 июля 2019 г., 16:23:30 UTC+3 пользователь Áureo Dias Neto 
написал:
>
>
> .
>
for me works 
1 up second gunicorn
2  dom2.conf 
upstream gunidom2 { server unix:/home/w2p/var/guni-dom2.sock 
fail_timeout=0; }

server {

listen xx.yy.zz.ww:443 ssl http2;
 server_name dom2.ru;
 add_header Strict-Transport-Security "max-age=31536000; 
includeSubDomains";

  add_header Allow "GET, POST, HEAD, DELETE" always;
  if ( $request_method !~ ^(GET|POST|HEAD|DELETE)$ ) {
  return 444;
 }

ssl_certificate /etc/letsencrypt/live/dom2.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dom2.ru/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/dom2.ru/chain.pem;

resolver 127.0.0.1 valid=86400 ipv6=off;

ssl on;

..
}
..
location / {

try_files $uri @proxy_to_gunidom2;
}

location @proxy_to_gunidom2 {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Host  dom2.ru;
proxy_redirect off;

add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block;";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" 
always;

proxy_set_headerX-Forwarded-By
$server_addr:$server_port;
proxy_set_headerX-Forwarded-Proto $scheme;
proxy_set_headerX-Real-IP $remote_addr;


proxy_pass http://gunidom2;
 rewrite ^/$ /dom2 last;
}


-- 
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/0e914b35-a6a1-49cb-adf4-1cd4b1ed41d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: is it possible to make social site like facebook/linkedin by web2py ?

2019-06-27 Thread Alex Beskopilny
Hi! imran tube

_only_ web2py ! 
download css-html-template and run app builder 
some demo 
https://alibsk.pythonanywhere.com/

четверг, 27 июня 2019 г., 6:08:54 UTC+3 пользователь imran tube написал:
>
> which  framework best for me django or web2py?
> web2py all demo site not work or old or unfinished...
>
> why you dont update or make tutorial like django?
>

-- 
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/6b6639e9-c0fc-41ea-9306-c67e8f13b9dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Upload files

2019-06-22 Thread Alex Beskopilny
if any ( ['.jpg' in file_name, '.JPG' in file_name ,  ]  ):
?

суббота, 22 июня 2019 г., 11:18:42 UTC+3 пользователь Константин Комков 
написал:
>
> I made upload form for files that winter and today when project is working 
> 3 days user told me that he can't load file. When I saw that file it name 
> was "name.JPG"  but in my code befor i find only .jpg. Now all is ok.
> for i in img:
> s = i.file[len(i.file)-5:len(i.file)]
> if ((s.find('.jpg')>-1) | (s.find('.JPG')>-1) | 
> (s.find('.jpeg')>-1) | (s.find('.JPEG')>-1) | (s.find('.png')>-1) | 
> (s.find('.PNG')>-1) | (s.find('.bmp')>-1) | (s.find('.BMP')>-1)):
> studDocs = studDocs + """ class="col col-pd"> src='"""+URL('bak','download',args=i.file)+"""'/> class='del-img'>"""
> elif ((s.find('.pdf')>-1) | (s.find('.PDF')>-1)):
> studDocs = studDocs + """ class="col col-pd">.pdf"""
> elif ((s.find('.tif')>-1) | (s.find('.TIF')>-1)):
> studDocs = studDocs + """ class="col col-pd">.tiff"""
>
> [image: uploadForm.png]
>

-- 
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/bf36b82f-f998-4508-a20b-1b60bcdca909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] backup page when site is broken

2019-05-19 Thread Alex Glaros
how would I redirect to a plain static web page that displays "This Web2py 
app is temporarily down while we install updates"? Could I redirect to 
another site? Is there code to sense when site is broken then automatically 
redirects users?

I use pythonanywhere.com, redirect through a SSL service and my routes.py 
looks like:

#!/usr/bin/python
# -*- codingf-8 -*-
routers = dict(
# base router
BASE=dict(
default_application='myDomain',
domains={'www.myDomain':'myDomain'}
),
)


thanks,

Alex Glaros

-- 
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/f4612741-b3ea-4ad5-a14e-7e7a7a569d3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: css templates layouts for web2py

2019-05-11 Thread Alex Beskopilny
 

This is not a template generator. 
This is a template installer to web2py env.
Examples for some free admin dashboards in applications dir

четверг, 9 мая 2019 г., 21:25:00 UTC+3 пользователь Alex Beskopilny написал:

   Hi !
>
>https://github.com/ali96343/facew2p.git
>
>Here is a script that generates web2py application from css templates.
> The script generates layouts, form (from html tag ), tables (from 
> html tag ).
> The script has been tested on 50 templates.
>   
>Thanks and best regards,
> Alex Beskopilny
>
>
>

-- 
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/650f556f-6eb7-488d-a73f-ec5913801fc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] css templates layouts for web2py

2019-05-09 Thread Alex Beskopilny
   Hi !

   https://github.com/ali96343/facew2p.git

   Here is a script that generates web2py application from css templates.
The script generates layouts, form (from html tag ), tables (from 
html tag ).
The script has been tested on 50 templates.
  
   Thanks and best regards,
Alex Beskopilny


-- 
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/6ec453d3-ae52-4ff3-aa5e-751f23854f25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: howto prevent XSS in json data

2019-04-18 Thread Alex
This also happens with the latest web2py version 2.18.5

I've opened an issue here:
https://github.com/web2py/web2py/issues/2182

On Wednesday, April 17, 2019 at 2:54:00 PM UTC+2, Leonel Câmara wrote:
>
> Please open an issue, you're right, this is a bug and a security problem, 
> it's also very easy to fix by simply copy pasting escapejs from django.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: howto prevent XSS in json data

2019-04-16 Thread Alex
Thanks for your suggestions. Although nothing gets me the desired result. 
If I use urllib.quote or XML in the controller way too much gets escaped 
(all < and > signs, blanks, etc.) which is not what I want. And I'd have to 
do this for all attributes in every controller function.

My problem is exactly the same as in this stackoverflow question for django:
https://stackoverflow.com/questions/14290517/safely-using-json-with-html-inside-of-the-json-in-django-templates
in Django there seems to be an escapejs filter

Then I found out that there is an ASSIGNJS helper in web2py which is 
actually exactly what I need. Therefor I could replace


var filterSettings = {{=XML(filter_settings)}};


with


{{=ASSIGNJS(filterSettings=filter_settings)}};


and expect everything to work fine and safe. Only to find out that this is 
vulnerable to the same exploit (at least in web2py 2.12.3). In case this 
still happens with the newest web2py version this is a major security flaw 
- if I'm not mistaken. I'll test this soon and then get back here.

why we're still using such an old version? I waited very long until web2py 
was Python 3 ready because upgrading web2py in our production system 
involves a lot of work (update deployment process and all instances, lots 
of testing, etc.). Since we need to upgrade to Python 3 anyway we only want 
to upgrade once for now.

On Tuesday, April 16, 2019 at 1:41:39 PM UTC+2, Leonel Câmara wrote:
>
> Another thing you can do is simply quote the name
>
>
> import urllib
> filter_settings = dict(name=urllib.quote(request.vars.name))
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: howto prevent XSS in json data

2019-04-15 Thread Alex
thanks for your answer. Problem is when I use sanitize then the output is
var filterSettings = {"section": 
"