[web2py] Re: certbot vs web2py -- geoip import break

2018-05-08 Thread Dave S


On Friday, May 4, 2018 at 3:45:25 PM UTC-7, Dave S wrote:
>
> Here's a wierd one:
>
> AWS Linux, nginx, uwsgi, web2py 2.15.4, very stable.  
>
> I use certbot --nginx to update my certs (yes, Let's Encrypt), which works 
> 90% (seems to have missed getting an ln step right at the end, fixed 
> manually). 
>

The ln step, to set up privkey.key turns out to be unsupported by certbot, 
but changing the nginx.conf to use privkey.pem is the recommended change 
for the LE community.
 

> But then my module which imports geolite2 from geoip gets "import error: 
> "No module named geoip\".  Running python from the command line, and 
> importing geoip manually, has no such problem.  python web2py.py -S has no 
> such problem.
>
> certbot (actually certbot-auto) updated python-tools, but then used a 
> virtual environment.  But it seems to have caused something to go awry.  Do 
> I need to restart my uwsgi master?  (I'm not yet crowned as emporer.)
>
> Any clues as to what's going on here?
>
> /dps
>
>
No geoip users here?

/dps
 

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


[web2py] Re: Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-08 Thread Francisco Ribeiro
Thank you, that has crossed my mind but I would then have to create another 
abstraction on top of the Scheduler groups to represent, well... groups. I 
even thought of conventions like common prefixes to identify which 
"user-group" belongs to which "group-group". Anyway, I gave up on the idea 
and is it looked to cluttered and implemented this functionality on the 
Scheduler, will submit a PR in case you are interested.

Basically, all you do is to create a task with broadcast=True and it should 
hit all the workers within the assigned worker_group. This should work even 
if new workers join the group later on and it should also work for both 
one-off tasks or tasks with an unlimited number of repeats. Finally, if you 
stop / disable / delete the broadcast task, no more tasks should be 
triggered like it, so you stop broadcasting. Happy to document this better, 
if are you happy to include it.

Kind regards,
Francisco

On Tuesday, 8 May 2018 19:52:29 UTC+1, Niphlod wrote:
>
> hint: if the api doesn't allow it, it's not an envisioned scenario.
>
> That being said, there's no limit on the worker-group configuration. 
> As auth relies on RBAC, workers rely on groups. 
> A particular group is able to process a given task ? Queue the task 
> assigning the correct group.
> Only one worker is able to process tasks of a specific group ? voilà!
> It's perfectly fine to run 10 workers and have 10 groups, even if each 
> group holds just one worker...
>
> On Monday, May 7, 2018 at 8:13:02 PM UTC+2, Francisco Ribeiro wrote:
>>
>> I have been testing my own hypothesis, it didn't work. I was unable to 
>> assign a task to a specific worker, I can only assign tasks to groups. 
>> Please correct me if I am wrong...
>>
>> On Sunday, 6 May 2018 16:16:08 UTC+1, Francisco Ribeiro wrote:
>>>
>>> Thank you for confirming.
>>>
>>> I presume that I still can take a list of workers belonging to a single 
>>> group and assign the same task multiple times (once per worker), which 
>>> would still suit my needs (expect if i want to cancel it for whatever 
>>> reason which becomes harder / less convenient). Do you see any problem 
>>> doing that?
>>>
>>> On Sunday, 6 May 2018 04:16:53 UTC+1, Massimo Di Pierro wrote:

 No. I do not believe there is any way to guarantee that every work will 
 execute the same task.


 On Friday, 4 May 2018 17:36:30 UTC-5, Francisco Ribeiro wrote:
>
> The question refers to submitting a task simultaneously to all workers 
> within a group.
>
> Thank you
>


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


[web2py] Re: At least one of a group of form fields is required

2018-05-08 Thread Anthony
Nothing built in for that -- you'll have to handle it via Javascript.

On Tuesday, May 8, 2018 at 2:20:22 PM UTC-4, 11-10...@usb.ve wrote:
>
> I'm making a form inside a module that is meant to show up in a bootstrap 
> modal in one of my views. 
>
> new_form = SQLFORM.factory(
> Field('title', type="string", required=True),
> Field('author', type="string"),
> Field('co-author', type="string"),
> Field('institution', type="string"),
> Field('date',  type='string'),
> labels = {
> 'title' : 'Title',
> 'author': 'Author(s)',
> 'coauthor': 'Coauthor(s)',
> 'institution': 'Institution',
> 'date': 'Date'
> },
> submit_button=T('Create')
> )
>
> Is there a way that I can check if at least one of the 'author', 
> 'coauthor' and 'institution' fields has been filled before processing the 
> form? So far, i've tried using an onvalidation function that effectively 
> checks this:
>
> def authors_check(form):
> if not(form.vars.author or form.vars.coauthor or 
> form.vars.institution):
> form.errors.author = 'Debe haber al menos un autor, o un coautor, 
> o un autor institucional'
>
> def process_form(form):
> if form.process(onvalidation=authors_check).accepted:
> ...
>
> The problem is that with this approach, the validation occurs after the 
> user has clicked the submit button and the modal has closed, the user would 
> have to navigate to open the modal all over again. Is there a way I can 
> check this before the user has hit the submit button, or at least to make 
> the modal not close if the form detects an error? 
>
> Here is the modal i have in my view:
>
> 
> 
>   
> 
>   
> 
>data-dismiss="modal">
>Add book 
> 
> 
>   
> Please fill the following form:
>   
> 
> {{=new_form}}
> 
>   
> 
>   
> 
>
> Thanks in advance for any help. 
>

-- 
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: Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-08 Thread Niphlod
hint: if the api doesn't allow it, it's not an envisioned scenario.

That being said, there's no limit on the worker-group configuration. 
As auth relies on RBAC, workers rely on groups. 
A particular group is able to process a given task ? Queue the task 
assigning the correct group.
Only one worker is able to process tasks of a specific group ? voilà!
It's perfectly fine to run 10 workers and have 10 groups, even if each 
group holds just one worker...

On Monday, May 7, 2018 at 8:13:02 PM UTC+2, Francisco Ribeiro wrote:
>
> I have been testing my own hypothesis, it didn't work. I was unable to 
> assign a task to a specific worker, I can only assign tasks to groups. 
> Please correct me if I am wrong...
>
> On Sunday, 6 May 2018 16:16:08 UTC+1, Francisco Ribeiro wrote:
>>
>> Thank you for confirming.
>>
>> I presume that I still can take a list of workers belonging to a single 
>> group and assign the same task multiple times (once per worker), which 
>> would still suit my needs (expect if i want to cancel it for whatever 
>> reason which becomes harder / less convenient). Do you see any problem 
>> doing that?
>>
>> On Sunday, 6 May 2018 04:16:53 UTC+1, Massimo Di Pierro wrote:
>>>
>>> No. I do not believe there is any way to guarantee that every work will 
>>> execute the same task.
>>>
>>>
>>> On Friday, 4 May 2018 17:36:30 UTC-5, Francisco Ribeiro wrote:

 The question refers to submitting a task simultaneously to all workers 
 within a group.

 Thank you

>>>

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


[web2py] At least one of a group of form fields is required

2018-05-08 Thread 11-10371
I'm making a form inside a module that is meant to show up in a bootstrap 
modal in one of my views. 

new_form = SQLFORM.factory(
Field('title', type="string", required=True),
Field('author', type="string"),
Field('co-author', type="string"),
Field('institution', type="string"),
Field('date',  type='string'),
labels = {
'title' : 'Title',
'author': 'Author(s)',
'coauthor': 'Coauthor(s)',
'institution': 'Institution',
'date': 'Date'
},
submit_button=T('Create')
)

Is there a way that I can check if at least one of the 'author', 'coauthor' 
and 'institution' fields has been filled before processing the form? So 
far, i've tried using an onvalidation function that effectively checks this:

def authors_check(form):
if not(form.vars.author or form.vars.coauthor or form.vars.institution):
form.errors.author = 'Debe haber al menos un autor, o un coautor, o 
un autor institucional'

def process_form(form):
if form.process(onvalidation=authors_check).accepted:
...

The problem is that with this approach, the validation occurs after the 
user has clicked the submit button and the modal has closed, the user would 
have to navigate to open the modal all over again. Is there a way I can 
check this before the user has hit the submit button, or at least to make 
the modal not close if the form detects an error? 

Here is the modal i have in my view:



  

  

  
   Add book 


  
Please fill the following form:
  

{{=new_form}}

  

  


Thanks in advance for any help. 

-- 
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: Insert data in firebird database

2018-05-08 Thread Константин Комков
I found only one working example.
tables.py
db_xml.define_table('bin_files',
Field('id','integer'),
Field('PARENT'),
Field('SRC_FILENAME'),
Field('DATA', 'blob'),
primarykey=['id','PARENT'],
migrate=False
   )
default.py
img = db_app(db_app.doc_images.person=='{0} {1} 
{2}'.format(session.abit_f,session.abit_i,session.abit_o)).select(db_app.doc_images.file)
filepath = os.path.join(request.folder,'uploads')
for i in img:
stream=open(filepath + '\\' + i.file, 'rb')
s=base64.encodestring(stream.read())
db_xml.executesql("""INSERT INTO bin_files 
(PARENT,SRC_FILENAME,DATA) VALUES 
({0},'{1}','{2}')""".format(entrant_id[0][0],i.file,s))
db_xml.commit()
I don't know how can I create the generator and trigger in web2py for using 
insert like this.
db_xml.bin_files.insert(PARENT=entrant_id[0][0],SRC_FILENAME=i.file,DATA=stream.read())



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