Re: [web2py] Re: LOAD in py4web

2020-02-27 Thread AGRogers
https://unpoly.com/

On Fri, 28 Feb 2020 at 16:22, Massimo Di Pierro 
wrote:

> never heard of unpolly.js and cannot find it. Have a link?
>
>
> On Wednesday, 26 February 2020 19:32:20 UTC-8, Carlos Costa wrote:
>>
>> LOAD is a very cool thing! And beginners just say WOW when they can
>> create ajax-like experience so easy.
>> But, IMO, it lacks some important features for modern apps, like error
>> handling and history handling.
>>
>> I have written some simple functions to help cover these things...
>>
>> Another way I found very useful was to use unpolly.js. It's magic but
>> makes me a little lazyer about getting things done with vue.js.
>> (BTW they created unpolly to avoid using things like vue, react, etc,
>> really!)
>>
>> I would like very much to use vue.js but I am still noob regarding how to
>> use it with py4web.
>> Maybe we should really encourage vue.js and stuff alike... but an initial
>> pattern would be cool.
>> And IMO it should be simple and very cleared stated in the docs.
>> So no one will miss LOAD.
>>
>> Em domingo, 23 de fevereiro de 2020 15:18:51 UTC-3, RHC escreveu:
>>>
>>> HI,
>>>
>>> I am beginning to experiment with py4web, I like the sound of it and I
>>> am looking to convert a web2py project to py4web to see how they compare.
>>>
>>> It appears that the LOAD (helper?) that was available in web2py
>>> templates is not available in py4web. I was using this to populate part of
>>> a web page, I liked the way you had the option to use LOAD to call a
>>> separate URL (within the same app) and insert the result into your page
>>> before returning the page to the client.
>>>
>>> What is the reason for the absence of LOAD in py4web? is there a
>>> recommended alternative method of achieving the same effect? I have used a
>>> mixture of ajax=True and ajax=False options for this feature.
>>>
>>> Thanks,
>>>
>>> Richard.
>>>
>> --
> 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/22d8b9cf-9ce2-464b-809e-32d4dd84fd02%40googlegroups.com
> 
> .
>

-- 
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/CACWMBMPXoWfp9iZ7yQtbCw_YU6yh-9M2_xAQ%3Dzj4ocyWTzxuXw%40mail.gmail.com.


[web2py] Re: prettydate in py4web

2020-02-27 Thread Massimo Di Pierro
Ho, there is no pretty date. But there is no need because this is better:

https://pypi.org/project/humanize/



On Thursday, 27 February 2020 13:26:23 UTC-8, Maurice Waka wrote:
>
> what changed in py4web with this:
>
> [[=prettydate(reply.modified_on)]]
>
>
>
> which is in web2py?
>
>
> Regards
>

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


[web2py] Re: LOAD in py4web

2020-02-27 Thread Massimo Di Pierro
never heard of unpolly.js and cannot find it. Have a link?


On Wednesday, 26 February 2020 19:32:20 UTC-8, Carlos Costa wrote:
>
> LOAD is a very cool thing! And beginners just say WOW when they can create 
> ajax-like experience so easy.
> But, IMO, it lacks some important features for modern apps, like error 
> handling and history handling.
>
> I have written some simple functions to help cover these things...
>
> Another way I found very useful was to use unpolly.js. It's magic but 
> makes me a little lazyer about getting things done with vue.js.
> (BTW they created unpolly to avoid using things like vue, react, etc, 
> really!)
>
> I would like very much to use vue.js but I am still noob regarding how to 
> use it with py4web.
> Maybe we should really encourage vue.js and stuff alike... but an initial 
> pattern would be cool.
> And IMO it should be simple and very cleared stated in the docs.
> So no one will miss LOAD.
>
> Em domingo, 23 de fevereiro de 2020 15:18:51 UTC-3, RHC escreveu:
>>
>> HI,
>>
>> I am beginning to experiment with py4web, I like the sound of it and I am 
>> looking to convert a web2py project to py4web to see how they compare.
>>
>> It appears that the LOAD (helper?) that was available in web2py templates 
>> is not available in py4web. I was using this to populate part of a web 
>> page, I liked the way you had the option to use LOAD to call a separate URL 
>> (within the same app) and insert the result into your page before returning 
>> the page to the client.
>>
>> What is the reason for the absence of LOAD in py4web? is there a 
>> recommended alternative method of achieving the same effect? I have used a 
>> mixture of ajax=True and ajax=False options for this feature.
>>
>> Thanks,
>>
>> Richard.
>>
>

-- 
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/22d8b9cf-9ce2-464b-809e-32d4dd84fd02%40googlegroups.com.


[web2py] Re: off topic - Alpine JS as an alternative to vuejs/react

2020-02-27 Thread Massimo Di Pierro
wow. Alpine is pretty good. I will give it a try.


On Monday, 24 February 2020 08:33:28 UTC-8, Ramos wrote:
>
> vuejs is awesome but for simple stuff maybe alpine js is simpler.
> Just asking your thoughts if any...
> https://github.com/alpinejs/alpine  
>

-- 
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/3d1f9908-3313-4c80-a8d7-142b4dfbef93%40googlegroups.com.


[web2py] Re: PY4WEB request.vars error

2020-02-27 Thread Massimo Di Pierro
Or request.json() to for content-type: application/json. That's what I use 
the most in POST

On Monday, 24 February 2020 07:52:46 UTC-8, Ruslan Gareev wrote:
>
> Hi!
>
> Now in py4web it will be (if POST vars): 
> request.forms.message or request.POST.message
>
> or if GET vars:
> request.query.message or request.GET.message
>
>
> понедельник, 24 февраля 2020 г., 20:11:02 UTC+5 пользователь Maurice Waka 
> написал:
>>
>> Hi 
>> I can't make a head or tail out of this.
>> What changed from e.g. 'request.vars.messag'?
>> DO you have any example I can use?
>> Regards
>>
>> On Monday, February 24, 2020 at 2:17:22 AM UTC+3, Val K wrote:
>>>
>>> p4web `request` is bottle request, see 
>>> https://bottlepy.org/docs/dev/api.html#bottle.Request 
>>>
>>> On Monday, February 24, 2020 at 12:30:29 AM UTC+3, Maurice Waka wrote:

 New issue with py4web.

 Whats the new code for request.vars??

 I get this error:


 Traceback (most recent call last):
  File "/home/maurice/.local/lib/python3.6/site-packages/bottle.py", 
 line 1397, in __getattr__
  var = self.environ['bottle.request.ext.%s'%name]
 KeyError: 'bottle.request.ext.vars'

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
  File "/home/maurice/py4web/py4web/core.py", line 551, in wrapper
  ret = func(*func_args, **func_kwargs)
  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
  ret = func(*args, **kwargs)
  File "apps/_scaffolds/controllers.py", line 86, in index
  if request.vars:
  File "/home/maurice/.local/lib/python3.6/site-packages/bottle.py", 
 line 1400, in __getattr__
  raise AttributeError('Attribute %r not defined.' % name)
 AttributeError: Attribute 'vars' not defined.




-- 
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/12815251-490e-4300-8cf1-3a2486a5921b%40googlegroups.com.


[web2py] Re: Py4web: ¿Practical example step by step?

2020-02-27 Thread Massimo Di Pierro
Kind of. In py4web there is a new app called myfeed. I have git commits 
that show how to build it step by step. About to make a video from it.


On Monday, 24 February 2020 04:39:39 UTC-8, Yuver Parra wrote:
>
> Good morning Massimo.
> Does the promised step-by-step manual already exist?
>
> El miércoles, 22 de enero de 2020, 1:25:05 (UTC-5), Massimo Di Pierro 
> escribió:
>>
>> I am preparing one. It will be done in 2 weeks. Promise.
>>
>> On Tuesday, 21 January 2020 01:15:27 UTC-8, Dave S wrote:
>>>
>>>
>>>
>>> On Monday, January 20, 2020 at 4:55:33 AM UTC-8, Yuver Parra wrote:


 Good morning and thanks in advance for sharing your knowledge in this 
 group.
 Do any of you have a practical example where you can follow step by 
 step learning from the installation of py4web to the setting up of a site?

 Thanks for the reply.

>>>
>>> When posting a new euqestion, please don't check "show at the top" --- 
>>> save that for messages that need to be displayed long-term,
>>> like etiquette or policy.
>>>
>>> Have you looked at README.md at
>>> https://github.com/web2py/py4web> ?
>>>
>>> This should make a small stand-alone server and one or more sample 
>>> applications.
>>>
>>> If you have looked at that introduction, what questions do you still 
>>> have?
>>>
>>> Also, look at the py4web documentation at
>>> 
>>>
>>> I haven't heard of any training videos yet (the older framework, web2py, 
>>> has several, but those wouldn't be useful for py4web).
>>>
>>> If you need to learn more about setting up a front-end server, such as 
>>> NginX, you should consult the NginX website.  
>>> (the web2py position on Apache is that if you don't have it already, you 
>>> should consider NginX or other easier-to-use front ends.)
>>>
>>> Good luck!
>>>
>>> /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/8700dc68-10d6-477f-93fe-46817016fc56%40googlegroups.com.


[web2py] Possible to Run Two Identical Web2py Instances on Two Computers for Active/Active Failover Purposes?

2020-02-27 Thread Tristan Britt
Context:
I have a working web2py website that does some internal data visualization 
for my job, where employees can upload files and visualize different 
metrics. My boss would like me to take a functional windows server cluster 
with two active nodes, and have the web2py webapp running on both nodes. 
Once the data gets uploaded, it doesn't get changed, just visualized. The 
windows cluster nodes have a shared volume with the web2py code and the 
databases it creates shared between them.

Goal:
In the event one node goes down there is already another instance of the 
web2py data visualization webapp running on the other node, and the only 
failover that has to happen is that the cluster url redirects users to the 
2nd nodes web2py instance. 

Is this, or something similar, possible? I've tried running the webapps on 
the same port only to get errors, and can run the webapp on different 
ports, but wonder if there might be any issues with two instances accessing 
the same database?

-- 
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/4ec7a9c6-6f98-441b-9369-28afcfc242be%40googlegroups.com.


[web2py] How to make links to another page

2020-02-27 Thread Stephen Hengeli
I know this is going to sound like a dumb question, but I am new to web2py 
and need to use it for my Capstone class.
I understand the modules and the controllers and views, but I am having 
trouble creating a link to a new html page and there doesn't seem to be a 
lot of 
information available online so I am asking here. 

What is happening is I can successfully call another controller, but all it 
does is show the dictionary values and page name. Since the test values 
being shown are correct, I know my module code is working and my controller 
index function is working properly. I simply cannot get it to show any of 
the HTML i have written. 

Is there something I am missing or is there a resource I am missing 
somewhere? 

Any help would be appreciated. 

-- 
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/64d49e3a-c8f9-4d5a-b5e3-ac40769928a9%40googlegroups.com.


[web2py] prettydate in py4web

2020-02-27 Thread Maurice Waka
what changed in py4web with this:

[[=prettydate(reply.modified_on)]]



which is in web2py?


Regards

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


[web2py] Re: py4web defining tables

2020-02-27 Thread Maurice Waka
Thanks a lot.
It worked.
Regards

On Thursday, February 27, 2020 at 8:46:00 PM UTC+3, Jim S wrote:
>
> Try commenting out 
>
> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
> __file__), "databases"))
>
> in models.py
>
> Do you already have that in common.py?
>
> In your controller you're importing db from common, but the instance in 
> common doesn't have any tables defined.  You redefined db in models.py and 
> added the table to that instance of it.
>
> I think the solution is to move the statement above from models.py to 
> common.py
>
> -Jim
>
>
>
>
> On Thursday, February 27, 2020 at 11:29:39 AM UTC-6, Maurice Waka wrote:
>>
>> In my models, I have:
>>
>> import os
>> import datetime as dt
>> from datetime import datetime, timedelta, date
>> from py4web import action, request, DAL, Field, Session, Cache, user_in
>> from py4web.utils.auth import Auth
>> from py4web import action, request, abort, redirect, URL, Field
>> from py4web.utils.form import Form, FormStyleBulma
>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, 
>> IS_IN_SET, IS_IN_DB, IS_EMAIL, IS_MATCH
>> from pydal.validators import *
>> from . common import db, session, T, cache, authenticated, 
>> unauthenticated, Field
>> from pydal.validators import *
>>
>> # exposes services necessary to access the db.thing via ajax
>> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
>> # define session and cache objects
>> session = Session(secret="some secret")
>> cache = Cache(size=1000)
>>
>> # define database and tables
>> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
>> __file__), "databases"))
>>
>> auth = Auth(session, db)
>> # (configure here)
>> auth.enable()
>>
>> db.define_table('answers',
>> Field('author', 'reference auth_user', default=auth.
>> user_id, writable=False, readable=False),
>> Field("message", 'text', requires=IS_NOT_EMPTY(), notnull
>> =False),
>> auth.signature
>> )
>>
>>
>>
>> In the controller:
>>
>>
>> from pydal.validators import *
>> from datetime import datetime, timedelta, date
>> from py4web.utils.auth import Auth
>> from py4web.utils.form import Form, FormStyleBulma
>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>> from .common import db, session, T, cache, auth, logger, authenticated, 
>> unauthenticated
>> from py4web import action, request, DAL, Field, Session, Cache, user_in, 
>> abort, redirect, URL, Translator
>> from pydal.validators import IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
>> IS_IN_DB, IS_EMAIL, IS_MATCH
>> from yatl.helpers import A, TEXTAREA, INPUT, TR, TD, TABLE, DIV, LABEL, 
>> FORM, SELECT, OPTION, P, H1, H2, H3, H4, H5, HTML, BODY
>> from . wellness_main import report
>> from . r_image import img_report
>>
>> auth = Auth(session, db)
>> # (configure here)
>> auth.enable()
>>
>>
>> @authenticated()
>> @action.uses(session, db, T, auth.user)
>> def index():
>> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
>> db(db.answers.modified_on < yesterday).delete()
>> """Avoid an empty table"""
>> user = db(db.posts.author== auth.user_id).select(db.posts.id, 
>> db.posts.author, orderby=~db.posts.id, limitby=(0,1)).first()
>> if user.author if user else None == auth.user_id:
>> pass
>> more code..
>> return dict(...)
>>
>> Regards
>>
>>
>> On Thursday, February 27, 2020 at 8:09:00 PM UTC+3, Jim S wrote:
>>>
>>> Yes, I am aware of that, but what file is that in?  You didn't specify.  
>>> Is that in the same controller the other snippet is in?  If so, then you're 
>>> redfining db and the table in your controller which in your second to last 
>>> line of your post you say you're not doing.  
>>>
>>> I'm confused...  I'd like to help, but need a clear picture of a minimal 
>>> common.py, models.py and your controller that reproduces this error.
>>>
>>> -Jim
>>>
>>> On Thursday, February 27, 2020 at 10:05:28 AM UTC-6, Maurice Waka wrote:

 I already have that, see above code second last line on imports

 On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:
>
> Where is db being defined in your controller?  Are you importing it 
> from common?
>
> In my controller I have
>
> from ..common import db, session, T, cache, auth, logger
>
> and later
>
> @action.uses("applications/index.html", session, db, T, auth.user)
> def index():
> page['sub_title'] = A('MENU', _href=URL('index'))
> return dict(page=page)
>
> Does that help?  If not, can you post a minimal common.py, models.py 
> and your controller?
>
> -Jim
>
> On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>>
>> Hello, from this code, I have already defined my table in models as 
>> follows:
>>
>> import os
>> import datetime as 

Re: [web2py] Re: The PyDal/Yatl Web2Py/Py4web Emmet/Weppy Ecosystem

2020-02-27 Thread Jim S
Thanks Kevin, I saw that, but other than the name change seems like not 
much activity.  Any other activity on it?  Seems like a nice framework.

-Jim

On Thursday, February 27, 2020 at 11:47:05 AM UTC-6, Kevin Keller wrote:
>
> Hey Jim, 
>
> Weppy is now re-named to Emmet:
>
> https://github.com/emmett-framework/emmett
>
>
>
> On Thu, Feb 27, 2020 at 6:38 PM Jim S > 
> wrote:
>
>> Kevin
>>
>> I'm curious about your comment on Weppy/Emmet evolving.  Looks like there 
>> has been only 1 commit in the past 16 months or so (it is possible I'm 
>> reading that wrong).  What do you know about their progress.  Also, I'd 
>> love to be able to use PyDAL as classes as used in weppy (while not taking 
>> away the current capabilities).  That would be a great step forward.
>>
>> -Jim
>>
>> On Thursday, February 27, 2020 at 10:23:19 AM UTC-6, Kevin Keller wrote:
>>>
>>> I was thinking, just by how often I go back to Web2Py, what an excellent 
>>> framework it is and
>>> the progress of Py4Web is also exciting, while also noticing how the 
>>> pydal/yatl based framework Weppy/Emmet is evolving, 
>>> that really there is no need anymore to think in terms of the future of 
>>> a single framework. 
>>>
>>> I feel like Web2Py has evolved into its own family sort of like: 
>>>
>>> Web2Py - the opinionated full stack low code enterprise framework
>>> Py4Web - the api first flexible microframework with some batteries 
>>> included
>>> Emmet/Weppy - the opinionated small scale framework
>>>
>>> I myself also used PyDal and Yatl with Flask which also worked nice. 
>>>
>>> I feel like the PyDal/Yatl combination has evolved into its own 
>>> ecosystem that can share a great deal of code
>>> you can easily switch from one to the other depending on your use case 
>>> and can happily co-exist.. no? 
>>>
>>> Almost felt like finding a name for the PyDal/Yatl based type of 
>>> frameworks which contrast the Django/ORM and SQLAlchemy/Almembic world of 
>>> frameworks 
>>> and shine through ease of use compared to those. 
>>>
>>>
>>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/88f6bbdf-770d-4752-ae5a-c688567e1dcf%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/adf146a0-27f0-4106-b7a2-03f0ceb7c55b%40googlegroups.com.


[web2py] BUG response.cookies and sessions2trash.py

2020-02-27 Thread 'Annet' via web2py-users
I scheduled cron to regularly trash the session in my web2py applications. 
this worked well
until I added this line of code to a model.py file;

response.cookies[response.session_id_name]['domain'] = '.leonexus.nl'

My scripts log any errors at ~my/logs/user/sessions2trash.log.
That file is full of lines like:

Traceback (most recent call last):
  File "/home/my/webapps/web2py/web2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File "applications/init/models/00_init_db.py", line 6, in 
response.cookies[response.session_id_name]['domain'] = '.mydomain.com'
KeyError: None

I know in python a KeyError is raised when a dictionary is accessed but the 
key requested is not in it.
However, I have no idea why the line of code interferes with calling 
/scripts/sessions2trash.py

I am working with web2py 2.14.5 and python 2.7
Hope someone can help me solve the issue.


Kind regards,

Annet

-- 
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/ca03bcf7-2e00-4aee-a645-8ea01fd90f3b%40googlegroups.com.


Re: [web2py] Re: py4web defining tables

2020-02-27 Thread Maurice Waka
I get it.
Let me work it out in the next hour.
Kind regards

On Thu, Feb 27, 2020, 20:46 Jim S  wrote:

> Try commenting out
>
> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
> __file__), "databases"))
>
> in models.py
>
> Do you already have that in common.py?
>
> In your controller you're importing db from common, but the instance in
> common doesn't have any tables defined.  You redefined db in models.py and
> added the table to that instance of it.
>
> I think the solution is to move the statement above from models.py to
> common.py
>
> -Jim
>
>
>
>
> On Thursday, February 27, 2020 at 11:29:39 AM UTC-6, Maurice Waka wrote:
>>
>> In my models, I have:
>>
>> import os
>> import datetime as dt
>> from datetime import datetime, timedelta, date
>> from py4web import action, request, DAL, Field, Session, Cache, user_in
>> from py4web.utils.auth import Auth
>> from py4web import action, request, abort, redirect, URL, Field
>> from py4web.utils.form import Form, FormStyleBulma
>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE,
>> IS_IN_SET, IS_IN_DB, IS_EMAIL, IS_MATCH
>> from pydal.validators import *
>> from . common import db, session, T, cache, authenticated,
>> unauthenticated, Field
>> from pydal.validators import *
>>
>> # exposes services necessary to access the db.thing via ajax
>> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
>> # define session and cache objects
>> session = Session(secret="some secret")
>> cache = Cache(size=1000)
>>
>> # define database and tables
>> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
>> __file__), "databases"))
>>
>> auth = Auth(session, db)
>> # (configure here)
>> auth.enable()
>>
>> db.define_table('answers',
>> Field('author', 'reference auth_user', default=auth.
>> user_id, writable=False, readable=False),
>> Field("message", 'text', requires=IS_NOT_EMPTY(), notnull
>> =False),
>> auth.signature
>> )
>>
>>
>>
>> In the controller:
>>
>>
>> from pydal.validators import *
>> from datetime import datetime, timedelta, date
>> from py4web.utils.auth import Auth
>> from py4web.utils.form import Form, FormStyleBulma
>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>> from .common import db, session, T, cache, auth, logger, authenticated,
>> unauthenticated
>> from py4web import action, request, DAL, Field, Session, Cache, user_in,
>> abort, redirect, URL, Translator
>> from pydal.validators import IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET,
>> IS_IN_DB, IS_EMAIL, IS_MATCH
>> from yatl.helpers import A, TEXTAREA, INPUT, TR, TD, TABLE, DIV, LABEL,
>> FORM, SELECT, OPTION, P, H1, H2, H3, H4, H5, HTML, BODY
>> from . wellness_main import report
>> from . r_image import img_report
>>
>> auth = Auth(session, db)
>> # (configure here)
>> auth.enable()
>>
>>
>> @authenticated()
>> @action.uses(session, db, T, auth.user)
>> def index():
>> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
>> db(db.answers.modified_on < yesterday).delete()
>> """Avoid an empty table"""
>> user = db(db.posts.author== auth.user_id).select(db.posts.id,
>> db.posts.author, orderby=~db.posts.id, limitby=(0,1)).first()
>> if user.author if user else None == auth.user_id:
>> pass
>> more code..
>> return dict(...)
>>
>> Regards
>>
>>
>> On Thursday, February 27, 2020 at 8:09:00 PM UTC+3, Jim S wrote:
>>>
>>> Yes, I am aware of that, but what file is that in?  You didn't specify.
>>> Is that in the same controller the other snippet is in?  If so, then you're
>>> redfining db and the table in your controller which in your second to last
>>> line of your post you say you're not doing.
>>>
>>> I'm confused...  I'd like to help, but need a clear picture of a minimal
>>> common.py, models.py and your controller that reproduces this error.
>>>
>>> -Jim
>>>
>>> On Thursday, February 27, 2020 at 10:05:28 AM UTC-6, Maurice Waka wrote:

 I already have that, see above code second last line on imports

 On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:
>
> Where is db being defined in your controller?  Are you importing it
> from common?
>
> In my controller I have
>
> from ..common import db, session, T, cache, auth, logger
>
> and later
>
> @action.uses("applications/index.html", session, db, T, auth.user)
> def index():
> page['sub_title'] = A('MENU', _href=URL('index'))
> return dict(page=page)
>
> Does that help?  If not, can you post a minimal common.py, models.py
> and your controller?
>
> -Jim
>
> On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>>
>> Hello, from this code, I have already defined my table in models as
>> follows:
>>
>> import os
>> import datetime as dt
>> from 

Re: [web2py] Re: The PyDal/Yatl Web2Py/Py4web Emmet/Weppy Ecosystem

2020-02-27 Thread Kevin Keller
Hey Jim,

Weppy is now re-named to Emmet:

https://github.com/emmett-framework/emmett



On Thu, Feb 27, 2020 at 6:38 PM Jim S  wrote:

> Kevin
>
> I'm curious about your comment on Weppy/Emmet evolving.  Looks like there
> has been only 1 commit in the past 16 months or so (it is possible I'm
> reading that wrong).  What do you know about their progress.  Also, I'd
> love to be able to use PyDAL as classes as used in weppy (while not taking
> away the current capabilities).  That would be a great step forward.
>
> -Jim
>
> On Thursday, February 27, 2020 at 10:23:19 AM UTC-6, Kevin Keller wrote:
>>
>> I was thinking, just by how often I go back to Web2Py, what an excellent
>> framework it is and
>> the progress of Py4Web is also exciting, while also noticing how the
>> pydal/yatl based framework Weppy/Emmet is evolving,
>> that really there is no need anymore to think in terms of the future of a
>> single framework.
>>
>> I feel like Web2Py has evolved into its own family sort of like:
>>
>> Web2Py - the opinionated full stack low code enterprise framework
>> Py4Web - the api first flexible microframework with some batteries
>> included
>> Emmet/Weppy - the opinionated small scale framework
>>
>> I myself also used PyDal and Yatl with Flask which also worked nice.
>>
>> I feel like the PyDal/Yatl combination has evolved into its own ecosystem
>> that can share a great deal of code
>> you can easily switch from one to the other depending on your use case
>> and can happily co-exist.. no?
>>
>> Almost felt like finding a name for the PyDal/Yatl based type of
>> frameworks which contrast the Django/ORM and SQLAlchemy/Almembic world of
>> frameworks
>> and shine through ease of use compared to those.
>>
>>
>> --
> 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/88f6bbdf-770d-4752-ae5a-c688567e1dcf%40googlegroups.com
> 
> .
>

-- 
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/CADHCKLR7Fc9pA9J07Ckk2FgSs_C25Q6ixChxHU946XETCRpLnQ%40mail.gmail.com.


[web2py] Re: py4web defining tables

2020-02-27 Thread Jim S
Try commenting out 

db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
__file__), "databases"))

in models.py

Do you already have that in common.py?

In your controller you're importing db from common, but the instance in 
common doesn't have any tables defined.  You redefined db in models.py and 
added the table to that instance of it.

I think the solution is to move the statement above from models.py to 
common.py

-Jim




On Thursday, February 27, 2020 at 11:29:39 AM UTC-6, Maurice Waka wrote:
>
> In my models, I have:
>
> import os
> import datetime as dt
> from datetime import datetime, timedelta, date
> from py4web import action, request, DAL, Field, Session, Cache, user_in
> from py4web.utils.auth import Auth
> from py4web import action, request, abort, redirect, URL, Field
> from py4web.utils.form import Form, FormStyleBulma
> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
> IS_IN_DB, IS_EMAIL, IS_MATCH
> from pydal.validators import *
> from . common import db, session, T, cache, authenticated, unauthenticated
> , Field
> from pydal.validators import *
>
> # exposes services necessary to access the db.thing via ajax
> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
> # define session and cache objects
> session = Session(secret="some secret")
> cache = Cache(size=1000)
>
> # define database and tables
> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
> __file__), "databases"))
>
> auth = Auth(session, db)
> # (configure here)
> auth.enable()
>
> db.define_table('answers',
> Field('author', 'reference auth_user', default=auth.
> user_id, writable=False, readable=False),
> Field("message", 'text', requires=IS_NOT_EMPTY(), notnull=
> False),
> auth.signature
> )
>
>
>
> In the controller:
>
>
> from pydal.validators import *
> from datetime import datetime, timedelta, date
> from py4web.utils.auth import Auth
> from py4web.utils.form import Form, FormStyleBulma
> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
> from .common import db, session, T, cache, auth, logger, authenticated, 
> unauthenticated
> from py4web import action, request, DAL, Field, Session, Cache, user_in, 
> abort, redirect, URL, Translator
> from pydal.validators import IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
> IS_IN_DB, IS_EMAIL, IS_MATCH
> from yatl.helpers import A, TEXTAREA, INPUT, TR, TD, TABLE, DIV, LABEL, 
> FORM, SELECT, OPTION, P, H1, H2, H3, H4, H5, HTML, BODY
> from . wellness_main import report
> from . r_image import img_report
>
> auth = Auth(session, db)
> # (configure here)
> auth.enable()
>
>
> @authenticated()
> @action.uses(session, db, T, auth.user)
> def index():
> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
> db(db.answers.modified_on < yesterday).delete()
> """Avoid an empty table"""
> user = db(db.posts.author== auth.user_id).select(db.posts.id, 
> db.posts.author, orderby=~db.posts.id, limitby=(0,1)).first()
> if user.author if user else None == auth.user_id:
> pass
> more code..
> return dict(...)
>
> Regards
>
>
> On Thursday, February 27, 2020 at 8:09:00 PM UTC+3, Jim S wrote:
>>
>> Yes, I am aware of that, but what file is that in?  You didn't specify.  
>> Is that in the same controller the other snippet is in?  If so, then you're 
>> redfining db and the table in your controller which in your second to last 
>> line of your post you say you're not doing.  
>>
>> I'm confused...  I'd like to help, but need a clear picture of a minimal 
>> common.py, models.py and your controller that reproduces this error.
>>
>> -Jim
>>
>> On Thursday, February 27, 2020 at 10:05:28 AM UTC-6, Maurice Waka wrote:
>>>
>>> I already have that, see above code second last line on imports
>>>
>>> On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:

 Where is db being defined in your controller?  Are you importing it 
 from common?

 In my controller I have

 from ..common import db, session, T, cache, auth, logger

 and later

 @action.uses("applications/index.html", session, db, T, auth.user)
 def index():
 page['sub_title'] = A('MENU', _href=URL('index'))
 return dict(page=page)

 Does that help?  If not, can you post a minimal common.py, models.py 
 and your controller?

 -Jim

 On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>
> Hello, from this code, I have already defined my table in models as 
> follows:
>
> import os
> import datetime as dt
> from datetime import datetime, timedelta, date
> from py4web import action, request, DAL, Field, Session, Cache, 
> user_in
> from py4web.utils.auth import Auth
> from py4web import action, request, abort, redirect, URL, Field
> from 

[web2py] py4web defining tables

2020-02-27 Thread Val K
There is import db from common, but later there is db = DAL(...) in the same 
file!

-- 
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/601d5362-6449-4033-8e8a-7e3410c36b0a%40googlegroups.com.


[web2py] Re: The PyDal/Yatl Web2Py/Py4web Emmet/Weppy Ecosystem

2020-02-27 Thread Jim S
Kevin

I'm curious about your comment on Weppy/Emmet evolving.  Looks like there 
has been only 1 commit in the past 16 months or so (it is possible I'm 
reading that wrong).  What do you know about their progress.  Also, I'd 
love to be able to use PyDAL as classes as used in weppy (while not taking 
away the current capabilities).  That would be a great step forward.

-Jim

On Thursday, February 27, 2020 at 10:23:19 AM UTC-6, Kevin Keller wrote:
>
> I was thinking, just by how often I go back to Web2Py, what an excellent 
> framework it is and
> the progress of Py4Web is also exciting, while also noticing how the 
> pydal/yatl based framework Weppy/Emmet is evolving, 
> that really there is no need anymore to think in terms of the future of a 
> single framework. 
>
> I feel like Web2Py has evolved into its own family sort of like: 
>
> Web2Py - the opinionated full stack low code enterprise framework
> Py4Web - the api first flexible microframework with some batteries included
> Emmet/Weppy - the opinionated small scale framework
>
> I myself also used PyDal and Yatl with Flask which also worked nice. 
>
> I feel like the PyDal/Yatl combination has evolved into its own ecosystem 
> that can share a great deal of code
> you can easily switch from one to the other depending on your use case and 
> can happily co-exist.. no? 
>
> Almost felt like finding a name for the PyDal/Yatl based type of 
> frameworks which contrast the Django/ORM and SQLAlchemy/Almembic world of 
> frameworks 
> and shine through ease of use compared to those. 
>
>
>

-- 
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/88f6bbdf-770d-4752-ae5a-c688567e1dcf%40googlegroups.com.


[web2py] Re: py4web defining tables

2020-02-27 Thread Maurice Waka
In my models, I have:

import os
import datetime as dt
from datetime import datetime, timedelta, date
from py4web import action, request, DAL, Field, Session, Cache, user_in
from py4web.utils.auth import Auth
from py4web import action, request, abort, redirect, URL, Field
from py4web.utils.form import Form, FormStyleBulma
from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
IS_IN_DB, IS_EMAIL, IS_MATCH
from pydal.validators import *
from . common import db, session, T, cache, authenticated, unauthenticated, 
Field
from pydal.validators import *

# exposes services necessary to access the db.thing via ajax
publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
# define session and cache objects
session = Session(secret="some secret")
cache = Cache(size=1000)

# define database and tables
db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
__file__), "databases"))

auth = Auth(session, db)
# (configure here)
auth.enable()

db.define_table('answers',
Field('author', 'reference auth_user', default=auth.user_id, 
writable=False, readable=False),
Field("message", 'text', requires=IS_NOT_EMPTY(), notnull=
False),
auth.signature
)



In the controller:


from pydal.validators import *
from datetime import datetime, timedelta, date
from py4web.utils.auth import Auth
from py4web.utils.form import Form, FormStyleBulma
from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
from .common import db, session, T, cache, auth, logger, authenticated, 
unauthenticated
from py4web import action, request, DAL, Field, Session, Cache, user_in, 
abort, redirect, URL, Translator
from pydal.validators import IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
IS_IN_DB, IS_EMAIL, IS_MATCH
from yatl.helpers import A, TEXTAREA, INPUT, TR, TD, TABLE, DIV, LABEL, 
FORM, SELECT, OPTION, P, H1, H2, H3, H4, H5, HTML, BODY
from . wellness_main import report
from . r_image import img_report

auth = Auth(session, db)
# (configure here)
auth.enable()


@authenticated()
@action.uses(session, db, T, auth.user)
def index():
yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
db(db.answers.modified_on < yesterday).delete()
"""Avoid an empty table"""
user = db(db.posts.author== auth.user_id).select(db.posts.id, 
db.posts.author, orderby=~db.posts.id, limitby=(0,1)).first()
if user.author if user else None == auth.user_id:
pass
more code..
return dict(...)

Regards


On Thursday, February 27, 2020 at 8:09:00 PM UTC+3, Jim S wrote:
>
> Yes, I am aware of that, but what file is that in?  You didn't specify.  
> Is that in the same controller the other snippet is in?  If so, then you're 
> redfining db and the table in your controller which in your second to last 
> line of your post you say you're not doing.  
>
> I'm confused...  I'd like to help, but need a clear picture of a minimal 
> common.py, models.py and your controller that reproduces this error.
>
> -Jim
>
> On Thursday, February 27, 2020 at 10:05:28 AM UTC-6, Maurice Waka wrote:
>>
>> I already have that, see above code second last line on imports
>>
>> On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:
>>>
>>> Where is db being defined in your controller?  Are you importing it from 
>>> common?
>>>
>>> In my controller I have
>>>
>>> from ..common import db, session, T, cache, auth, logger
>>>
>>> and later
>>>
>>> @action.uses("applications/index.html", session, db, T, auth.user)
>>> def index():
>>> page['sub_title'] = A('MENU', _href=URL('index'))
>>> return dict(page=page)
>>>
>>> Does that help?  If not, can you post a minimal common.py, models.py and 
>>> your controller?
>>>
>>> -Jim
>>>
>>> On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:

 Hello, from this code, I have already defined my table in models as 
 follows:

 import os
 import datetime as dt
 from datetime import datetime, timedelta, date
 from py4web import action, request, DAL, Field, Session, Cache, user_in
 from py4web.utils.auth import Auth
 from py4web import action, request, abort, redirect, URL, Field
 from py4web.utils.form import Form, FormStyleBulma
 from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
 from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, 
 IS_IN_SET, IS_IN_DB, IS_EMAIL, IS_MATCH
 from pydal.validators import *
 from . common import db, session, T, cache, authenticated, 
 unauthenticated, Field
 from pydal.validators import *


 ### Define your table below


 # exposes services necessary to access the db.thing via ajax
 publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
 # define session and cache objects
 session = Session(secret="some secret")
 cache = Cache(size=1000)


 # define database and tables

[web2py] Re: py4web defining tables

2020-02-27 Thread Jim S
Yes, I am aware of that, but what file is that in?  You didn't specify.  Is 
that in the same controller the other snippet is in?  If so, then you're 
redfining db and the table in your controller which in your second to last 
line of your post you say you're not doing.  

I'm confused...  I'd like to help, but need a clear picture of a minimal 
common.py, models.py and your controller that reproduces this error.

-Jim

On Thursday, February 27, 2020 at 10:05:28 AM UTC-6, Maurice Waka wrote:
>
> I already have that, see above code second last line on imports
>
> On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:
>>
>> Where is db being defined in your controller?  Are you importing it from 
>> common?
>>
>> In my controller I have
>>
>> from ..common import db, session, T, cache, auth, logger
>>
>> and later
>>
>> @action.uses("applications/index.html", session, db, T, auth.user)
>> def index():
>> page['sub_title'] = A('MENU', _href=URL('index'))
>> return dict(page=page)
>>
>> Does that help?  If not, can you post a minimal common.py, models.py and 
>> your controller?
>>
>> -Jim
>>
>> On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>>>
>>> Hello, from this code, I have already defined my table in models as 
>>> follows:
>>>
>>> import os
>>> import datetime as dt
>>> from datetime import datetime, timedelta, date
>>> from py4web import action, request, DAL, Field, Session, Cache, user_in
>>> from py4web.utils.auth import Auth
>>> from py4web import action, request, abort, redirect, URL, Field
>>> from py4web.utils.form import Form, FormStyleBulma
>>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>>> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, 
>>> IS_IN_SET, IS_IN_DB, IS_EMAIL, IS_MATCH
>>> from pydal.validators import *
>>> from . common import db, session, T, cache, authenticated, 
>>> unauthenticated, Field
>>> from pydal.validators import *
>>>
>>>
>>> ### Define your table below
>>>
>>>
>>> # exposes services necessary to access the db.thing via ajax
>>> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
>>> # define session and cache objects
>>> session = Session(secret="some secret")
>>> cache = Cache(size=1000)
>>>
>>>
>>> # define database and tables
>>> #connection = sqlite.connect('cache.db', timeout=10)
>>> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
>>> __file__), "databases"))#db = DAL("sqlite://storage.db", 
>>> folder=os.path.join(os.path.dirname(__file__), "databases"))
>>> #db = DAL( "postgres://mauricewaka:b3th32dau2a##@localhost:5432/py4db", 
>>> migrate=False)
>>> auth = Auth(session, db)
>>> # (configure here)
>>> auth.enable()
>>>
>>>
>>> db.define_table('answers',
>>> Field('author', 'reference auth_user', default=auth.
>>> user_id, writable=False, readable=False),
>>> Field("message", 'text', requires=IS_NOT_EMPTY(), 
>>> notnull=False),
>>> auth.signature
>>> )
>>>
>>>
>>>
>>>
>>> In the controllers, this is my code:
>>>
>>> @authenticated()
>>> @action.uses(auth.user)
>>> def index():
>>>
>>> ...some code...
>>> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
>>>
>>> db(db.answers.modified_on < yesterday).delete()
>>> ...some more code
>>>
>>>
>>>
>>> But I get this errors:
>>> Traceback (most recent call last):
>>>  File "/home/maurice/py4web/py4web/core.py", line 551, in wrapper
>>>  ret = func(*func_args, **func_kwargs)
>>>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>>>  ret = func(*args, **kwargs)
>>>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>>>  ret = func(*args, **kwargs)
>>>  File "apps/scaffoldx/controllers.py", line 571, in index
>>>  db(db.answers.modified_on < yesterday).delete()
>>>  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", 
>>> line 763, in __getattr__
>>>  return BasicStorage.__getattribute__(self, key)
>>> AttributeError: 'DAL' object has no attribute 'answers'
>>>
>>>
>>>
>>> What could be wrong here and how can I solve it?
>>>
>>> N/B
>>>
>>> I have tried to define the table inside the controller code with an error 
>>> coming as : 'table already defined'. When I remove the definition then the 
>>> above error comes.
>>>
>>> Regards
>>>
>>>

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


[web2py] The PyDal/Yatl Web2Py/Py4web Emmet/Weppy Ecosystem

2020-02-27 Thread Kevin Keller
I was thinking, just by how often I go back to Web2Py, what an excellent 
framework it is and
the progress of Py4Web is also exciting, while also noticing how the 
pydal/yatl based framework Weppy/Emmet is evolving, 
that really there is no need anymore to think in terms of the future of a 
single framework. 

I feel like Web2Py has evolved into its own family sort of like: 

Web2Py - the opinionated full stack low code enterprise framework
Py4Web - the api first flexible microframework with some batteries included
Emmet/Weppy - the opinionated small scale framework

I myself also used PyDal and Yatl with Flask which also worked nice. 

I feel like the PyDal/Yatl combination has evolved into its own ecosystem 
that can share a great deal of code
you can easily switch from one to the other depending on your use case and 
can happily co-exist.. no? 

Almost felt like finding a name for the PyDal/Yatl based type of frameworks 
which contrast the Django/ORM and SQLAlchemy/Almembic world of frameworks 
and shine through ease of use compared to those. 


-- 
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/72d1d3fe-fbc4-4011-a13c-ed8b6c4f2071%40googlegroups.com.


[web2py] Re: py4web defining tables

2020-02-27 Thread Maurice Waka
I already have that, see above code second last line on imports

On Thursday, February 27, 2020 at 4:35:25 PM UTC+3, Jim S wrote:
>
> Where is db being defined in your controller?  Are you importing it from 
> common?
>
> In my controller I have
>
> from ..common import db, session, T, cache, auth, logger
>
> and later
>
> @action.uses("applications/index.html", session, db, T, auth.user)
> def index():
> page['sub_title'] = A('MENU', _href=URL('index'))
> return dict(page=page)
>
> Does that help?  If not, can you post a minimal common.py, models.py and 
> your controller?
>
> -Jim
>
> On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>>
>> Hello, from this code, I have already defined my table in models as 
>> follows:
>>
>> import os
>> import datetime as dt
>> from datetime import datetime, timedelta, date
>> from py4web import action, request, DAL, Field, Session, Cache, user_in
>> from py4web.utils.auth import Auth
>> from py4web import action, request, abort, redirect, URL, Field
>> from py4web.utils.form import Form, FormStyleBulma
>> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
>> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, 
>> IS_IN_SET, IS_IN_DB, IS_EMAIL, IS_MATCH
>> from pydal.validators import *
>> from . common import db, session, T, cache, authenticated, 
>> unauthenticated, Field
>> from pydal.validators import *
>>
>>
>> ### Define your table below
>>
>>
>> # exposes services necessary to access the db.thing via ajax
>> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
>> # define session and cache objects
>> session = Session(secret="some secret")
>> cache = Cache(size=1000)
>>
>>
>> # define database and tables
>> #connection = sqlite.connect('cache.db', timeout=10)
>> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
>> __file__), "databases"))#db = DAL("sqlite://storage.db", 
>> folder=os.path.join(os.path.dirname(__file__), "databases"))
>> #db = DAL( "postgres://mauricewaka:b3th32dau2a##@localhost:5432/py4db", 
>> migrate=False)
>> auth = Auth(session, db)
>> # (configure here)
>> auth.enable()
>>
>>
>> db.define_table('answers',
>> Field('author', 'reference auth_user', default=auth.
>> user_id, writable=False, readable=False),
>> Field("message", 'text', requires=IS_NOT_EMPTY(), notnull
>> =False),
>> auth.signature
>> )
>>
>>
>>
>>
>> In the controllers, this is my code:
>>
>> @authenticated()
>> @action.uses(auth.user)
>> def index():
>>
>> ...some code...
>> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
>>
>> db(db.answers.modified_on < yesterday).delete()
>> ...some more code
>>
>>
>>
>> But I get this errors:
>> Traceback (most recent call last):
>>  File "/home/maurice/py4web/py4web/core.py", line 551, in wrapper
>>  ret = func(*func_args, **func_kwargs)
>>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>>  ret = func(*args, **kwargs)
>>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>>  ret = func(*args, **kwargs)
>>  File "apps/scaffoldx/controllers.py", line 571, in index
>>  db(db.answers.modified_on < yesterday).delete()
>>  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", 
>> line 763, in __getattr__
>>  return BasicStorage.__getattribute__(self, key)
>> AttributeError: 'DAL' object has no attribute 'answers'
>>
>>
>>
>> What could be wrong here and how can I solve it?
>>
>> N/B
>>
>> I have tried to define the table inside the controller code with an error 
>> coming as : 'table already defined'. When I remove the definition then the 
>> above error comes.
>>
>> Regards
>>
>>

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


[web2py] Re: py4web defining tables

2020-02-27 Thread Jim S
Where is db being defined in your controller?  Are you importing it from 
common?

In my controller I have

from ..common import db, session, T, cache, auth, logger

and later

@action.uses("applications/index.html", session, db, T, auth.user)
def index():
page['sub_title'] = A('MENU', _href=URL('index'))
return dict(page=page)

Does that help?  If not, can you post a minimal common.py, models.py and 
your controller?

-Jim

On Thursday, February 27, 2020 at 5:55:23 AM UTC-6, Maurice Waka wrote:
>
> Hello, from this code, I have already defined my table in models as 
> follows:
>
> import os
> import datetime as dt
> from datetime import datetime, timedelta, date
> from py4web import action, request, DAL, Field, Session, Cache, user_in
> from py4web.utils.auth import Auth
> from py4web import action, request, abort, redirect, URL, Field
> from py4web.utils.form import Form, FormStyleBulma
> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
> from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
> IS_IN_DB, IS_EMAIL, IS_MATCH
> from pydal.validators import *
> from . common import db, session, T, cache, authenticated, unauthenticated
> , Field
> from pydal.validators import *
>
>
> ### Define your table below
>
>
> # exposes services necessary to access the db.thing via ajax
> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
> # define session and cache objects
> session = Session(secret="some secret")
> cache = Cache(size=1000)
>
>
> # define database and tables
> #connection = sqlite.connect('cache.db', timeout=10)
> db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
> __file__), "databases"))#db = DAL("sqlite://storage.db", 
> folder=os.path.join(os.path.dirname(__file__), "databases"))
> #db = DAL( "postgres://mauricewaka:b3th32dau2a##@localhost:5432/py4db", 
> migrate=False)
> auth = Auth(session, db)
> # (configure here)
> auth.enable()
>
>
> db.define_table('answers',
> Field('author', 'reference auth_user', default=auth.
> user_id, writable=False, readable=False),
> Field("message", 'text', requires=IS_NOT_EMPTY(), notnull=
> False),
> auth.signature
> )
>
>
>
>
> In the controllers, this is my code:
>
> @authenticated()
> @action.uses(auth.user)
> def index():
>
> ...some code...
> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)
>
> db(db.answers.modified_on < yesterday).delete()
> ...some more code
>
>
>
> But I get this errors:
> Traceback (most recent call last):
>  File "/home/maurice/py4web/py4web/core.py", line 551, in wrapper
>  ret = func(*func_args, **func_kwargs)
>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>  ret = func(*args, **kwargs)
>  File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
>  ret = func(*args, **kwargs)
>  File "apps/scaffoldx/controllers.py", line 571, in index
>  db(db.answers.modified_on < yesterday).delete()
>  File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", 
> line 763, in __getattr__
>  return BasicStorage.__getattribute__(self, key)
> AttributeError: 'DAL' object has no attribute 'answers'
>
>
>
> What could be wrong here and how can I solve it?
>
> N/B
>
> I have tried to define the table inside the controller code with an error 
> coming as : 'table already defined'. When I remove the definition then the 
> above error comes.
>
> Regards
>
>

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


[web2py] py4web defining tables

2020-02-27 Thread Maurice Waka
Hello, from this code, I have already defined my table in models as follows:

import os
import datetime as dt
from datetime import datetime, timedelta, date
from py4web import action, request, DAL, Field, Session, Cache, user_in
from py4web.utils.auth import Auth
from py4web import action, request, abort, redirect, URL, Field
from py4web.utils.form import Form, FormStyleBulma
from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
from pydal.validators import * #IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, 
IS_IN_DB, IS_EMAIL, IS_MATCH
from pydal.validators import *
from . common import db, session, T, cache, authenticated, unauthenticated, 
Field
from pydal.validators import *


### Define your table below


# exposes services necessary to access the db.thing via ajax
publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
# define session and cache objects
session = Session(secret="some secret")
cache = Cache(size=1000)


# define database and tables
#connection = sqlite.connect('cache.db', timeout=10)
db = DAL("sqlite://xstorage.db", folder=os.path.join(os.path.dirname(
__file__), "databases"))#db = DAL("sqlite://storage.db", 
folder=os.path.join(os.path.dirname(__file__), "databases"))
#db = DAL( "postgres://mauricewaka:b3th32dau2a##@localhost:5432/py4db", 
migrate=False)
auth = Auth(session, db)
# (configure here)
auth.enable()


db.define_table('answers',
Field('author', 'reference auth_user', default=auth.user_id, 
writable=False, readable=False),
Field("message", 'text', requires=IS_NOT_EMPTY(), notnull=
False),
auth.signature
)




In the controllers, this is my code:

@authenticated()
@action.uses(auth.user)
def index():

...some code...
yesterday = dt.datetime.utcnow() - dt.timedelta(days=1)

db(db.answers.modified_on < yesterday).delete()
...some more code



But I get this errors:
Traceback (most recent call last):
 File "/home/maurice/py4web/py4web/core.py", line 551, in wrapper
 ret = func(*func_args, **func_kwargs)
 File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
 ret = func(*args, **kwargs)
 File "/home/maurice/py4web/py4web/core.py", line 512, in wrapper
 ret = func(*args, **kwargs)
 File "apps/scaffoldx/controllers.py", line 571, in index
 db(db.answers.modified_on < yesterday).delete()
 File "/home/maurice/.local/lib/python3.6/site-packages/pydal/base.py", 
line 763, in __getattr__
 return BasicStorage.__getattribute__(self, key)
AttributeError: 'DAL' object has no attribute 'answers'



What could be wrong here and how can I solve it?

N/B

I have tried to define the table inside the controller code with an error 
coming as : 'table already defined'. When I remove the definition then the 
above error comes.

Regards

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