Re: [web2py] How to read image in blob format from a existing db

2021-05-18 Thread Chris
I could do it with pydal but with sqlite3 library worked perfect. Is maybe a 
pydal bug ?

Cheers.

--
Sent from Canary (https://canarymail.io)

> On martes, may. 18, 2021 at 1:59 p. m., Chris  (mailto:chriiisti...@gmail.com)> wrote:
> Data is already in binary in db.
>
>
>
> Making more test when pydal retrieve the blob data from the db is only 
> getting just a part of the information.
>
> When in print the rows after the select i get a small sample like this:
>
> images = cherry_db(cherry_db.image.node_id == 
> i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)
>
> for m in images:
> print(m['png’])
>
>
> b'<\xd1\x88\x1c4l\x04\x84\xce 0\x13\xc6\x01\r\xdd\xd0'
>
>
> Cheers
>
> --
> Sent from Canary (https://canarymail.io)
>
> > On martes, may. 18, 2021 at 1:51 p. m., Kevin Keller  > (mailto:keller...@gmail.com)> wrote:
> > I think you have to convert the image file to binary data before saving tad 
> > blob etc..?
> >
> > https://pynative.com/python-mysql-blob-insert-retrieve-file-image-as-a-blob-in-mysql/
> >
> >
> >
> > On Tue, May 18, 2021, 19:04 Chris  > (mailto:chriiisti...@gmail.com)> wrote:
> > > Hi, i’m trying to read images from a existing sqlite db. For some reason 
> > > when i save the images to disk, they are corrupted.
> > > this is my code:
> > >
> > > cherry_db = DAL('sqlite://{}'.format(form.vars.cherry_file), 
> > > folder=upload_folder, migrate=False)
> > >
> > > cherry_db.define_table('image',
> > > Field('node_id', 'integer', requires=IS_NOT_EMPTY()),
> > > Field('png', 'blob')
> > > )
> > >
> > >
> > > images = cherry_db(cherry_db.image.node_id == 
> > > i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)
> > >
> > > for m in images:
> > > name = str(uuid.uuid4())
> > > print('image {}'.format(name))
> > > print(m['png'])
> > > im = open('{}'.format(session.project_folder+'/'+name+'.png'), 'wb')
> > > im.write(m['png'])
> > > im.close()
> > >
> > >
> > >
> > > Any help is appreciated
> > >
> > > Cheers.
> > > Chris.
> > >
> > > --
> > > Sent from Canary (https://canarymail.io)
> > >
> > > --
> > > 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 
> > > (mailto:web2py+unsubscr...@googlegroups.com).
> > > To view this discussion on the web visit 
> > > https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary
> > >  
> > > (https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary?utm_medium=email_source=footer).
> > --
> > 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 
> > (mailto:web2py+unsubscr...@googlegroups.com).
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/web2py/CADHCKLTUpqY99R9qfcgvJ7Thi9263LSbtD2XJx6NjEym-kLQgQ%40mail.gmail.com
> >  
> > (https://groups.google.com/d/msgid/web2py/CADHCKLTUpqY99R9qfcgvJ7Thi9263LSbtD2XJx6NjEym-kLQgQ%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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/3f7419fc-a9e0-4ca6-b031-dd2839be2ca4%40Canary.


Re: [web2py] How to read image in blob format from a existing db

2021-05-18 Thread Chris
Data is already in binary in db.

Making more test when pydal retrieve the blob data from the db is only getting 
just a part of the information.

When in print the rows after the select i get a small sample like this:

images = cherry_db(cherry_db.image.node_id == 
i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)

for m in images:
print(m['png’])

b'<\xd1\x88\x1c4l\x04\x84\xce 0\x13\xc6\x01\r\xdd\xd0'

Cheers

--
Sent from Canary (https://canarymail.io)

> On martes, may. 18, 2021 at 1:51 p. m., Kevin Keller  (mailto:keller...@gmail.com)> wrote:
> I think you have to convert the image file to binary data before saving tad 
> blob etc..?
>
> https://pynative.com/python-mysql-blob-insert-retrieve-file-image-as-a-blob-in-mysql/
>
>
>
> On Tue, May 18, 2021, 19:04 Chris  (mailto:chriiisti...@gmail.com)> wrote:
> > Hi, i’m trying to read images from a existing sqlite db. For some reason 
> > when i save the images to disk, they are corrupted.
> > this is my code:
> >
> > cherry_db = DAL('sqlite://{}'.format(form.vars.cherry_file), 
> > folder=upload_folder, migrate=False)
> >
> > cherry_db.define_table('image',
> > Field('node_id', 'integer', requires=IS_NOT_EMPTY()),
> > Field('png', 'blob')
> > )
> >
> >
> > images = cherry_db(cherry_db.image.node_id == 
> > i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)
> >
> > for m in images:
> > name = str(uuid.uuid4())
> > print('image {}'.format(name))
> > print(m['png'])
> > im = open('{}'.format(session.project_folder+'/'+name+'.png'), 'wb')
> > im.write(m['png'])
> > im.close()
> >
> >
> >
> > Any help is appreciated
> >
> > Cheers.
> > Chris.
> >
> > --
> > Sent from Canary (https://canarymail.io)
> >
> > --
> > 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 
> > (mailto:web2py+unsubscr...@googlegroups.com).
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary
> >  
> > (https://groups.google.com/d/msgid/web2py/30b99d7b-941c-4387-80cd-9f521399af82%40Canary?utm_medium=email_source=footer).
> --
> 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 
> (mailto:web2py+unsubscr...@googlegroups.com).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/CADHCKLTUpqY99R9qfcgvJ7Thi9263LSbtD2XJx6NjEym-kLQgQ%40mail.gmail.com
>  
> (https://groups.google.com/d/msgid/web2py/CADHCKLTUpqY99R9qfcgvJ7Thi9263LSbtD2XJx6NjEym-kLQgQ%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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/b627c3b9-0527-4124-8a57-f47ff511c427%40Canary.


[web2py] How to read image in blob format from a existing db

2021-05-18 Thread Chris
Hi, i’m trying to read images from a existing sqlite db. For some reason when i 
save the images to disk, they are corrupted.
this is my code:

cherry_db = DAL('sqlite://{}'.format(form.vars.cherry_file), 
folder=upload_folder, migrate=False)

cherry_db.define_table('image',
Field('node_id', 'integer', requires=IS_NOT_EMPTY()),
Field('png', 'blob')
)

images = cherry_db(cherry_db.image.node_id == 
i['node_id']).select(cherry_db.image.node_id, cherry_db.image.png)

for m in images:
name = str(uuid.uuid4())
print('image {}'.format(name))
print(m['png'])
im = open('{}'.format(session.project_folder+'/'+name+'.png'), 'wb')
im.write(m['png'])
im.close()

Any help is appreciated

Cheers.
Chris.

--
Sent from Canary (https://canarymail.io)

-- 
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/30b99d7b-941c-4387-80cd-9f521399af82%40Canary.


Re: [web2py] string validation

2021-05-12 Thread Chris
Hi, i don’t know a specific way to do that but maybe the following can help.

You can create a function which delete/disable the account with if some url 
patterns are found in first name and last name

In your models add this function:

def _valid_user(s, i):
# i —> contains the user id
# s —> contains a dictionary with the user information

if any(c in s.first_name for c in ['www', 'http', 'https', '%', '/', '.']):
print('spammer user')
print('dissabling account’)

elif any(c in s.last_name for c in ['www', 'http', 'https', '%', '/', '.']):
print('spammer user')
print('dissabling account')

And this after auth declaration:

db.auth_user._after_insert.append(_valid_user)

Or maybe declaring manually the auth table with a custom validator, but I'm not 
sure if is possible…

Cheers.
Chris.

--
Sent from Canary (https://canarymail.io)

> On miércoles, may. 12, 2021 at 3:21 a. m., Manuele  (mailto:manuele.pese...@gmail.com)> wrote:
> Hi!
>
> I have a quite specific question... can anyone help me to implement a
> validator that reject all text containing a URL inside?
>
> Some spammers are annoying me registering some fake account introducing
> links in registration fields such like first name, last name... I hope
> in this way to limit it. Adding Google reCaptcha v2 to the registration
> forms didn't help.
>
> Thanks a lot
>
> Manuele
>
> --
> 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/92075f49-9036-2e9e-28d1-e045f699413d%40gmail.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/9ed7b2ab-e887-48f2-96b3-1cef066db7b4%40Canary.


Re: [web2py] web2py 2.21.1 is OUT

2020-12-10 Thread Chris
Thanks for this new release!

Web2py is something really great!

A big thanks to all the team behind of the preoject.

Cheers.
Chris.

--

> On sábado, nov. 28, 2020 at 1:22 a. m., Massimo Di Pierro 
> mailto:massimo.dipie...@gmail.com)> wrote:
>
> Hello everybody,
>
> first of all my apologies to you all. I have been absent from this list for 
> some time, mostly because busy with py4web.
>
> I made a new release (2.21.1) of web2py which includes mostly small bug fixes 
> but no new features. Please report any problem.
>
> At this point web2py has been stable for long time so we are not planning to 
> add features.
>
> py4web on the other side is growing fast. It now has Auth, 
> internationalization, Form, Grid and it is 20x faster than wb2py. pyDAL woks 
> the in the same way as in web2py. I insist you should check it out and 
> consider moving you code. It is easy and we will help.
>
> Massimo
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to web2py+unsubscr...@googlegroups.com 
> (mailto:web2py+unsubscr...@googlegroups.com).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/3db686af-90dc-4864-891a-fe7050cf40c7n%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/web2py/3db686af-90dc-4864-891a-fe7050cf40c7n%40googlegroups.com?utm_medium=email_source=footer).

-- 
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/cb61188f-0a3b-4ec8-9ca6-9502a2cadc8a%40Canary.


Re: [web2py] Hosting my web2py application

2020-10-27 Thread Chris
Hi, you can check the install script of waf2py and get the part where the 
apache server is installed with web2py. you may need to adjust the paths.
This is for a debian system

https://github.com/ITSec-Chile/Waf2Py/blob/master/installer/waf2py_installer.sh

—
Cheers.
Chris.

> On martes, oct. 27, 2020 at 12:44 p. m., mostwanted  (mailto:godirao...@gmail.com)> wrote:
> How do I setup a private home server to host my web2py application? What do i 
> need & how do i put it together? If anyone has done it before please share 
> the process or direct me to where I can find the information.
>
> Regards;
>
> Mostwanted
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to web2py+unsubscr...@googlegroups.com 
> (mailto:web2py+unsubscr...@googlegroups.com).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/6d1e2e29-a423-43d2-b9fe-1e6cae251f26n%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/web2py/6d1e2e29-a423-43d2-b9fe-1e6cae251f26n%40googlegroups.com?utm_medium=email_source=footer).

-- 
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/dbf16672-4ddb-4b8f-ba4d-083b1abb8cf9%40Canary.


signature.asc
Description: PGP signature


Re: [web2py] Re: How to reject request based on location

2020-10-27 Thread Chris
Hi, here you have some examples:

Web server level

Here there is examples about how to deny an IP and network ranges in nginx, if 
you can modify the nginx.conf file then is easy.
https://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/

At OS level.
If you have control of IP tables you can do it there also.
This is how to block an entire subnet:

# iptables -A INPUT -s 192.168.100.0/24 -j DROP

Application level:

In your model (db.py) add the following at the beginning:
Example with multiples ip ranges

if IS_IPV4(minip=('192.168.20.19', '192.168.30.100'),maxip=('192.168.20.19', 
'192.168.30.199'))(request['env']['REMOTE_ADDR'])[1] == None:
raise HTTP(403)

--
Cheers.
Chris.

> On martes, oct. 27, 2020 at 2:45 p. m., Eliezer (Vlad) Tseytkin 
> mailto:westgate6...@gmail.com)> wrote:
> I see... Could you please give me a hint on where to find how to accomplish 
> this in nginx? (I use PythonAnywhere)
> On Tue, Oct 27, 2020 at 1:15 AM valq...@gmail.com (mailto:valq...@gmail.com) 
> mailto:valq7...@gmail.com)> wrote:
> > It is better to do this at front server like nginx, Apache or even at 
> > os-level. In web2py, models files are processed for each request, so you 
> > can just raise HTTP at db.py
> >
> > вторник, 27 октября 2020 г. в 04:52:57 UTC+3, Vlad:
> > > I've discovered that my site is constantly bothered by weird locations - 
> > > not that there is anything intrinsically wrong with those countries, but 
> > > those locations have nothing to do with actual customers. I want to 
> > > reject the requests from those locations altogether.
> > >
> > > I can reject any specific page in controller code, but how do I reject 
> > > ANY request altogether, without coding it into multiple places? --
> > 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/af2Ct41wEE0/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to 
> > web2py+unsubscr...@googlegroups.com 
> > (mailto:web2py+unsubscr...@googlegroups.com).
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/web2py/36ef2c26-b63f-48f1-b032-51f4774171c6n%40googlegroups.com
> >  
> > (https://groups.google.com/d/msgid/web2py/36ef2c26-b63f-48f1-b032-51f4774171c6n%40googlegroups.com?utm_medium=email_source=footer).
> --
> 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 
> (mailto:web2py+unsubscr...@googlegroups.com).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/CABZ%2BKCCmiak3RNNqhWxDmy0YCuutZS5z3FU9QbQLUnDCcBO91w%40mail.gmail.com
>  
> (https://groups.google.com/d/msgid/web2py/CABZ%2BKCCmiak3RNNqhWxDmy0YCuutZS5z3FU9QbQLUnDCcBO91w%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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/7d747bbc-1bc2-4161-81a3-684c39da7886%40Canary.


signature.asc
Description: PGP signature


[web2py] Multiples requieres in SQLFORM

2018-10-22 Thread Chris V.
Hello list,

I need to have 2 requires in the same field, one requires must be a select 
multiple, but also it can be a different value of initial select multiple, 
this because in the view the select multiple values are changed with 
javascript .

It is possible to make something like the following?: 
Field("Grado", default=grados_roca[2],* requires=IS_NOT_EMPTY() 
OR IS_IN_SET(range(2, (len(grados_roca) + 1)), grados_roca)), ??*

And if is possible, how could I make this ?


I tryied with this but i had no lucky:
Field("Grado", default=grados_roca[2], requires=[IS_NOT_EMPTY(), 
IS_IN_SET(range(2, (len(grados_roca) + 1)), grados_roca))]),

this is my sql form:

SQLFORM.factory(Field("nombre_ruta", requires=IS_NOT_EMPTY()),
   Field("Modalidad", 
default=modalidades[1],requires=IS_IN_SET(modalidades)),
   Field("Tipo", 
default='Monolargo', requires=IS_IN_SET(tipo)),
   Field("Grado", 
default=grados_roca[2], requires=IS_IN_SET(range(2, (len(grados_roca) + 
1)), grados_roca)),
   Field("Largos", default="3",

 requires=IS_IN_SET(range(1, 51))),
   Field("Zona", 
default=zonas_list[0],

 requires=IS_IN_SET(zonas_list, zonas_list_name)),
   Field("Observacion", 'text', 
length=300,
 default='No se han 
registrado observaciones', label="Observaciones"),
   _name="agregar_ruta",
       submit_button="Agregar",
   )


Cheers!
Chris.

-- 
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: Exporting a table to csv

2018-09-04 Thread Chris Insinger
Hi Dave, 

You’re right, I’m using python3. I thought it might be related to that so 
yesterday I added an issue on the github site for the book:

https://github.com/web2py/web2py-book/issues/393

If that’s the wrong place/way please let me know. 

Regards,
Chris

Sent from my iPhone

>> On 5 Sep 2018, at 7:21 AM, Dave S  wrote:
>> 
>> On Monday, September 3, 2018 at 10:31:25 PM UTC-7, Chris_I wrote:
>> Hi there,
>> 
>> Found a way to solve it, and thought I'd share in case others search on this 
>> topic.
>> 
>> Replace the str(...) below with str(...).encode(), so that it looks like 
>> this:
>> 
>> open('test.csv', 'wb').write(str(db(db.student).select()).encode())
>> 
>> Regards,
>> 
>> Chris
> 
> Are you using Python3?  While web2py itself has been updated to work with 
> Python3, the examples in the book are still assuming Python2 (2.7 or later).  
> It's perhaps time to add a warning to that effect in the book.
> 
> /dps
> 
>  
>> 
>>> On Monday, 3 September 2018 22:53:11 UTC+8, Chris_I wrote:
>>> Hello All,
>>> 
>>> Just started learning web2py a few days ago, and am really enjoying it!
>>> 
>>> Working through the chapter on DAL in the Book, I noticed I got an error 
>>> when doing this:
>>> 
>>> open('test.csv', 'wb').write(str(db(db.student).select()))
>>> 
>>> The message I get is:
>>> 
>>> TypeError: a bytes-like object is required, not 'str'
>>> 
>>> 
>>> 
>>> It occurs in:
>>> 
>>> 
>>> 
>>> File "mypath/web2py/gluon/packages/dal/pydal/base.py", line 844, in 
>>> export_to_csv_file
>>> 
>>> 
>>> ofile.write('TABLE %s\r\n' % table)
>>> 
>>> 
>>> 
>>> 
>>> 
>>> The select() returns 5 perfectly normal-looking rows.
>>> 
>>> 
>>> 
>>> Am I overlooking something obvious?
>>> 
>>> 
>>> 
>>> Thanks,
>>> 
>>> 
>>> 
>>> Chris
>>> 
> 
> -- 
> 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] Violating Unique constraint in field doesn't go to standard 500 page

2017-06-29 Thread Chris
Hello!

I'm running 2.14.6-stable+timestamp.2016.05.10.00.21.47 and have hit this 
issue:

If I have a Field where unique=True, inserting a row with a duplicate Field 
value triggers the constraint, as expected. However, the error does not 
lead to a page linking to a ticket, but instead to a generic page saying 
Server Error.

I've traced the error down to this section of globals.py:

@property
def body(self):
if self._body is None:
try:
self._body = copystream_progress(self)
except IOError:
raise HTTP(400, "Bad Request - HTTP body is incomplete")
return self._body


The error thrown by copystream_progress is of type , and seems to occur because of a timeout opening 
env['wsgi.input'] (globals.py, copystream_progress)

I haven't been able to trace the error further, but here's the Rocket 
output to stderr:


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

  File "\dynamic\gluon\rocket.py", line 1337, in run
self.run_app(conn)

  File "\dynamic\gluon\rocket.py", line 1838, in run_app
output = self.app(environ, self.start_response)

  File "\dynamic\gluon\main.py", line 653, in app_with_logging
ret[0] = wsgiapp(environ, responder2)

  File "\dynamic\gluon\main.py", line 564, in wsgibase
return wsgibase(new_environ, responder)

  File "\dynamic\gluon\main.py", line 534, in wsgibase
if request.body:

  File "\dynamic\gluon\globals.py", line 281, in body
raise HTTP(400, "Bad Request - HTTP body is incomplete")

HTTP: 400 BAD REQUEST

Any help you can give would be most welcome!

-- 
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: Using validate_and_insert with a computed field

2017-04-21 Thread Chris
Many thanks Anthony!

That looks like it will work for now...I may specifically handle call that 
code just before validate_and_insert calls in the web app, so I don't get 
rid of readURL validation in a place where I need it.

On Friday, April 21, 2017 at 4:46:51 PM UTC-4, Anthony wrote:
>
> Thanks. I updated the Github issue, as there are multiple problems with 
> the current implementation of the .validate_and_ methods.
>
> For now, you should be able to get around the two issues you observe by 
> removing the validators:
>
> db.story.titleAsSlug.requires = db.story.readURL.requires = None
>
> You can probably permanently set the titleAsSlug requires to None, as it 
> will not appear in forms anyway. The default readURL validator, on the 
> other hand, may be needed if you intend to allow inserts/updates directly 
> via SQLFORM.process().
>
> The problem is that the default validator assigned to titleAsSlug 
> transforms None to '', and the default validator for readURL transforms 
> None to 'None'. These values then get inserted in the record.
>
> Anthony
>
> On Friday, April 21, 2017 at 9:48:53 AM UTC-4, Chris wrote:
>>
>> Can do, here's an example:
>>
>> # DB
>>
>> db.define_table('story',
>> Field('title',
>>   length=512,
>>   widget=lambda field, value: SQLFORM.widgets.string.widget(field
>> ,
>> value,
>> _size=40),
>>   requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=1, maxsize=512)]),
>> Field('titleAsSlug',
>>   compute=lambda(r): urls.convert_to_slug(r['title'])),
>> Field('readURL', unique=True, label=T('URL'), required=False,
>>   widget=lambda field, value:
>>   SQLFORM.widgets.string.widget(field,
>> value,
>> _size=60,
>> _placeholder='
>> http://www.example.com')),
>> )
>>
>> # Test
>>
>> class TestModels(unittest.TestCase):
>> def testStoryNewCreate(self):
>> dct_new_story = {
>>  "title": "Unit Test"}
>> new_story = db.story.validate_and_insert(**dct_new_story)
>> self.assertFalse(new_story["errors"], "Error inserting a new 
>> story: " + str(new_story)) 
>>
>> The readURL field generates an error that the entry is found in the 
>> database. Unique=True is a DB constraint according to the web2py manual and 
>> NULLs in PostgreSQL and SQL in general don't violate the unique constraint. 
>> Web2py attaches an IS_NOT_IN_DB validator that converts None to "None" 
>> instead of null, which only works until there is a row with a readURL of 
>> 'None'.
>> The titleAsSlug field is set to an empty string by the validator, which 
>> is perhaps why validate_and_insert doesn't compute it where insert does.
>>
>> Hope that's helpful, thanks for anything you can do here!
>>
>>
>> On Thursday, April 20, 2017 at 11:05:02 PM UTC-4, Anthony wrote:
>>>
>>> Need to see the fields.
>>
>>

-- 
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: Using validate_and_insert with a computed field

2017-04-21 Thread Chris
Can do, here's an example:
# DB

db.define_table('story',
Field('title',
  length=512,
  widget=lambda field, value: SQLFORM.widgets.string.widget(field,
value,
_size=40),
  requires=[IS_NOT_EMPTY(), IS_LENGTH(minsize=1, maxsize=512)]),
Field('titleAsSlug',
  compute=lambda(r): urls.convert_to_slug(r['title'])),
Field('readURL', unique=True, label=T('URL'), required=False,
  widget=lambda field, value:
  SQLFORM.widgets.string.widget(field,
value,
_size=60,
_placeholder=
'http://www.example.com')),
)

# Test

class TestModels(unittest.TestCase):
def testStoryNewCreate(self):
dct_new_story = {
 "title": "Unit Test"}
new_story = db.story.validate_and_insert(**dct_new_story)
self.assertFalse(new_story["errors"], "Error inserting a new story: 
" + str(new_story)) 

The readURL field generates an error that the entry is found in the 
database. Unique=True is a DB constraint according to the web2py manual and 
NULLs in PostgreSQL and SQL in general don't violate the unique constraint. 
Web2py attaches an IS_NOT_IN_DB validator that converts None to "None" 
instead of null, which only works until there is a row entitled 'None'.
The titleAsSlug field is set to an empty string by the validator, which is 
perhaps why validate_and_insert doesn't compute it where insert does.


On Thursday, April 20, 2017 at 11:05:02 PM UTC-4, Anthony wrote:
>
> Need to see the fields.

-- 
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: Using validate_and_insert with a computed field

2017-04-20 Thread Chris
Thanks for the update!

I'm passing all of the fields needed by the compute function. It looks 
something like this:

dct_new_user = { fields here }
# new_user = db.auth_user.insert(**dct_new_user)
new_user = db.auth_user.validate_and_insert(**dct_new_user)

The former calculates the computed field, but the latter does not.

On Thursday, April 20, 2017 at 7:57:12 PM UTC-4, Anthony wrote:
>
> I'm not sure if this is the cause of your problem, but I just posted an 
> issue: https://github.com/web2py/pydal/issues/462
>
> Anthony
>
> On Thursday, April 20, 2017 at 10:30:14 AM UTC-4, Anthony wrote:
>>
>> On Wednesday, April 19, 2017 at 7:50:46 PM UTC-4, Chris wrote:
>>>
>>> Uh oh...I just removed requires from the computed field and reran my 
>>> unit tests, and now validate_and_insert inserts but the computed field 
>>> isn't calculated at all! I tried insert and it does the computation.
>>>
>>> Is there some reason validate_and_insert would not compute where insert 
>>> does?
>>>
>>
>> The computed field will not get a value if any of the fields needed by 
>> the compute function are missing. Also, I notice that when 
>> .validate_and_insert() is called, if any of the fields are set to None, 
>> they end up getting dropped before being passed to .insert() (this should 
>> probably be considered a bug). So, if you are setting a field needed by the 
>> compute function to None, then that would cause the compute to fail. If 
>> that's not your situation, then you'll have to show more code to diagnose 
>> the problem.
>>
>> 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.


Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-19 Thread Chris
Uh oh...I just removed requires from the computed field and reran my unit 
tests, and now validate_and_insert inserts but the computed field isn't 
calculated at all! I tried insert and it does the computation.

Is there some reason validate_and_insert would not compute where insert 
does?


On Wednesday, April 19, 2017 at 7:27:45 PM UTC-4, Chris wrote:
>
> I looked it up:
>
> Notice that requires=... is enforced at the level of forms, required=True 
>> is enforced at the level of the DAL (insert), while notnull, unique and 
>> ondelete are enforced at the level of the database. While they sometimes 
>> may seem redundant, it is important to maintain the distinction when 
>> programming with the DAL.
>>
>
>  The mix of form, DAL and database level validation threw me off, but I 
> think I get it now. requires= would be checked before any DAL logic. I'll 
> remove the logic from the computed field. Hopefully it should be populated 
> for all future values. Thanks!
>
> On Tuesday, April 18, 2017 at 7:08:39 PM UTC-4, Anthony wrote:
>>
>> On Tuesday, April 18, 2017 at 5:41:38 PM UTC-4, Chris wrote:
>>>
>>> Thanks for the info Anthony! I'll try one of those approaches.
>>>
>>> Why is validation run before compute?
>>>
>>
>> In terms of implementation, compute is handled in the .insert() method, 
>> which must necessarily run after validation. I suppose we could add code to 
>> calculate computed values before validation in the .validate_and_ methods, 
>> but I don't think that really makes sense. Computed fields should not need 
>> to be validated, as they are in control of generating their own values. You 
>> should instead validate the inputs to the computed field.
>>
>> 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.


Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-19 Thread Chris
I looked it up:

Notice that requires=... is enforced at the level of forms, required=True 
> is enforced at the level of the DAL (insert), while notnull, unique and 
> ondelete are enforced at the level of the database. While they sometimes 
> may seem redundant, it is important to maintain the distinction when 
> programming with the DAL.
>

 The mix of form, DAL and database level validation threw me off, but I 
think I get it now. requires= would be checked before any DAL logic. I'll 
remove the logic from the computed field. Hopefully it should be populated 
for all future values. Thanks!

On Tuesday, April 18, 2017 at 7:08:39 PM UTC-4, Anthony wrote:
>
> On Tuesday, April 18, 2017 at 5:41:38 PM UTC-4, Chris wrote:
>>
>> Thanks for the info Anthony! I'll try one of those approaches.
>>
>> Why is validation run before compute?
>>
>
> In terms of implementation, compute is handled in the .insert() method, 
> which must necessarily run after validation. I suppose we could add code to 
> calculate computed values before validation in the .validate_and_ methods, 
> but I don't think that really makes sense. Computed fields should not need 
> to be validated, as they are in control of generating their own values. You 
> should instead validate the inputs to the computed field.
>
> 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] Using validate_and_insert with a computed field

2017-04-17 Thread Chris
Hello,

I've got a users table with a computed field:

db.define_table(
auth.settings.table_user_name,
[...]
Field('calculated_field', requires=IS_NOT_EMPTY(),
  compute=lambda(r): calculate_field(r)),

And a bit of code that uses validate_and_insert() to insert a row:

dct_new_user = {...}

new_user = db.auth_user.validate_and_insert(**dct_new_user)

This code always fails, returning 


Is this a bug? If not, what should I do to get around it?

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.


[web2py] MySQL / Web2py datetime issue

2017-02-20 Thread Chris Dodson
I have a manually built the MySQL table and then use migrate=False in 
Web2py.  I can enter hours use the add_to_table function passing in the 
table_name, the work_date_start and work_date_end show up in this form as 
the datetime picker.  I can choose from this and add the info into the 
table, as they show up correctly in MySQL.  When I try to view the data in 
show_table function these two dates show up as None.  The timestamp field 
time_added_to_table does show the datetime correctly in a format like 
'2017-02-10 19:37:35'.  Any ideas?

Below are the descriptions of MySQL and the Web2py info used.

I manually build tables in MySQL, here's the table using describe 
billable_hours;
+-+-+--+-+---++
| Field   | Type| Null | Key | Default   | 
Extra  |
+-+-+--+-+---++
| id  | bigint(20)  | NO   | PRI | NULL  | 
auto_increment |
| time_added_to_table | timestamp   | NO   | | CURRENT_TIMESTAMP 
||
| work_date_start | datetime(6) | YES  | | NULL  
||
| work_date_end   | datetime(6) | YES  | | NULL  
||
| work_details| text| YES  | | NULL  
||
| customer_id | bigint(20)  | YES  | MUL | NULL  
||
| billing_state_id| bigint(20)  | YES  | MUL | NULL  
||
+-+-+--+-+---++
7 rows in set (0.00 sec)

Here's the web2py info in my_models.py:
-
db.define_table('billing_notes', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('note', 'string'),  
format='%(note)s', migrate=False)

db.define_table('customers', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('customer', 'string'),  
format='%(customer)s', migrate=False)

db.define_table('billing_states', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('billing_state', 'string'),  
format='%(billing_state)s', migrate=False)

db.define_table('billable_hours', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('work_date_start', 'datetime'), 
Field('work_date_end', 'datetime'), Field('work_details', 'text'), 
Field('customer_id', db.customers, requires=IS_IN_DB(db, "customers.id", 
"%(customer)s")), Field('billing_state_id', db.billing_states, 
requires=IS_IN_DB(db, "billing_states.id", "%(billing_state)s")),  
format='%(work_date_start)s', migrate=False)
---
My controller in default.py is:
def add_to_table():
   table_name=request.vars['tname']
   form = SQLFORM(db[table_name])
   if form.process().accepted:
   response.flash = 'form accepted'
   elif form.errors:
   response.flash = 'form has errors'
   else:
   response.flash = 'please fill out the form'
   return dict(form=form)

def show_table():
# shows the table's data
table_name=request.vars['tname']
response.flash=table_name
q=db[table_name]['id']>0
s=db(q)
rows=s.select()
#print(rows)
return dict(rows=rows


---
Thanks!
cd

-- 
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: Not seeing logging.error messages in nginx error_log

2016-05-04 Thread Chris Guest
Hi DaveS,

So to clarify when I used mod_wsgi & apache I used to get logging.error 
messages saved into my apache error.log .
Now that I use uwsgi & nginx this doesn't happen.
I am not sure what your answer means as I am not familiar with what a 
logging.conf file is. I cannot find a logging.conf file in either 
/etc/uwsgi /etc/nginx or under my web2py instance.
I am not particularly trying to consolidate logs - I am not seeing these 
messages in any log. 

Thanks,
Chris

-- 
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] Not seeing logging.error messages in nginx error_log

2016-05-04 Thread Chris Guest
Not seeing logging.error in nginx error_log


I have a mostly successful install of web2py application with uwsgi and 
nginx on centos using setup-web2py-nginx-uwsgi-centos70.sh .

But I can't figure out how to configure nginx, uwsgi and wsgihandler.py so 
that logging.error messages appear in the error_log file. 
I have been able to configure it so that nginx [notice] and [info] messages 
appear but these are generated by nginx itself and are not coming from 
logging.notice or logging.info calls in the web2py application. 
 
Can someone post a recipe as to how this is done?

Thanks,
Chris

-- 
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] IP tables commands in setup-web2py-nginx-uwsgi-centos64.sh

2015-12-28 Thread Chris Guest
I've been looking at the script, setup-web2py-nginx-uwsgi-centos64.sh .
Towards the end of it, are these two commands:
/etc/init.d/iptables stop
chkconfig --del iptables

Why is it necessary to stop iptables and then remove all run level symlinks 
under /etc/rc[0-6].d ?




-- 
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] Changing Bootstrap Navbar to light background colour

2015-12-02 Thread Chris Guest
I recently needed to modify the stock Bootstrap CSS so that the Navbar had 
a light colour,  #fafafb .

I added the following to  static/css/web2py-bootstrap3.css . I just thought 
that I would share it here in case is useful for others.


.navbar-default{
background-color:#fafafb;
border-color:#fafafb;
}

.navbar-inner {
background-color:#fafafb; 
border-color:#fafafb;
background-repeat: no-repeat;
filter: none;
}

.navbar .nav > li > a {
color: #3e3f3a;
}
.navbar .nav > li > a:active, .navbar .nav > li > a:hover {
color: #808285; 
}

-- 
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: Changing Bootstrap Navbar to light background colour

2015-12-02 Thread Chris Guest
I didn't remove any classes from  static/css/bootstrap.min.css 
or static/css/bootstrap-theme.min.css .
I only added code to static/css/web2py-bootstrap3.css .
If there's a simpler way to do this, please let me know.


On Thursday, December 3, 2015 at 11:33:11 AM UTC+11, Leonel Câmara wrote:
>
> Did you remove the navbar-inverse class? That's what makes it black.
>

-- 
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] How to start a web2py application on another ser

2015-10-01 Thread Chris Andrew
Hi guys,
I currently have two systems that have web2py installed on them.
System 1 has app1 installed on web2py and System 2 has app2 installed.
Is it possible for me to call functions of app2 which is on System 2 using 
app1 which is on System1?
They are both connected to my home network.
Thank you in advance.

-- 
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] How to include session data in error tickets

2015-09-29 Thread Chris
Hello,

I put this function in my controller to test error handling:

def error():
raise Exception("I am a test error.")

When I go to /error, I get an error ticket, as expected, but that error 
doesn't include any data, just the traceback. I seem to recall a few years 
back that tickets would include helpful things like the current session 
state, variables being passed to each function, etc. but now I almost never 
see that information.

Did something change in web2py? I feel like this should be obvious but I'm 
at a loss for where to look.

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.


[web2py] "Module proxy_http does not exist!" can't start Web2py

2015-09-07 Thread Chris Armour
Hello,

I want to use web2py for a Raspberry Pi project, but when I try to install 
the framework I get:

setting up apache modules
=
Module ssl already enabled
Module proxy already enabled
ERROR: /etc/apache2/mods-enabled/proxy_http.load is a dangling symlink!
ERROR: Module proxy_http does not exist!
Module headers already enabled
Module expires already enabled
Module wsgi already enabled
Module rewrite already enabled

Does anyone have any idea what the solution is to this? I have tried 
deleting the symlink file "/etc/apache2/mods-enabled/proxy_http.load" and 
that doesn't help. Is there some way to load the proxy_http module?

I've tried rerunning the install a few times with the same result. 

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.


[web2py] Does web2py support reCAPTCHA v2?

2015-07-25 Thread Chris
I recently got an email notifying me that Google is upgrading its captcha 
to the new no CAPTCHA version. Does web2py support that by default? I 
tried searching in the mailing list but couldn't find the right keywords. 
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.


[web2py] Re: Using datatables and web2py

2015-07-12 Thread Chris Guest
Hi Mirek,

On Thursday, July 2, 2015 at 9:52:44 PM UTC+10, Mirek Zvolský wrote:

 I have not such error in your jsfiddle.
 What about to give console.log(column) after if (column) {


I have changed my web2py page to this:

 if (column) {

 console.log(

 i + ': ' + column.style + ': ' + 
 column.visible()

 );

 if (column.style===undefined)

 column.style = '';

 column.visible( ! column.visible() );

 console.log(

 i + ': ' + column.style + ': ' + 
 column.visible()

 );

 }


I am now seeing this in the console: 

 a.toggle-vis click event
 0: undefined: true
 0: : false
 1: undefined: true
 1: : false


Chris 


 Dne čtvrtek 2. července 2015 3:46:23 UTC+2 Chris Guest napsal(a):

 I have a very wide html table. I want to selectively hide groups of 
 columns at a time using a list of a.
 Someone suggested using Datatables.net. So I have developed a proof of 
 concept and all looks well.

 http://jsfiddle.net/ChrisGuest/orgj7oL9/

 Now when I drop this code into a web2py as below, I end up with wrong 
 behaviour and seeing this error in the JS Console:

 a.toggle-vis click event
 0: : false
 1: : false
 a.toggle-vis click event
 0: : false
 1: : false
 a.toggle-vis click event
 0: : false
 1: : false
 a.toggle-vis click event
 *Uncaught TypeError: Cannot read property 'style' of undefined*


 I suspected that this could be caused by a conflict between DataTables.js 
 and another JavaScript module so I went through  commented them all out 
 except for jquery.js .
 Unfortunately the problems still persists. 
 I have documented how I use DataTables.js with web2py. I am wondering if 
 I've missed something important here. I'd be curious if anyone else could 
 get this to go.

 Thanks,
 Chris


 I have modified layout.html to include:

 link rel=stylesheet href=
 https://cdn.datatables.net/1.10.7/css/jquery.dataTables.css; /
 script src='
 https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js' 
  /script


 view/batch/demo.html ( see http://jsfiddle.net/ChrisGuest/orgj7oL9/ for 
 complete table code).

 {{extend 'layout.html'}}
 
 h1Results/h1
 
 ul.../ul
 table id=batch_table
 ...
 /table
 
 script
 
 $(document).ready(function() {
 var table = $('#batch_table').DataTable( {
 scrollY: 200px,
 paging: false
 } );
 
 $('a.toggle-vis').on('click', function (e) {
 e.preventDefault();
 
 console.log('a.toggle-vis click event');
 // Get the column API object
 var data_columns =  $(this).attr('data-column');
 if (data_columns.length) {
 var data_columns = data_columns.split(',');
 for (var i=0; idata_columns.length; i++) { 
 var column = table.column(data_columns[i]);   
  
 if (column) {
 if (column.style===undefined)
 column.style = '';
 column.visible( ! column.visible() );
 console.log(
 i + ': ' + column.style + ': ' + 
 column.visible()
 );
 }
 }
 }
  
 });
 
 });
 
 /script



-- 
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] Using datatables and web2py

2015-07-01 Thread Chris Guest
I have a very wide html table. I want to selectively hide groups of columns 
at a time using a list of a.
Someone suggested using Datatables.net. So I have developed a proof of 
concept and all looks well.

http://jsfiddle.net/ChrisGuest/orgj7oL9/

Now when I drop this code into a web2py as below, I end up with wrong 
behaviour and seeing this error in the JS Console:

a.toggle-vis click event
0: : false
1: : false
a.toggle-vis click event
0: : false
1: : false
a.toggle-vis click event
0: : false
1: : false
a.toggle-vis click event
*Uncaught TypeError: Cannot read property 'style' of undefined*


I suspected that this could be caused by a conflict between DataTables.js 
and another JavaScript module so I went through  commented them all out 
except for jquery.js .
Unfortunately the problems still persists. 
I have documented how I use DataTables.js with web2py. I am wondering if 
I've missed something important here. I'd be curious if anyone else could 
get this to go.

Thanks,
Chris


I have modified layout.html to include:

link rel=stylesheet 
href=https://cdn.datatables.net/1.10.7/css/jquery.dataTables.css; /
script src='https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js' 
 /script


view/batch/demo.html ( see http://jsfiddle.net/ChrisGuest/orgj7oL9/ for 
complete table code).

{{extend 'layout.html'}}

h1Results/h1

ul.../ul
table id=batch_table
...
/table

script

$(document).ready(function() {
var table = $('#batch_table').DataTable( {
scrollY: 200px,
paging: false
} );

$('a.toggle-vis').on('click', function (e) {
e.preventDefault();

console.log('a.toggle-vis click event');
// Get the column API object
var data_columns =  $(this).attr('data-column');
if (data_columns.length) {
var data_columns = data_columns.split(',');
for (var i=0; idata_columns.length; i++) { 
var column = table.column(data_columns[i]);
if (column) {
if (column.style===undefined)
column.style = '';
column.visible( ! column.visible() );
console.log(
i + ': ' + column.style + ': ' + 
column.visible()
);
}
}
}
 
});

});

/script

-- 
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: Caching Logic in web2py

2015-05-04 Thread Chris Modzelewski
Awesome! Thank you very much for this explanation!

All the best,
Chris

On Tuesday, April 28, 2015 at 6:22:49 PM UTC-4, Leonel Câmara wrote:

 This one:

 A. Does the cached object get updated:

 The cached object is updated immediately because it's the same object. 
 Cache ram does not clone it. Notice that the behaviour will be different if 
 you're using cache disk.

 Do know that doing this is a very bad idea, as you will run into all sorts 
 of thread safety problems. You should consider cached values immutable if 
 you don't want to worry about safety yourself.


 And finally, if I wish to force a changed value of some_object to be saved 
 to the cache, am I correct that I should then call:
 some_object.arg3 = 
 some_object = cache.ram(self.id_attribute, lambda self, time=0)


 This will force the change, but, again, if it's the same object the change 
 will already be there.

  Does this mean that the next time someone instantiates an object of 
 class SomeClass with the same arg1 value but a different time_expire 
 value, the cached object will be overwritten?

 It will be overwritten if the cached value has a timestamp that is expired 
 with the given time_expire value. 
   


 I think that maybe your problem is that you're not understanding what the 
 cache is actually saving in your example. When you put an object in cache 
 ram, what's actually in the cache is a reference to the object. So if you 
 have a reference to that same object somewhere else and you modify it, 
 you're actually modifying the same object that cache is referencing.

 Cache disk is different, because cache disk pickles your object and when 
 you ask it for a value it unpickles it, so each time you will get a new 
 object albeit with the same attributes.


-- 
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: A text field in PostgreSQL is mixing unicode and str types

2015-05-04 Thread Chris
Just spent some time reviewing this - looks OK now, I think I must have 
screwed up somewhere.

All db text fields in web2py are supposed to be bytestrings of type 
'str', right?

On Sunday, May 3, 2015 at 8:15:19 AM UTC-4, Niphlod wrote:

 can you post an example app to reproduce the issue ?

 On Thursday, April 30, 2015 at 9:18:13 PM UTC+2, Chris wrote:

 I'm using web2py with PostgreSQL and it's working pretty well, however, 
 there's a weird problem. When I load a row with a text column in it, that 
 column isn't one consistent type. It appears as type 'unicode' when it 
 includes extended characters and type 'str' when it doesn't. I end up 
 having to look up the type and call decode on just the strs 
 http://stackoverflow.com/questions/8481006/unicodedecodeerror-on-join 
 to make sure they all have a consistent type and avoid the dreaded 
 UnicodeDecodeError.

 This is causing a bug on my setup which is Linux:
 2.9.12-stable+timestamp.2015.01.17.06.11.03
 (Running on Rocket 1.2.6, Python 2.7.0)

 Will this/has this been patched? Is this a bug with my version of Python?



-- 
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] A text field in PostgreSQL is mixing unicode and str types

2015-04-30 Thread Chris
I'm using web2py with PostgreSQL and it's working pretty well, however, 
there's a weird problem. When I load a row with a text column in it, that 
column isn't one consistent type. It appears as type 'unicode' when it 
includes extended characters and type 'str' when it doesn't. I end up 
having to look up the type and call decode on just the strs 
http://stackoverflow.com/questions/8481006/unicodedecodeerror-on-join to 
make sure they all have a consistent type and avoid the dreaded 
UnicodeDecodeError.

This is causing a bug on my setup which is Linux:
2.9.12-stable+timestamp.2015.01.17.06.11.03
(Running on Rocket 1.2.6, Python 2.7.0)

Will this/has this been patched? Is this a bug with my version of Python?

-- 
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] Caching Logic in web2py

2015-04-28 Thread Chris Modzelewski
Hi Everyone,

I have some questions about how caching works in web2py. I'm not interested 
at this point in understanding how to cache entire views or anything like 
that - in this case, I'm interested in understanding the principles behind 
how web2py implements caching:

Let's say that I have a class that accepts some arguments that is defined 
like so:

class SomeClass():
def __init__(self, arg1 = None, arg2 = None, arg3 = None):
self.arg1 = arg1
self.arg2 = arg2
self.arg3 = arg3

if arg1 is not None:
self.id_attribute = 'ID Value Here' + arg1
self = cache.ram(self.id_attribute, lambda self, time=(60*60*24*
30))

return self

Now the *first* time I instantiate an object of SomeClass, say by calling:
some_object = SomeClass(arg1=123, arg2=456, arg3=789)

Then this will create an object of class SomeClass, and (because arg1 is 
not None) will save that object to the cache (in ram) with the following 
attributes:
some_object.arg1 == 123
some_object.arg2 == 456
some_object.arg3 == 789
some_object.id_attribute == 'ID Value Here123'

Is the above so far correct?

If so, then what happens if I perform an operation on some_object, like so:

some_object.arg2 = 654

In this case:

A. Does the cached object get updated:

   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?
   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?

or:

B. The local object gets updated, but the cached value does not change:

   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?
   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?

or: C. Something else?

And then what happens when I have some other function try to do something 
using some_object?

some_other_value = some_object.arg2 + 987

Specifically, does the value of some_object.arg2 get read from the cache or 
from the object itself:

   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?
   - if this statement gets executed  (60*60*24*30) seconds from when the 
   object was instantiated?

And finally, if I wish to force a changed value of some_object to be saved 
to the cache, am I correct that I should then call:
some_object.arg3 = 
some_object = cache.ram(self.id_attribute, lambda self, time=0)

which will explicitly change the cached version of some_object? Does this 
mean that the next time someone instantiates an object of class SomeClass 
with the same arg1 value but a different time_expire value, the cached 
object will be overwritten?

Any help / clarification / explanation would be much appreciated!

Thanks in advance,
Chris

-- 
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] Debugging auth permissions

2015-04-22 Thread Chris Guest
Here is a block of code that I added to the views/default/user.html 
template of my application in order to debug a permission issue.

I am posting it here the hope that it is useful to others.


{{  
if request.args(0)=='not_authorized':
groups = db(db.auth_membership.user_id == 
auth.user.id).select(db.auth_membership.group_id)
group_ids = [group.group_id for group in groups]
group_details = 
db(db.auth_group.id.belongs(group_ids)).select(db.auth_group.id, 
db.auth_group.role)

rows = db.executesql('SELECT group_id, name, table_name, record_id FROM 
auth_permission ORDER BY group_id', as_dict=True)

}}
h3User groups:/h3
ul
{{for group in group_details:}}
li{{=group['id']}}: {{=group['role']}}/li
ul
{{for row in rows:
if row['group_id']!= group['id']: continue}}
li{{=row['name']}} {{=row['table_name']}}/li
{{pass}}
/ul
{{pass}}
/ul
{{  
pass
}}

-- 
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: IMPORTANT - WEB2PY CONSULTING

2015-03-04 Thread Chris
I do web2py consulting work on the side but I'm an individual. Can I 
include just an email address, and not a webpage? (web...@adventurecow.com, 
US)

On Sunday, February 15, 2015 at 5:21:36 PM UTC-5, Massimo Di Pierro wrote:

 We need to update the list of companies that provide web2py consulting.
 This list is obsolete:

 http://web2py.com/init/default/support 
 http://www.google.com/url?q=http%3A%2F%2Fweb2py.com%2Finit%2Fdefault%2Fsupportsa=Dsntz=1usg=AFQjCNGDKUvDhAvmPCgUGrzXBJr44i3eEg

 Some links are broke. Most pages do not even mention web2py. Some of them 
 have a design that is simply not acceptable for a web development company.

 That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
 page to have a decent design and MENTION WEB2PY on the main site. Then 
 respond to this thread by providing an updated link and the country were 
 you incorporated. If you have a self-employed individual list your country 
 of residence.



-- 
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] Why does the auth.login() form use a custom URL function with self.settings.controller?

2015-01-20 Thread Chris
Hello! I was recently debugging an issue with my login forms - on a failed 
login, I redirect to a nonexistent page.

Let's say I'm on /init/controller1/method1 and insert an auth.login() form. 
On a failed login, we redirect to the request page:

 redirect(
 self.url(args=request.args, vars=request.get_vars),
 client_side=settings.client_side)
https://github.com/web2py/web2py/blob/master/gluon/tools.py#L2512

I had assumed this method would bounce you back to the page you made the 
failed login attempt on. However, instead of using the current controller, 
it uses auth.settings.controller:


 def url(self, f=None, args=None, vars=None, scheme=False):
 if args is None:
 args = []
 if vars is None:
 vars = {}
 return URL(c=self.settings.controller,
 f=f, args=args, vars=vars, scheme=scheme)

https://github.com/web2py/web2py/blob/master/gluon/tools.py#L1250

Is there any particular reason that we jump to a specific controller, no 
matter what controller auth.login is on? I changed auth.settings.controller 
to None and it seems to work great, but I was wondering if we could remove 
this setting.

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.


Re: [web2py] Re: reddit clone - foreign key constraint failed

2014-12-24 Thread Chris Simpson
Hi William,

Thanks for the information!

Regards,




2014-12-23 8:33 GMT+00:00 William Chen williamch...@gmail.com:

 Hi Chris, I had the same problem and found this thread when I was
 searching for a solution.

 The solution is to simply create 1 or more comments using app admin.

 If table B references table A, then you need populate to populate table A
 before you populate table B, else there will be an error. In our case, the
 table comm references to itself in this line:
 Field('parent_comm', 'reference comm')

 So we need to manually add new comments, before we populate the table
 comm.

 Hope this helps.


 On Wednesday, 28 May 2014 23:05:06 UTC+8, Chris Simpson wrote:


 Hi Uri,

 Did you ever find a solution to this?
 On Wednesday, May 14, 2014 12:01:29 PM UTC+2, Uri Tamir wrote:

 Hi all,
 I've been following Massimo's video tutorials
 http://vimeo.com/76047107 (which are *great!* thanks Massimo)

 when trying to build the reddit clone and populate it i get a ticket
 - class 'sqlite3.IntegrityError' foreign key constraint failed

 the database was populated with users and posts but not with comments. I
 tried to make sure my code is exactly as the code Massimo showed but /w no
 success.

 any suggestions?

 db.define_table('category',
 Field('name', requires = (IS_SLUG(), IS_LOWER(),
 IS_NOT_IN_DB(db, 'category.name'

 db.define_table('post',
 Field('category', 'reference category', readable=False,
 writable=False),
 Field('title', 'string', requires=IS_NOT_EMPTY()),
 Field('url', requires=IS_EMPTY_OR(IS_URL())),
 Field('body', 'text', requires=IS_NOT_EMPTY()),
 Field('votes', 'integer', default=0, readable=False,
 writable=False),
 auth.signature) # created_on, created_by, modified_on,
 modified_by, is_active

 db.define_table('post_vote',
 Field('post', 'reference post'),
 Field('score', 'integer', default=+1), # numerical
 representation of votes
 auth.signature)

 db.define_table('comm',
 Field('post', 'reference post'),
 Field('parent_comm', 'reference comm'),
 Field('votes', 'integer'),
 Field('body', 'text'),
 auth.signature)

 db.define_table('comm_vote',
 Field('comm', 'reference comm'),
 Field('score', 'integer', default=+1), # numerical
 representation of votes
 auth.signature)

 from gluon.contrib.populate import populate
 if db(db.auth_user).count()2:
 populate(db.auth_user, 100)
 db.commit()
 if db(db.post).count()2:
 populate(db.post, 500)
 db.commit()
 if db(db.comm).count()2:
 populate(db.comm, 1000)
 db.commit()


  --
 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/9L1Ycuw7ZPo/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.


[web2py] Re: UPDATED AGENDA! Bay Area web2py meetup (refreshments) -- 12/5/2014, 6:30PM - 9:00PM -- BE THERE!!!

2014-12-03 Thread Chris Sears
I'll go.

-- 
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: Migrating only a single auth table ?

2014-11-23 Thread Chris Baron
Ah, I think I understand.  Thank you.

On Wednesday, November 19, 2014 10:29:17 AM UTC-6, Leonel Câmara wrote:

 No it won't fail, it won't try to recreate auth_user unless you deleted 
 your .table files, in which case you need to do a fake migration first.


-- 
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: Migrating only a single auth table ?

2014-11-19 Thread Chris Baron
Then you can define your auth.settings.extra_fields['auth_group'], put 
your extra columns there, and do a regular migration. -- This is the first 
thing I tried to do.  Won't that fail because auth_user already exists?  I 
only want to migrate a single table -- auth_group.

On Wednesday, November 19, 2014 6:21:55 AM UTC-6, Leonel Câmara wrote:

 If it fails because it already exists you need to do a fake migration on 
 auth_user, I would undo the changes to auth_group and then do a migration 
 using fake_migrate as needed for already exists errors. Then you can define 
 your auth.settings.extra_fields['auth_group'], put your extra columns 
 there, and do a regular migration.




-- 
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] Migrating only a single auth table ?

2014-11-18 Thread Chris Baron
I am trying to add columns to auth_group, but the migration breaks here :

auth.define_tables(username=False, signature=False, migrate=True)

It tries to migrate auth_user first, and fails because it already exists. 
 How do I migrate only the auth_group table ?

-- 
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] How to pass an array from jQuery to controller

2014-07-02 Thread Chris
Eval can be used to crash a Python app or hack into it, so *please don't 
use it*, as tempting as it may be!! 
(http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html)

I spent some time working on this and found that something like this is a 
decent way to do it:

script
//http://stackoverflow.com/questions/8890524/pass-array-to-ajax-request-in-ajax
info = [];
info[0] = 'hi';
info[1] = 'hello';


$.ajax({
 type: POST,
 data: {info:info},
 url: index.php,
 success: function(msg){
 $('.answer').html(msg);
 }
});

/script


In web2py:


def getRequestVars(name):
varValue = request.vars[name + '[]']
if type(varValue) == str:
return [varValue] #check for single value
else:
return varValue


info = getRequestVars('info')

This approach is nice because you can use both web2py and jQuery's 
automatic array handling. :)


On Wednesday, August 31, 2011 2:18:09 AM UTC-4, rochacbruno wrote:

 I dont know if this is the best approach, but I juste tested here and 
 works.

 On Wed, Aug 31, 2011 at 2:17 AM, Noel Villamor noe...@gmail.com 
 javascript: wrote:

 I wanted to pass an array from jQuery to a controller.

 script
 var xyz= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
 $(function() {
 $(body).click(function(event) {
   
  ajax({{=URL('default','mycontroller')}}+?array=+xyz,[],'target'); 

 });
 });
 /script

 the above will call this url:
 /default/mycontroller?array=['Sun','Mon','Tue','Wed','Thu','Fri','Sat']

  

 def mycontroller():
# Here, I wanted to receive xyz as an array.


   myarray = eval(request.vars.array)


 the above will receive the string and evaluate as a Python list.

 (BUT, BE CAREFUL!! it can be used to crash your app)

 another solution may be better than the above, is to split the array as 
 args and pass it separated.

 script

 var xyz= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
 args = xyz.join(/)

  $(function() {
  $(body).click(function(event) {
 ajax({{=URL('default','mycontroller')}}+args ,[],'target'); 

  });
 });

 /script

 the url will be called as

 /default/mycontroller/Sun/Mon/Tue/Wed/Thu/'Fri/Sat

 in controller

 def mycrontroller():

 array = request.args
 array[0] # Sun

 The second approach is better ans safe.
 -- 



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py with postgresql and DB triggers

2014-06-14 Thread Chris Farrar
Hi Massimo,

I'm simply recording in another table that an insert has been made in the 
reorder table.

Here's the full function:

def oncreatereorderhandler(form):
myid = form.vars.id
newreorderrow = db.reorder(myid)

#now do something with newreorderrow
db.trans.insert(ProductID=newreorderrow.uuid, TransactionType='New 
Reorder',
Quantity=form.vars.Quantity, Notes='Initial Stock', 
UserID=auth.user.uuid
,TransactionTime=datetime.now())


Thanks for your help!


On Friday, June 13, 2014 12:53:09 PM UTC-4, Massimo Di Pierro wrote:

 What does #now do something with newreorderrow do? 

 On Thursday, 12 June 2014 14:12:45 UTC-5, Chris Farrar wrote:

 Hi,

 I'm struggling with a strange issue.

 I have a web2py application with a simple data model.  I have a table 
 called reorder.  The user is able to interact with reorder using a 
 SQLFORM.grid.   I have implemented the oncreate call back.  My oncreate 
 callback gets the id of the newly inserted reorder record then does 
 something with it.


 def oncreatereorderhandler(form):
 myid = form.vars.id
 newreorderrow = db.reorder(myid)
 #now do something with newreorderrow


 Generally this works well.  form.vars.id correctly corresponds to the id 
 of the newly inserted row and life is happy.  The problem occurs when I put 
 a database trigger on the reorder table that fires after the insert. 
  Whenever this trigger is on the database the value of form.vars.id is 
 nonsense.  The actual id of the inserted row is fine it's just that the 
 value of form.vars.id in now way corresponds to it.  For example, after 
 the trigger is added, the values of form.vars.id will be 4 for the very 
 next insert.  For every insert after the value will increment by 3 (eg 4, 
 7, 10, 13, etc).  When I remove the trigger everything returns to normal.  

 How is form.vars.id populated and how would a DB trigger interfere?

 Here's the trigger and associated procedure.   It was generated by 
 symmetricds.

 CREATE TRIGGER sym_on_i_for_rrdr_trggr_crp
   AFTER INSERT
   ON reorder
   FOR EACH ROW
   EXECUTE PROCEDURE fsym_on_i_for_rrdr_trggr_crp();


 -- Function: fsym_on_i_for_rrdr_trggr_crp()

 -- DROP FUNCTION fsym_on_i_for_rrdr_trggr_crp();

 CREATE OR REPLACE FUNCTION fsym_on_i_for_rrdr_trggr_crp()
   RETURNS trigger AS
 $BODY$   
 
  begin 
 
if 1=1 and 
 public.sym_triggers_disabled() = 0 then   
 
   insert into public.sym_data 
 
 (table_name, 
 event_type, trigger_hist_id, row_data, channel_id, transaction_id, 
 source_node_id, external_data, create_time) 
values( 
 
 
  'reorder', 
 
  'I',   
 
 
 8, 
 
   
   case when new.uuid is null then '' else '' || 
 replace(replace(cast(new.uuid as varchar),$$\$$,$$\\$$),'',$$\$$) || 
 '' end||','||
   case when new.id is null then '' else '' || 
 cast(cast(new.id as numeric) as varchar) || '' end||','||
   case when new.modified_on is null then '' else '' || 
 to_char(new.modified_on, '-MM-DD HH24:MI:SS.US') || '' end||','||
   case when new.productid is null then '' else '' || 
 replace(replace(cast(new.productid as varchar),$$\$$,$$\\$$),'',$$\$$) 
 || '' end||','||
   case when new.reorderquantity is null then '' else '' || 
 cast(cast(new.reorderquantity as numeric) as varchar) || '' end||','||
   case when new.receivedquantity is null then '' else '' || 
 cast(cast(new.receivedquantity as numeric) as varchar) || '' end||','||
   case when new.reorderdate is null then '' else '' || 
 to_char

[web2py] Web2py with postgresql and DB triggers

2014-06-13 Thread Chris Farrar
Hi,

I'm struggling with a strange issue.

I have a web2py application with a simple data model.  I have a table 
called reorder.  The user is able to interact with reorder using a 
SQLFORM.grid.   I have implemented the oncreate call back.  My oncreate 
callback gets the id of the newly inserted reorder record then does 
something with it.


def oncreatereorderhandler(form):
myid = form.vars.id
newreorderrow = db.reorder(myid)
#now do something with newreorderrow


Generally this works well.  form.vars.id correctly corresponds to the id of 
the newly inserted row and life is happy.  The problem occurs when I put a 
database trigger on the reorder table that fires after the insert. 
 Whenever this trigger is on the database the value of form.vars.id is 
nonsense.  The actual id of the inserted row is fine it's just that the 
value of form.vars.id in now way corresponds to it.  For example, after the 
trigger is added, the values of form.vars.id will be 4 for the very next 
insert.  For every insert after the value will increment by 3 (eg 4, 7, 10, 
13, etc).  When I remove the trigger everything returns to normal.  

How is form.vars.id populated and how would a DB trigger interfere?

Here's the trigger and associated procedure.   It was generated by 
symmetricds.

CREATE TRIGGER sym_on_i_for_rrdr_trggr_crp
  AFTER INSERT
  ON reorder
  FOR EACH ROW
  EXECUTE PROCEDURE fsym_on_i_for_rrdr_trggr_crp();


-- Function: fsym_on_i_for_rrdr_trggr_crp()

-- DROP FUNCTION fsym_on_i_for_rrdr_trggr_crp();

CREATE OR REPLACE FUNCTION fsym_on_i_for_rrdr_trggr_crp()
  RETURNS trigger AS
$BODY$ 
  
 begin 

   if 1=1 and 
public.sym_triggers_disabled() = 0 then   

  insert into public.sym_data 

(table_name, 
event_type, trigger_hist_id, row_data, channel_id, transaction_id, 
source_node_id, external_data, create_time) 
   values( 


 'reorder', 

 'I',   


8, 

  
  case when new.uuid is null then '' else '' || 
replace(replace(cast(new.uuid as varchar),$$\$$,$$\\$$),'',$$\$$) || 
'' end||','||
  case when new.id is null then '' else '' || cast(cast(new.id 
as numeric) as varchar) || '' end||','||
  case when new.modified_on is null then '' else '' || 
to_char(new.modified_on, '-MM-DD HH24:MI:SS.US') || '' end||','||
  case when new.productid is null then '' else '' || 
replace(replace(cast(new.productid as varchar),$$\$$,$$\\$$),'',$$\$$) 
|| '' end||','||
  case when new.reorderquantity is null then '' else '' || 
cast(cast(new.reorderquantity as numeric) as varchar) || '' end||','||
  case when new.receivedquantity is null then '' else '' || 
cast(cast(new.receivedquantity as numeric) as varchar) || '' end||','||
  case when new.reorderdate is null then '' else '' || 
to_char(new.reorderdate, '-MM-DD HH24:MI:SS.US') || '' end||','||
  case when new.expectedreceivedate is null then '' else '' || 
to_char(new.expectedreceivedate, '-MM-DD HH24:MI:SS.US') || '' 
end||','||
  case when new.vendorso is null then '' else '' || 
replace(replace(cast(new.vendorso as varchar),$$\$$,$$\\$$),'',$$\$$) 
|| '' end||','||
  case when new.customerpo is null then '' else '' || 
replace(replace(cast(new.customerpo as varchar),$$\$$,$$\\$$),'',$$\$$) 
|| '' end||','||
  case when new.edigenerated is null then '' else '' || 
replace(replace(cast(new.edigenerated as 
varchar),$$\$$,$$\\$$),'',$$\$$) || '' end||','||
  case when new.active is null then '' else '' || 
replace(replace(cast(new.active as 

[web2py] Is it easy to create a grid data entry form using web2py?

2014-06-03 Thread Chris Green
This may be trying to run before I can walk but never mind!  :-)

Is it easy to create a grid type table editing form in web2py?  I just
want an easy way to edit an existing table, edit existing fields and
add new rows.  It's just simple data, text and numeric fields in a
sqlite3 database.

I want to edit the data in place, no pop-up forms or windows, just
click on a field and edit the data, tab to the next field and the
changed data is saved (could be delayed to when on leaves the form but
I don't want to have to do any explcit 'save' action).

Add a new row at the bottom by tab off the last field of the last
existing row or maybe cursor down on last row or just have an empty
row always at the bottom (like MS Access).

The table will already exist and I want to see all the columns, no
need for views or selects (though I might find uses for them in the
future).

This is to run on an existing system (xubuntu 14.04) running apache2
web server with various bits and pieces already running on it.  I'm
fairly happy with installing web apps and use Python quite a lot for
small scripts but I haven't really worked with a development framework
like web2py before.

-- 
Chris Green

-- 
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: reddit clone - foreign key constraint failed

2014-05-29 Thread Chris Simpson

Hi Uri,

Did you ever find a solution to this?
On Wednesday, May 14, 2014 12:01:29 PM UTC+2, Uri Tamir wrote:

 Hi all,
 I've been following Massimo's video tutorials 
 http://vimeo.com/76047107(which are 
 *great!* thanks Massimo)

 when trying to build the reddit clone and populate it i get a ticket 
 - class 'sqlite3.IntegrityError' foreign key constraint failed

 the database was populated with users and posts but not with comments. I 
 tried to make sure my code is exactly as the code Massimo showed but /w no 
 success.

 any suggestions?

 db.define_table('category',
 Field('name', requires = (IS_SLUG(), IS_LOWER(), 
 IS_NOT_IN_DB(db, 'category.name'

 db.define_table('post',
 Field('category', 'reference category', readable=False, 
 writable=False),
 Field('title', 'string', requires=IS_NOT_EMPTY()),
 Field('url', requires=IS_EMPTY_OR(IS_URL())),
 Field('body', 'text', requires=IS_NOT_EMPTY()),
 Field('votes', 'integer', default=0, readable=False, 
 writable=False),
 auth.signature) # created_on, created_by, modified_on, 
 modified_by, is_active

 db.define_table('post_vote',
 Field('post', 'reference post'),
 Field('score', 'integer', default=+1), # numerical 
 representation of votes
 auth.signature)

 db.define_table('comm',
 Field('post', 'reference post'),
 Field('parent_comm', 'reference comm'),
 Field('votes', 'integer'),
 Field('body', 'text'),
 auth.signature)

 db.define_table('comm_vote',
 Field('comm', 'reference comm'),
 Field('score', 'integer', default=+1), # numerical 
 representation of votes
 auth.signature)

 from gluon.contrib.populate import populate
 if db(db.auth_user).count()2:
 populate(db.auth_user, 100)
 db.commit()
 if db(db.post).count()2:
 populate(db.post, 500)
 db.commit()
 if db(db.comm).count()2:
 populate(db.comm, 1000)
 db.commit()




-- 
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: Customize bootstrap 3 forms

2014-05-20 Thread Chris DeGroot
Hi Joe,

Thanks for that trick!

Chris

On Friday, May 16, 2014 9:28:07 PM UTC-4, Joe Barnhart wrote:

 Formstyle can be a callable function, which allows you to do exactly what 
 you want.  To add parameters to a formstyle function, you first create your 
 own version of the basic formstyle (as you did with your version of the 
 bootstrap3 form), then wrap it in a lambda which presets the new values 
 you added to the signature.  Finally, hand the lambda off to the SQLFORM 
 when you call it and you can have anything you want in your formstyle.

 See an example:  
 https://groups.google.com/forum/#!topic/web2py/VSr2oLNnozg


 On Thursday, May 15, 2014 2:52:25 PM UTC-7, Chris DeGroot wrote:

 Hi everyone,

 I just submitted a pull request for some changes I was working on to make 
 bootstrap 3 forms more customizable: 
 https://github.com/web2py/web2py/pull/444

 What do you think?  I've done some testing on my projects, but I can't 
 say everything is fully tested.  I would be interested in opinions on a 
 good approach to testing in web2py and feedback on the approach taken.

 Regards,

 Chris



-- 
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: Customize bootstrap 3 forms

2014-05-16 Thread Chris DeGroot
I closed the pull request at the request of niphlod.  I have squashed my 
commits.  The branch can be found here: 
https://github.com/ctdegroot/web2py/tree/CustomBootstrapForms

Anyways, I'm new to contributing to web2py, but I would really like to 
contribute what I can.  These changes are something I ultimately did for 
myself, but I think others might also find them useful.  Unfortunately I 
don't really know your development practices or how you like to receive 
potential new features.

On Thursday, May 15, 2014 5:52:25 PM UTC-4, Chris DeGroot wrote:

 Hi everyone,

 I just submitted a pull request for some changes I was working on to make 
 bootstrap 3 forms more customizable: 
 https://github.com/web2py/web2py/pull/444

 What do you think?  I've done some testing on my projects, but I can't say 
 everything is fully tested.  I would be interested in opinions on a good 
 approach to testing in web2py and feedback on the approach taken.

 Regards,

 Chris


-- 
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: {{include}} not being rendered

2014-05-15 Thread Chris DeGroot
Can you check if there are any errors given by your browser about the files 
not being found?  Maybe take a look at the html that is generated and see 
what is there.

Paths should be relative to the /views folder; can you confirm that all of 
the paths are correct?


On Thursday, May 15, 2014 8:37:23 AM UTC-4, Annet wrote:

 In a view called layout.html in a folder 'admin' I have the following code:

 {{extend 'scaffolding/inner_layout.html'}}

 section class=main-content bottom40
   div class=container

 {{include 'buildingblocks/my_header.html'}}

 div class=row page-header
   div class=col-sm-2 col-sm-offset-1
 a href={{=URL(ADMINNAV)}}img src={{=URL('dbmodel', 'static', 
 'img/sysicons/adm-index.svg')}} class=img-responsive alt= width=64px 
 height=64px //a
   /div !-- /.col-sm-2 --
   div class=col-sm-9
 h3Admin overzicht/h3
   /div !-- /.col-sm-9 --
 /div !-- /.row --

 {{include 'buildingblocks/page_header.html'}}

 div class=row
   div class=col-sm-9 col-sm-offset-2
 {{include 'buildingblocks/alert.html'}}
 {{if form:}}
   {{=form}}
 {{pass}}
 {{include}}
   /div !-- /.col-sm-9 col-sm-offset-2 --
   div class=col-sm-1
   /div !-- /.col-sm-1 --
 /div !-- /.row --

   /div !-- /.container --
 /section !-- /.main-content --


 When I put the following section in a view called: my_block.html in folder 
 'buildingblocks'

 div class=row
 div class=col-sm-9 col-sm-offset-2
   {{include 'buildingblocks/alert.html'}}
   {{if form:}}
 {{=form}}
   {{pass}}
   {{include}}
 /div !-- /.col-sm-9 col-sm-offset-2 --
 div class=col-sm-1
 /div !-- /.col-sm-1 --
  /div !-- /.row --

 and replace the code with {{include 'buildingblocks/my_block.html'}}
 The alert and the form are rendered, but the content of {{include}}
 isn't rendered at all.

 For instance the following function:

 def index():
 response.view = 'admin/index.html'
 return dict(form=None)

 and view admin.html:

 {{extend 'admin/layout.html'}}

 h2Test view/h2

 Does render anything. I have no idea why not. I hope one of you does.


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


[web2py] Customize bootstrap 3 forms

2014-05-15 Thread Chris DeGroot
Hi everyone,

I just submitted a pull request for some changes I was working on to make 
bootstrap 3 forms more 
customizable: https://github.com/web2py/web2py/pull/444

What do you think?  I've done some testing on my projects, but I can't say 
everything is fully tested.  I would be interested in opinions on a good 
approach to testing in web2py and feedback on the approach taken.

Regards,

Chris

-- 
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] Crash in gluon/html.py

2014-03-24 Thread Chris Hobbs
html.py does not seem to be unicode-safe. It contains (line 1914 or 
thereabouts):

components.append(OPTION(c, _value=str(c)))

In my case c contains Max-Guénaël (i.e., uMax-Gu\xe9na\xebl). The str(c) 
dies nastily.

Is this a bug or am I asking too much of web2py?

-- 
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] Crash in gluon/html.py caused by unicode characters

2014-03-24 Thread Chris Hobbs
I tried to post this problem earlier, but it doesn't seem to have appeared. 
If it has now appeared twice, then I apologise and suggest you read the two 
stereoscopically.

/gluon/html.py in _fixup at line 1914 has the line

components.append(OPTION(c, _value=str(c)))

This call to str() coughs and explodes when presented with the string 
uMax-Gu\xe9na\xebl 
as it was in my application yesterday as part of a SELECT().

Should this be unicode-safe or am I expecting too much of web2py?

-- 
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] Problem with uploads using a remote sftp file system

2014-03-20 Thread Chris DeGroot
I am trying to deploy my web2py app on Heroku.  I have a database table 
containing an upload field that I want to put on a remote filesystem using 
sftp.  In db.py, I have set up the file system:

from fs import sftpfs

file_system = sftpfs.SFTPFS('???',

root_path='???',

username='???',

password='???')

In my table I define a field:

Field('zip_file',

  'upload',

  required=True,

  uploadfs=file_system,

  autodelete=True)

If I run my app on my local machine, the file is uploaded to the sftp 
server as expected.  When I run the app on Heroku (which will use a 
postgresql database) it does not go to the remote filesystem, rather is 
placed into the postgresql database on Heroku.  Any ideas why this wouldn't 
be working?

-- 
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: Problem with uploads using a remote sftp file system

2014-03-20 Thread Chris DeGroot
After some digging, I think I may have found the issue.  See my pull 
request: https://github.com/web2py/web2py/pull/409.  Comments welcome.

On Wednesday, March 19, 2014 9:45:13 PM UTC-4, Chris DeGroot wrote:

 I am trying to deploy my web2py app on Heroku.  I have a database table 
 containing an upload field that I want to put on a remote filesystem using 
 sftp.  In db.py, I have set up the file system:

 from fs import sftpfs

 file_system = sftpfs.SFTPFS('???',

 root_path='???',

 username='???',

 password='???')

 In my table I define a field:

 Field('zip_file',

   'upload',

   required=True,

   uploadfs=file_system,

   autodelete=True)

 If I run my app on my local machine, the file is uploaded to the sftp 
 server as expected.  When I run the app on Heroku (which will use a 
 postgresql database) it does not go to the remote filesystem, rather is 
 placed into the postgresql database on Heroku.  Any ideas why this wouldn't 
 be working?


-- 
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: please help testing windows and mac binary

2014-03-20 Thread Chris DeGroot
Hi Massimo,

I don't think the binary is working on my system; I am using OSX Mavericks 
(10.9.2).  I never use the binaries, so I don't know what to expect, but if 
I try to launch the application (i.e. by double clicking on it), an icon 
starts to appear in the Dock and then disappears.

Chris

On Thursday, March 20, 2014 12:16:13 PM UTC-4, Massimo Di Pierro wrote:

 problems have been reported with the windows and mac binaries for 2.9.x.

 Can you please help?

 Download the nightly builds:
 http://web2py.com/examples/static/nightly/web2py_win.zip
 http://web2py.com/examples/static/nightly/web2py_osx.zip

 and let us know if they work/do-not-work for you. Which OS version?

 Massimo


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


[web2py] Re: please help testing windows and mac binary

2014-03-20 Thread Chris DeGroot
Apparently my post was deleted... the binary does not seem to work on OSX 
10.9.2.  The icon flashes briefly and then disappears.

Chris

On Thursday, March 20, 2014 12:16:13 PM UTC-4, Massimo Di Pierro wrote:

 problems have been reported with the windows and mac binaries for 2.9.x.

 Can you please help?

 Download the nightly builds:
 http://web2py.com/examples/static/nightly/web2py_win.zip
 http://web2py.com/examples/static/nightly/web2py_osx.zip

 and let us know if they work/do-not-work for you. Which OS version?

 Massimo


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


[web2py] subscripts inside database

2014-03-20 Thread Chris Hepworth
In my current project I have a table that accepts chemical formulas. To 
accurately display a formula, however, I need to be able to render 
subscripts. I had tried to put an HTML sub tag around the number, but 
this is saved as lt;subgt;

Normally I would love that web2py does this automatically for me, but in 
this instance it was the only way I could think to make this work.

Is there a way to insert a subscript number into a database and have it 
render properly automatically?

-- 
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: Problem with web2py on Heroku

2014-03-14 Thread Chris DeGroot


I think I may have made sense of the error above.  Based on the code below, 
DatabaseStoredFile.web2py_filesystem is set to true even if the table 
creation fails (which it does), as I don't think the error will be caught 
before it gets to that line.  A few lines later, it tries to access that 
table, causing the error logged by Heroku.  Therefore, the key error seems 
to be that the creation of the web2py_filesystem table is failing.


if not self.web2py_filesystem:

if db._adapter.dbengine == 'mysql':

sql = CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;

elif db._adapter.dbengine in ('postgres', 'sqlite'):

sql = CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
VARCHAR(255), content TEXT, PRIMARY KEY(path));

self.db.executesql(sql)

DatabaseStoredFile.web2py_filesystem = True


On Thursday, March 13, 2014 11:40:59 AM UTC-4, Chris DeGroot wrote:

 I am looking again at the Heroku logs, specifically the line

 ERROR:web2py.dal:Could not retrieve applications/CaeSuite/databases/
 9e6a7c1bb77d791a89631de258057aed_web2py_session_CaeSuite.table

 Why is it looking for a file in */databases? 

 Chris

 On Thursday, March 13, 2014 10:14:32 AM UTC-4, Massimo Di Pierro wrote:

 Is this is a problem that worked before and then stopped working? Have 
 you changed anything on the database side? Do you have data that you need 
 to recovered.

 If at all an option, try delete the database and make a new one. 

 Somehow there is a problem with the web2py_filesystem table where web2py 
 stores metadata on platforms that lack a persistent filesystem. This an be 
 recovered but it is complicated to explain without direct access to the 
 system. It really depends on how it got there and what is in there.

 Massimo


 On Wednesday, 12 March 2014 17:53:08 UTC-5, Chris DeGroot wrote:

 Hello;

 I have tried everything I could think of to solve this problem, but I 
 just can't find a solution.  I am trying to deploy my application to 
 Heroku, following the instructions in the web2py manual.  The welcome app 
 works fine, so I think generally I have deployed the app properly.  The 
 application works on my local machine.  The error I am getting looks like 
 this:

 Traceback (most recent call last):
   File /app/web2py/gluon/restricted.py, line 217, in restricted
 exec ccode in environment
   File /app/web2py/applications/CaeSuite/models/db.py 
 https://warm-basin-8163.herokuapp.com/admin/default/edit/CaeSuite/models/db.py,
  line 16, in module
 db = get_db(name=None, pool_size=10)
   File /app/web2py/gluon/contrib/heroku.py, line 26, in get_db
 current.session.connect(current.request, current.response, db=db)
   File /app/web2py/gluon/globals.py, line 869, in connect
 migrate=table_migrate,
   File /app/web2py/gluon/dal.py, line 8223, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /app/web2py/gluon/dal.py, line 8260, in lazy_define_table
 polymodel=polymodel)
   File /app/web2py/gluon/dal.py, line 1102, in create_table
 query), table)
   File /app/web2py/gluon/dal.py, line 850, in log
 logfile = self.file_open(table._loggername, 'a')
   File /app/web2py/gluon/dal.py, line 4578, in file_open
 return DatabaseStoredFile(self.db,filename,mode)
   File /app/web2py/gluon/dal.py, line 4506, in __init__
 self.db.executesql(sql)
   File /app/web2py/gluon/dal.py, line 8433, in executesql
 adapter.execute(query)
   File /app/web2py/gluon/dal.py, line 1969, in execute
 return self.log_execute(*a, **b)
   File /app/web2py/gluon/dal.py, line 1963, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 InternalError: current transaction is aborted, commands ignored until end 
 of transaction block

 Variablesself.cursor.executebuilt-in method execute of 
 psycopg2._psycopg.cursor 
 objectselfgluon.contrib.heroku.HerokuPostgresAdapter 
 objectself.cursorcursor object at 0x287a338; closed: 0b{}a('CREATE TABLE 
 IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY 
 KEY(path));',)retundefinedcommand'CREATE TABLE IF NOT EXISTS 
 web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));'


 I would really appreciate any help!!  Thanks,


 Chris



-- 
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] Problem with web2py on Heroku

2014-03-13 Thread Chris DeGroot
Hello;

I have tried everything I could think of to solve this problem, but I just 
can't find a solution.  I am trying to deploy my application to Heroku, 
following the instructions in the web2py manual.  The welcome app works 
fine, so I think generally I have deployed the app properly.  The 
application works on my local machine.  The error I am getting looks like 
this:

Traceback (most recent call last):
  File /app/web2py/gluon/restricted.py, line 217, in restricted
exec ccode in environment
  File /app/web2py/applications/CaeSuite/models/db.py 
https://warm-basin-8163.herokuapp.com/admin/default/edit/CaeSuite/models/db.py,
 line 16, in module
db = get_db(name=None, pool_size=10)
  File /app/web2py/gluon/contrib/heroku.py, line 26, in get_db
current.session.connect(current.request, current.response, db=db)
  File /app/web2py/gluon/globals.py, line 869, in connect
migrate=table_migrate,
  File /app/web2py/gluon/dal.py, line 8223, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File /app/web2py/gluon/dal.py, line 8260, in lazy_define_table
polymodel=polymodel)
  File /app/web2py/gluon/dal.py, line 1102, in create_table
query), table)
  File /app/web2py/gluon/dal.py, line 850, in log
logfile = self.file_open(table._loggername, 'a')
  File /app/web2py/gluon/dal.py, line 4578, in file_open
return DatabaseStoredFile(self.db,filename,mode)
  File /app/web2py/gluon/dal.py, line 4506, in __init__
self.db.executesql(sql)
  File /app/web2py/gluon/dal.py, line 8433, in executesql
adapter.execute(query)
  File /app/web2py/gluon/dal.py, line 1969, in execute
return self.log_execute(*a, **b)
  File /app/web2py/gluon/dal.py, line 1963, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
InternalError: current transaction is aborted, commands ignored until end of 
transaction block

Variablesself.cursor.executebuilt-in method execute of 
psycopg2._psycopg.cursor objectselfgluon.contrib.heroku.HerokuPostgresAdapter 
objectself.cursorcursor object at 0x287a338; closed: 0b{}a('CREATE TABLE IF 
NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY 
KEY(path));',)retundefinedcommand'CREATE TABLE IF NOT EXISTS web2py_filesystem 
(path VARCHAR(255), content TEXT, PRIMARY KEY(path));'


I would really appreciate any help!!  Thanks,


Chris

-- 
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 on heroku getting InternalError: current transaction is aborted... Ticket

2014-03-13 Thread Chris DeGroot
Did you solve this problem?  I have the same issue and the links at then 
end don't help.

On Friday, December 27, 2013 11:45:24 PM UTC-5, Ismael Serratos wrote:

 Hello everybody, today I tried to push my application to Heroku by using 
 the setup-web2py-heroku.sh script. It works fine, but when opening my app I 
 get a ticket with this content:

 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.4: /app/.heroku/python/bin/python (prefix: /app/.heroku/python)
 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 27.
 28.
 29.
 30.

 Traceback (most recent call last):
   File /app/gluon/restricted.py, line 217, in restricted
 exec ccode in environment
   File /app/applications/init/models/db.py 
 https://frozen-sea-3926.herokuapp.com/admin/default/edit/init/models/db.py, 
 line 16, in module
 db = get_db(name=HEROKU_POSTGRESQL_RED_URL, pool_size=10)
   File /app/gluon/contrib/heroku.py, line 26, in get_db
 current.session.connect(current.request, current.response, db=db)
   File /app/gluon/globals.py, line 833, in connect
 migrate=table_migrate,
   File /app/gluon/dal.py, line 8139, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /app/gluon/dal.py, line 8176, in lazy_define_table
 polymodel=polymodel)
   File /app/gluon/dal.py, line 1056, in create_table
 query), table)
   File /app/gluon/dal.py, line 815, in log
 logfile = self.file_open(table._loggername, 'a')
   File /app/gluon/dal.py, line 4488, in file_open
 return DatabaseStoredFile(self.db,filename,mode)
   File /app/gluon/dal.py, line 4416, in __init__
 self.db.executesql(sql)
   File /app/gluon/dal.py, line 8349, in executesql
 adapter.execute(query)
   File /app/gluon/dal.py, line 1916, in execute
 return self.log_execute(*a, **b)
   File /app/gluon/dal.py, line 1910, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 InternalError: current transaction is aborted, commands ignored until end of 
 transaction block

 I'm getting this ticket with my app and even with a blank copy of web2py and 
 the default apps. The admin interface works just fine. What can be the cause 
 of this issue?

 *Note: In the traceback I pasted here I did replace the get_db connection 
 name to the generated one, but the traceback is basically the same if I use 
 the default (none).

 Best regards,

 Ismael Serratos.





-- 
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: Problem with web2py on Heroku

2014-03-13 Thread Chris DeGroot
The Heroku logs might also help (password removed):

2014-03-13T01:37:17.022191+00:00 heroku[web.1]: Starting process with 
command `python web2py/web2py.py -a '{PASSWORD}' -i 0.0.0.0 -p 35330`

2014-03-13T01:37:20.361879+00:00 app[web.1]: web2py Web Framework

2014-03-13T01:37:20.361879+00:00 app[web.1]: Version 
2.9.3-stable+timestamp.2014.03.03.16.38.00

2014-03-13T01:37:20.362162+00:00 app[web.1]: please visit:

2014-03-13T01:37:20.361879+00:00 app[web.1]: Created by Massimo Di Pierro, 
Copyright 2007-2014

2014-03-13T01:37:20.361879+00:00 app[web.1]: Database drivers available: 
SQLite(sqlite3), MySQL(pymysql), PostgreSQL(psycopg2), PostgreSQL(pg8000), 
IMAP(imaplib)

2014-03-13T01:37:20.362162+00:00 app[web.1]: http://127.0.0.1:35330/

2014-03-13T01:37:20.362283+00:00 app[web.1]: use kill -SIGTERM 2 to 
shutdown the web2py server

2014-03-13T01:37:20.555609+00:00 heroku[web.1]: State changed from starting 
to up

2014-03-13T01:43:05.311936+00:00 app[web.1]: Traceback (most recent call 
last):

2014-03-13T01:43:05.311936+00:00 app[web.1]: if db.executesql(query):

2014-03-13T01:43:05.311936+00:00 app[web.1]: ERROR:web2py.dal:Could not 
retrieve 
applications/CaeSuite/databases/9e6a7c1bb77d791a89631de258057aed_web2py_session_CaeSuite.table

2014-03-13T01:43:05.311936+00:00 app[web.1]:   File 
/app/web2py/gluon/dal.py, line 4560, in exists

2014-03-13T01:43:05.311936+00:00 app[web.1]:   File 
/app/web2py/gluon/dal.py, line 8433, in executesql

2014-03-13T01:43:05.311936+00:00 app[web.1]:   File 
/app/web2py/gluon/dal.py, line 1969, in execute

2014-03-13T01:43:05.311936+00:00 app[web.1]: adapter.execute(query)

2014-03-13T01:43:05.311936+00:00 app[web.1]: return 
self.log_execute(*a, **b)

2014-03-13T01:43:05.312193+00:00 app[web.1]: 

2014-03-13T01:43:05.311936+00:00 app[web.1]:   File 
/app/web2py/gluon/dal.py, line 1963, in log_execute

2014-03-13T01:43:05.312193+00:00 app[web.1]:  ^

2014-03-13T01:43:05.312193+00:00 app[web.1]: 

2014-03-13T01:43:05.311936+00:00 app[web.1]: ret = 
self.cursor.execute(command, *a[1:], **b)

2014-03-13T01:43:05.312193+00:00 app[web.1]: ProgrammingError: relation 
web2py_filesystem does not exist

2014-03-13T01:43:05.312193+00:00 app[web.1]: LINE 1: SELECT path FROM 
web2py_filesystem WHERE path='applications/...

-- 
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: Problem with web2py on Heroku

2014-03-13 Thread Chris DeGroot
Hi Massimo,

This application worked until I switched to the Postgresql database, so it 
is definitely a database problem.  Originally I was using the default 
database, which I guess is file-based, so the data would be lost about once 
a day when Heroku cleaned out its files.  That was fine for testing, but 
obviously I need a persistent database for production.  

Right now, I don't care about the data in the database; in fact it should 
be empty since it has not worked since I changed the database.

I have already tried deleting the database by removing the add-on from 
Heroku and adding a new one.  According to the Heroku admin panel there are 
no tables existing in the new database.

I also tried deleting the app from Heroku and deploying it all over again, 
which also did not work.

Can you elaborate or point to some information on how web2py treats the 
metadata?  There is no web2py_filesystem in my database.  Can you think of 
a reason why it would not have been created?

Chris

On Thursday, March 13, 2014 10:14:32 AM UTC-4, Massimo Di Pierro wrote:

 Is this is a problem that worked before and then stopped working? Have you 
 changed anything on the database side? Do you have data that you need to 
 recovered.

 If at all an option, try delete the database and make a new one. 

 Somehow there is a problem with the web2py_filesystem table where web2py 
 stores metadata on platforms that lack a persistent filesystem. This an be 
 recovered but it is complicated to explain without direct access to the 
 system. It really depends on how it got there and what is in there.

 Massimo


 On Wednesday, 12 March 2014 17:53:08 UTC-5, Chris DeGroot wrote:

 Hello;

 I have tried everything I could think of to solve this problem, but I 
 just can't find a solution.  I am trying to deploy my application to 
 Heroku, following the instructions in the web2py manual.  The welcome app 
 works fine, so I think generally I have deployed the app properly.  The 
 application works on my local machine.  The error I am getting looks like 
 this:

 Traceback (most recent call last):
   File /app/web2py/gluon/restricted.py, line 217, in restricted
 exec ccode in environment
   File /app/web2py/applications/CaeSuite/models/db.py 
 https://warm-basin-8163.herokuapp.com/admin/default/edit/CaeSuite/models/db.py,
  line 16, in module
 db = get_db(name=None, pool_size=10)
   File /app/web2py/gluon/contrib/heroku.py, line 26, in get_db
 current.session.connect(current.request, current.response, db=db)
   File /app/web2py/gluon/globals.py, line 869, in connect
 migrate=table_migrate,
   File /app/web2py/gluon/dal.py, line 8223, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /app/web2py/gluon/dal.py, line 8260, in lazy_define_table
 polymodel=polymodel)
   File /app/web2py/gluon/dal.py, line 1102, in create_table
 query), table)
   File /app/web2py/gluon/dal.py, line 850, in log
 logfile = self.file_open(table._loggername, 'a')
   File /app/web2py/gluon/dal.py, line 4578, in file_open
 return DatabaseStoredFile(self.db,filename,mode)
   File /app/web2py/gluon/dal.py, line 4506, in __init__
 self.db.executesql(sql)
   File /app/web2py/gluon/dal.py, line 8433, in executesql
 adapter.execute(query)
   File /app/web2py/gluon/dal.py, line 1969, in execute
 return self.log_execute(*a, **b)
   File /app/web2py/gluon/dal.py, line 1963, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 InternalError: current transaction is aborted, commands ignored until end of 
 transaction block

 Variablesself.cursor.executebuilt-in method execute of 
 psycopg2._psycopg.cursor 
 objectselfgluon.contrib.heroku.HerokuPostgresAdapter 
 objectself.cursorcursor object at 0x287a338; closed: 0b{}a('CREATE TABLE 
 IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY 
 KEY(path));',)retundefinedcommand'CREATE TABLE IF NOT EXISTS 
 web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));'


 I would really appreciate any help!!  Thanks,


 Chris



-- 
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: Problem with web2py on Heroku

2014-03-13 Thread Chris DeGroot
I am looking again at the Heroku logs, specifically the line

ERROR:web2py.dal:Could not retrieve applications/CaeSuite/databases/
9e6a7c1bb77d791a89631de258057aed_web2py_session_CaeSuite.table

Why is it looking for a file in */databases? 

Chris

On Thursday, March 13, 2014 10:14:32 AM UTC-4, Massimo Di Pierro wrote:

 Is this is a problem that worked before and then stopped working? Have you 
 changed anything on the database side? Do you have data that you need to 
 recovered.

 If at all an option, try delete the database and make a new one. 

 Somehow there is a problem with the web2py_filesystem table where web2py 
 stores metadata on platforms that lack a persistent filesystem. This an be 
 recovered but it is complicated to explain without direct access to the 
 system. It really depends on how it got there and what is in there.

 Massimo


 On Wednesday, 12 March 2014 17:53:08 UTC-5, Chris DeGroot wrote:

 Hello;

 I have tried everything I could think of to solve this problem, but I 
 just can't find a solution.  I am trying to deploy my application to 
 Heroku, following the instructions in the web2py manual.  The welcome app 
 works fine, so I think generally I have deployed the app properly.  The 
 application works on my local machine.  The error I am getting looks like 
 this:

 Traceback (most recent call last):
   File /app/web2py/gluon/restricted.py, line 217, in restricted
 exec ccode in environment
   File /app/web2py/applications/CaeSuite/models/db.py 
 https://warm-basin-8163.herokuapp.com/admin/default/edit/CaeSuite/models/db.py,
  line 16, in module
 db = get_db(name=None, pool_size=10)
   File /app/web2py/gluon/contrib/heroku.py, line 26, in get_db
 current.session.connect(current.request, current.response, db=db)
   File /app/web2py/gluon/globals.py, line 869, in connect
 migrate=table_migrate,
   File /app/web2py/gluon/dal.py, line 8223, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /app/web2py/gluon/dal.py, line 8260, in lazy_define_table
 polymodel=polymodel)
   File /app/web2py/gluon/dal.py, line 1102, in create_table
 query), table)
   File /app/web2py/gluon/dal.py, line 850, in log
 logfile = self.file_open(table._loggername, 'a')
   File /app/web2py/gluon/dal.py, line 4578, in file_open
 return DatabaseStoredFile(self.db,filename,mode)
   File /app/web2py/gluon/dal.py, line 4506, in __init__
 self.db.executesql(sql)
   File /app/web2py/gluon/dal.py, line 8433, in executesql
 adapter.execute(query)
   File /app/web2py/gluon/dal.py, line 1969, in execute
 return self.log_execute(*a, **b)
   File /app/web2py/gluon/dal.py, line 1963, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 InternalError: current transaction is aborted, commands ignored until end of 
 transaction block

 Variablesself.cursor.executebuilt-in method execute of 
 psycopg2._psycopg.cursor 
 objectselfgluon.contrib.heroku.HerokuPostgresAdapter 
 objectself.cursorcursor object at 0x287a338; closed: 0b{}a('CREATE TABLE 
 IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY 
 KEY(path));',)retundefinedcommand'CREATE TABLE IF NOT EXISTS 
 web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));'


 I would really appreciate any help!!  Thanks,


 Chris



-- 
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: web2py on heroku getting InternalError: current transaction is aborted... Ticket

2014-03-13 Thread Chris DeGroot
That's unfortunate to hear that you haven't resolved it.  I am having the 
exact same problem.  Locally everything is fine, on Heroku, nothing.

On Thursday, March 13, 2014 11:06:51 AM UTC-4, Ismael Serratos wrote:

 Nope, in fact I switched to ror :S because I needed to run on heroku ASAP.

 But I still getting the error on every web2py application I try to deploy 
 on heroku. If I use postgres locally everything works just fine.

 On 12/03/2014, at 18:31, Chris DeGroot cdeg...@gmail.com javascript: 
 wrote:

 Did you solve this problem?  I have the same issue and the links at then 
 end don't help.

 On Friday, December 27, 2013 11:45:24 PM UTC-5, Ismael Serratos wrote:

 Hello everybody, today I tried to push my application to Heroku by using 
 the setup-web2py-heroku.sh script. It works fine, but when opening my app I 
 get a ticket with this content:

 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.4: /app/.heroku/python/bin/python (prefix: /app/.heroku/python)
 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 27.
 28.
 29.
 30.

 Traceback (most recent call last):
   File /app/gluon/restricted.py, line 217, in restricted
 exec ccode in environment
   File /app/applications/init/models/db.py 
 https://frozen-sea-3926.herokuapp.com/admin/default/edit/init/models/db.py,
  line 16, in module
 db = get_db(name=HEROKU_POSTGRESQL_RED_URL, pool_size=10)
   File /app/gluon/contrib/heroku.py, line 26, in get_db
 current.session.connect(current.request, current.response, db=db)
   File /app/gluon/globals.py, line 833, in connect
 migrate=table_migrate,
   File /app/gluon/dal.py, line 8139, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /app/gluon/dal.py, line 8176, in lazy_define_table
 polymodel=polymodel)
   File /app/gluon/dal.py, line 1056, in create_table
 query), table)
   File /app/gluon/dal.py, line 815, in log
 logfile = self.file_open(table._loggername, 'a')
   File /app/gluon/dal.py, line 4488, in file_open
 return DatabaseStoredFile(self.db,filename,mode)
   File /app/gluon/dal.py, line 4416, in __init__
 self.db.executesql(sql)
   File /app/gluon/dal.py, line 8349, in executesql
 adapter.execute(query)
   File /app/gluon/dal.py, line 1916, in execute
 return self.log_execute(*a, **b)
   File /app/gluon/dal.py, line 1910, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
 InternalError: current transaction is aborted, commands ignored until end of 
 transaction block

 I'm getting this ticket with my app and even with a blank copy of web2py and 
 the default apps. The admin interface works just fine. What can be the cause 
 of this issue?

 *Note: In the traceback I pasted here I did replace the get_db connection 
 name to the generated one, but the traceback is basically the same if I use 
 the default (none).

 Best regards,

 Ismael Serratos.



  -- 
 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/w2RJBqKIwRE/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com javascript:.
 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] ImportError - no module named...

2014-02-11 Thread Chris Hepworth

I recently had to set up a new environment (my desktop running Ubuntu is 
dead) on my Windows laptop. I have a module called *qrcode *that worked 
fine in my old environment and hasn't had an issue on pythonanywhere. After 
I cloned the application, however, I received this error. Is there 
something special about Windows? I am working on replacing my desktop, but 
in the meantime I would love to get this working. Any help would be much 
appreciated!

type 'exceptions.ImportError' No module named mqr.modules
Version  
  
web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27)

Traceback

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

Traceback (most recent call last):
  File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, in 
restricted
  File C:/web2py/applications/mqr/controllers/cms.py 
http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 105, in 
module
import qrcode
  File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 76, in 
custom_importer
ImportError: No module named 

-- 
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/groups/opt_out.


[web2py] Re: ImportError - no module named...

2014-02-11 Thread Chris Hepworth
Considering I had another import failure for PIL (which I thought I had but 
didn't) that wouldn't be surprising. The Windows Python 2.7 install sure 
doesn't seem to include much. I'll take a look at the module's dependencies 
and post again if that fixes it. Thank you!

On Tuesday, February 11, 2014 1:15:35 PM UTC-7, Niphlod wrote:

 are all the dependencies of that module satisfied on the windows 
 environment ?
 for imported modules, if some of the libraries it depends on are missing, 
 the error that web2py can show is that it's unable to import the module 
 (meaning, it can't load it because there is some error in it vs - what 
 you're probably guessing - its a non-existant module )

 On Tuesday, February 11, 2014 9:09:32 PM UTC+1, Chris Hepworth wrote:


 I recently had to set up a new environment (my desktop running Ubuntu is 
 dead) on my Windows laptop. I have a module called *qrcode *that worked 
 fine in my old environment and hasn't had an issue on pythonanywhere. After 
 I cloned the application, however, I received this error. Is there 
 something special about Windows? I am working on replacing my desktop, but 
 in the meantime I would love to get this working. Any help would be much 
 appreciated!

 type 'exceptions.ImportError' No module named mqr.modules
 Version  
   
 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27)

 Traceback

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

 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, 
 in restricted
   File C:/web2py/applications/mqr/controllers/cms.py 
 http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 105, 
 in module
 import qrcode
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 76, 
 in custom_importer
 ImportError: No module named 



-- 
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/groups/opt_out.


[web2py] Re: ImportError - no module named...

2014-02-11 Thread Chris Hepworth
There is an import for pymaging, which must have already been installed on 
my Ubuntu machine. Installing it on Windows seems to be more trouble than 
its worth, so I'll just wait to get my Ubuntu environment set up on another 
machine. Thanks for the suggestion though!

On Tuesday, February 11, 2014 1:15:35 PM UTC-7, Niphlod wrote:

 are all the dependencies of that module satisfied on the windows 
 environment ?
 for imported modules, if some of the libraries it depends on are missing, 
 the error that web2py can show is that it's unable to import the module 
 (meaning, it can't load it because there is some error in it vs - what 
 you're probably guessing - its a non-existant module )

 On Tuesday, February 11, 2014 9:09:32 PM UTC+1, Chris Hepworth wrote:


 I recently had to set up a new environment (my desktop running Ubuntu is 
 dead) on my Windows laptop. I have a module called *qrcode *that worked 
 fine in my old environment and hasn't had an issue on pythonanywhere. After 
 I cloned the application, however, I received this error. Is there 
 something special about Windows? I am working on replacing my desktop, but 
 in the meantime I would love to get this working. Any help would be much 
 appreciated!

 type 'exceptions.ImportError' No module named mqr.modules
 Version  
   
 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27)

 Traceback

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

 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, 
 in restricted
   File C:/web2py/applications/mqr/controllers/cms.py 
 http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 105, 
 in module
 import qrcode
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 76, 
 in custom_importer
 ImportError: No module named 



-- 
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/groups/opt_out.


[web2py] Re: ImportError - no module named...

2014-02-11 Thread Chris Hepworth
Just to test I set up a VM running Ubuntu. I installed all relevant 
packages and I am still receiving the same error. Any suggestions?

On Tuesday, February 11, 2014 2:12:42 PM UTC-7, Chris Hepworth wrote:

 There is an import for pymaging, which must have already been installed on 
 my Ubuntu machine. Installing it on Windows seems to be more trouble than 
 its worth, so I'll just wait to get my Ubuntu environment set up on another 
 machine. Thanks for the suggestion though!

 On Tuesday, February 11, 2014 1:15:35 PM UTC-7, Niphlod wrote:

 are all the dependencies of that module satisfied on the windows 
 environment ?
 for imported modules, if some of the libraries it depends on are missing, 
 the error that web2py can show is that it's unable to import the module 
 (meaning, it can't load it because there is some error in it vs - what 
 you're probably guessing - its a non-existant module )

 On Tuesday, February 11, 2014 9:09:32 PM UTC+1, Chris Hepworth wrote:


 I recently had to set up a new environment (my desktop running Ubuntu is 
 dead) on my Windows laptop. I have a module called *qrcode *that worked 
 fine in my old environment and hasn't had an issue on pythonanywhere. After 
 I cloned the application, however, I received this error. Is there 
 something special about Windows? I am working on replacing my desktop, but 
 in the meantime I would love to get this working. Any help would be much 
 appreciated!

 type 'exceptions.ImportError' No module named mqr.modules
 Version  
   
 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27)

 Traceback

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

 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, 
 in restricted
   File C:/web2py/applications/mqr/controllers/cms.py 
 http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 
 105, in module
 import qrcode
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 76, in custom_importer
 ImportError: No module named 



-- 
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/groups/opt_out.


[web2py] Re: ImportError - no module named...

2014-02-11 Thread Chris Hepworth
https://groups.google.com/forum/#!searchin/web2py/importerror/web2py/FEYjCpBPpWU/9OfvXCeyPMoJ

I found this thread as I searched for a solution. I can confirm that in my 
app, there is an __init__.py in modules. It is blank (as it has been since 
I created the app), but it is there. Could this have something to do with 
the issue?

On Tuesday, February 11, 2014 4:21:54 PM UTC-7, Chris Hepworth wrote:

 Just to test I set up a VM running Ubuntu. I installed all relevant 
 packages and I am still receiving the same error. Any suggestions?

 On Tuesday, February 11, 2014 2:12:42 PM UTC-7, Chris Hepworth wrote:

 There is an import for pymaging, which must have already been installed 
 on my Ubuntu machine. Installing it on Windows seems to be more trouble 
 than its worth, so I'll just wait to get my Ubuntu environment set up on 
 another machine. Thanks for the suggestion though!

 On Tuesday, February 11, 2014 1:15:35 PM UTC-7, Niphlod wrote:

 are all the dependencies of that module satisfied on the windows 
 environment ?
 for imported modules, if some of the libraries it depends on are 
 missing, the error that web2py can show is that it's unable to import the 
 module (meaning, it can't load it because there is some error in it vs - 
 what you're probably guessing - its a non-existant module )

 On Tuesday, February 11, 2014 9:09:32 PM UTC+1, Chris Hepworth wrote:


 I recently had to set up a new environment (my desktop running Ubuntu 
 is dead) on my Windows laptop. I have a module called *qrcode *that 
 worked fine in my old environment and hasn't had an issue on 
 pythonanywhere. After I cloned the application, however, I received this 
 error. Is there something special about Windows? I am working on replacing 
 my desktop, but in the meantime I would love to get this working. Any help 
 would be much appreciated!

 type 'exceptions.ImportError' No module named mqr.modules
 Version  
   
 web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
 2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27)

 Traceback

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

 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, 
 in restricted
   File C:/web2py/applications/mqr/controllers/cms.py 
 http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 
 105, in module
 import qrcode
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 76, in custom_importer
 ImportError: No module named 



-- 
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/groups/opt_out.


[web2py] Displaying computed data from form submission

2014-01-24 Thread Chris Hepworth
I have played with doing this several different ways, but to no avail. 
Currently I have a function: 

def qrret():
rows = db().select(db.geo_item.f_name,db.geo_item.f_qrcode, orderby=db.
geo_item.f_name)
rows2 = db().select(db.geo_collection.f_name, db.geo_collection.f_qrcode
, orderby=db.geo_collection.f_name)
items=[]
colls=[]
for row in rows:
items += [
OPTION(row.f_name, _value=row.f_qrcode)
]
for row in rows2:
colls += [
OPTION(row.f_name, _value=row.f_qrcode)
]
fields = [DIV(H4(Items), SELECT(items, _name=items, _multiple=True,_size
=10), _class=span6), 
DIV(H4(Collections), SELECT(colls, _name=colls, _multiple=True,_size
=10), _class=span6), BR(), 
DIV(INPUT(_type='submit'), _style=margin-top: 20px, _class=
span12)]
form=FORM(fields, onvalidation=qrparse)
return dict(form=form)

This function returns the form as I need it in the view. The onvalidation 
function 'qrparse' is:

def qrparse(form):
codes = form.vars.items
codes += form.vars.colls
images = qrmake(codes)
return images

Which in turn calls:

def qrmake(codes):
images = []
background = Image.new('RGBA', (1275,1650), (255, 255, 255, 255))
margin = 150
bg_w,bg_h=background.size
offset_left = margin
offset_down = margin
rowend = bg_w - margin
pageend = bg_h - margin
for i in xrange(len(codes)):
code = codes[i]
try:
img = Image.open(request.folder + 'uploads/' + code)
except:
continue
img.thumbnail((300, 300), Image.ANTIALIAS)
img_w,img_h=img.size
pasted = False
while pasted == False:
if offset_left + img_w  rowend:
offset_down += img_h
offset_left = margin
elif offset_down + img_h  pageend:
images += background
images += qrmake(codes[i:])
return images
else:
background.paste(img,(offset_left,offset_down))
pasted = True
images += background
return images

What I need to happen though is to display the images that I generated in 
the validation. I have played with doing this several different ways, but 
nothing has worked so far. Am I approaching this the wrong way or is there 
something I am missing?

-- 
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/groups/opt_out.


[web2py] Re: Displaying computed data from form submission

2014-01-24 Thread Chris Hepworth
I feel ridiculous admitting this, but I didn't realize I had omitted the 
code saving them into the global variables. The result set doesn't need to 
be persistent, so storing it to the database would be unnecessary. It will 
only be displayed to the user once.

On Friday, January 24, 2014 1:38:01 PM UTC-7, Jaime Sempere wrote:


 Maybe I am wrong, but i think you are not storing the images. When you do :  
   

 form=FORM(fields, onvalidation=qrparse)

 Did you guessed qrparse return values are being stored in form or 
 somewhere?

 You need to store in a cookie, global variable (and then show them in the 
 view using {{=}}) or maybe save in in the form like a prepopulate field (I 
 don't know where you want to show the images).

 Could you tell us where would you like to show the images?


-- 
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/groups/opt_out.


Re: [web2py] Re: Dynamic form generation using FORM()

2014-01-15 Thread Chris Hepworth
I actually have a very odd data set that is getting put into the form. They
represent several different tables and the only real unifying feature is
the uploaded photos. The idea is to fetch a list of photos to retrieve for
the user using a single form. That is why the checkbox value is the
encrypted name of the file and the assigned name is displayed next to them.


On Wed, Jan 15, 2014 at 6:08 AM, Tim Richardson t...@growthpath.com.auwrote:

 out of curiosity why not use SQLFORM.grid with selectable?

 --
 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/lRbZyCV70z4/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/groups/opt_out.


-- 
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/groups/opt_out.


[web2py] Dynamic form generation using FORM()

2014-01-14 Thread Chris Hepworth
I am trying to make a custom form which allows the selection of a set of 
images that are in the database. So far I have the following code:

rows = db().select(db.a_table.name,db.a_table.image)
fields = []
for row in rows:
fields += [
INPUT(_type=checkbox, _value=row.image) , row.f_name
]
form=FORM(fields,INPUT(_type='submit'))

I know for sure that the database query is correct and is not a problem at 
all now. However, when I insert the form into the view it appears as 
follows:

[gluon.html.INPUT object at 0xaf12bc2c, 'Koi', gluon.html.INPUT objectat 
0xaf12bb8c, 'Goldfish'...

The only thing that renders as intended is the submit button. Am I going 
about this problem the right way? And if not, is there a way to achieve the 
effect I want? 

-- 
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/groups/opt_out.


[web2py] Re: Dynamic form generation using FORM()

2014-01-14 Thread Chris Hepworth
You know, I hate to say it but that never even occurred to me to try. I got 
so distracted with other things that I never took the time to really 
evaluate what could be happeing. Thank you, Anthony.

On Tuesday, January 14, 2014 5:23:23 PM UTC-7, Anthony wrote:

 If you want to submit a list of inputs to FORM(), then that's all you can 
 submit. So, append the submit input to the fields list and then just do 
 FORM(fields).

 Also, if db.a_table.image is an upload field, it will just store the 
 transformed filename, which won't be very informative to the users. You'll 
 probably want to show the original filename (it may be easiest to store 
 that in a separate field rather than extract it from the transformed 
 filename).

 Anthony

 On Tuesday, January 14, 2014 4:44:49 PM UTC-5, Chris Hepworth wrote:

 I am trying to make a custom form which allows the selection of a set of 
 images that are in the database. So far I have the following code:

 rows = db().select(db.a_table.name,db.a_table.image)
 fields = []
 for row in rows:
 fields += [
 INPUT(_type=checkbox, _value=row.image) , row.f_name
 ]
 form=FORM(fields,INPUT(_type='submit'))

 I know for sure that the database query is correct and is not a problem 
 at all now. However, when I insert the form into the view it appears as 
 follows:

 [gluon.html.INPUT object at 0xaf12bc2c, 'Koi', gluon.html.INPUT objectat 
 0xaf12bb8c, 'Goldfish'...

 The only thing that renders as intended is the submit button. Am I going 
 about this problem the right way? And if not, is there a way to achieve the 
 effect I want? 



-- 
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/groups/opt_out.


[web2py] Re: IntegrityError: column email is not unique

2013-12-18 Thread Chris Hepworth
Thank you for that, I didn't realize I needed to drop the tables. It is 
working exactly as expected now.

On Tuesday, December 17, 2013 8:08:06 PM UTC-7, Massimo Di Pierro wrote:

 The problem is that my workaround is not retroactive. I believe the bug is 
 fixed but does not apply to tables created before the upgrade with the 
 fixed code.
 You have to manually alter table and remove the UNIQUE attribute. web2py 
 is not smart enough to be able to do that.

 On Tuesday, 17 December 2013 16:38:11 UTC-6, Chris Hepworth wrote:

 Running version 2.8.2-stable+timestamp.2013.11.28.13.54.07 I recieved 
 the same error as described above. I also tried to use the workaround 
 Massimo suggested below, but without success, the update still fails. Do I 
 need to delete my current archive table before attempting this? 

 On Monday, July 16, 2012 3:54:54 PM UTC-6, Remco K wrote:

 Hi everyone,

 I got stuck in creating an update form for an auth_user.

 In the auth_user table i made an extra field:

 Field('email', length=128, default='', unique=True, notnull=True),

 Now everytime i try to update the user information (the last name) i get 
 the error:

 IntegrityError: column email is not unique

 I try to combine updating the user information with creating an archive 
 entry for the previous entry:

 _id = db.auth_user(request.args(0)) or redirect(URL('index'))
 form = SQLFORM(db.auth_user, _id)
 if form.process(onsuccess=auth.archive).accepted:

 This method works for an other table which doesnt have an Field with 
 Unique=True but not for this table with this Unique=True value.

 Someone who can help me out a bit?

 Thanks in advance!
 Remco



-- 
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/groups/opt_out.


[web2py] Re: IntegrityError: column email is not unique

2013-12-17 Thread Chris Hepworth
Running version 2.8.2-stable+timestamp.2013.11.28.13.54.07 I recieved the 
same error as described above. I also tried to use the workaround Massimo 
suggested below, but without success, the update still fails. Do I need to 
delete my current archive table before attempting this? 

On Monday, July 16, 2012 3:54:54 PM UTC-6, Remco K wrote:

 Hi everyone,

 I got stuck in creating an update form for an auth_user.

 In the auth_user table i made an extra field:

 Field('email', length=128, default='', unique=True, notnull=True),

 Now everytime i try to update the user information (the last name) i get 
 the error:

 IntegrityError: column email is not unique

 I try to combine updating the user information with creating an archive 
 entry for the previous entry:

 _id = db.auth_user(request.args(0)) or redirect(URL('index'))
 form = SQLFORM(db.auth_user, _id)
 if form.process(onsuccess=auth.archive).accepted:

 This method works for an other table which doesnt have an Field with 
 Unique=True but not for this table with this Unique=True value.

 Someone who can help me out a bit?

 Thanks in advance!
 Remco

-- 
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/groups/opt_out.


[web2py] LOAD Helper produces only loading... on fresh install.

2013-12-02 Thread Chris Hepworth
I have recently installed web2py, so I don't think the issue is out of date 
files. I have been following the recipe in the documentation, so my code is 
as follows:

index.html:
{{extend 'layout.html'}}

{{=LOAD('comments','post.load',ajax=True)}}

post.load:
{{for post in comments:}}
div class=post
  On {{=post.created_on}} {{=post.created_by.first_name}}
  says span class=post_body{{=post.f_comment}}/span
/div
{{pass}}
{{=form}}
The table definition I used had f_comment in place of body for the main 
text of the comment.

comments.py:

@auth.requires_login()
def post():
db.t_comment.f_approved.writable = False
db.t_comment.f_approved.readable = False
form=SQLFORM(db.t_comment).process()
comments=db(db.t_comment).select()
return dict(form=form,comments=comments)

Loading the page my accessing through app/comments/post.load works fine and 
the functionality is there. But when the index page loads, it never gets 
beyond loading 

-- 
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/groups/opt_out.


[web2py] Re: LOAD Helper produces only loading... on fresh install.

2013-12-02 Thread Chris Hepworth
I found my error.

On Monday, December 2, 2013 11:06:45 AM UTC-7, Chris Hepworth wrote:

 I have recently installed web2py, so I don't think the issue is out of 
 date files. I have been following the recipe in the documentation, so my 
 code is as follows:

 index.html:
 {{extend 'layout.html'}}

 {{=LOAD('comments','post.load',ajax=True)}}

 post.load:
 {{for post in comments:}}
 div class=post
   On {{=post.created_on}} {{=post.created_by.first_name}}
   says span class=post_body{{=post.f_comment}}/span
 /div
 {{pass}}
 {{=form}}
 The table definition I used had f_comment in place of body for the main 
 text of the comment.

 comments.py:

 @auth.requires_login()
 def post():
 form=SQLFORM(db.t_comment).process()
 comments=db(db.t_comment).select()
 return dict(form=form,comments=comments)

 Loading the page my accessing through app/comments/post.load works fine 
 and the functionality is there. But when the index page loads, it never 
 gets beyond loading 


-- 
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/groups/opt_out.


[web2py] Re: If logic in the menu.py model

2013-11-18 Thread Chris Hepworth
That worked perfectly! Thank you for the help, I guess my command of basic 
Python isn't nearly as good as I had thought...

On Saturday, November 16, 2013 2:05:40 AM UTC-7, Massimo Di Pierro wrote:

 This is not valid python syntax. Try:

 submenu = []

 response.menu = [(T('Manage'),URL(),URL(),submenu), ...]

 if auth.has_membership('admin'): submenu += [
 (T('Users'),URL('cms','users_manage')==URL(),URL('cms',
 'users_manage'),[]),   
 (T('Groups'),URL('cms','groups_manage')==URL(),URL('cms',
 'groups_manage'),[]),
 (T('Exhibits'),URL('cms','exhibits_manage')==URL(),URL('cms',
 'exhibits_manage'),[])]
 if auth.has_membership('collection_admin'): submenu += [
 (T('Display'),URL('cms','display_manage')==URL(),URL('cms',
 'display_manage'),[]),
 (T('Items'),URL('cms','items_manage')==URL(),URL('cms',
 'items_manage'),[]),
 (T('Categories'),URL('cms','categories_manage')==URL(),URL('cms',
 'categories_manage'),[]),
 (T('Tours'),URL('cms','tours_manage')==URL(),URL('cms',
 'tours_manage'),[])]
 if auth.has_membership('comment_moderator'): submenu += [
 (T('Comments'),URL('cms','comments_manage')==URL(),URL('cms',
 'comments_manage'),[]),
 ]


 On Friday, 15 November 2013 19:06:25 UTC-6, Chris Hepworth wrote:

 I am new to web2py and have what may be a stupid question.

 In the application I am designing there are a number of different tables 
 I have basic SQLforms to manage. I already have access control being 
 enforced in the controller using the appropriate decorators, but I would 
 like to further increase security by limiting which options are available 
 in the menu. I was trying to use if statements as follows:

 (T('Manage'),URL(),URL(),[
 if auth.has_membership('admin'):
 (T('Users'),URL('cms','users_manage')==URL(),URL('cms',
 'users_manage'),[]),   
 (T('Groups'),URL('cms','groups_manage')==URL(),URL('cms',
 'groups_manage'),[]),
 (T('Exhibits'),URL('cms','exhibits_manage')==URL(),URL('cms',
 'exhibits_manage'),[]),
 if auth.has_membership('collection_admin'):
 (T('Display'),URL('cms','display_manage')==URL(),URL('cms',
 'display_manage'),[]),
 (T('Items'),URL('cms','items_manage')==URL(),URL('cms',
 'items_manage'),[]),
 (T('Categories'),URL('cms','categories_manage')==URL(),URL('cms',
 'categories_manage'),[]),
 (T('Tours'),URL('cms','tours_manage')==URL(),URL('cms',
 'tours_manage'),[]),
 if auth.has_membership('comment_moderator'):
 (T('Comments'),URL('cms','comments_manage')==URL(),URL('cms',
 'comments_manage'),[]),
 ]),

 The error traceback indicates that the if statement is invalid, but I 
 don't see why that would be. If someone with more experience could 
 illuminate me, I would be much 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.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] If logic in the menu.py model

2013-11-16 Thread Chris Hepworth
I am new to web2py and have what may be a stupid question.

In the application I am designing there are a number of different tables I 
have basic SQLforms to manage. I already have access control being enforced 
in the controller using the appropriate decorators, but I would like to 
further increase security by limiting which options are available in the 
menu. I was trying to use if statements as follows:

(T('Manage'),URL(),URL(),[
if auth.has_membership('admin'):
(T('Users'),URL('cms','users_manage')==URL(),URL('cms',
'users_manage'),[]),   
(T('Groups'),URL('cms','groups_manage')==URL(),URL('cms',
'groups_manage'),[]),
(T('Exhibits'),URL('cms','exhibits_manage')==URL(),URL('cms',
'exhibits_manage'),[]),
if auth.has_membership('collection_admin'):
(T('Display'),URL('cms','display_manage')==URL(),URL('cms',
'display_manage'),[]),
(T('Items'),URL('cms','items_manage')==URL(),URL('cms',
'items_manage'),[]),
(T('Categories'),URL('cms','categories_manage')==URL(),URL('cms',
'categories_manage'),[]),
(T('Tours'),URL('cms','tours_manage')==URL(),URL('cms',
'tours_manage'),[]),
if auth.has_membership('comment_moderator'):
(T('Comments'),URL('cms','comments_manage')==URL(),URL('cms',
'comments_manage'),[]),
]),

The error traceback indicates that the if statement is invalid, but I don't 
see why that would be. If someone with more experience could illuminate me, 
I would be much 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.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Web2Py Hangs on Recaptcha Form Submission

2013-10-19 Thread Chris Stuff
Hello all,

I'm having an issue where I am using a simple form controller that 
essentially just has a Recaptcha field and a submit button:

def form():
from gluon.tools import Recaptcha
form = FORM (
Recaptcha(request, public_key, private_key),
INPUT(_type='submit'))
if form.process().accepted:
response.flash = 'Thanks!'
elif form.errors:
response.flash = 'Invalid Entry'
else:
response.flash = 'No thanks!'
return dict(form=form)

I call it using {{=form}}

If I submit the Recaptcha field with nothing in there, it responds 
immediately with an invalid submission.  If I fill in anything in the 
Recaptcha field (incorrect or otherwise), the browser just hangs there and 
I have to reset the web server. I have checked communications between my 
server and the Recaptcha server and it seems fine.  Also, I have made sure 
that I haven't mixed up any keys.

Has anyone else run into this issue recently?

Thanks,
Chris

-- 
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/groups/opt_out.


[web2py] Re: Truncated Data on Migration

2013-06-22 Thread Chris
Derek, the main issue isn't truncation at insert time.  In a web2py 
DAL-mediated create table statement, DAL code unilaterally reduces MySQL 
varchar lengths to 255, whether the specific version of MySQL could 
tolerate a longer varchar or not.  The developer says, column abc should be 
varchar(1000); DAL runs the define_table; the resulting column is 
varchar(255); no error is raised; developer has no reason to think there's 
a problem; then inserts data and mySQL silently truncates (corrupts) it. 
 The DAL problem would be equally bad, although easier for the developer to 
notice / and sooner, if MySQL didn't perform truncation.  The fact that 
MySQL performs truncation silently makes it that much more important that 
DAL not change the column definition silently.

If I use the mysql command line tool, create table xyz (abc varchar(1000)) 
results in a column of length 1000.  If I use the logically equivalent DAL 
define_table statement, it results in a column of length 255.  The two 
approaches, given the same inputs, really should have the same outcome.

The behavior is also inconsistent among DB engines.  For any DBMS other 
then MySQL, DAL enforces a max varchar length of 2^15.  However, Oracle 9i 
has a max varchar length of 4000; SQL Server 2005 has a max of 8000; etc. 
 Many DBMS versions have some limit.  In those cases, DAL attempts to 
define the table per the developer's instructions and returns a 
DBMS-specific error if a column length is unacceptable.  The same should be 
done for MySQL.

The correct behavior is to return an error if the developer issues a 
define_table statement that can't be fulfilled by the database layer.




On Wednesday, June 19, 2013 7:15:44 PM UTC-4, Derek wrote:

 It's not web2py's fault that MySQL silently truncates data.

 http://www.davidpashley.com/blog/databases/mysql/silently-truncated


 On Wednesday, June 19, 2013 5:52:26 AM UTC-7, Chris wrote:

 The main problem is that the failure is silent.  It makes no sense that a 
 developer declares a field to be length 1000, and DAL arbitrarily reduces 
 that to 255 instead of providing an error message.  I understand why 255 
 may be a safe default limit for MySQL; but if so then fail the field 
 creation with a relevant error message (and maybe reference Jonathan's 
 solution re: how to override maxcharlength if the developer knows the DBMS 
 version can handle the larger limit).

 In the current 2.5.1 code, looking in dal.py:

 class MySQLAdapter(BaseAdapter):
 
 maxcharlength = 255

 ...

 class Table(object):
 ...
 def __init__(self,
 db,
 tablename,
 *fields,
 **args
 ):
 ...
 for field in fields:
 ...
 if db and not field.type in ('text', 'blob', 'json') and \
 db._adapter.maxcharlength  field.length:
 field.length = db._adapter.maxcharlength   ### problem 
 line


 I'd recommend the last line above, marked ### problem line, be replaced 
 with something like, raise ValueError('Requested field length exceeds 
 adapter maxcharlength, cannot create.  See http://whatever for a way to 
 override this limit.')

 ??



-- 

--- 
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/groups/opt_out.




[web2py] Re: Truncated Data on Migration

2013-06-19 Thread Chris
The main problem is that the failure is silent.  It makes no sense that a 
developer declares a field to be length 1000, and DAL arbitrarily reduces 
that to 255 instead of providing an error message.  I understand why 255 
may be a safe default limit for MySQL; but if so then fail the field 
creation with a relevant error message (and maybe reference Jonathan's 
solution re: how to override maxcharlength if the developer knows the DBMS 
version can handle the larger limit).

In the current 2.5.1 code, looking in dal.py:

class MySQLAdapter(BaseAdapter):

maxcharlength = 255

...

class Table(object):
...
def __init__(self,
db,
tablename,
*fields,
**args
):
...
for field in fields:
...
if db and not field.type in ('text', 'blob', 'json') and \
db._adapter.maxcharlength  field.length:
field.length = db._adapter.maxcharlength   ### problem line


I'd recommend the last line above, marked ### problem line, be replaced 
with something like, raise ValueError('Requested field length exceeds 
adapter maxcharlength, cannot create.  See http://whatever for a way to 
override this limit.')

??

-- 

--- 
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/groups/opt_out.




[web2py] Preventing repeated submissions, or rate limiting submissions

2013-05-28 Thread Chris Teodorski
Aside from a Captcha (I'd rather not go that route, but may have to), is 
there a way to limit the number of times a user can submit a form in a 
certain amount of time?  

This isn't a login, but I'd prefer to prevent someone from brute forcing 
the correct submission.

Thanks for your ideas,

Chris


-- 

--- 
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/groups/opt_out.




[web2py] Re: Preventing repeated submissions, or rate limiting submissions

2013-05-28 Thread Chris Teodorski
On Tuesday, 28 May 2013 15:35:48 UTC-4, Niphlod wrote:

 If your problem lies into the realm of this form shouldn't be submitted 
 more than 5 times in 5 seconds you can play a little bit with your 
 controller


That is exactly what my problem is, or what I'm trying to prevent. 

-- 

--- 
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/groups/opt_out.




[web2py] Re: Preventing repeated submissions, or rate limiting submissions

2013-05-28 Thread Chris Teodorski
Just brute force prevention.  This should always be a human submitting with 
no bursts.



On Tuesday, 28 May 2013 15:46:33 UTC-4, Niphlod wrote:

 then the question should be are you in the search of a method that 
 enables users to submit 5 forms in 1 second but NOT 6 forms in 5 seconds 
 (i.e. do you allow short bursts/peeks) or just something that prevents 
 bruteforce and allows 1 submit in a second (pretty irrelevant waiting-time 
 for a human user)?

 On Tuesday, May 28, 2013 9:39:12 PM UTC+2, Chris Teodorski wrote:

 On Tuesday, 28 May 2013 15:35:48 UTC-4, Niphlod wrote:

 If your problem lies into the realm of this form shouldn't be submitted 
 more than 5 times in 5 seconds you can play a little bit with your 
 controller


 That is exactly what my problem is, or what I'm trying to prevent. 



-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-24 Thread Chris Teodorski
Anthony,

Once again, thanks for the help.

Chris

On Sunday, 19 May 2013 22:38:48 UTC-4, Chris Teodorski wrote:

 I will try my best here to explain what I'm after -- I'm clueless on how 
 to do it.  I added a custom field to db.auth_user called team_name.  Each 
 registered user should have a unique team name.  

 In a seperate table, I have a team name and a list of challenges, 
 1,2,3,etc.I want the team name of this table to reference the team_name 
 in auth_user.  I've tried several different variations -- but each time I 
 seem to either hang web2py or I get keyed tables can only reference 
 other keyed tables.
  
 my additions to auth_user look like 
 this: auth.settings.extra_fields['auth_user'] = [Field('team_name')]
 my other table definition looks like this at the moment -- but I've tried 
 other ways:
 db.define_table('t_teams',
 Field('name', db.auth_user.team_name),
 Field('f_chal1', type='boolean',
   label=T('Chal1')),
 Field('f_chal2', type='boolean',
   label=T('Chal2')),
 Field('f_chal3', type='boolean',
   label=T('Chal3')),
 Field('f_chal4', type='boolean',
   label=T('Chal4')),

 Thanks again for all the help.

 Chris





-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-23 Thread Chris Teodorski
Anthony,

How do I set them to writable when I need them to be?  I'm attempting to 
update them in a controller and I'm not sure how to do it

Chris


On Monday, 20 May 2013 12:19:32 UTC-4, Anthony wrote:

 Setting a field's writable attribute to False prevents users from 
 inputting values in forms, and setting the readable attribute to False 
 prevents the field from appearing at all. Note, you can set these 
 attributes dynamically, so they can default to False, but you can 
 selectively set them to True in particular contexts.

 Anthony

 On Monday, May 20, 2013 12:13:48 PM UTC-4, Chris Teodorski wrote:

 Sorry - it is a one to one relationship.  So if I include it as part of 
 the auth_user table -- I will need to prevent users form directly editing 
 the challenge fields (and not expose them on registration) -- so I guess I 
 now need to figure out how to do that.

 Thanks again for the help.


 On Monday, 20 May 2013 11:43:13 UTC-4, Anthony wrote:

 I assumed this was a one-to-many relationship, but given that it is 
 actually one-to-one, you certainly could just put the t_teams fields 
 directly in the auth_user table.

 Anthony

 On Monday, May 20, 2013 10:02:11 AM UTC-4, Chris Teodorski wrote:

 Let me try again to explain what I'm striving for and see if that helps 
 you guys help me.  I'm really trying to explain as concisely as possible, 
 without explaining the nitty gritty of what I'm trying to do.

 In my ideal situation, when a user registers, they create a team name 
 as part of the registration process.  When registration occurs a row is 
 added to the the t_teams table which contains a field for their team name 
 and their status on all of the challenges.   

 Now that I'm explaining it -- perhaps the 'right' solution is to just 
 add the extra fields to the auth_user table and not bother with having a 
 secondary table.

 Chris




 On Monday, 20 May 2013 09:47:14 UTC-4, Chris Teodorski wrote:

 I'm going to give this a try -- but I'm honestly not sure exactly what 
 this field definition does.  I'm going to play with it a bit and RTFM to 
 see if I can figure it out.



 On Monday, 20 May 2013 09:26:23 UTC-4, Anthony wrote:

 Would it work for you to just have a foreign key reference to the 
 auth_user primary key, which is the id field? You could set the 
 represent 
 attribute of the name field to display the team_name value from the 
 referenced auth_user record.

 db.define_table('t_teams',
 Field('name', db.auth_user,
   requires=IS_IN_DB(db, 'auth_user.id', '%s(team_name)s'),
   represent=lambda id, r: db.auth_user(id).team_name))

 Anthony

 On Monday, May 20, 2013 7:49:49 AM UTC-4, Chris Teodorski wrote:

 What I'm trying to do -- and obviously not explaining well is to 
 have t_teams.name to be a foreign key for the field custom field in 
 auth_users.

 Does that explain it any better?

 On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote:

 uhm. 
 what do you want (as examples) in auth_user.team_name and what on 
 t_teams.name ?
 if you want e.g. a-team in auth_user.team_name and a-team in 
 t_teams.name, and a record in t_teams must exist only with a 
 name that is one of the team_name values of the auth_user table 
 (i.e. you 
 have to create the user BEFORE the t_teams), then you can't create 
 that 
 reference.

 You should use a Field('name', requires=IS_IN_DB(db, 
 'auth_user.team_name'))






-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-23 Thread Chris Teodorski
So I'm stuck again and once again -- appreciate any help.  What I'm doing 
it pretty simple, I think.  The code runs fine -- no error messages, but 
the field isn't updated as I expect.  So something is borked.  flag 
contains an integer from 1-16.  The field in the db is called f_chal1, 
f_chal2, etc.

def update_scoreboard(flag):
team = auth.user.id
print flag
print team
challenge = 'f_chal' + str(flag)
print challenge
row = db(db.auth_user.id == team).select().first()
db.auth_user.challenge.writable=True
print row
row.challenge = True
row.update_record()
db.commit()


On Sunday, 19 May 2013 22:38:48 UTC-4, Chris Teodorski wrote:

 I will try my best here to explain what I'm after -- I'm clueless on how 
 to do it.  I added a custom field to db.auth_user called team_name.  Each 
 registered user should have a unique team name.  

 In a seperate table, I have a team name and a list of challenges, 
 1,2,3,etc.I want the team name of this table to reference the team_name 
 in auth_user.  I've tried several different variations -- but each time I 
 seem to either hang web2py or I get keyed tables can only reference 
 other keyed tables.
  
 my additions to auth_user look like 
 this: auth.settings.extra_fields['auth_user'] = [Field('team_name')]
 my other table definition looks like this at the moment -- but I've tried 
 other ways:
 db.define_table('t_teams',
 Field('name', db.auth_user.team_name),
 Field('f_chal1', type='boolean',
   label=T('Chal1')),
 Field('f_chal2', type='boolean',
   label=T('Chal2')),
 Field('f_chal3', type='boolean',
   label=T('Chal3')),
 Field('f_chal4', type='boolean',
   label=T('Chal4')),

 Thanks again for all the help.

 Chris





-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-20 Thread Chris Teodorski
What I'm trying to do -- and obviously not explaining well is to have 
t_teams.name to be a foreign key for the field custom field in auth_users.

Does that explain it any better?

On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote:

 uhm. 
 what do you want (as examples) in auth_user.team_name and what on 
 t_teams.name ?
 if you want e.g. a-team in auth_user.team_name and a-team in 
 t_teams.name, and a record in t_teams must exist only with a name that 
 is one of the team_name values of the auth_user table (i.e. you have to 
 create the user BEFORE the t_teams), then you can't create that reference.

 You should use a Field('name', requires=IS_IN_DB(db, 
 'auth_user.team_name'))






-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-20 Thread Chris Teodorski
I'm going to give this a try -- but I'm honestly not sure exactly what this 
field definition does.  I'm going to play with it a bit and RTFM to see if 
I can figure it out.



On Monday, 20 May 2013 09:26:23 UTC-4, Anthony wrote:

 Would it work for you to just have a foreign key reference to the 
 auth_user primary key, which is the id field? You could set the represent 
 attribute of the name field to display the team_name value from the 
 referenced auth_user record.

 db.define_table('t_teams',
 Field('name', db.auth_user,
   requires=IS_IN_DB(db, 'auth_user.id', '%s(team_name)s'),
   represent=lambda id, r: db.auth_user(id).team_name))

 Anthony

 On Monday, May 20, 2013 7:49:49 AM UTC-4, Chris Teodorski wrote:

 What I'm trying to do -- and obviously not explaining well is to have 
 t_teams.name to be a foreign key for the field custom field in 
 auth_users.

 Does that explain it any better?

 On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote:

 uhm. 
 what do you want (as examples) in auth_user.team_name and what on 
 t_teams.name ?
 if you want e.g. a-team in auth_user.team_name and a-team in 
 t_teams.name, and a record in t_teams must exist only with a name 
 that is one of the team_name values of the auth_user table (i.e. you have 
 to create the user BEFORE the t_teams), then you can't create that 
 reference.

 You should use a Field('name', requires=IS_IN_DB(db, 
 'auth_user.team_name'))






-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-20 Thread Chris Teodorski
Let me try again to explain what I'm striving for and see if that helps you 
guys help me.  I'm really trying to explain as concisely as possible, 
without explaining the nitty gritty of what I'm trying to do.

In my ideal situation, when a user registers, they create a team name as 
part of the registration process.  When registration occurs a row is added 
to the the t_teams table which contains a field for their team name and 
their status on all of the challenges.   

Now that I'm explaining it -- perhaps the 'right' solution is to just add 
the extra fields to the auth_user table and not bother with having a 
secondary table.

Chris




On Monday, 20 May 2013 09:47:14 UTC-4, Chris Teodorski wrote:

 I'm going to give this a try -- but I'm honestly not sure exactly what 
 this field definition does.  I'm going to play with it a bit and RTFM to 
 see if I can figure it out.



 On Monday, 20 May 2013 09:26:23 UTC-4, Anthony wrote:

 Would it work for you to just have a foreign key reference to the 
 auth_user primary key, which is the id field? You could set the represent 
 attribute of the name field to display the team_name value from the 
 referenced auth_user record.

 db.define_table('t_teams',
 Field('name', db.auth_user,
   requires=IS_IN_DB(db, 'auth_user.id', '%s(team_name)s'),
   represent=lambda id, r: db.auth_user(id).team_name))

 Anthony

 On Monday, May 20, 2013 7:49:49 AM UTC-4, Chris Teodorski wrote:

 What I'm trying to do -- and obviously not explaining well is to have 
 t_teams.name to be a foreign key for the field custom field in 
 auth_users.

 Does that explain it any better?

 On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote:

 uhm. 
 what do you want (as examples) in auth_user.team_name and what on 
 t_teams.name ?
 if you want e.g. a-team in auth_user.team_name and a-team in 
 t_teams.name, and a record in t_teams must exist only with a name 
 that is one of the team_name values of the auth_user table (i.e. you have 
 to create the user BEFORE the t_teams), then you can't create that 
 reference.

 You should use a Field('name', requires=IS_IN_DB(db, 
 'auth_user.team_name'))






-- 

--- 
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/groups/opt_out.




[web2py] Re: Referencing auth_user custom field in another table

2013-05-20 Thread Chris Teodorski
Sorry - it is a one to one relationship.  So if I include it as part of the 
auth_user table -- I will need to prevent users form directly editing the 
challenge fields (and not expose them on registration) -- so I guess I now 
need to figure out how to do that.

Thanks again for the help.


On Monday, 20 May 2013 11:43:13 UTC-4, Anthony wrote:

 I assumed this was a one-to-many relationship, but given that it is 
 actually one-to-one, you certainly could just put the t_teams fields 
 directly in the auth_user table.

 Anthony

 On Monday, May 20, 2013 10:02:11 AM UTC-4, Chris Teodorski wrote:

 Let me try again to explain what I'm striving for and see if that helps 
 you guys help me.  I'm really trying to explain as concisely as possible, 
 without explaining the nitty gritty of what I'm trying to do.

 In my ideal situation, when a user registers, they create a team name as 
 part of the registration process.  When registration occurs a row is added 
 to the the t_teams table which contains a field for their team name and 
 their status on all of the challenges.   

 Now that I'm explaining it -- perhaps the 'right' solution is to just add 
 the extra fields to the auth_user table and not bother with having a 
 secondary table.

 Chris




 On Monday, 20 May 2013 09:47:14 UTC-4, Chris Teodorski wrote:

 I'm going to give this a try -- but I'm honestly not sure exactly what 
 this field definition does.  I'm going to play with it a bit and RTFM to 
 see if I can figure it out.



 On Monday, 20 May 2013 09:26:23 UTC-4, Anthony wrote:

 Would it work for you to just have a foreign key reference to the 
 auth_user primary key, which is the id field? You could set the 
 represent 
 attribute of the name field to display the team_name value from the 
 referenced auth_user record.

 db.define_table('t_teams',
 Field('name', db.auth_user,
   requires=IS_IN_DB(db, 'auth_user.id', '%s(team_name)s'),
   represent=lambda id, r: db.auth_user(id).team_name))

 Anthony

 On Monday, May 20, 2013 7:49:49 AM UTC-4, Chris Teodorski wrote:

 What I'm trying to do -- and obviously not explaining well is to have 
 t_teams.name to be a foreign key for the field custom field in 
 auth_users.

 Does that explain it any better?

 On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote:

 uhm. 
 what do you want (as examples) in auth_user.team_name and what on 
 t_teams.name ?
 if you want e.g. a-team in auth_user.team_name and a-team in 
 t_teams.name, and a record in t_teams must exist only with a name 
 that is one of the team_name values of the auth_user table (i.e. you 
 have 
 to create the user BEFORE the t_teams), then you can't create that 
 reference.

 You should use a Field('name', requires=IS_IN_DB(db, 
 'auth_user.team_name'))






-- 

--- 
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/groups/opt_out.




[web2py] write place for a sql query

2013-05-19 Thread Chris Teodorski
I have a form, that users submit -- when they submit the form, I want to 
validate it against valid data in the database, but I'm not sure where that 
query belongs.  I was trying to put it in a controller but it's not working 
like I expected.  Where is the right place to put these database calls, 
both queries and updates?

Thanks for the help.

Chris

-- 

--- 
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/groups/opt_out.




[web2py] Re: write place for a sql query

2013-05-19 Thread Chris Teodorski
The event is tied to the submit, in this case, it's basically a test 
question.  When the correct answer is submitted by the user (based upon a 
check of the database) then their row in the table is updated as having 
been correct.


On Sunday, 19 May 2013 15:39:05 UTC-4, Niphlod wrote:

 it depends if this event is bound to the user pressing the submit on 
 a form, maybe the best place is the onvalidation callback of the accepts() 
 or process() method


 http://web2py.com/books/default/chapter/29/07?search=onvalidation#onvalidation

 On Sunday, May 19, 2013 8:37:32 PM UTC+2, Chris Teodorski wrote:

 I have a form, that users submit -- when they submit the form, I want to 
 validate it against valid data in the database, but I'm not sure where that 
 query belongs.  I was trying to put it in a controller but it's not working 
 like I expected.  Where is the right place to put these database calls, 
 both queries and updates?

 Thanks for the help.

 Chris



-- 

--- 
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/groups/opt_out.




[web2py] Referencing auth_user custom field in another table

2013-05-19 Thread Chris Teodorski
I will try my best here to explain what I'm after -- I'm clueless on how to 
do it.  I added a custom field to db.auth_user called team_name.  Each 
registered user should have a unique team name.  

In a seperate table, I have a team name and a list of challenges, 
1,2,3,etc.I want the team name of this table to reference the team_name 
in auth_user.  I've tried several different variations -- but each time I 
seem to either hang web2py or I get keyed tables can only reference other 
keyed tables.
 
my additions to auth_user look like 
this: auth.settings.extra_fields['auth_user'] = [Field('team_name')]
my other table definition looks like this at the moment -- but I've tried 
other ways:
db.define_table('t_teams',
Field('name', db.auth_user.team_name),
Field('f_chal1', type='boolean',
  label=T('Chal1')),
Field('f_chal2', type='boolean',
  label=T('Chal2')),
Field('f_chal3', type='boolean',
  label=T('Chal3')),
Field('f_chal4', type='boolean',
  label=T('Chal4')),

Thanks again for all the help.

Chris



-- 

--- 
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/groups/opt_out.




[web2py] Re: write place for a sql query

2013-05-19 Thread Chris Teodorski
actually I did want to toss out any bad answer - to onvalidation was 
EXACTLY what I needed.  Thanks so much.

On Sunday, 19 May 2013 18:06:57 UTC-4, Niphlod wrote:

 so no, the onvalidation is meant to reject the submission if something 
 in the form doesn't need to be stored in the database.
 But, you want it stored no matter what, and then checked to see if it's 
 correct.
 This can be done hooking up to the _after_insert event on the table where 
 you store answers

 http://web2py.com/books/default/chapter/29/06?search=after_insert

 On Sunday, May 19, 2013 11:26:23 PM UTC+2, Chris Teodorski wrote:

 The event is tied to the submit, in this case, it's basically a test 
 question.  When the correct answer is submitted by the user (based upon a 
 check of the database) then their row in the table is updated as having 
 been correct.


 On Sunday, 19 May 2013 15:39:05 UTC-4, Niphlod wrote:

 it depends if this event is bound to the user pressing the submit 
 on a form, maybe the best place is the onvalidation callback of the 
 accepts() or process() method


 http://web2py.com/books/default/chapter/29/07?search=onvalidation#onvalidation

 On Sunday, May 19, 2013 8:37:32 PM UTC+2, Chris Teodorski wrote:

 I have a form, that users submit -- when they submit the form, I want 
 to validate it against valid data in the database, but I'm not sure where 
 that query belongs.  I was trying to put it in a controller but it's not 
 working like I expected.  Where is the right place to put these database 
 calls, both queries and updates?

 Thanks for the help.

 Chris



-- 

--- 
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/groups/opt_out.




[web2py] Re: need teaching advice (JS+jQuery)

2013-04-06 Thread Chris May


On Wednesday, April 3, 2013 3:10:23 PM UTC-4, Derek wrote:

 Flickr, Panaramio, RSS to JSON (http://ejohn.org/projects/rss2json/) 
 Yahoo YQL (http://developer.yahoo.com/yql/guide/response.html), Twitter, 
 Salesforce.com...

 One thing that bugs me is that jQuery returns jQuery objects not dom 
 objects, so certain things you want to do just don't work if you treat it 
 like regular JS.


You can access the DOM object very easily by appending '[0]' to the jQuery 
object.

For instance, $('#element')[0] will return the DOM element with the id of 
element, or jQuery('a[href=#]')[0] will return the first anchor tag 
with a href of #.

-- 

--- 
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/groups/opt_out.




[web2py] Re: need teaching advice (JS+jQuery)

2013-04-06 Thread Chris May
Your date has passed, so I don't know how useful this will be, but when I 
introduce people to jQuery, I usually start with fun, gimmicky things, like 
changing all the images in a web page to photos of cats:

jQuery('img').each(function() {var my = jQuery(this); 
my.attr('src','http://www.placekitten.com/'+my.width()+'/'+my.height())})

And then move on to show how jQuery enables you to interact with things on 
the page, like fading things in and out, resizing things, recoloring 
things, and then using mouseovers or clicks to trigger these things on 
other objects.

You could also show jQuery getting twitter updates.

On Wednesday, April 3, 2013 1:47:15 PM UTC-4, Massimo Di Pierro wrote:

 Tomorrow I am starting teach a new class. I did not create the class, it 
 was assigned to me. The class is for undergraduate students who have little 
 or no programming experience but know HTML+CSS. No server-side programming 
 experience. The class should cover JS+jQuery but no server-side programming.

 What are some cool uses of JS/jQuery that do not involve server-side 
 programming? 
 I am thinking of hooking to some JSONP services. Is there any you would 
 suggest?

 Massimo


-- 

--- 
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/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-06 Thread Chris May
Wow. It's cool that web2py ships with a websockets implementation. I was 
also thinking like Arnon about how to implement server-sent events with 
web2py.

As such I do want to add, maybe for posterity sake, that websockets serve a 
different use case than server-sent events, and are more complicated.
http://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource

But, with so much figured out already maybe it is better to use websockets.



-- 

--- 
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/groups/opt_out.




[web2py] Re: Truncated Data on Migration

2013-04-03 Thread Chris
It would probably be difficult to keep DAL up to date with DBMS releases -- 
would hate to have to rev some part of web2py every time even one of the 
supported DBMSs has a version change.  And even then, version alone may not 
answer the question, since max field lengths can be affected by database 
configuration options as well.

A better solution would be for DAL to probe the actual DBMS capabilities -- 
if there is a question about an issue like a max string length, allow DAL 
to control one table (dbms_capabilities?) that can be used to test actual 
limits.  E.g. if a DB model file specifies a string field of length 8000 
and that is above the previously-tested limit, drop and create 
dbms_capabilities with a string(8000) field, write 8000 characters to it, 
read it back, and see if the result matches the input.  This would be a 
very thorough way to find the limits of any database exactly as configured.

Not sure if this would be needed for other data types too (decimal 
precision or ??) but could be generalized.

The original problem of silently accepting a database definition that the 
DBMS can't produce is really concerning.




On Friday, September 14, 2012 9:39:14 AM UTC-4, Chris wrote:

 ... whatever the max length is for the particular DBMS / version, if the 
 Field() call specifies a length longer than the max, return the same error 
 as for other invalid field lengths (like -1).




-- 

--- 
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/groups/opt_out.




  1   2   3   4   5   >