[web2py] Re: markmin.js

2016-02-11 Thread Niphlod
what is not 100% compatible ? if we want to push this, we should promote it 
instead of relying on python code

On Thursday, February 11, 2016 at 4:55:19 AM UTC+1, Massimo Di Pierro wrote:
>
> and the link:
>
> https://github.com/mdipierro/markmin.js
>
> On Wednesday, 10 February 2016 21:55:06 UTC-6, Massimo Di Pierro wrote:
>>
>> I have a new version of markmin.js I recommend this over the python 
>> implementation. It is better to render on the client because oembed does 
>> not require setting up server side caching. The JS version allows sanitized 
>> HTML. Also the heavy lifting is moved to the client. It is not 100% 
>> compatible but very close. 
>>
>

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


Re: [web2py] Re: Unittest Web2py with Test Runner Error database is locked

2016-02-11 Thread Maelle Taurand
Tanks for your reply.

I'm not in a production environnement. I'm using web2py with students as
teaching tools.

In fact, my database is sqlite. I'm running 2.12-3 version of web2py on a
linux machine. Python version is 2.7.10.






2016-02-10 21:46 GMT+01:00 Dave S :

>
>
> On Wednesday, February 10, 2016 at 11:53:27 AM UTC-8, Maelle Taurand wrote:
>>
>>
>> Hy,
>>
>> I want to make  unit test with web2py.
>>
>> I follow this page :
>> https://pythonhosted.org/web2py_utils/test_runner.html.
>>
>> Is Web2py Test Runner  always a good way for unittesting ?
>>
>>
>> After  running execute_tests.py, i have got thie result and an error
>> (logged in report file)
>>
>>
> Is your database using sqlite?  (That's the "out of the box" web2py
> configuration, but locking issues vs concurrency make it less desirable as
> a production database)..  You should also tell us what version of web2py,
> what python version, and what OS.  If you're running on one of the Windows
> OS platforms, then your python version may be the one bundled with web2py.
>
> /dps
>
>
>
>>
>>
>>
>>
>>
>>
>>
>>
>> *Result : self.assertEquals(self.nbP+1,
>> len(self.db().select(self.db.person.id)))AssertionError: 2 != 1*It seems
>> the insert was not performed ?
>>
>>
>> ERROR: test_ajoutPerson (web2py_utils.test_runner.TestAjoutPerson)
>> --
>> Traceback (most recent call last):
>>   File "xx/web2py/applications/app1/tests/manage.py", line 28, in
>> test_ajoutPerson
>> res = self.env['ajoutPerson']("titi")
>>   File "xx/web2py/applications/app1/controllers/manage.py", line 24,
>> in ajoutPerson
>> db.person.insert(name=name)
>>   File "xx/web2py/gluon/packages/dal/pydal/objects.py", line 712, in
>> insert
>> ret = self._db._adapter.insert(self, self._listify(fields))
>>   File "xxweb2py/gluon/packages/dal/pydal/adapters/base.py", line
>> 739, in insert
>> raise e
>> OperationalError: database is locked
>>
>>
>>
>>
>> Thanks for help,
>>
>>
>> Here is the controller's function i want to test.
>>
>> **
>> controller : manage.py
>>
>> def formAjoutPerson():
>> form=SQLFORM(db.person)  # person is a table that contains one field
>> named 'name'
>>
>> if form.validate():
>>
>> name=form.vars.name
>>
>> mess=ajoutPerson(name)
>> response.flash = mess
>>
>> elif form.errors :
>> response.flash='error in the form'
>>
>> return locals()
>>
>> def ajoutPerson(name):
>>
>> # the libelle must be unique
>> rows = db(db.person.name == name).select(db.person.id)
>>
>> if len(rows) == 0:
>> db.person.insert(name=name)
>> mess = 'new person added'
>> else:
>> mess = 'Error : name already exists
>> return mess
>>
>>
>>
>>
>> **
>> Here is the test
>>
>> class TestAjoutPerson(unittest.TestCase):
>>
>>def setUp(self):
>>   self.env = new_env(app='app1', controller='manage')
>>   self.db = copy_db(self.env, db_name='db', db_link='sqlite:memory')
>>
>>
>>
>>   self.db.person.insert(name="toto")
>>   self.db.commit()
>>
>>   rows=self.db().select(self.db.person.id)
>>   self.nbP=len(rows)
>>
>># Test method
>>def test_ajoutPerson(self):
>>
>>  res = self.env['ajoutPerson']("titi")
>>  self.db.commit()
>>  self.assertEquals("new person added", res)
>>
>>  #TEST
>>  self.assertEquals(self.nbP+1, len(self.db().select(self.db.person.id
>> )))
>>
>>
>>
>> suite = unittest.TestSuite() # define a group of unit tests
>> suite.addTest(unittest.makeSuite(TestAjoutTest)) #add to the suite test
>> class
>>
>> unittest.TextTestRunner(verbosity=2).run(suite)
>>
>> **
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Mr2UepU4_hI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: [web2py] Re: python Script

2016-02-11 Thread Yoel Benitez Fonseca
also [1]:

...
python web2py.py -S app -M -R applications/app/private/myscript.py -A a b c

where -S app tells web2py to run "myscript.py" as "app", -M tells
web2py to execute models, and -A a b c passes optional command line
arguments sys.argv=['applications/app/private/myscript.py','a','b','c']
to "myscript.py".
...

I have used this method for complex data migrations.

[1] 
http://web2py.com/books/default/chapter/29/04/the-core#Running-tasks-in-the-background

2016-02-10 18:42 GMT-05:00, Dave S :
> On Wednesday, February 10, 2016 at 2:01:52 PM UTC-8, snehalash...@gmail.com
>
> wrote:
>>
>> can we write the python script inweb2py
>>
>
> There are 2 answers to this.  Web2Py depends on a Python installation.  (In
>
> Windows, it's own copy is packaged with Web2py).  You can run ordinary
> Python scripts in that Python enviornment.  But also, Web2Py provides an
> "application-aware" shell enviornment  for running scripts, which can also
> run ordinary Python scripts or it can be used to run scripts that know
> about your application's models and modules.
>
> For a more complete description of this, Chapters 1 and 3 of the book are
> good places to start; Chapter 2 provides a quick introduction to Python.
> http://web2py.com/books/default/chapter/29/01/introduction>
>
> /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.
>


-- 
Yoel Benítez Fonseca
http://redevil.cubava.cu/
$ python -c "import this"

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


[web2py] Re: web2py Italy

2016-02-11 Thread Francesco Ronzitti
Sarebbe bello fossimo nella lista...
http://www.web2py.com/examples/default/usergroups

Un saluto a tutti i Devel Ita

Il giorno mercoledì 18 dicembre 2013 20:57:17 UTC+1, Gael Princivalle ha 
scritto:
>
> Comunque direi che per ovvi motivi il web2py-users rimane lo strumento 
> principale per porre domande. A noi users italiani di fare comunità e di 
> mettere in web2py-it quello che ci sembra congruo per darci uno strumento 
> complementare.
>
>
>

-- 
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: markmin.js

2016-02-11 Thread Massimo Di Pierro
For basic thinks like **bold**, ''italic'', ``code``, it is the same. But 
the python version does not support embedded html. The JS version does not 
support tables and nested lists. The python version uses the format [[label 
http:// image]] while the JS version uses the format image:http:// 
(same for video and audio and frames). The JS version does not support 
``...``:class_name.

I like the JS version because it is cleaner and faster and if something is 
nor supported one can use html.



On Thursday, 11 February 2016 03:26:11 UTC-6, Niphlod wrote:
>
> what is not 100% compatible ? if we want to push this, we should promote 
> it instead of relying on python code
>
> On Thursday, February 11, 2016 at 4:55:19 AM UTC+1, Massimo Di Pierro 
> wrote:
>>
>> and the link:
>>
>> https://github.com/mdipierro/markmin.js
>>
>> On Wednesday, 10 February 2016 21:55:06 UTC-6, Massimo Di Pierro wrote:
>>>
>>> I have a new version of markmin.js I recommend this over the python 
>>> implementation. It is better to render on the client because oembed does 
>>> not require setting up server side caching. The JS version allows sanitized 
>>> HTML. Also the heavy lifting is moved to the client. It is not 100% 
>>> compatible but very close. 
>>>
>>

-- 
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: markmin.js

2016-02-11 Thread Niphlod
hardly 99%  it's another markmin version entirely :°°°D

On Thursday, February 11, 2016 at 3:48:49 PM UTC+1, Massimo Di Pierro wrote:
>
> For basic thinks like **bold**, ''italic'', ``code``, it is the same. But 
> the python version does not support embedded html. The JS version does not 
> support tables and nested lists. The python version uses the format [[label 
> http:// image]] while the JS version uses the format image:http:// 
> (same for video and audio and frames). The JS version does not support 
> ``...``:class_name.
>
> I like the JS version because it is cleaner and faster and if something is 
> nor supported one can use html.
>
>
>
> On Thursday, 11 February 2016 03:26:11 UTC-6, Niphlod wrote:
>>
>> what is not 100% compatible ? if we want to push this, we should promote 
>> it instead of relying on python code
>>
>> On Thursday, February 11, 2016 at 4:55:19 AM UTC+1, Massimo Di Pierro 
>> wrote:
>>>
>>> and the link:
>>>
>>> https://github.com/mdipierro/markmin.js
>>>
>>> On Wednesday, 10 February 2016 21:55:06 UTC-6, Massimo Di Pierro wrote:

 I have a new version of markmin.js I recommend this over the python 
 implementation. It is better to render on the client because oembed does 
 not require setting up server side caching. The JS version allows 
 sanitized 
 HTML. Also the heavy lifting is moved to the client. It is not 100% 
 compatible but very close. 

>>>

-- 
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: markmin.js

2016-02-11 Thread Ron Chatterjee
So, how do we go about using it? May be an example can be posted using the 
forum app in appliance? 

On Thursday, February 11, 2016 at 10:02:42 AM UTC-5, Niphlod wrote:
>
> hardly 99%  it's another markmin version entirely :°°°D
>
> On Thursday, February 11, 2016 at 3:48:49 PM UTC+1, Massimo Di Pierro 
> wrote:
>>
>> For basic thinks like **bold**, ''italic'', ``code``, it is the same. But 
>> the python version does not support embedded html. The JS version does not 
>> support tables and nested lists. The python version uses the format [[label 
>> http:// image]] while the JS version uses the format image:http:// 
>> (same for video and audio and frames). The JS version does not support 
>> ``...``:class_name.
>>
>> I like the JS version because it is cleaner and faster and if something 
>> is nor supported one can use html.
>>
>>
>>
>> On Thursday, 11 February 2016 03:26:11 UTC-6, Niphlod wrote:
>>>
>>> what is not 100% compatible ? if we want to push this, we should promote 
>>> it instead of relying on python code
>>>
>>> On Thursday, February 11, 2016 at 4:55:19 AM UTC+1, Massimo Di Pierro 
>>> wrote:

 and the link:

 https://github.com/mdipierro/markmin.js

 On Wednesday, 10 February 2016 21:55:06 UTC-6, Massimo Di Pierro wrote:
>
> I have a new version of markmin.js I recommend this over the python 
> implementation. It is better to render on the client because oembed does 
> not require setting up server side caching. The JS version allows 
> sanitized 
> HTML. Also the heavy lifting is moved to the client. It is not 100% 
> compatible but very close. 
>


-- 
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] alternative autocomplete widget

2016-02-11 Thread Carlos Cesar Caballero Díaz
Hi, right now I am working in a plugin with an autocomplete widget using 
typeahead.js:


https://github.com/daxslab/web2py-typeahead

Any clues, suggestions, recomendations etc... will be very welcomed.

Greetings.

--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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: Check to see if a field is in another table in a computed field

2016-02-11 Thread Anthony
On Wednesday, February 10, 2016 at 5:01:52 PM UTC-5, Greg White wrote:
>
> Want a computed field to show whether or not a field value exists in 
> another table
>
> started with this...
>
> db.define_table(
> 'inventory',
> Field('name'),
> Field('qty', label='Quantity'),
> Field('MatSize',label='Material Size'),
> format = '%(name)s') 
>
> db.define_table(
> 'POrequest',
> Field('name', 'reference requestor', label='Requestor'),
> Field('JobNum', 'reference jobs', label='Job #'),
> Field('description', 'text', notnull=True),
> Field('InInventory', compute=lambda r: r['description'] IN r[
> db.inventory.name]),  <<< this row right here is what I need help with
> format = '%(name)s')
>

compute=lambda r: not db(db.inventory.name == r.description).isempty() 

Anthony

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


[web2py] Re: Displalay a form in light box or pop up window in view

2016-02-11 Thread billmackalister
Thank you for your answer Massimo. When I implemented this. 

Apply To This Post

It shows me a button and then I get redirected to another page. I just 
wanted a pop up window open up with a form to submit that user can move 
around without being redirected to another page.





On Wednesday, February 10, 2016 at 10:51:11 PM UTC-5, Massimo Di Pierro 
wrote:
>
> I see you want a different window, not a modal.
>
> then you have to put the form logic in its own controller action and call 
> it from js
>
> click me
>
> On Wednesday, 10 February 2016 18:00:44 UTC-6, billmac...@gmail.com 
>  wrote:
>>
>> Thank you for the answer Massimo. I did this like you said to put the 
>> form in the body in index/popup.html however, it didn't pop up like the 
>> example in the link above. Instead I got it in the same browser. I am 
>> guessing my implementation is wrong.
>>
>> 
>>   
>> 
>>   
>> > aria-hidden="true">×
>> Modal title
>>   
>>   
>> 
>>   {{=form}}
>>   
>>   
>>   
>> > data-dismiss="modal">Close
>> Save 
>> changes
>>   
>> 
>>   
>> 
>>
>>
>>
>>
>> On Wednesday, February 10, 2016 at 5:06:28 PM UTC-5, Massimo Di Pierro 
>> wrote:
>>>
>>> Bootstrap3 has built-int modals: 
>>> https://nakupanda.github.io/bootstrap3-dialog/
>>> You can but {{=form}} in the body of the modal.
>>>
>>> On Tuesday, 9 February 2016 14:26:05 UTC-6, billmac...@gmail.com wrote:

 Hello, A new user migrating from Django to web2py and absolutely loving 
 it. A quick question. How do I use a light box or a pop up window to 
 display a form in my view?


 for example in default/index.html

 {{=form}}

 Want to show that form  in a pop up window.  

>>>

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


Re: [web2py] alternative autocomplete widget

2016-02-11 Thread Richard Vézina
Nice!

There is also semantic ui autocomplete that is worth to give a look at :
http://semantic-ui.com/modules/search.html

Though I like typeahead because it highlight which letters have been found
and where, but I it shouldn't be a requirement...

I would move to semantic in the long run...

I will try to give a try to your integration... I can share with you my
integration of bootstrap 2.3.2 typeahead but twitter typeahead is different
and the integration I did was mostly in javascript make use of callback and
server side feeding, you seem have proceed differently. But let me know if
you think it can bring you any clue.

Richard

On Thu, Feb 11, 2016 at 11:19 AM, Carlos Cesar Caballero Díaz <
desarro...@spicm.cfg.sld.cu> wrote:

> Hi, right now I am working in a plugin with an autocomplete widget using
> typeahead.js:
>
> https://github.com/daxslab/web2py-typeahead
>
> Any clues, suggestions, recomendations etc... will be very welcomed.
>
> Greetings.
>
> --
> Este mensaje le ha llegado mediante el servicio de correo electronico que
> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema
> Nacional de Salud. La persona que envia este correo asume el compromiso de
> usar el servicio a tales fines y cumplir con las regulaciones establecidas
>
> Infomed: http://www.sld.cu/
>
> --
> 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.
>

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


Re: [web2py] Re: ubuntu web2py

2016-02-11 Thread Mirek Zvolský
I am trying do the same on Debian 8 Jessie and have a question:
>From where do you have /etc/uwsgi/web2py.ini
I have no such file. From that reason your point (5) will fail for me.




Dne středa 10. února 2016 14:46:37 UTC+1 Jim S napsal(a):
>
> I got this working!
>
> Here is what I did.
>
> 1. Run the normal web2py installation script for nginx/ubuntu
> 2. sudo nano edit /etc/systemd/system/emperor.uwsgi.service
>
> Add these lines
> [Unit]
> Description = uWSGI Emperor
> After = syslog.target
>
>
> [Service]
> ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
> RuntimeDirectory = uwsgi
> Restart = always
> KillSignal = SIGQUIT
> Type = notify
> StandardError = syslog
> NotifyAccess = all
>
>
> [Install]
> WantedBy = multi-user.target
>
> 3. Exit and save the file
> 4. systemctl enable emperor.uwsgi.service
> 5. systemctl start emperor.uwsgi.service
>
> You should now be able to browse to http://localhost or https://localhost
>
> On restart of the system, this service will automatically start.
>
> Let me know if you have questions.
>
> -Jim
>
> Thanks niphlod for the pointers and encouragement...
>

-- 
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] input class="integer" interrupt

2016-02-11 Thread lucas
hey everyone,

so under the sqlform.custom.beginsqlform.custom.end with the view, and 
more specifically, under the sqlform.custom.widget of db type 'integer' 
where the widget is of class="integer" there is javascript/jQuery code 
attached to those inputs that only allow digits and the negative sign. 
 that is how i like it to work.

on top of that, i would like to add an onkeyup="jfunction()" that if a c 
key is pressed, it can call out to a javascript/jQuery function i place 
under the head block, grabs and passes that id of that widget, pulls up a 
side div in the left_sidebar, and then still runs the javascript/jQuery 
code that would normally run as if i didn't interrupt it in the first place 
without the onkeyup event.

how can i do that properly?  essentially, i want the side div that pops up 
to be a calculator type that can place its final value back in the original 
integer input that the c was typed in.  make sense?  thank you in advance, 
lucas

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


Re: [web2py] Re: ubuntu web2py

2016-02-11 Thread Mirek Zvolský
I have found the content for web2py.ini in web2py repository:
https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

...and it works - great !
http://81.2.244.50/welcome
Debian 8 Jessie, Forpsi virtual server 1G RAM (1 EUR/month, however maybe 
for IT,DE,UK,CZ customers only)




Dne čtvrtek 11. února 2016 18:45:46 UTC+1 Mirek Zvolský napsal(a):
>
> I am trying do the same on Debian 8 Jessie and have a question:
> From where do you have /etc/uwsgi/web2py.ini
> I have no such file. From that reason your point (5) will fail for me.
>
>
>
>
> Dne středa 10. února 2016 14:46:37 UTC+1 Jim S napsal(a):
>>
>> I got this working!
>>
>> Here is what I did.
>>
>> 1. Run the normal web2py installation script for nginx/ubuntu
>> 2. sudo nano edit /etc/systemd/system/emperor.uwsgi.service
>>
>> Add these lines
>> [Unit]
>> Description = uWSGI Emperor
>> After = syslog.target
>>
>>
>> [Service]
>> ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
>> RuntimeDirectory = uwsgi
>> Restart = always
>> KillSignal = SIGQUIT
>> Type = notify
>> StandardError = syslog
>> NotifyAccess = all
>>
>>
>> [Install]
>> WantedBy = multi-user.target
>>
>> 3. Exit and save the file
>> 4. systemctl enable emperor.uwsgi.service
>> 5. systemctl start emperor.uwsgi.service
>>
>> You should now be able to browse to http://localhost or https://localhost
>>
>> On restart of the system, this service will automatically start.
>>
>> Let me know if you have questions.
>>
>> -Jim
>>
>> Thanks niphlod for the pointers and encouragement...
>>
>

-- 
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][Off topic] Python 3.5 technology award

2016-02-11 Thread Richard


http://www.infoworld.com/article/3023050/open-source-tools/infoworlds-2016-technology-of-the-year-award-winners.html#slide18

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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: ubuntu web2py

2016-02-11 Thread Jim Steil
It gets created in the web2py/nginx/ubuntu install script.

-Jim

On Thu, Feb 11, 2016 at 11:45 AM, Mirek Zvolský  wrote:

> I am trying do the same on Debian 8 Jessie and have a question:
> From where do you have /etc/uwsgi/web2py.ini
> I have no such file. From that reason your point (5) will fail for me.
>
>
>
>
> Dne středa 10. února 2016 14:46:37 UTC+1 Jim S napsal(a):
>>
>> I got this working!
>>
>> Here is what I did.
>>
>> 1. Run the normal web2py installation script for nginx/ubuntu
>> 2. sudo nano edit /etc/systemd/system/emperor.uwsgi.service
>>
>> Add these lines
>> [Unit]
>> Description = uWSGI Emperor
>> After = syslog.target
>>
>>
>> [Service]
>> ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
>> RuntimeDirectory = uwsgi
>> Restart = always
>> KillSignal = SIGQUIT
>> Type = notify
>> StandardError = syslog
>> NotifyAccess = all
>>
>>
>> [Install]
>> WantedBy = multi-user.target
>>
>> 3. Exit and save the file
>> 4. systemctl enable emperor.uwsgi.service
>> 5. systemctl start emperor.uwsgi.service
>>
>> You should now be able to browse to http://localhost or https://localhost
>>
>> On restart of the system, this service will automatically start.
>>
>> Let me know if you have questions.
>>
>> -Jim
>>
>> Thanks niphlod for the pointers and encouragement...
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/ZM9IIEjtHSI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] alternative autocomplete widget

2016-02-11 Thread Carlos Cesar Caballero Díaz
Hi Richard, will be very good take a look to your solution, right now I 
have some javascript generated server side and I really want to remove 
it. Once the server side javascript is removed should be easy adapt the 
plugin to other technologies.


I have been watching semantic some time ago and I really like it, but 
unfortunately I work offline most of the time and is very difficult to 
use the semantic doc and tools... but in the future I would move to 
semantic too.


Greetings.


El 11/02/16 a las 12:07, Richard Vézina escribió:

Nice!

There is also semantic ui autocomplete that is worth to give a look at 
: http://semantic-ui.com/modules/search.html


Though I like typeahead because it highlight which letters have been 
found and where, but I it shouldn't be a requirement...


I would move to semantic in the long run...

I will try to give a try to your integration... I can share with you 
my integration of bootstrap 2.3.2 typeahead but twitter typeahead is 
different and the integration I did was mostly in javascript make use 
of callback and server side feeding, you seem have proceed 
differently. But let me know if you think it can bring you any clue.


Richard

On Thu, Feb 11, 2016 at 11:19 AM, Carlos Cesar Caballero Díaz 
mailto:desarro...@spicm.cfg.sld.cu>> wrote:


Hi, right now I am working in a plugin with an autocomplete widget
using typeahead.js:

https://github.com/daxslab/web2py-typeahead

Any clues, suggestions, recomendations etc... will be very welcomed.

Greetings.

--
Este mensaje le ha llegado mediante el servicio de correo
electronico que ofrece Infomed para respaldar el cumplimiento de
las misiones del Sistema Nacional de Salud. La persona que envia
este correo asume el compromiso de usar el servicio a tales fines
y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

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


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




--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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: input class="integer" interrupt

2016-02-11 Thread Niphlod
there's no callback available on web2py.js for it. either code your own 
widget or override event_handlers() in your own js appropriately.

On Thursday, February 11, 2016 at 6:55:16 PM UTC+1, lucas wrote:
>
> hey everyone,
>
> so under the sqlform.custom.beginsqlform.custom.end with the view, and 
> more specifically, under the sqlform.custom.widget of db type 'integer' 
> where the widget is of class="integer" there is javascript/jQuery code 
> attached to those inputs that only allow digits and the negative sign. 
>  that is how i like it to work.
>
> on top of that, i would like to add an onkeyup="jfunction()" that if a c 
> key is pressed, it can call out to a javascript/jQuery function i place 
> under the head block, grabs and passes that id of that widget, pulls up a 
> side div in the left_sidebar, and then still runs the javascript/jQuery 
> code that would normally run as if i didn't interrupt it in the first place 
> without the onkeyup event.
>
> how can i do that properly?  essentially, i want the side div that pops up 
> to be a calculator type that can place its final value back in the original 
> integer input that the c was typed in.  make sense?  thank you in advance, 
> lucas
>

-- 
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: background color of block sidebar

2016-02-11 Thread Ron Chatterjee
try this:


 {{block right_sidebar}}



some other content





{{end}}


and style it like this:


#side_color {
position: relative
top: 2px;
line-height:1px;
background-color:#ee;
height:3000px;
width:7000px;
float:left;
padding:1px; 
}


Should come pretty close to what you looking for


On Wednesday, February 10, 2016 at 5:01:52 PM UTC-5, rajjm...@gmail.com 
wrote:
>
> playing with blocks. 
>
> I have 
>
> {{block right_sidebar}}
>
> {{end}}
>
> I would like to set the background color different in the sidebar area 
> comparing my main page. Any help from the community?
>

-- 
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] Problems with Upload files

2016-02-11 Thread Alfonso Serra
Hey everyone.

Im having a hard time to import and process a csv file.

I would like to:
- upload the file, 
- let the user do some kind of preprocess, (map columns, and such).
- insert records.
- dispose the uploaded file.

Its a double post i gotta do, one to submit the file, and another for the 
user to process and commit the previously uploaded file. is it wise to 
place the file into the session? or is it better to just store the path to 
the uploaded file to handle it later?

This is the first form
form1 = SQLFORM.factory(
 Field("file", "upload", default="", uploadfolder = 
"applications/myapp/uploads", requires=[IS_NOT_EMPTY("Please select a file."
),
  IS_UPLOAD_FILENAME(error_message="Only csv files allowed", 
extension="[csv]", lastdot=True),
  IS_BINARY(False, "Binary files not allowed")]), ...

The problems im having are:
if i dont specify an upload folder i get an error.

 you must specify a 
Field(...,uploadfolder=...)
I wonder why the sqlform doesnt know where to store the file, it is no big 
deal, easy to solve but 

when the file is uploaded, an empty file gets created as 
"no_table.file.96474e907bab4168.6d657472696c792e637376.csv", which is ok 
but its empty.

So my question is, do i have to read the request.post_vars.file to save the 
content to that automatically created empty file?

The request.post_vars.file has a reference to, apparently, that file 
handler, but i cant save any content with that.

myfile = request.post_vars.file
content = myfile.file.read()
content = content.decode("iso-8859-1").encode("utf-8")
with myfile.fp as f:
f.write(content)

Does anyone know resources or care to explain how to upload files without 
db interaction?
The docs doesnt have much about these cases.

Thank you very much.



-- 
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: Displalay a form in light box or pop up window in view

2016-02-11 Thread Val K
Hi!
Here is my solution.  I have modal_wrapper function. In controller file, I 
have two controllers -  main_page and modal_content: 



def main_page():

main_pg=DIV()

m_cont = LOAD(f='*modal_content**.load*', ajax=True, ajax_trap=True  )  

dialog = modal_wrapper(m_cont, _id='*cont_id*', header='Header', 
footer='footer')

show_modal_btn = BUTTON( 'Show modal',
   _type="button",
   _class = "btn 
btn-default",
   _onclick=""" $('#
*cont_id*').modal('show')   """)

#don't forget to add dialog and show_modal_btn to main page
main_pg.append(show_modal_btn)   # or main_pg.append( DIV(show_modal_btn) 
 ) or something else
main_pg.append(dialog)

   return dict(main_pg = main_pg)




# keep in mind just one thing:
#   this controller is exposed by *.load, so it must return a dict of ONE 
element 
#   to return more than one element - wrap all in one DIV:
#   ret = DIV()
#   ret.append( ... ) 
#   ret.append( form )  
#  ret.append( ... )
#  return dict(ret = ret) 

def modal_content():

form = SQLFORM(...) # or even form = SQLFORM.grid(...)

return dict(form=form)



# means bootstrap 3
def modal_wrapper(content, _id, header='', footer=''):

main_wrap = DIV('',  _class="modal fade",  _role="dialog", _id=_id, 
_tabindex="-1" )
title_id = _id + '_title'
main_wrap['_aria-labelledby']=title_id

dialog_div=DIV('', _class="modal-dialog" , _role="document")
content_div=DIV('', _class="modal-content")
header_div = DIV( _class="modal-header")

close_cross = BUTTON(
SPAN(XML('×'), **{'_aria-hidden':"true"}),
_type="button",  _class="close",
 data={'dismiss':"modal"},
 **{'_aria-label':"Close"}
 )
title_h4 = H4( header,  _class="modal-title",  _id = title_id)
body_div = DIV( content, _class="modal-body")


close_btn = BUTTON('Close',  _type="button", _class="btn btn-default", 
data={'dismiss':"modal"})
footer_div =  DIV( footer, close_btn, _class="modal-footer")

# gluon all
main_wrap[0] = dialog_div
dialog_div[0] = content_div

header_div.append(close_cross)
header_div.append(title_h4)

[content_div.append(c) for c in (header_div, body_div, footer_div)]
return main_wrap








On Thursday, February 11, 2016 at 8:07:32 PM UTC+3, billmac...@gmail.com 
wrote:
>
> Thank you for your answer Massimo. When I implemented this. 
>
> Apply To This Post
>
> It shows me a button and then I get redirected to another page. I just 
> wanted a pop up window open up with a form to submit that user can move 
> around without being redirected to another page.
>
>
>
>
>
> On Wednesday, February 10, 2016 at 10:51:11 PM UTC-5, Massimo Di Pierro 
> wrote:
>>
>> I see you want a different window, not a modal.
>>
>> then you have to put the form logic in its own controller action and call 
>> it from js
>>
>> click 
>> me
>>
>> On Wednesday, 10 February 2016 18:00:44 UTC-6, billmac...@gmail.com 
>> wrote:
>>>
>>> Thank you for the answer Massimo. I did this like you said to put the 
>>> form in the body in index/popup.html however, it didn't pop up like the 
>>> example in the link above. Instead I got it in the same browser. I am 
>>> guessing my implementation is wrong.
>>>
>>> 
>>>   
>>> 
>>>   
>>> >> aria-hidden="true">×
>>> Modal title
>>>   
>>>   
>>> 
>>>   {{=form}}
>>>   
>>>   
>>>   
>>> >> data-dismiss="modal">Close
>>> Save 
>>> changes
>>>   
>>> 
>>>   
>>> 
>>>
>>>
>>>
>>>
>>> On Wednesday, February 10, 2016 at 5:06:28 PM UTC-5, Massimo Di Pierro 
>>> wrote:

 Bootstrap3 has built-int modals: 
 https://nakupanda.github.io/bootstrap3-dialog/
 You can but {{=form}} in the body of the modal.

 On Tuesday, 9 February 2016 14:26:05 UTC-6, billmac...@gmail.com wrote:
>
> Hello, A new user migrating from Django to web2py and absolutely 
> loving it. A quick question. How do I use a light box or a pop up window 
> to 
> display a form in my view?
>
>
> for example in default/index.html
>
> {{=form}}
>
> Want to show that form  in a pop up window.  
>


-- 
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: Displalay a form in light box or pop up window in view

2016-02-11 Thread billmackalister
Thank you! Works great.



On Thursday, February 11, 2016 at 4:27:22 PM UTC-5, Val K wrote:
>
> Hi!
> Here is my solution.  I have modal_wrapper function. In controller file, I 
> have two controllers -  main_page and modal_content: 
>
>
>
> def *main_page*():
>
> main_pg=DIV()
> 
> m_cont = LOAD(f='*modal_content**.load*', ajax=True, ajax_trap=True 
>  )  
>
> dialog = modal_wrapper(m_cont, _id='*cont_id*', header='Header', 
> footer='footer')
> 
> show_modal_btn = BUTTON( 'Show modal',
>_type="button",
>_class = "btn 
> btn-default",
>_onclick=""" $('#
> *cont_id*').modal('show')   """)
>
> #don't forget to add dialog and show_modal_btn to main page
> main_pg.append(show_modal_btn)   # or main_pg.append( DIV(show_modal_btn) 
>  ) or something else
> main_pg.append(dialog)
>
>return dict(main_pg = main_pg)
>
>
>
>
> # keep in mind just one thing:
> #   this controller is exposed by *.load, so it must return a dict of ONE 
> element 
> #   to return more than one element - wrap all in one DIV:
> #   ret = DIV()
> #   ret.append( ... ) 
> #   ret.append( form )  
> #  ret.append( ... )
> #  return dict(ret = ret) 
>
> def *modal_content*():
> 
> form = SQLFORM(...) # or even form = SQLFORM.grid(...)
>
> return dict(form=form)
>
>
>
> # means bootstrap 3
> def* modal_wrapper*(content, _id, header='', footer=''):
>
> main_wrap = DIV('',  _class="modal fade",  _role="dialog", _id=_id, 
> _tabindex="-1" )
> title_id = _id + '_title'
> main_wrap['_aria-labelledby']=title_id
>
> dialog_div=DIV('', _class="modal-dialog" , _role="document")
> content_div=DIV('', _class="modal-content")
> header_div = DIV( _class="modal-header")
>
> close_cross = BUTTON(
> SPAN(XML('×'), **{'_aria-hidden':"true"}),
> _type="button",  _class="close",
>  data={'dismiss':"modal"},
>  **{'_aria-label':"Close"}
>  )
> title_h4 = H4( header,  _class="modal-title",  _id = title_id)
> body_div = DIV( content, _class="modal-body")
>
>
> close_btn = BUTTON('Close',  _type="button", _class="btn btn-default", 
> data={'dismiss':"modal"})
> footer_div =  DIV( footer, close_btn, _class="modal-footer")
>
> # gluon all
> main_wrap[0] = dialog_div
> dialog_div[0] = content_div
>
> header_div.append(close_cross)
> header_div.append(title_h4)
>
> [content_div.append(c) for c in (header_div, body_div, footer_div)]
> return main_wrap
>
>
>
>
>
>
>
>
> On Thursday, February 11, 2016 at 8:07:32 PM UTC+3, billmac...@gmail.com 
> wrote:
>>
>> Thank you for your answer Massimo. When I implemented this. 
>>
>> Apply To This Post
>>
>> It shows me a button and then I get redirected to another page. I just 
>> wanted a pop up window open up with a form to submit that user can move 
>> around without being redirected to another page.
>>
>>
>>
>>
>>
>> On Wednesday, February 10, 2016 at 10:51:11 PM UTC-5, Massimo Di Pierro 
>> wrote:
>>>
>>> I see you want a different window, not a modal.
>>>
>>> then you have to put the form logic in its own controller action and 
>>> call it from js
>>>
>>> click 
>>> me
>>>
>>> On Wednesday, 10 February 2016 18:00:44 UTC-6, billmac...@gmail.com 
>>> wrote:

 Thank you for the answer Massimo. I did this like you said to put the 
 form in the body in index/popup.html however, it didn't pop up like the 
 example in the link above. Instead I got it in the same browser. I am 
 guessing my implementation is wrong.

 
   
 
   
 >>> aria-hidden="true">×
 Modal title
   
   
 
   {{=form}}
   
   
   
 >>> data-dismiss="modal">Close
 Save 
 changes
   
 
   
 




 On Wednesday, February 10, 2016 at 5:06:28 PM UTC-5, Massimo Di Pierro 
 wrote:
>
> Bootstrap3 has built-int modals: 
> https://nakupanda.github.io/bootstrap3-dialog/
> You can but {{=form}} in the body of the modal.
>
> On Tuesday, 9 February 2016 14:26:05 UTC-6, billmac...@gmail.com 
> wrote:
>>
>> Hello, A new user migrating from Django to web2py and absolutely 
>> loving it. A quick question. How do I use a light box or a pop up window 
>> to 
>> display a form in my view?
>>
>>
>> for example in default/index.html
>>
>> {{=form}}
>>
>> Want to show that form  in a pop up window.  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Rep

[web2py] Re: Problems with Upload files

2016-02-11 Thread Alfonso Serra
Ok the first mistake ive made
file.seek(0) returns None so file.seek(0).read() doesnt make sense.

-- 
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: Check to see if a field is in another table in a computed field

2016-02-11 Thread Greg White
I should have mentioned that I tried IS_IN_DB first off and it didn't work

On Wednesday, February 10, 2016 at 4:25:48 PM UTC-7, Dave S wrote:
>
>
>
> On Wednesday, February 10, 2016 at 2:01:52 PM UTC-8, Greg White wrote:
>>
>> Want a computed field to show whether or not a field value exists in 
>> another table
>>
>
>
> I'm not sure that is the right approach.  I think that the standard 
> validator IS_IN_DB() is what you want, instead.
>
>  http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
> >
> (IS_IN_DB is the second validator in that section)
>
> The example shown appears to be similar to what I think you're trying to 
> do.
>
> /dps
>
>
>> started with this...
>>
>> db.define_table(
>> 'inventory',
>> Field('name'),
>> Field('qty', label='Quantity'),
>> Field('MatSize',label='Material Size'),
>> format = '%(name)s') 
>>
>> db.define_table(
>> 'POrequest',
>> Field('name', 'reference requestor', label='Requestor'),
>> Field('JobNum', 'reference jobs', label='Job #'),
>> Field('description', 'text', notnull=True),
>> Field('InInventory', compute=lambda r: r['description'] IN r[
>> db.inventory.name]),  <<< this row right here is what I need help with
>> format = '%(name)s')
>>
>> trying to verify row by row in a computed field if 
>> db.POrequest.description is in any row of db.inventory.name
>>
>> help 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Problems with Upload files

2016-02-11 Thread Val K
1. If you specify uploadfolder, it must be absolute path - something like 
os.path.join(request.folder, 'path_relative_to_your_app')
2. To store file I use like this:
   dst = open('your_file_absolute_name', 'wb')
   shutil.copyfileobj(form.vars.file, dst)
   dst.close()

  it works


On Friday, February 12, 2016 at 1:51:33 AM UTC+3, Alfonso Serra wrote:
>
> Ok the first mistake ive made
> file.seek(0) returns None so file.seek(0).read() doesnt make sense.
>
>

-- 
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: Problems with Upload files

2016-02-11 Thread Alfonso Serra
Hi val thanks for your answer.

Althought as you said, an absolute path is safer, a relative path as i have 
in the field form, looks like it works.

I got that part covered with:
filename = form1.vars.csvfile
file = request.post_vars.csvfile.file
file.seek(0) #something is consuming the file so i gotta rewind
content = file.read()
dest = os.path.join(os.path.abspath("."), uploadfolder)
dest = os.path.join(dest, filename)
   
with open(dest, "wb") as f:
f.write(content)

idk why but form.vars.myfile is storing only the filename of the 
automatically created file inside the upload folder.
Im reading the submitted file from request.post_vars and using 
form.vars.myfile to store the content manually.


>>

-- 
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: Rows not releasing all the memory back

2016-02-11 Thread Alfonso Serra
You can try "del rows" to remove the reference from memory before 
collecting 
del a single row raises a TypeError but del rows doesnt. It may 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: Check to see if a field is in another table in a computed field

2016-02-11 Thread Anthony
What are you trying to do? Do you want to store this information in the 
POrequest table, or do you want to prevent inserts if the item is not in 
the db.inventory table? If the latter, IS_IN_DB will certainly work, but 
note that validators only get run if you are using SQLFORM or if you call 
.validate_and_insert().

Anthony

On Thursday, February 11, 2016 at 6:02:16 PM UTC-5, Greg White wrote:
>
> I should have mentioned that I tried IS_IN_DB first off and it didn't work
>
> On Wednesday, February 10, 2016 at 4:25:48 PM UTC-7, Dave S wrote:
>>
>>
>>
>> On Wednesday, February 10, 2016 at 2:01:52 PM UTC-8, Greg White wrote:
>>>
>>> Want a computed field to show whether or not a field value exists in 
>>> another table
>>>
>>
>>
>> I'm not sure that is the right approach.  I think that the standard 
>> validator IS_IN_DB() is what you want, instead.
>>
>> > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
>> >
>> (IS_IN_DB is the second validator in that section)
>>
>> The example shown appears to be similar to what I think you're trying to 
>> do.
>>
>> /dps
>>
>>
>>> started with this...
>>>
>>> db.define_table(
>>> 'inventory',
>>> Field('name'),
>>> Field('qty', label='Quantity'),
>>> Field('MatSize',label='Material Size'),
>>> format = '%(name)s') 
>>>
>>> db.define_table(
>>> 'POrequest',
>>> Field('name', 'reference requestor', label='Requestor'),
>>> Field('JobNum', 'reference jobs', label='Job #'),
>>> Field('description', 'text', notnull=True),
>>> Field('InInventory', compute=lambda r: r['description'] IN r[
>>> db.inventory.name]),  <<< this row right here is what I need help with
>>> format = '%(name)s')
>>>
>>> trying to verify row by row in a computed field if 
>>> db.POrequest.description is in any row of db.inventory.name
>>>
>>> help 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to set default country in dropdown list

2016-02-11 Thread Winter Kryz


I created a module Countries.py with all the country names, imported into 
my model db.py and 

 Field ('countries', requires = IS_IN_SET(COUNTRIES), default='United 
States'),

then when I go to execute it, I get the following error

 (1025, "Error on rename of 
'./Kryz@0024db_egressum_we2py/#sql-3348_193e111' to 
'./Kryz@0024db_egressum_we2py/Person' (errno: 150)") 

What am I doing wrong?



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


Re: [web2py] Re: form.accepts fails with 'links' browser

2016-02-11 Thread /dev/sdc3

OK.  Is it useful for me to submit a patch?

Browser, BTW, is text-mode links: latest version, but doesn't see
a lot of development.

-mg


On Sun, Feb 07, 2016 at 07:43:17AM -0800, Anthony wrote:
> In fact, wrapping in the div with display:none may not be necessary anyway 
> -- I think that itself was probably just a hack to deal with very old 
> browsers in which hidden fields took up some space in the display.
> 
> Anthony
> 
> On Sunday, February 7, 2016 at 10:37:51 AM UTC-5, Anthony wrote:
> >
> > Are you using an old browser? I don't think this is a problem in modern 
> > browsers.
> >
> > Anthony
> >
> > On Sunday, February 7, 2016 at 12:32:03 AM UTC-5, ..mg.. wrote:
> >>
> >> Hi! 
> >>
> >> I'm trying to run a simple web2py (2.13.4-stable) form from links 
> >> (2.8/2.12), 
> >> and I've found a strange bug. 
> >>
> >> web2py's form.accepts is failing because the formkey and formname fields 
> >> aren't being submitted.  links isn't submitting those fields because 
> >> web2py is wrapping them in a . 
> >>
> >> Replacing my line 2183 in gluon/html.py, in FORM.hidden_fields: 
> >>
> >> return DIV(c, _style="display:none;") 
> >>
> >> with 
> >>
> >> return DIV(c) 
> >>
> >> fixes the problem for me. 
> >>
> >> I'm wondering:  what's the reason behind the "display: none;" there?  I 
> >> can understand the browser not submitting them on security concerns, but 
> >> I'm ignorant of what the specs say about this corner case. 
> >>
> >> Best, 
> >>
> >> -mg 
> >>   
> >>
> >
> 
> -- 
> 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.

-- 
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: Displalay a form in light box or pop up window in view

2016-02-11 Thread Val K
LOAD() works like URL(), so,  to pass args/vars to modal_content you could 
write
m_cont = LOAD(f='*modal_content**.load*', *args=[ ],  vars={ }*,   
ajax=True, ajax_trap=True  )  # see LOAD in web2py book

in modal_content controller there is nothing new, everything is as usual  
def modal_content():
   arg_0 = request.args(0)
   a = request.vars.a

  

On Friday, February 12, 2016 at 1:16:35 AM UTC+3, billmac...@gmail.com 
wrote:
>
> Thank you! Val  and the app works great.
>
> One question:
>
> Instead of controller, I have the button displayed in the view as:
>
> {{=BUTTON( 'Apply',_type="button",_class = "btn 
> btn-default",_style="background-color:green;background-image:none",_onclick="""
>  
> $('#cont_id').modal('show')   """ )}}
>
> It works, however, I need to pass an argument to my controller 
> "modal_content". How do I  pass a request.args(0) from my view to the 
> controller in above? Just like I would do 
>
>   onclick='window.open("{{=URL("*modal_content*",args=something.id)}}", 
> "mywindow");'>Apply
>
>
> Since I don't see the URL or callback to the javascript. Thanks in advance.
>
>
> On Thursday, February 11, 2016 at 4:27:22 PM UTC-5, Val K wrote:
>>
>> Hi!
>> Here is my solution.  I have modal_wrapper function. In controller file, 
>> I have two controllers -  main_page and modal_content: 
>>
>>
>>
>> def *main_page*():
>>
>> main_pg=DIV()
>> 
>> m_cont = LOAD(f='*modal_content**.load*', ajax=True, ajax_trap=True 
>>  )  
>>
>> dialog = modal_wrapper(m_cont, _id='*cont_id*', header='Header', 
>> footer='footer')
>> 
>> show_modal_btn = BUTTON( 'Show modal',
>>_type="button",
>>_class = "btn 
>> btn-default",
>>_onclick=""" $('#
>> *cont_id*').modal('show')   """)
>>
>> #don't forget to add dialog and show_modal_btn to main page
>> main_pg.append(show_modal_btn)   # or main_pg.append( 
>> DIV(show_modal_btn) 
>>  ) or something else
>> main_pg.append(dialog)
>>
>>return dict(main_pg = main_pg)
>>
>>
>>
>>
>> # keep in mind just one thing:
>> #   this controller is exposed by *.load, so it must return a dict of ONE 
>> element 
>> #   to return more than one element - wrap all in one DIV:
>> #   ret = DIV()
>> #   ret.append( ... ) 
>> #   ret.append( form )  
>> #  ret.append( ... )
>> #  return dict(ret = ret) 
>>
>> def *modal_content*():
>> 
>> form = SQLFORM(...) # or even form = SQLFORM.grid(...)
>>
>> return dict(form=form)
>>
>>
>>
>> # means bootstrap 3
>> def* modal_wrapper*(content, _id, header='', footer=''):
>>
>> main_wrap = DIV('',  _class="modal fade",  _role="dialog", _id=_id, 
>> _tabindex="-1" )
>> title_id = _id + '_title'
>> main_wrap['_aria-labelledby']=title_id
>>
>> dialog_div=DIV('', _class="modal-dialog" , _role="document")
>> content_div=DIV('', _class="modal-content")
>> header_div = DIV( _class="modal-header")
>>
>> close_cross = BUTTON(
>> SPAN(XML('×'), **{'_aria-hidden':"true"}),
>> _type="button",  _class="close",
>>  data={'dismiss':"modal"},
>>  **{'_aria-label':"Close"}
>>  )
>> title_h4 = H4( header,  _class="modal-title",  _id = title_id)
>> body_div = DIV( content, _class="modal-body")
>>
>>
>> close_btn = BUTTON('Close',  _type="button", _class="btn 
>> btn-default", data={'dismiss':"modal"})
>> footer_div =  DIV( footer, close_btn, _class="modal-footer")
>>
>> # gluon all
>> main_wrap[0] = dialog_div
>> dialog_div[0] = content_div
>>
>> header_div.append(close_cross)
>> header_div.append(title_h4)
>>
>> [content_div.append(c) for c in (header_div, body_div, footer_div)]
>> return main_wrap
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, February 11, 2016 at 8:07:32 PM UTC+3, billmac...@gmail.com 
>> wrote:
>>>
>>> Thank you for your answer Massimo. When I implemented this. 
>>>
>>> Apply To This Post
>>>
>>> It shows me a button and then I get redirected to another page. I just 
>>> wanted a pop up window open up with a form to submit that user can move 
>>> around without being redirected to another page.
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, February 10, 2016 at 10:51:11 PM UTC-5, Massimo Di Pierro 
>>> wrote:

 I see you want a different window, not a modal.

 then you have to put the form logic in its own controller action and 
 call it from js

 click 
 me

 On Wednesday, 10 February 2016 18:00:44 UTC-6, billmac...@gmail.com 
 wrote:
>
> Thank you for the answer Massimo. I did this like you said to put the 
> form in the body in index/popup.html however, it didn't pop up like the 
> example in the link above. Instead I got it in the same browser. I am 
> guessing my impl

[web2py] Re: Problems with Upload files

2016-02-11 Thread Val K

I think you haven't from.process()
form=SQLFORM()  # or SQLFORM.factory   - just  makes a set of 
html-like-component (set of DIV(), INPUT() and so on)
form.process() - filters and fills form with request.vars, does validation 
 and so on



On Friday, February 12, 2016 at 2:50:14 AM UTC+3, Alfonso Serra wrote:
>
> Hi val thanks for your answer.
>
> Althought as you said, an absolute path is safer, a relative path as i 
> have in the field form, looks like it works.
>
> I got that part covered with:
> filename = form1.vars.csvfile
> file = request.post_vars.csvfile.file
> file.seek(0) #something is consuming the file so i gotta rewind
> content = file.read()
> dest = os.path.join(os.path.abspath("."), uploadfolder)
> dest = os.path.join(dest, filename)
>
> with open(dest, "wb") as f:
> f.write(content)
>
> idk why but form.vars.myfile is storing only the filename of the 
> automatically created file inside the upload folder.
> Im reading the submitted file from request.post_vars.csvfile and using 
> form.vars.myfile to store the content manually.
>
>
>>>

-- 
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: Rows not releasing all the memory back

2016-02-11 Thread Jitun John
I am using to remove rows...

for row in alerts_rows.exclude(lambda row: row.id > 0):
pass


On Friday, February 12, 2016 at 5:49:38 AM UTC+5:30, Alfonso Serra wrote:
>
> You can try "del rows" to remove the reference from memory before 
> collecting 
> del a single row raises a TypeError but del rows doesnt. It may 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: Problems with Upload files

2016-02-11 Thread Alfonso Serra
Thats not the issue. Sry i didnt post the whole declaration but yes im 
calling process.

This is the declaration
form = SQLFORM.factory( fields...).process(formname = "form1")

The problem was the IS_BINARY validator which was consuming the file before 
it got saved. If i remove it the file is stored properly.

Its a bit embarrasing but thanks for the answers.

Still, is there a way to set a default upload folder for factory fields?

Thanks

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