[web2py] .tar.gz files get renamed to .gz on upload

2018-11-19 Thread Jordan Ladora
Hi,

This is kind of a bug and kind of a feature, and I presume it would happen 
with any two-part file extension. 

When I upload a .tar.gz file into my app, w2p appropriately renames the 
file preserving the extension, but the problem is, w2p assumes the 
extension is .gz and not the entire .tar.gz string, which causes an issue 
in my app, where .tar.gz and .gz files are handled differently. 

I looked through the source but wasn't able to find where the uploaded file 
renaming was done. 

This is on 2.17.2

Thanks for any help!


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


[web2py] Re: Big file uploads not always inserting into db with sqlite/rocket

2018-10-10 Thread Jordan Ladora
Firefox!

Thanks very much for this - it's really helpful.

I use apache/postgres on production servers but it will take me a very long 
time to upload such a big file to those [remote] servers, so I was testing 
locally. Based on your experience, I think my issue is probably just due to 
the limitations of rocket, so I won't sweat it. ;)

-jl


On Wednesday, October 10, 2018 at 3:41:29 PM UTC-6, Dave S wrote:
>
>
>
> On Wednesday, October 10, 2018 at 9:31:04 AM UTC-7, Jordan Ladora wrote:
>>
>> Hi!
>>
>> I just noticed that uploading files up to around 120mb using a simple 
>> form (crud.create) and model works reliably using the default setup on 
>> linux (sqlite and rocket). But when trying to upload files around 500mb, 
>> while the file always goes correctly to the upload folder, the db insert 
>> only occurs around 25% of the time, maybe even less.. basically sometimes 
>> it works but usually it doesn't.
>>
>> The sizes of 120mb and 500mb are just the big files I happened to have. I 
>> haven't gone through and tested up to what file size it is when things stop 
>> working reliably.
>>
>> Was wondering if anyone had a similar experience?
>>
>  
>
>> TY!
>>
> -jl
>>
>>
>
>
> First question:  what's uploading the file (what browser or client is 
> being used)?  
>
> Also, I used to use Rocket on a low-traffic production server running on 
> AWS linux, but had occasional issues with big files, especially from a 
> Windows client using WinInet calls.  The issue was at least in part the 
> signalling of the end of transfer; the client generally got finished and 
> went back to minding its own business while the server sat around waiting 
> for completion, and eventually timing out.  I also had problems with the 
> system breaking after an update of my LetsEncrypt certificates (I don't 
> think I figured out what broke).
>
> For those reasons, I switched to NginX, and have been very happy.  Basic 
> setup is quite easy (the sample installation scripts were pretty close to 
> what I did -- I cribbed heavily from them; for AWS it was a matter of 
> combining part of the Ubunto with part of the Centos  scripts.
>
> For more detail on my experiences,
> https://groups.google.com/d/msg/web2py/lSdsqHLftVQ/Hf1j7z5jCwAJ>
> that connects to a thread about the Rocket server hanging (headlined as 
> "crash") in
> https://groups.google.com/d/msg/web2py/dTK5lxWBsIA/3sIYnwMsBwAJ>
>
> In the client-happy-server-logs-a-timeout scenario, the file eventually 
> showed up in the download dir; I don't remember if the database entry was 
> completed.
>
> Rocket (in it's web2py fork) have been pretty stable for a long time, and 
> I think it is unlikely to get much maintenance until a security issue shows 
> up.
>
> /dps
>
>
>  
>

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


[web2py] Big file uploads not always inserting into db with sqlite/rocket

2018-10-10 Thread Jordan Ladora
Hi!

I just noticed that uploading files up to around 120mb using a simple form 
(crud.create) and model works reliably using the default setup on linux 
(sqlite and rocket). But when trying to upload files around 500mb, while 
the file always goes correctly to the upload folder, the db insert only 
occurs around 25% of the time, maybe even less.. basically sometimes it 
works but usually it doesn't.

The sizes of 120mb and 500mb are just the big files I happened to have. I 
haven't gone through and tested up to what file size it is when things stop 
working reliably.

Was wondering if anyone had a similar experience?

TY!
-jl

-- 
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] selinux users and roles for homemade task queue

2018-02-27 Thread Jordan Ladora
Hi,

I have user apache running w2p, and this user cannot log in, has no 
directory, etc. I also set selinux user mapping for apache on creation to 
further limit what it can do. ie-


*useradd -s /sbin/nologin -d /dev/null -c 'apache webserver' -Z user_u 
apache*
...and I use apache to also start the homemade task queues, eg-


*sudo -u apache nohup python web2py.py -S init -M -R HTQ_script.py*
...this is called by the root user since apache cannot log in. But where 
selinux is concerned, the HTQ script runs as the root user (because the 
root user uses sudo to run the command as apache) and is thus unconfined. 
(see e.g. https://wiki.gentoo.org/wiki/SELinux/Unconfined_domains for why 
this is potentially risky).

i.e.-

# as root

*id -Z*

*unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023*
# as root sudo apache

*sudo -u apache id -Z*

*unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023*

I tried messing around with sudo's '-r' param to set other user roles for 
apache when calling the HTQ script above (like suggested here 
)
 
but couldn't get it to work. I'm also using targeted policy and not MLS so 
that might be part of the issue. I started to look into this deeper but 
really don't want to have to sit down and read a book on selinux to figure 
it all out, and then started to wonder if this matters at all, anyway, and 
thought maybe the best thing to do would be to ask here. So the question 
is, is there any security risk to calling a HTQ script as a selinux 
unconfined user??

Thanks for any help,
jl



-- 
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: session var in table decimal field throws error on postgres

2018-02-27 Thread Jordan Ladora
Sure, really not much to see.. not sure if this is what you're asking, but 
I've got the module in the modules folder, and in a model I have-


*from _vars import **
...which throws an error that w2p is unable to find it, so I just use-



*from sys import pathpath append('...web2py/applications/init/modules')*
...and the import is fine. 



On Monday, February 26, 2018 at 5:52:47 PM UTC-7, Anthony wrote:
>
> On Monday, February 26, 2018 at 5:29:46 PM UTC-5, Jordan Ladora wrote:
>>
>> Forgot to reply to this earlier but I ended up putting them in a module 
>> to be imported. 
>>
>> Incidentally, I noticed when importing a module (from outside the regular 
>> system path for python libs) into a model, I needed to append the 
>> app/modules folder path before doing the import.
>>
>
> You should not need to do that. Can we see your exact code?
>
> 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: session var in table decimal field throws error on postgres

2018-02-26 Thread Jordan Ladora
Forgot to reply to this earlier but I ended up putting them in a module to 
be imported. 

Incidentally, I noticed when importing a module (from outside the regular 
system path for python libs) into a model, I needed to append the 
app/modules folder path before doing the import. Never needed to import 
anything from modules into a model before (just controllers) but wanted to 
mention it in case someone else does this. 

Thanks again.


On Thursday, February 1, 2018 at 4:08:02 PM UTC-7, Anthony wrote:
>
> On Thursday, February 1, 2018 at 4:53:59 PM UTC-5, Jordan Ladora wrote:
>>
>> Hi Anthony,
>>
>> Thanks again for this. I had dozens of vars that were needlessly declared 
>> as session vars. 
>>
>> I was wondering how to make global vars declared in a model accessible 
>> from a compiled module (that is placed in the modules folder and imported 
>> when needed by models and controllers)? e.g. from your example above, how 
>> could a compiled module access the DECPLACES global variable?
>>
>
> There are  a couple options. First, you could put those constants 
> themselves in a module instead of a model file, and then import them into 
> models, modules, controllers, etc. Alternatively, in your module, you can 
> do something like:
>
> from gluon import current
>
> def some_function():
> decplaces = current.globalenv['DECPLACES'] # This goes inside a 
> function, not at the top level of the module.
> ...
>
> current.globalenv is a dictionary of the web2py global environment.
>
> I would probably take the first approach.
>
> 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] postgres not making new table in model

2018-02-12 Thread Jordan Ladora
I've got a postgres server running which has been working fine the last 
month or so with no issues. 

I just added a new table in a model but cannot get the migration to work. 
Everything was updated correctly in the databases folder after doing this, 
and I've got 

migrate=True

...in all my table declarations and 

migrate=True
fake_migrate_all=True

...in my DAL string. 

I tried trashing all the files in the databases folder (which were 
recreated properly by w2p, including making a new one for the new table), 
restarting postgres, and turning migrate and fake_migrate_all to either 
True or False. But I kept getting tickets with 'relation  does 
not exist' when trying to do an insert. Listing all the tables in postgres 
does not show the new table, so I'm thinking I'm probably missing something 
in a model. 

Thanks for any suggestions,
-jl

-- 
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: Convert languages.lazyT object to string

2018-02-12 Thread Jordan Ladora
Thank you both for your help and patience with this. Oversight on my part-- 

I was mistaken by the ticket thrown - the first ticket I got when running 
this was for the 'message' (which i tried to cast to string to fix it 
before i posted here) param in the email, but then after that i was getting 
very similar tickets for other fields, at least some of which were still 
lazyT (e.g. subject). So, i'd actually begun to fix the problem by casting 
to str() as you both suggested, but kept throwing tickets and didn't look 
at those additional tickets closely enough to realize that i'd already 
begun to fix the problem.. :0  Then i started messing around in the console 
and posted here about those errors, too. 

Bottom line - problems went away by casting the lazyT to str() like you 
recommended. :)



On Thursday, February 8, 2018 at 6:37:37 PM UTC-7, Anthony wrote:
>
> On Thursday, February 8, 2018 at 2:49:52 PM UTC-5, Jordan Ladora wrote:
>>
>> Trying to get this to work but not getting anywhere-
>>
>> *from gluon import languages  # EDITED from '*
>>
>> *from gluon import *'abc = languages.lazyT("abc")*
>>
>
> The lazyT class takes a "T" argument, which should be in instance of the 
> "translator" class.
>  
>
>> I have a library that expects a basestring object but w2p in that context 
>> returns a lazyT (this is for password reset using a commercial service as a 
>> mailer). Specifically, this is gluon/tools.py line 3637 - the 'message' 
>> param is a lazyT object and I need a string.
>>
>
> auth.messages is an instance of gluon.storage.Messages -- when you 
> retrieve an attribute, it passes the value to current.T, which yields the 
> lazyT object. You can simply pass the value to str() to convert it to the 
> translated string.
>
> Anthony
>

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


[web2py] Re: Convert languages.lazyT object to string

2018-02-08 Thread Jordan Ladora
Hi,

I'm actually not trying to use it directly- I'm trying to convert a lazyT 
object (which is passed as email message text to make a reset password link 
by gluon/tools.py line 3637 in latest release) to a string bc I have an 
outside library (boto3) that expects a parameter (text of an email message) 
as a string. 




On Thursday, February 8, 2018 at 2:44:12 PM UTC-7, Leonel Câmara wrote:
>
> Why are you trying to use lazyT directly? If you want to do that you need 
> to build the lazyT class with a translator object. Something like:
>
> abc = languages.lazyT("abc", 
> languages.translator('path_to_language_files', 'en'))
>

-- 
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: How to use auth mailer with commercial service?

2018-02-08 Thread Jordan Ladora
This worked great for me. Just wanted to add a couple notes in case anyone 
else is interested-

I made ses_mailer a class with a call to send for compatibility with w2p's 
built-in mail capabilities. 

So, something like-

class ses_mailer(object):
  def send(self, to='', )

And then in the model-

auth.settings.mailer = ses_mailer()


Thanks again for the help, Anthony.
-j


On Tuesday, December 12, 2017 at 11:32:07 AM UTC-7, Jordan Ladora wrote:
>
> Cool! Thanks Anthony, I will try that.
>
>
>
> On Tue, Dec 12, 2017 at 11:02 AM, Anthony  wrote:
>
>> No, but you can pass a custom mailer to the Auth system to get it to send 
>> emails via AWS SES. You custom mailer should take the same arguments as the 
>> web2py mail.send() method (in particular, Auth just needs the "to", 
>> "subject", and "message" arguments) -- so, something like:
>>
>> def ses_mailer(to, subject, message):
>> # Use "to", "subject", and "message" in the below call to the boto 
>> send() 
>> method.
>> boto3.client('ses', ...).send(...)
>>
>> Then either:
>>
>> auth = Auth(..., mailer=ses_mailer)
>>
>> or after defining auth:
>>
>> auth.settings.mailer = ses_mailer
>>
>> Anthony
>>
>>
>> On Tuesday, December 12, 2017 at 11:40:06 AM UTC-5, Jordan Ladora wrote:
>>>
>>> Hi,
>>>
>>> How can I have the w2p default mailer use a commercial service, in my 
>>> case, AWS SES via boto?
>>>
>>> I've got these lines in a model and would like to have w2p send 
>>> verification & reset password emails via boto-
>>>
>>> *mail = auth.settings.mailer*
>>> *mail.settings.server = ...*
>>> *mail.settings.server = ...*
>>> *mail.settings.sender = ...*
>>> *mail.settings.login = ...*
>>> *auth.settings.registration_requires_verification = True*
>>> *auth.settings.registration_requires_approval = True*
>>> *auth.messages.verify_email = 'Click on the link http://' + 
>>> request.env.http_host + URL(r=request, c='default', f='user', 
>>> args=['verify_email']) + '/%(key)s to verify your email'*
>>> *auth.settings.reset_password_requires_verification = True*
>>> *auth.messages.reset_password = 'Click on the link http://' + 
>>> request.env.http_host + URL(r=request, c='default', f='user', 
>>> args=['reset_password']) + '/%(key)s to reset your password'*
>>>
>>>
>>> Thanks!
>>> -j
>>>
>>> -- 
>> 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/i13e9RJOxY0/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] Convert languages.lazyT object to string

2018-02-08 Thread Jordan Ladora
Trying to get this to work but not getting anywhere-








*from gluon import *abc = languages.lazyT("abc")str(abc)abc.read()*...etc. 
keeps throwing-

*AttributeError: 'NoneType' object has no attribute 'translate'*
I have a library that expects a basestring object but w2p in that context 
returns a lazyT (this is for password reset using a commercial service as a 
mailer). Specifically, this is gluon/tools.py line 3637 - the 'message' 
param is a lazyT object and I need a string. 

Thanks,
-j

-- 
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: session var in table decimal field throws error on postgres

2018-02-01 Thread Jordan Ladora
Hi Anthony,

Thanks again for this. I had dozens of vars that were needlessly declared
as session vars.

I was wondering how to make global vars declared in a model accessible from
a compiled module (that is placed in the modules folder and imported when
needed by models and controllers)? e.g. from your example above, how could
a compiled module access the DECPLACES global variable?

Cheers,
j



On Fri, Dec 29, 2017 at 4:14 PM, Anthony  wrote:

> On Friday, December 29, 2017 at 12:38:24 PM UTC-5, Jordan Ladora wrote:
>>
>> Brilliant - thank you very much for the thoughtful reply.
>>
>> I actually set it as a session var bc there are several tables with a
>> decimal field that I want to be consistent with each other,
>>
>
> Note, the session is unique per user, so it doesn't make sense to store a
> global value in the session, as you are unnecessarily storing a separate
> copy of it for each user. Instead, just create a constant somewhere in a
> model file and use that in your table definitions:
>
> DECPLACES = 7
>
> Or if the only place you need that constant is in defining decimal fields,
> just store the entire field type as a constant:
>
> DECFIELD = 'decimal(100, 7)'
>
> Then in your table definitions:
>
> db.define_table(..., Field('myfield', DECFIELD, ...))
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/WDUqTculX1Q/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: session var in table decimal field throws error on postgres

2017-12-29 Thread Jordan Ladora
Brilliant - thank you very much for the thoughtful reply. 

I actually set it as a session var bc there are several tables with a 
decimal field that I want to be consistent with each other, BUT I really 
appreciate your point about accidentally triggering db migrations. I hadn't 
considered that.

-jl


On Thursday, December 28, 2017 at 3:18:41 PM UTC-7, Anthony wrote:
>
> On Thursday, December 28, 2017 at 11:22:25 AM UTC-5, Jordan Ladora wrote:
>>
>> Hi,
>>
>> I'm using postgres and have a table-
>>
>> db.define_table('volumes',
>> Field('vol', 'decimal(100, session.decplaces)', default=0, 
>> readable=False, writable=False),
>> auth.signature, migrate=True,
>> )
>>
>
> Notice that 'decimal(100, session.decplaces)' is a string literal, not 
> Python code calling a decimal() function. The string literal is parsed by 
> the DAL, extracting the strings "100" and "session.decplaces", expecting 
> each to be interpretable as an integer. Of course, the string 
> "session.decplaces" is not an integer, so you get an error. Instead, you 
> have to create a string that includes the relevant integer value:
>
> 'decimal(100, %s)' % session.decplaces
>
> which will ultimately generate the string:
>
> 'decimal(100, 7)'
>
> Generally, though, storing the number of decimal places in a session 
> variable is probably not a good idea. Presumably you are using the session 
> because you want to allow different user sessions to have different numbers 
> of decimal places. But that doesn't work because the decimal places can 
> affect the database schema (depending on the database) -- so every time a 
> different user makes a request, you'll end up running a database migration 
> if migrations are turned on, or otherwise there will be no point to 
> specifying the different decimal places if migrations are turned off. In 
> any case, you will not end up with custom decimal places for each user, as 
> the decimal places are defined for an entire column, not per row. Pick one 
> decimal place and use it for all users (which means there is no reason to 
> store it in the session).
>
> 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] session var in table decimal field throws error on postgres

2017-12-28 Thread Jordan Ladora
Hi,

I'm using postgres and have a table-

db.define_table('volumes',
Field('vol', 'decimal(100, session.decplaces)', default=0, 
readable=False, writable=False),
auth.signature, migrate=True,
)

I have the session var declared before the table-

session.decplaces = 7

but I keep throwing "ValueError invalid literal for int() with base 10: 
session.decplaces" when loading the page. 

I tried casting session.decplaces to int, float but no luck- same error-

Field('vol', 'decimal(100, int(session.decplaces))', default=0, 
readable=False, writable=False),

Field('vol', 'decimal(100, int(float(session.decplaces)))', default=0, 
readable=False, writable=False),

Field('vol', 'decimal(100, float(session.decplaces))', default=0, 
readable=False, writable=False),

I can hardcode it-

Field('vol', 'decimal(100, 7)', default=0, readable=False, 
writable=False),

...and it works just fine, but I'd really like to be able to use the 
session var for this. 

TIA for any help!
-jl

-- 
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: How to use auth mailer with commercial service?

2017-12-12 Thread Jordan Ladora
Cool! Thanks Anthony, I will try that.



On Tue, Dec 12, 2017 at 11:02 AM, Anthony  wrote:

> No, but you can pass a custom mailer to the Auth system to get it to send
> emails via AWS SES. You custom mailer should take the same arguments as the
> web2py mail.send() method (in particular, Auth just needs the "to",
> "subject", and "message" arguments) -- so, something like:
>
> def ses_mailer(to, subject, message):
> # Use "to", "subject", and "message" in the below call to the boto send()
> method.
> boto3.client('ses', ...).send(...)
>
> Then either:
>
> auth = Auth(..., mailer=ses_mailer)
>
> or after defining auth:
>
> auth.settings.mailer = ses_mailer
>
> Anthony
>
>
> On Tuesday, December 12, 2017 at 11:40:06 AM UTC-5, Jordan Ladora wrote:
>>
>> Hi,
>>
>> How can I have the w2p default mailer use a commercial service, in my
>> case, AWS SES via boto?
>>
>> I've got these lines in a model and would like to have w2p send
>> verification & reset password emails via boto-
>>
>> *mail = auth.settings.mailer*
>> *mail.settings.server = ...*
>> *mail.settings.server = ...*
>> *mail.settings.sender = ...*
>> *mail.settings.login = ...*
>> *auth.settings.registration_requires_verification = True*
>> *auth.settings.registration_requires_approval = True*
>> *auth.messages.verify_email = 'Click on the link http://' +
>> request.env.http_host + URL(r=request, c='default', f='user',
>> args=['verify_email']) + '/%(key)s to verify your email'*
>> *auth.settings.reset_password_requires_verification = True*
>> *auth.messages.reset_password = 'Click on the link http://' +
>> request.env.http_host + URL(r=request, c='default', f='user',
>> args=['reset_password']) + '/%(key)s to reset your password'*
>>
>>
>> Thanks!
>> -j
>>
>> --
> 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/i13e9RJOxY0/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] How to use auth mailer with commercial service?

2017-12-12 Thread Jordan Ladora
Hi,

How can I have the w2p default mailer use a commercial service, in my case, 
AWS SES via boto?

I've got these lines in a model and would like to have w2p send 
verification & reset password emails via boto-

*mail = auth.settings.mailer*
*mail.settings.server = ...*
*mail.settings.server = ...*
*mail.settings.sender = ...*
*mail.settings.login = ...*
*auth.settings.registration_requires_verification = True*
*auth.settings.registration_requires_approval = True*
*auth.messages.verify_email = 'Click on the link http://' + 
request.env.http_host + URL(r=request, c='default', f='user', 
args=['verify_email']) + '/%(key)s to verify your email'*
*auth.settings.reset_password_requires_verification = True*
*auth.messages.reset_password = 'Click on the link http://' + 
request.env.http_host + URL(r=request, c='default', f='user', 
args=['reset_password']) + '/%(key)s to reset your password'*


Thanks!
-j

-- 
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: Basic question about app compile

2017-09-21 Thread Jordan Ladora
i see- thanks!

On Thursday, September 21, 2017 at 10:10:27 AM UTC-6, Anthony wrote:
>
> On Thursday, September 21, 2017 at 11:25:38 AM UTC-4, Jordan Ladora wrote:
>>
>>
>> Thank you both very much for the help. I didn't find that thread you 
>> mentioned, Anthony, before I posted my question yesterday. Thanks for 
>> mentioning all that.
>>
>> Incidentally, is there any way to install the compiled & packed app 
>> without appadmin? For security & compactness I run 
>> scripts/make_min_web2py.py & there's no admin.
>>
>
> The .w2p file generated by the admin app is just a gzipped tar file, so 
> you can unpack it as you would any such file.
>
> 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: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-09-21 Thread Jordan Ladora
My bad - I was confused there. Forgot to post this earlier, but you were 
totally right; it's only happening when not logged in. 

Thanks again for your patience & help.

-j



On Tuesday, June 6, 2017 at 2:41:56 PM UTC-6, Jordan Ladora wrote:
>
> Thank you for checking that.
>
> Yeah, I'm still getting this, even when logged in. As a temp workaround I 
> swapped all the instances of "validate_and_insert" in my app for "insert".
>
> I did find a note I made a couple years ago from back before I upgraded to 
> the latest version that said validate_and_insert would not work if no 
> fields were set, like in the '## no fields-' example I posted on 6/3, so 
> maybe this is due to something else I have e.g. in db.py...
>
>
>
> On Monday, June 5, 2017 at 10:43:16 AM UTC-6, Anthony wrote:
>>
>> On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>>>
>>> Thanks. It's also throwing the identical error when using the app's web 
>>> page as a logged in user.
>>>
>>
>> Are you sure? I tried it as a logged in user and it works fine (using 
>> your exact table definition and insert code).
>>
>> Anthony
>>
>

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


[web2py] Re: Basic question about app compile

2017-09-21 Thread Jordan Ladora

Thank you both very much for the help. I didn't find that thread you 
mentioned, Anthony, before I posted my question yesterday. Thanks for 
mentioning all that.

Incidentally, is there any way to install the compiled & packed app without 
appadmin? For security & compactness I run scripts/make_min_web2py.py & 
there's no admin.

Thanks again,
-j

 

On Wednesday, September 20, 2017 at 1:14:22 PM UTC-6, Jordan Ladora wrote:
>
> Hi,
>
> I was just wondering how the folder layout works when byte compiling an 
> app. I was trying some things on the basic Welcome app to try and sort it 
> out.
>
> After compiling the Welcome app, I tried two things. I moved out the 
> source files from the controllers, models, and views folders, and either 
> just left the compiled folder in place, or went and replaced all the source 
> files from the controllers, models, and views folders with those files from 
> the compiled folder. Neither of these attempts worked, throwing 'invalid 
> controller' errors. 
>
> The app obviously worked after compiling when I just left everything (the 
> original source files in controllers, models, views, and everything in the 
> compiled folder) in place, but I guess my question is if there is a way to 
> run a compiled app only using the compiled files from the compiled folder 
> and omit the original source files from mvc folders. 
>
> TY,
> -jl
>
>

-- 
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] Basic question about app compile

2017-09-20 Thread Jordan Ladora
Hi,

I was just wondering how the folder layout works when byte compiling an 
app. I was trying some things on the basic Welcome app to try and sort it 
out.

After compiling the Welcome app, I tried two things. I moved out the source 
files from the controllers, models, and views folders, and either just left 
the compiled folder in place, or went and replaced all the source files 
from the controllers, models, and views folders with those files from the 
compiled folder. Neither of these attempts worked, throwing 'invalid 
controller' errors. 

The app obviously worked after compiling when I just left everything (the 
original source files in controllers, models, views, and everything in the 
compiled folder) in place, but I guess my question is if there is a way to 
run a compiled app only using the compiled files from the compiled folder 
and omit the original source files from mvc folders. 

TY,
-jl

-- 
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: What does wikimenu do?

2017-08-30 Thread Jordan Ladora
oh i see - thanks Anthony!


On Wed, Aug 30, 2017 at 9:34 AM, Anthony  wrote:

> The wiki is described here: http://web2py.com/books/default/chapter/29/03/
> overview#The-built-in-web2py-wiki
>
> It appears auth.wikimenu isn't mentioned, but here is the code:
> https://github.com/web2py/web2py/blob/master/gluon/tools.py#L4228.
>
> It simply adds wiki menu items to response.menu.
>
> Anthony
>
> On Wednesday, August 30, 2017 at 11:25:43 AM UTC-4, Jordan Ladora wrote:
>>
>> The welcome app models/menu.py has the lines-
>>
>> if "auth" in locals():
>> auth.wikimenu
>>
>> ...but I can't find anything here or in the book about what the wikimenu
>> does? I have this commented out and all seems to be fine.
>>
>> Sorry if this is a silly question; just wondering..
>>
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/JIOvTbTCnZQ/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] What does wikimenu do?

2017-08-30 Thread Jordan Ladora
The welcome app models/menu.py has the lines-

if "auth" in locals():
auth.wikimenu

...but I can't find anything here or in the book about what the wikimenu 
does? I have this commented out and all seems to be fine.

Sorry if this is a silly question; just wondering..

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] Custom js popup confirmation not working

2017-06-15 Thread Jordan Ladora
Hello,

I'm trying to get a custom js confirmation popup working. This is pretty 
much verbatim from the 2nd answer at - 
https://stackoverflow.com/questions/887029/how-to-implement-confirmation-dialog-in-jquery-ui-dialog

When I add this code below to the view, this kills the rest of the js on 
the page, e.g. no dropdown menus work anymore, anywhere. The firefox 
console prints the 'TypeError: $(...).dialog is not a function' error at 
the start of the '$("#dialog").dialog({' line (see the view below). I can't 
figure out this error; some places say it's due to conflicting js/jq 
libraries loaded but I don't think that's the case here since I have a 
pretty standard web2py install.

Here's the portions of my view-




jQuery(document).ready(function() {

$("#dialog").dialog({
modal: true,
bgiframe: true,
width: 500,
height: 200,
autoOpen: false
});

$(".lb").click(function(e) {

e.preventDefault();
var theHREF = $(this).attr("href");

$("#dialog").dialog('option', 'buttons', {
"Confirm" : function() {
window.location.href = theHREF;
},
"Cancel" : function() {
$(this).dialog("close");
}
});

$("#dialog").dialog("open");

});

});











 


Action

{{=A('Delete', 
_href=URL('startup', 'delete_record', args=['maindb', 6]))}}








-- 
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: Login page - Menu bar does not work

2017-06-07 Thread Jordan Ladora
Perfect, thank you.

On Tue, Jun 6, 2017 at 9:13 PM, Anthony  wrote:

> Note, this has already been fixed in the master branch, so should be fine
> in the next release.
>
> Anthony
>
>
> On Tuesday, June 6, 2017 at 11:11:26 PM UTC-4, Anthony wrote:
>>
>> On Tuesday, June 6, 2017 at 4:13:26 PM UTC-4, Jordan Ladora wrote:
>>>
>>> I notice the same problem.
>>>
>>> Using firefox, the js console reveals that web2py-bootstrap3.js is
>>> trying to call the function "web2py.validate_entropy", which is in
>>> web2py.js, but cannot find it.
>>>
>>
>> web2py.validate_entropy in web2py.js is inside a closure, so cannot be
>> accessed in web2py-bootstrap3.js. This is a bug -- the ajax_fields function
>> was copied from web2py.js, and the reference to web2py.validate_entropy was
>> left as is, even though the variable "web2py" is not defined in
>> web2py-bootstrap3.js. You can fix it by changing:
>>
>>   web2py.validate_entropy($(this));
>>
>> to:
>>
>>   $.web2py.validate_entropy($(this));
>>
>> Note, this problem only arises if you add the IS_STRONG validator to
>> db.auth_user.password.requires (which is not the default). In that case,
>> the PasswordWidget in sqlhtml.py adds a "data-web2py_entropy", which
>> triggers the call to the above line. The reason the menus don't work
>> properly is because the above line breaks the Javascript code.
>>
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/JOWoLDKpcaw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-06 Thread Jordan Ladora
Thank you for checking that.

Yeah, I'm still getting this, even when logged in. As a temp workaround I 
swapped all the instances of "validate_and_insert" in my app for "insert".

I did find a note I made a couple years ago from back before I upgraded to 
the latest version that said validate_and_insert would not work if no 
fields were set, like in the '## no fields-' example I posted on 6/3, so 
maybe this is due to something else I have e.g. in db.py...



On Monday, June 5, 2017 at 10:43:16 AM UTC-6, Anthony wrote:
>
> On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>>
>> Thanks. It's also throwing the identical error when using the app's web 
>> page as a logged in user.
>>
>
> Are you sure? I tried it as a logged in user and it works fine (using your 
> exact table definition and insert code).
>
> Anthony
>

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


[web2py] Re: Login page - Menu bar does not work

2017-06-06 Thread Jordan Ladora
I notice the same problem. 

Using firefox, the js console reveals that web2py-bootstrap3.js is trying 
to call the function "web2py.validate_entropy", which is in web2py.js, but 
cannot find it.

The error is:
* ReferenceError: web2py is not defined. * (line 14, posn 7 of 
web2py-bootstrap3.js). 

I'm not sure how to make web2py-bootstrap3.js see web2py.js. 

Can someone please look into this and post a fix? TY.




On Wednesday, September 21, 2016 at 5:18:11 PM UTC-6, SR wrote:
>
> When I am in the Login page, the menu items does not work.
> Any idea why it is not working?
> 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: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-05 Thread Jordan Ladora
Thanks. It's also throwing the identical error when using the app's web
page as a logged in user.

Suggestions?


On Mon, Jun 5, 2017 at 10:19 AM, Anthony  wrote:

> The problem is that you have auth.signature but are doing inserts without
> a logged in user. As a result, the values of the created_by and modified_by
> fields are None but are required to be id's from the db.auth_user table.
> This should simply result in a failed validation rather than an exception,
> but the IS_IN_DB validator breaks when None values are passed in for id or
> integer fields (I would consider it a bug).
>
> Anthony
>
>
> On Saturday, June 3, 2017 at 2:17:31 PM UTC-4, Jordan Ladora wrote:
>
>> Yes, I was able to reproduce with a fresh install of web2py-
>>
>> Here's what I did-
>> 
>> -
>> extracted new copy of web2py from DL src
>>
>> modified welcome app-
>>  in models/db.py commented out this block-
>>   if not request.env.web2py_runtime_gae: / else:
>>  ..and replaced with-
>>db = DAL('sqlite://storage.sqlite', lazy_tables=True,
>> ignore_field_case=False, pool_size=10, check_reserved=['postgres',
>> 'postgres_nonreserved'])
>>
>> created models/db_data.py and added-
>>
>>  db.define_table('datatable',
>> Field('title', length=128),
>> Field('name', requires=IS_IN_SET(['a','b','c'], multiple=False,
>> zero=None), readable=False, writable=False, length=128),
>> Field('dtype', requires=IS_IN_SET(['1','2','3'], multiple=False),
>> label="Type", readable=False, writable=False, length=128),
>> Field('finished', 'boolean', default=False, readable=False,
>> writable=False),
>> Field('the_timestamp', 'datetime', readable=False, writable=False),
>> Field('alive', 'boolean', default=True, readable=False,
>> writable=False),
>> Field( 'comments', 'text' ),
>> auth.signature, migrate=True,
>> format = '%(title)s %(datatype)s %(species)s'
>> )
>>
>> created welcome/databases folder
>>
>>
>> 
>>
>> launched with-
>>
>> python '.../web2py.py' -S welcome -M
>>
>> >>> from datetime import datetime
>>
>> ## insert two fields-
>> >>> new_record = db.datatable.validate_and_insert(dtype='1',
>> the_timestamp=datetime.utcnow())
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_fields = self._validate_fields(fields)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in
>> _validate_fields
>> value, error = self[fieldname].validate(raw_value)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
>> (value, error) = validator(value)
>>   File ".../gluon/validators.py", line 660, in __call__
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>>
>> ## no fields-
>> >>> new_record = db.datatable.validate_and_insert()
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File ".../gluon/packages/dal/pydal/objects.py", line 749, in
>> validate_and_insert
>> response, new_fields = self._validate_fields(fields)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 741, in
>> _validate_fields
>> value, error = self[fieldname].validate(raw_value)
>>   File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
>> (value, error) = validator(value)
>>   File ".../gluon/validators.py", line 660, in __call__
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>>
>> ## 'name' field here should throw error for not being in set defined by
>> model-
>> >>> new_record = db.datatable.validate_and_insert(title='test title',
>> name='test name', dtype='1', finished=False, the_timestamp=datetime.utcnow(),
>> alive=True, comments='this is a test')
&g

Re: [web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-03 Thread Jordan Ladora
Yes, I was able to reproduce with a fresh install of web2py-

Here's what I did-
-
extracted new copy of web2py from DL src

modified welcome app-
 in models/db.py commented out this block-
  if not request.env.web2py_runtime_gae: / else:
 ..and replaced with-
   db = DAL('sqlite://storage.sqlite', lazy_tables=True,
ignore_field_case=False, pool_size=10, check_reserved=['postgres',
'postgres_nonreserved'])

created models/db_data.py and added-

 db.define_table('datatable',
Field('title', length=128),
Field('name', requires=IS_IN_SET(['a','b','c'], multiple=False,
zero=None), readable=False, writable=False, length=128),
Field('dtype', requires=IS_IN_SET(['1','2','3'], multiple=False),
label="Type", readable=False, writable=False, length=128),
Field('finished', 'boolean', default=False, readable=False,
writable=False),
Field('the_timestamp', 'datetime', readable=False, writable=False),
Field('alive', 'boolean', default=True, readable=False, writable=False),
Field( 'comments', 'text' ),
auth.signature, migrate=True,
format = '%(title)s %(datatype)s %(species)s'
)

created welcome/databases folder




launched with-

python '.../web2py.py' -S welcome -M

>>> from datetime import datetime

## insert two fields-
>>> new_record = db.datatable.validate_and_insert(dtype='1',
the_timestamp=datetime.utcnow())
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## no fields-
>>> new_record = db.datatable.validate_and_insert()
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## 'name' field here should throw error for not being in set defined by
model-
>>> new_record = db.datatable.validate_and_insert(title='test title',
name='test name', dtype='1', finished=False,
the_timestamp=datetime.utcnow(), alive=True, comments='this is a test')
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## all fields-
>>> new_record = db.datatable.validate_and_insert(title='test title',
name='a', dtype='1', finished=False, the_timestamp=datetime.utcnow(),
alive=True, comments='this is a test')
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


Thanks again for your help.



On Fri, Jun 2, 2017 at 11:04 AM, Anthony  wrote:

> Can we see the code and full traceback?
>
> --
> 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/Cqz5GbP0

[web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-02 Thread Jordan Ladora
Hi Anthony,

Thanks for your response. 

I didn't use the admin gui to upgrade but rather DL'd the new src zip and 
moved my app into it and then replaced all the files within the app that 
get upgraded (like static, languages, some of the views, etc.) 

I just checked that everything has been upgraded, incl pydal. 

-j



On Friday, June 2, 2017 at 5:56:11 AM UTC-6, Anthony wrote:
>
> How did you upgrade? Is it possible you did not upgrade PyDAL or get its 
> proper version?
>
> Anthony
>
> On Thursday, June 1, 2017 at 11:00:11 PM UTC-4, Jordan Ladora wrote:
>>
>> Hello,
>>
>> I just belatedly upgraded from 8/9/15 (v2.12.2-stable) -> 5/10/16 
>> (v2.14.6-stable) 
>> and have about 100 instances of 'validate_and_insert' in my application.
>>
>> My app was previously (with 8/9/15 version) running these instances of 
>> 'validate_and_insert' A-OK but now, basically every instance of 
>> 'validate_and_insert' is throwing an error. When I use the shell I get a 
>> traceback that ends in:
>>
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>> It does this every single time I try to run 'validate_and_insert' when 
>> otherwise everything seems fine (and when I go back to the previous version 
>> and run the same exact code in the shell it goes fine).
>>
>> If I change the 'validate_and_insert' to just 'insert' it works, but I'd 
>> like to keep the code the way it was before.. anyone else stumble on this 
>> or have a suggestion?
>>
>> fyi it seems a little similar to the 5/8/17 thread "Validate_and_insert 
>> fails because "id" has no value" where he is also using 2.14.6-stable.
>>
>> Thank you!
>>
>>

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


[web2py] 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-01 Thread Jordan Ladora
Hello,

I just belatedly upgraded from 8/9/15 (v2.12.2-stable) -> 5/10/16
(v2.14.6-stable)
and have about 100 instances of 'validate_and_insert' in my application.

My app was previously (with 8/9/15 version) running these instances of
'validate_and_insert' A-OK but now, basically every instance of
'validate_and_insert' is throwing an error. When I use the shell I get a
traceback that ends in:

if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'

It does this every single time I try to run 'validate_and_insert' when
otherwise everything seems fine (and when I go back to the previous version
and run the same exact code in the shell it goes fine).

If I change the 'validate_and_insert' to just 'insert' it works, but I'd
like to keep the code the way it was before.. anyone else stumble on this
or have a suggestion?

fyi it seems a little similar to the 5/8/17 thread "Validate_and_insert
fails because "id" has no value" where he is also using 2.14.6-stable.

Thank you!

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


[web2py] Re: Routes.py - Remove Application prefix

2015-08-09 Thread Jordan Ladora
I was wondering how to also incorporate routing any asp/jsp/php requests to 
the jammer app in this example?

Can you add it to routes_in? eg-

routes_in = (
  ('/admin/$anything', '/admin/$anything'),
  ('/$anything', '/init/$anything'),
 ('.*.(php|PHP|asp|ASP|jsp|JSP)','jammer/default/jam'),
)

Is this correct?



On Monday, March 1, 2010 at 11:46:31 PM UTC-8, Elam Watkins wrote:
>
> Thanks all, it's working now.  I did what mdipierro suggested.
>
> On Mar 1, 6:20 am, mdipierro  wrote:
> > oops. Try this
> >
> > routes_in = (
> >   ('/admin/$anything', '/admin/$anything'),
> >   ('/$anything', '/init/$anything'),
> > )
> > routes_out = (('/init/$anything', '/$anything'),)
> >
> > On Mar 1, 8:18 am, Mengu  wrote:
> >
> >
> >
> > > massimo, this breaks admin. :)
> >
> > > On 1 Mart, 14:53, mdipierro  wrote:
> >
> > > > or the new simpler way
> >
> > > > routes_in = (('/$anything', '/init/$anything'),)
> > > > routes_out = (('/init/$anything', '/$anything'),)
> >
> > > > On Mar 1, 5:51 am, Álvaro Justen [Turicas] 
> > > > wrote:
> >
> > > > > On Mon, Mar 1, 2010 at 03:47, Elam Watkins  
> wrote:
> > > > > > I downloaded web2py version 1.75.5. I then renamed the welcome
> > > > > > application to init.
> >
> > > > > > I want to remove the application prefix from the application's 
> URLs
> > > > > > because I want to only expose one application.  I created a 
> routes.py
> > > > > > in the web2py folder and tried the following:
> >
> > > > > > #-
> > > > > > routes_in = (
> > > > > >  ('/testme', '/init/default/index'),
> > > > > > )
> > > > > > routes_out = (
> > > > > >  ('/init/default/index', '/testme'),
> > > > > > )
> > > > > > #-
> >
> > > > > > It worked fine.
> >
> > > > > > I then tried
> >
> > > > > > #-
> > > > > > routes_in = (
> > > > > >  ('/(?P.*)', '/init/   any>'),
> > > > > > )
> > > > > > routes_out = (
> > > > > >  ('/init/(?P.*)', '/   any>'),
> > > > > > )
> > > > > > #-
> >
> > > > > There is some typo in the online book. You should use "\g". See [1]
> > > > > for one example (/docs).
> >
> > > > > > and this:
> >
> > > > > > #-
> > > > > > routes_in = (
> > > > > >  ('/$c/$f', '/init/$c/$f'),
> > > > > > )
> >
> > > > > > routes_out = (
> > > > > >  ('/init/$c/$f', '/$c/$f'),
> > > > > > )
> > > > > > #-
> >
> > > > > Try this:
> >
> > > > > routes_in = (
> > > > >   ('/', '/init'),
> > > > >   ('/$c/?', '/init/$c'),
> > > > >   ('/$c/$f', '/init/$c/$f'),
> > > > > )
> >
> > > > > routes_out = (
> > > > >   ('/init/$c/$f', '/$c/$f'),
> > > > > )
> >
> > > > > [1]http://web2py.com/AlterEgo/default/show/67
> >
> > > > > > Neither worked.  This is straight from the book:
> > > > > >http://web2py.com/book/default/section/4/15
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the 
> Google Groups "web2py-users" group.
> > > > > > To post to this group, send email to web...@googlegroups.com 
> .
> > > > > > To unsubscribe from this group, send email to 
> web2py+un...@googlegroups.com .
> > > > > > For more options, visit this group athttp://
> groups.google.com/group/web2py?hl=en.
> >
> > > > > --
> > > > > Álvaro Justen - Turicas
> > > > >  http://blog.justen.eng.br/
> > > > >  21 9898-0141- Hide quoted text -
> >
> > - Show quoted text -
>

-- 
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] Update a session variable from a module

2015-04-09 Thread Jordan Ladora
I've got some code (currently in a file in models) where default session
settings are set from a db record-

def init_settings(db_record):
  session.timezone = db_record.timezone

etc.

The problem is that I want to move this code into a module for production,
but don't know how to update 'session' from a module. The modularized code
is-

def init_settings(db_record):
  current.session.timezone = db_record.timezone

...but indeed, that does not update the session variable! Is there any way
'session' can be updated from a module?

TIA,
-jl

-- 
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] Running register_onaccept code when registration is disabled

2015-04-08 Thread Jordan Ladora
Following the example in the book, I use in db.py-

def give_create_permission(form):
  group_id = auth.id_group('user_%s' & auth.user_id)
  auth.add_permission(group_id, 'read', db.comment)

auth.settings.register_onaccept = give_create_permission

...but what to do when you also have-

auth.settings.actions_disabled.append('register')

With registration disabled, user accounts are created manually with the
appadmin, so 'register_onaccept' code does not run. Is there way to run
'give_create_permission' when the user logs in the first time, or a way to
check for 'read' permission on db.comment?

Thanks for help,
-J

-- 
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: Handling spaces in filename with response.stream

2014-12-19 Thread Jordan Ladora
Hi Leonel,

Yes. that fixed it - thanks very much for your help.

-j

On Thu, Dec 18, 2014 at 10:52 AM, Leonel Câmara 
wrote:
>
> I think this is a bug in Response.stream it does this:
>
> headers["Content-Disposition"] = \
> "attachment;filename=%s" % attname
>
> When it should do this:
>
> headers["Content-Disposition"] = \
> 'attachment;filename="%s"' % attname
>
> The difference is that now it's using double quotes around the filename
> which is permitted for parameters.
>
> Can you edit this line in your web2py's gluon/globals.py, restart web2py
> and see if it now works correctly?
>
> Also submit an issue so we remember to fix it :)
>
> --
> 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/vJweEV8aXaQ/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] Handling spaces in filename with response.stream

2014-12-18 Thread Jordan Ladora
I'm using response.stream, like - 

response.stream(open(file_path, 'r'), attachment=True, chunk_size=4096, 
filename='abc def ghi.txt')

When there is a space in the filename, I get a downloaded file with a name 
that is the first part split on ' ', same as calling filename.split(' 
')[0]. 

For example, with filename='abc def ghi.txt', I am getting 'abc' as the 
name of the downloaded file.

How can I avoid this?

Thanks,
-j

-- 
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] Simple dropdown animated menu

2014-12-12 Thread Jordan Ladora
I have a table of links that I would like to have more compactly stored in 
a dropdown menu. I tried a js script from a book in my views to try and get 
a menu that drops down on mouser hover, like the default response.menu in 
menu.py, but I'm not getting the animation, similar to calling the MENU 
helper and seeing a static, fully expanded menu. 

Can someone please point me to a snippet or a resource that has something 
that is at all similar to this?

TIA,
jl

-- 
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: jQuery select form items based on name startswith...

2014-07-01 Thread Jordan Ladora
Thanks, Niphlod, that is very helpful.. I think I'm on the right track now!


On Tue, Jul 1, 2014 at 12:02 PM, Niphlod  wrote:

> 1st rule: never, never, never use inline javascript.
> 2nd rule: start with console.log() and an open debugger (firebug, chrome
> developer tools, etc)
> 3rd rule: use the quotes! you are terribly wrong with those
> 3rd rule: simplify the code, then expand.
>
> $('#div2 button').on('click', function() {
>console.log($("input[name^='something'"))
> })
>
>
> On Tuesday, July 1, 2014 6:14:41 PM UTC+2, Jordan Ladora wrote:
>>
>> Hi,
>>
>> I'm trying to make a button that will check some boxes in a form based on
>> the checkboxes' name attributes.
>>
>> But I can't get this to work-
>> 
>>   Deselect All
>> 
>>
>> I'm basing it off http://api.jquery.com/attribute-starts-with-selector/
>>
>> I've tried a few different things but cannot get it to do anything good..
>>
>> Thanks for any pointers,
>> -jl
>>
>>  --
> 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/oZ_u_XPbEys/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] jQuery select form items based on name startswith...

2014-07-01 Thread Jordan Ladora
Hi,

I'm trying to make a button that will check some boxes in a form based on 
the checkboxes' name attributes. 

But I can't get this to work-

  Deselect All


I'm basing it off http://api.jquery.com/attribute-starts-with-selector/

I've tried a few different things but cannot get it to do anything good.. 

Thanks for any pointers,
-jl

-- 
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: Running google visualization js in a LOAD component

2014-02-20 Thread Jordan Ladora
Thanks for your help!!!

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


[web2py] Running google visualization js in a LOAD component

2014-01-18 Thread Jordan Ladora
Example from 
https://google-developers.appspot.com/chart/interactive/docs/gallery/combochart

If I place this code in a standard .html view, it works fine-


jQuery(document).ready(function() {

setTimeout(function() {
// Google Visualization stuff goes here

  function drawVisualization() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable([
  ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 
'Rwanda', 'Average'],
  ['2004/05',  165,  938, 522, 
998,   450,  614.6],
  ['2005/06',  135,  1120,599, 
1268,  288,  682],
  ['2006/07',  157,  1167,587, 
807,   397,  623],
  ['2007/08',  139,  1110,615, 
968,   215,  609.4],
  ['2008/09',  136,  691, 629, 
1026,  366,  569.6]
]);

var options = {
  title : 'Monthly Coffee Production by Country',
  vAxis: {title: "Cups"},
  hAxis: {title: "Month"},
  seriesType: "bars",
  series: {5: {type: "line"}}
};

var chart = new 
google.visualization.ComboChart(document.getElementById("chart_div"));
chart.draw(data, options);
  }
  google.setOnLoadCallback(drawVisualization);

}, 0);

});




...but if I move this code to a LOAD component, and call it from the view, 
the graph is not rendered. I can't tell why this is and don't get any 
helpful error msgs (eg in the web console).

It's also necessary to put these lines of code in the .html that calls the 
LOAD component (not in the .load file)-

https://www.google.com/jsapi";>

  google.load('visualization', '1', {packages: ['corechart']});



TIA for any pointers,
-jl

-- 
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: Change name of file inserted via upload field at download time

2013-10-16 Thread Jordan Ladora
This is great - works perfectly. 

Thanks again for all the help!
j

On Wednesday, October 16, 2013 8:46:46 AM UTC-7, Anthony wrote:
>
> Sorry, turns out the filename stored in the db must be the *last* URL 
> argument, not the first -- so the order of the URL args should be reversed. 
> Actually, there are some limitations regarding characters allowed in URL 
> args, so it might be a better idea to put the new filename in the query 
> string (i.e., a URL variable):
>
> URL('default', 'download', args=download_path, vars=dict(filename=
> 'new_title'))
>
> The download function would then be:
>
> def download():
> return response.download(request, db, download_filename=request.vars.
> filename)
>
> And yes, the new file name will appear in the URL -- that's how it is 
> communicated to the download function.
>
> Anthony
>
> On Wednesday, October 16, 2013 11:31:49 AM UTC-4, Jordan Ladora wrote:
>>
>> Hi Anthony,
>>
>> Thanks for the help.
>>
>> The download_path variable doesn't change regardless of whether the 
>> download() function includes, or is passed, the 'download_filename' arg. 
>> Indeed, the file downloads successfully when the download function is the 
>> default, ie -
>>
>> def download():
>> return response.download(request, db)
>>
>> ..and when download() is called with just this one arg -
>>
>> {{=A('Download', _href=URL('default', 'download', 
>> args=download_path))}}   
>>
>>
>> When I added the second parameter to the call to download()-
>>
>> {{=A('Download w title', _href=URL('default', 'download', 
>> args=[download_path, 'new_title']))}}   
>>
>> ..I changed the download() function in the default controller to this-
>>
>> def download():
>> return response.download(request, db, attachment=True, 
>> download_filename=request.args(1))
>>
>>
>> The db field from the model looks like this-
>> Field('file', 'upload', length=128, autodelete=True, 
>> requires=IS_NOT_EMPTY()), 
>>
>>
>> It might be most telling to show the links that are generated in the 
>> view.. the [working] link for -
>> {{=A('Download', _href=URL('default', 'download', 
>> args=download_path))}}   
>>
>> ..looks like:
>>
>> http://127.0.0.1:8000/test_app/default/download/main_db.file.b36e427143f2c727.64633532346236612d373033622d343235352d383330302d616362613637366136396262.txt
>>
>>
>> And the link for -
>> {{=A('Download w title', _href=URL('default', 'download', 
>> args=[download_path, 'new_title']))}}   
>>
>> ..looks like:
>>
>> http://127.0.0.1:8000/test_app/default/download/main_db.file.b36e427143f2c727.64633532346236612d373033622d343235352d383330302d616362613637366136396262.txt/new_title
>>
>>
>> The latter generates the 404 error. As you can see, when I add the 
>> 'download_filename' arg, a new path is generated with the desired filename 
>> appended to the path, which doesn't seem to make sense.
>>
>> Thanks again for your help. Let me know if there is any more info I can 
>> provide.
>>
>> Cheers,
>> jl
>>  
>>
>>
>>
>>
>> On Tuesday, October 15, 2013 8:21:42 PM UTC-7, Anthony wrote:
>>>
>>> We need to see more code -- maybe your model and the code that generates 
>>> the value of download_path. response.download() will return a 404 if the 
>>> filename is not of the right format, it can't find the table/field, or it 
>>> can't retrieve the file.
>>>
>>> Anthony
>>>
>>> On Tuesday, October 15, 2013 10:06:45 PM UTC-4, Jordan Ladora wrote:
>>>>
>>>> Ha! Thanks for that.. I upgraded to 2.7.4. but get 404 not found when I 
>>>> use Anthony's code..
>>>>
>>>> in the view-
>>>>
>>>> {{=A('Download', _href=URL('default', 'download', 
>>>> args=download_path))}}   
>>>> {{=A('Download w title', _href=URL('default', 'download', 
>>>> args=[download_path, 'new_title']))}}   
>>>>
>>>>
>>>> in default.py-
>>>>
>>>> @auth.requires_login()
>>>> def download():
>>>> """
>>>> allows downloading of uplo

[web2py] Re: Change name of file inserted via upload field at download time

2013-10-16 Thread Jordan Ladora
Hi Anthony,

Thanks for the help.

The download_path variable doesn't change regardless of whether the 
download() function includes, or is passed, the 'download_filename' arg. 
Indeed, the file downloads successfully when the download function is the 
default, ie -

def download():
return response.download(request, db)

..and when download() is called with just this one arg -

{{=A('Download', _href=URL('default', 'download', 
args=download_path))}}   


When I added the second parameter to the call to download()-

{{=A('Download w title', _href=URL('default', 'download', 
args=[download_path, 'new_title']))}}   

..I changed the download() function in the default controller to this-

def download():
return response.download(request, db, attachment=True, 
download_filename=request.args(1))


The db field from the model looks like this-
Field('file', 'upload', length=128, autodelete=True, 
requires=IS_NOT_EMPTY()), 


It might be most telling to show the links that are generated in the view.. 
the [working] link for -
{{=A('Download', _href=URL('default', 'download', 
args=download_path))}}   

..looks like:
http://127.0.0.1:8000/test_app/default/download/main_db.file.b36e427143f2c727.64633532346236612d373033622d343235352d383330302d616362613637366136396262.txt


And the link for -
{{=A('Download w title', _href=URL('default', 'download', 
args=[download_path, 'new_title']))}}   

..looks like:
http://127.0.0.1:8000/test_app/default/download/main_db.file.b36e427143f2c727.64633532346236612d373033622d343235352d383330302d616362613637366136396262.txt/new_title


The latter generates the 404 error. As you can see, when I add the 
'download_filename' arg, a new path is generated with the desired filename 
appended to the path, which doesn't seem to make sense.

Thanks again for your help. Let me know if there is any more info I can 
provide.

Cheers,
jl
 




On Tuesday, October 15, 2013 8:21:42 PM UTC-7, Anthony wrote:
>
> We need to see more code -- maybe your model and the code that generates 
> the value of download_path. response.download() will return a 404 if the 
> filename is not of the right format, it can't find the table/field, or it 
> can't retrieve the file.
>
> Anthony
>
> On Tuesday, October 15, 2013 10:06:45 PM UTC-4, Jordan Ladora wrote:
>>
>> Ha! Thanks for that.. I upgraded to 2.7.4. but get 404 not found when I 
>> use Anthony's code..
>>
>> in the view-
>>
>> {{=A('Download', _href=URL('default', 'download', 
>> args=download_path))}}   
>> {{=A('Download w title', _href=URL('default', 'download', 
>> args=[download_path, 'new_title']))}}   
>>
>>
>> in default.py-
>>
>> @auth.requires_login()
>> def download():
>> """
>> allows downloading of uploaded files
>> http:///[app]/default/download/[filename]
>> """
>> ##response.download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, 
>> attachment=True, download_filename=None):
>> return response.download(request, db, 
>> download_filename=request.args(1))
>>
>>
>> ...hopefully there is something else silly that i am doing wrong here...?
>>
>> Thanks,
>> jl
>>
>>
>> On Tuesday, October 15, 2013 3:01:49 PM UTC-7, Niphlod wrote:
>>>
>>> You're using an old version of web2py :D
>>>
>>> On Tuesday, October 15, 2013 11:40:55 PM UTC+2, Jordan Ladora wrote:
>>>>
>>>> Err.. I get an unknown parameter error for the 'download_filename' .. 
>>>> looking into globals.py I see 
>>>>
>>>> def download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, 
>>>> attachment=True):
>>>>
>>>> so I'm not sure about where this parameter goes(?)
>>>>
>>>> Thanks,
>>>> -j
>>>>
>>>>>
>>>>>

-- 
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: Change name of file inserted via upload field at download time

2013-10-15 Thread Jordan Ladora
Ha! Thanks for that.. I upgraded to 2.7.4. but get 404 not found when I use 
Anthony's code..

in the view-

{{=A('Download', _href=URL('default', 'download', 
args=download_path))}}   
{{=A('Download w title', _href=URL('default', 'download', 
args=[download_path, 'new_title']))}}   


in default.py-

@auth.requires_login()
def download():
"""
allows downloading of uploaded files
http:///[app]/default/download/[filename]
"""
##response.download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, 
attachment=True, download_filename=None):
return response.download(request, db, download_filename=request.args(1))


...hopefully there is something else silly that i am doing wrong here...?

Thanks,
jl


On Tuesday, October 15, 2013 3:01:49 PM UTC-7, Niphlod wrote:
>
> You're using an old version of web2py :D
>
> On Tuesday, October 15, 2013 11:40:55 PM UTC+2, Jordan Ladora wrote:
>>
>> Err.. I get an unknown parameter error for the 'download_filename' .. 
>> looking into globals.py I see 
>>
>> def download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, 
>> attachment=True):
>>
>> so I'm not sure about where this parameter goes(?)
>>
>> Thanks,
>> -j
>>
>>>
>>>

-- 
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: Change name of file inserted via upload field at download time

2013-10-15 Thread Jordan Ladora
Awesome - thanks, 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/groups/opt_out.


[web2py] Change name of file inserted via upload field at download time

2013-10-15 Thread Jordan Ladora
Hello,

I've got a table with files inserted into an upload field. Downloading 
works fine when I pass the file path to the default download controller. 

{{=A('Download', _href=URL('default', 'download', 
args=download_path))}}  

However, I'd like the user to be able to change only the name of the file 
that is downloaded without having to do any file copying or additional 
database inserts. Nor do I want to break web2py's file renaming system. I 
want to allow for the possibility that the user might decide to rename the 
file later on after they uploaded it by storing the new name and presenting 
it at download time.. it seems like this can be done via response.stream 
but I cannot make this happen..

I've tried these two strategies (and many modifications) but get errors, 
404 not found, or invalid requests...

in the view-

{{=A('Download1', _href=URL('default', 'download1', 
args=[download_path, 'new_title']))}}   
{{=A('Download2', _href=URL('default', 'download2', 
args=[download_path, 'new_title']))}}   


in the default controller-

@auth.requires_login()
def download1():
response.headers['Content-Type'] = "application/octet-stream"
response.headers['Content-Disposition'] = 'attachment; filename=%s' % 
request.args(1)

return response.stream(request.args(0))


@auth.requires_login()
def download2():

return response.stream(request.args(0), attachment=True, 
filename=request.args(1))



...is this possible? Thanks in advance for help.
-j

-- 
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: Custom form with jquery acts weird

2013-09-28 Thread Jordan Ladora
Thanks for that - I'd assumed the button in the form was related, but let 
me try and isolate the other problem and make another app that reproduces 
it.



On Saturday, September 28, 2013 10:09:58 AM UTC-7, Anthony wrote:
>
>
> form=crud.create(db.comments)
>> if form.process().accepted
>>
>
> Right, you cannot do that. 
>
>  
>
>>   form = SQLFORM.factory(*fields)
>>   if form.accepts(request, session): 
>>
>
> The above is perfectly fine (though form.process().accepted is now 
> preferred to form.accepts(request, session)).
>
> My question was exactly what problem are you having with the above? The 
> app you attached uses the above, and it works fine.
>
> 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/groups/opt_out.


[web2py] Re: Custom form with jquery acts weird

2013-09-28 Thread Jordan Ladora
Hi Anthony,

Thanks for your note. Like I said, I understand the helpful comments on 
fixing the  issue. 

However, what is unclear to me still is Massimo's (and yours here - 
https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ
 
) comments on form processing.. Massimo pointed out that, a la Jonas' post, 
that you cannot do -

form=crud.create(db.comments)
if form.process().accepted

...yet I have:

  form = SQLFORM.factory(*fields)
  if form.accepts(request, session): 

...and that also seems to be wrong (no doubt, since process() is a shortcut 
for accepts(), they are doing the same thing). BUT I am not sure how to 
correct it - you both said that process is getting called twice. OK, if I 
shouldn't use 'if form.accepts(request, session): ' then what should I use 
to process (and call validation on) the form once the user clicks 'Submit' ?

Thanks again,
-jl






On Friday, September 27, 2013 7:36:04 PM UTC-7, Anthony wrote:
>
> If you follow Massimo's suggestion:
>
> Cancel
>
> everything seems to work fine. What problem do you have after making that 
> change?
>
> Anthony
>
> On Friday, September 27, 2013 9:00:47 PM UTC-4, Jordan Ladora wrote:
>>
>> Hi Massimo,
>>
>> Thanks for your help. I think I'm crystal clear on your explanation 
>> regarding the button, but I'm still confused on the other issue that 
>> Anthony answered previously, despite his and your posts.. 
>>
>> In my controller I used:
>>
>>   form = SQLFORM.factory(*fields)
>>
>>   if form.accepts(request, session): 
>>
>>
>> Could you please be a little more specific? What should I use here 
>> instead of 'form.accepts' ? I think this is causing me trouble elsewhere in 
>> my application, too, and it would be really helpful if I knew a little bit 
>> more..
>>
>> Thanks again,
>> -J
>>
>>
>>
>> On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote:
>>>
>>> Hi,
>>>
>>> I have the same problem as 
>>>
>>>
>>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ
>>>
>>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ
>>>
>>> From the first thread/link above, "...if I use a regular form, 
>>> {{=form}}, then validation works but not if I use the custom form. Also 
>>> form.process() works, so the problem seems to be related to custom forms.."
>>>
>>> Those threads seemed to end without finding a solution. I think the 
>>> author of those threads didn't realize that the form is actually being 
>>> validated, but it doesn't seem like it b/c the error messages do not show 
>>> with the custom form. 
>>>
>>> In my hands, if I use a custom form, it validates OK but form errors do 
>>> not display and, quite often, any jquery code in the view misbehaves (which 
>>> is the real problem). This behavior turns on and off depending ONLY on 
>>> whether I have a custom form. I used {{=custom.form.begin}} and 
>>> {{=custom.form.end}} and {{=form.custom.widget.xyz}} and 
>>> {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then 
>>> everything works perfectly. 
>>>
>>> In the controller, I used 
>>>
>>> if form.accepts(request, session, onvalidation=abc):
>>>   ...
>>>
>>>
>>> Thanks for any help. I love the custom forms and it really stinks not 
>>> being able to use them with jQuery!!
>>>
>>> -jl
>>>
>>> ps - I previously posted with more details about this problem, before I 
>>> realized the problem seems related more generally to javascript/jquery + 
>>> custom forms -
>>>
>>> https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg
>>> https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI
>>>
>>>
>>>

-- 
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: Custom form with jquery acts weird

2013-09-27 Thread Jordan Ladora
Hi Massimo,

Thanks for your help. I think I'm crystal clear on your explanation 
regarding the button, but I'm still confused on the other issue that 
Anthony answered previously, despite his and your posts.. 

In my controller I used:

  form = SQLFORM.factory(*fields)

  if form.accepts(request, session): 


Could you please be a little more specific? What should I use here instead 
of 'form.accepts' ? I think this is causing me trouble elsewhere in my 
application, too, and it would be really helpful if I knew a little bit 
more..

Thanks again,
-J



On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> I have the same problem as 
>
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ
>
> From the first thread/link above, "...if I use a regular form, {{=form}}, 
> then validation works but not if I use the custom form. Also form.process() 
> works, so the problem seems to be related to custom forms.."
>
> Those threads seemed to end without finding a solution. I think the author 
> of those threads didn't realize that the form is actually being validated, 
> but it doesn't seem like it b/c the error messages do not show with the 
> custom form. 
>
> In my hands, if I use a custom form, it validates OK but form errors do 
> not display and, quite often, any jquery code in the view misbehaves (which 
> is the real problem). This behavior turns on and off depending ONLY on 
> whether I have a custom form. I used {{=custom.form.begin}} and 
> {{=custom.form.end}} and {{=form.custom.widget.xyz}} and 
> {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then 
> everything works perfectly. 
>
> In the controller, I used 
>
> if form.accepts(request, session, onvalidation=abc):
>   ...
>
>
> Thanks for any help. I love the custom forms and it really stinks not 
> being able to use them with jQuery!!
>
> -jl
>
> ps - I previously posted with more details about this problem, before I 
> realized the problem seems related more generally to javascript/jquery + 
> custom forms -
>
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI
>
>
>

-- 
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: Custom form with jquery acts weird

2013-09-20 Thread Jordan Ladora
Ahhh f*ck it, then...



On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> I have the same problem as 
>
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ
>
> From the first thread/link above, "...if I use a regular form, {{=form}}, 
> then validation works but not if I use the custom form. Also form.process() 
> works, so the problem seems to be related to custom forms.."
>
> Those threads seemed to end without finding a solution. I think the author 
> of those threads didn't realize that the form is actually being validated, 
> but it doesn't seem like it b/c the error messages do not show with the 
> custom form. 
>
> In my hands, if I use a custom form, it validates OK but form errors do 
> not display and, quite often, any jquery code in the view misbehaves (which 
> is the real problem). This behavior turns on and off depending ONLY on 
> whether I have a custom form. I used {{=custom.form.begin}} and 
> {{=custom.form.end}} and {{=form.custom.widget.xyz}} and 
> {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then 
> everything works perfectly. 
>
> In the controller, I used 
>
> if form.accepts(request, session, onvalidation=abc):
>   ...
>
>
> Thanks for any help. I love the custom forms and it really stinks not 
> being able to use them with jQuery!!
>
> -jl
>
> ps - I previously posted with more details about this problem, before I 
> realized the problem seems related more generally to javascript/jquery + 
> custom forms -
>
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI
>
>
>

-- 
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] Custom form with jquery acts weird

2013-09-17 Thread Jordan Ladora
Hi,

I have the same problem as 

https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ
https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ

>From the first thread/link above, "...if I use a regular form, {{=form}}, 
then validation works but not if I use the custom form. Also form.process() 
works, so the problem seems to be related to custom forms.."

Those threads seemed to end without finding a solution. I think the author 
of those threads didn't realize that the form is actually being validated, 
but it doesn't seem like it b/c the error messages do not show with the 
custom form. 

In my hands, if I use a custom form, it validates OK but form errors do not 
display and, quite often, any jquery code in the view misbehaves (which is 
the real problem). This behavior turns on and off depending ONLY on whether 
I have a custom form. I used {{=custom.form.begin}} and 
{{=custom.form.end}} and {{=form.custom.widget.xyz}} and 
{{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then 
everything works perfectly. 

In the controller, I used 

if form.accepts(request, session, onvalidation=abc):
  ...


Thanks for any help. I love the custom forms and it really stinks not being 
able to use them with jQuery!!

-jl

ps - I previously posted with more details about this problem, before I 
realized the problem seems related more generally to javascript/jquery + 
custom forms -

https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg
https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI


-- 
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] jQuery and custom form giving unwanted form submit

2013-08-28 Thread Jordan Ladora
Hi all,

I initially noticed the problem of unwanted form submits when trying to 
make elements from a custom form sortable w/ jquery, but the problem 
extends further..

I first posted the problem here - 
https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg

It also happens when I implement 
https://groups.google.com/forum/#!topic/web2py/cehv_umpS-U to check all 
checkboxes in a view..

Bottom line is, when I combine certain jQuery functions with custom forms ( 
http://web2py.com/books/default/chapter/29/07#Custom-forms ), clicking 
buttons on those forms causes the form to unwantedly accept or validate.. 
when I remove the custom form elements and just use {{=form}} in the view, 
the js code behaves as intended and the form does not accept or validate 
until I click the Submit button. 

Thanks for any help. I can't figure out why this happens..
-jl

-- 

--- 
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: jQuery help with form and page reload on button click

2013-08-20 Thread Jordan Ladora
I just noticed that this also happens in another view if I use a custom 
form. When I simply show the form as {{=form}} then jQuery does not cause 
the form to submit.. in that case, the js/jQuery code is inside a button 
that causes checkboxes to be selected on the page when the button is 
clicked. Not sure how to modulate this behavior..


On Monday, August 19, 2013 12:43:00 PM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> I'm trying to make div's in a view sortable. I initially tried  
>
> jQuery('div *').sortable()
>
> ..with no luck, and then tried the code below, using up and down buttons. 
> They work to move the content in the divs up or down, but clicking them 
> also causes form submission and page reload. I'm sure I'm missing 
> something, but I'd like to stop causing the page to reload when the up and 
> down buttons are clicked.
>
> Thanks for any help,
> -j
>
>
>
>
>
> {{extend 'layout.html'}}
>
> src="<a  rel="nofollow" href="http://code.jquery.com/jquery-1.7.2.min.js"">http://code.jquery.com/jquery-1.7.2.min.js"</a>;>
>
> 
> jQuery(document).ready(function() {
>
> jQuery('.up').click(function() {
> var parent = jQuery(this).parent();
> parent.insertBefore(parent.prev());
> });
>
> jQuery('.down').click(function() {
> var parent = jQuery(this).parent();
> parent.insertAfter(parent.next());
> });
>
> });
> 
>
>
> {{=form.custom.begin}}
>
> 
>   Up
>   Down
>
>   {{=form.custom.widget.a}}
>
>   
> {{=form.custom.widget.a1}}
>   
> 
>
> 
>   Up
>   Down
>
>   {{=form.custom.widget.b}}
>
>   
> {{=form.custom.widget.b1}}
>   
> 
>
> 
>   Up
>   Down
>
>   {{=form.custom.widget.c}}
>
>   
> {{=form.custom.widget.c1}}
>   
> 
>
> Click here when ready: {{=form.custom.submit}}
>
> {{=form.custom.end}}
>
>  'window.location="{{=URL('mainhome')}}";'>Cancel
>
>
> 
> request.vars
> {{=BEAUTIFY(request.vars)}}
> 
>
>

-- 

--- 
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] jQuery help with form and page reload on button click

2013-08-19 Thread Jordan Ladora
Hi,

I'm trying to make div's in a view sortable. I initially tried  

jQuery('div *').sortable()

..with no luck, and then tried the code below, using up and down buttons. 
They work to move the content in the divs up or down, but clicking them 
also causes form submission and page reload. I'm sure I'm missing 
something, but I'd like to stop causing the page to reload when the up and 
down buttons are clicked.

Thanks for any help,
-j





{{extend 'layout.html'}}

src="http://code.jquery.com/jquery-1.7.2.min.js";>


jQuery(document).ready(function() {

jQuery('.up').click(function() {
var parent = jQuery(this).parent();
parent.insertBefore(parent.prev());
});

jQuery('.down').click(function() {
var parent = jQuery(this).parent();
parent.insertAfter(parent.next());
});

});



{{=form.custom.begin}}


  Up
  Down

  {{=form.custom.widget.a}}

  
{{=form.custom.widget.a1}}
  



  Up
  Down

  {{=form.custom.widget.b}}

  
{{=form.custom.widget.b1}}
  



  Up
  Down

  {{=form.custom.widget.c}}

  
{{=form.custom.widget.c1}}
  


Click here when ready: {{=form.custom.submit}}

{{=form.custom.end}}

Cancel



request.vars
{{=BEAUTIFY(request.vars)}}


-- 

--- 
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: jquery .hide() interfering with validators

2013-08-15 Thread Jordan Ladora
A I see - it works perfectly now - thanks very much for your help!!

-j

-- 

--- 
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: Testing if db insert was successful

2013-08-11 Thread Jordan Ladora
I see, thanks!


On Sat, Aug 10, 2013 at 1:39 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> If it does not raise an exception it is successfull. The issue is that
> unless you are in a controller action you have to db.commit() or the insert
> will be un-committed.
>
>
> On Saturday, 10 August 2013 17:07:17 UTC+2, Jordan Ladora wrote:
>>
>> Hi,
>>
>> I'm unable to figure out how to check when a simple db insert() was
>> successful. In my code below, regardless of whether the db insert is
>> successful or not, the code after 'if new_record:' always executes..
>>
>>
>> new_record = db.abc.insert(a='this', b='that', c='theotherthing')
>>
>> if new_record:
>>
>>
>>
>> How can I code "if db insert was successful:" ?
>>
>> Thanks,
>> -J
>>
>  --
>
> ---
> 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/QABiqKdKmlg/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.
>
>
>

-- 

--- 
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: Testing if db insert was successful

2013-08-10 Thread Jordan Ladora
Oops my bad - unrelated problem caused this - please disregard. 

o:

Thanks.


On Saturday, August 10, 2013 8:07:17 AM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> I'm unable to figure out how to check when a simple db insert() was 
> successful. In my code below, regardless of whether the db insert is 
> successful or not, the code after 'if new_record:' always executes..
>
>
> new_record = db.abc.insert(a='this', b='that', c='theotherthing')
>
> if new_record:
>
>
>
> How can I code "if db insert was successful:" ?
>
> Thanks,
> -J
>

-- 

--- 
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] Testing if db insert was successful

2013-08-10 Thread Jordan Ladora
Hi,

I'm unable to figure out how to check when a simple db insert() was
successful. In my code below, regardless of whether the db insert is
successful or not, the code after 'if new_record:' always executes..


new_record = db.abc.insert(a='this', b='that', c='theotherthing')

if new_record:



How can I code "if db insert was successful:" ?

Thanks,
-J

-- 

--- 
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] jquery .hide() interfering with validators

2013-08-10 Thread Jordan Ladora
I have a SQLFORM.factory form that has multiple fields, one hidden by
default in the view (via jquery) and shown when another field, a dropdown
select, changes to some value. In the code below, field_A is shown if
field_B 'Choice 2' is selected.

The problem is that fields (eg field_A) which are shown only after the
dropdown is changed are not being validated properly. Here, field_B and
field_C are validated just fine (they are never hidden), yet field_A is not
validated in the code below - it could be anything and the form will still
submit.



form = SQLFORM.factory(
Field( 'field_A', requires=IS_IN_SET(['Choice 1', 'Choice 2'],
multiple=False, zero='Please choose') ),
Field( 'field_B', requires=IS_IN_SET(['Choice 1', 'Choice 2'],
multiple=False, zero='Please choose') ),
Field( 'field_C', requires=IS_IN_SET(['Choice 1', 'Choice 2'],
multiple=False, zero='Please choose') )
)


def cvalidator(form):
if form.vars.field_B == 'B Choice 2':
if not form.vars.field_A: form.vars.field_A.errors = 'Fill it in'

if form.accepts(request.vars, session, onvalidation=cvalidator): pass




jQuery(document).ready(function() {

jQuery('#no_table_field_A__row').hide();

jQuery('#no_table_field_B').change(function(){

if( jQuery('#no_table_field_B option:selected').text()=='Choice 2'
){
jQuery('#no_table_field_A__row').show();
}else{
jQuery('#no_table_field_A__row').hide();};

});
});


{{=form}}



How can I get all fields to validate properly here?

Thanks for help,
-j

-- 

--- 
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] jQuery bug in view. Trying to show/hide a textbox based on a checkbox being checked.

2013-07-25 Thread Jordan Ladora
Perfect - thanks for your help. I was sloppy with the javascript..

Best,
-j


On Thu, Jul 25, 2013 at 4:21 PM, Paolo Caruccio
wrote:

> I double checked your script and I discovered some errors.
>
> Please try this:
>
> 
> jQuery(document).ready(function() {
> jQuery('#no_table_cnd').change(function(){
> if( jQuery('#no_table_cnd').prop('checked') ){
>
> jQuery('#no_table_nnd__row').show();
> }else{
> jQuery('#no_table_nnd__row').hide();};
> });
> });
> 
>
>
> Il giorno venerdì 26 luglio 2013 00:52:01 UTC+2, Jordan Ladora ha scritto:
>>
>> Hi Paolo,
>>
>> Thanks, but no luck.. I replaced
>>
>>   if( jQuery('#no_table_cnd').attr('**checked') );
>>
>> with
>>
>>   if( jQuery('#no_table_cnd').prop('**checked') );
>>
>> ..but the box is still displayed by default & doesn't change when I
>> check/uncheck the checkbox..
>>
>> Cheers,
>> -j
>>
>>
>>
>> On Thu, Jul 25, 2013 at 12:39 PM, Paolo Caruccio 
>> wrote:
>>
>>> Maybe related with https://groups.google.**com/d/msg/web2py/om58tz-DVOk/
>>> **Lt5beXcLiH8J<https://groups.google.com/d/msg/web2py/om58tz-DVOk/Lt5beXcLiH8J>
>>>
>>> By resuming the api:
>>>
>>>  *As of jQuery 1.6*, the .prop() method provides a way to explicitly
>>>> retrieve property values, while .attr() retrieves attributes.
>>>
>>>
>>> Therefore, you should replace .attr() with .prop() if you are using a
>>> recent version of jQuery
>>>
>>>
>>>
>>> Il giorno giovedì 25 luglio 2013 21:05:36 UTC+2, Jordan Ladora ha
>>> scritto:
>>>>
>>>> Hi,
>>>>
>>>> I'm still stuck here.. I tried a few other things. I just want to
>>>> show/hide #nnd based on whether or not #cnd is checked. This example is in
>>>> the manual, but I still cannot get it to work..
>>>>
>>>> Here's the form-
>>>>
>>>>fields = []
>>>> fields.append( Field( 'cnd', 'boolean', default=True) )
>>>> fields.append( Field( 'nnd') )
>>>>
>>>> form = SQLFORM.factory(*fields)
>>>>
>>>>
>>>> And the view-
>>>>
>>>> 
>>>>
>>>> jQuery(document).ready(**functio**n()
>>>>   {
>>>> jQuery('#no_table_nnd__row').**h**ide();
>>>> jQuery('#no_table_cnd').**change**(function(){
>>>>   if( jQuery('#no_table_cnd').attr('checked') );
>>>> jQuery('#no_table_nnd__row').**s**how();
>>>>   else
>>>> jQuery('#no_table_nnd__row').**h**ide();});
>>>>   });
>>>>
>>>> 
>>>>
>>>>
>>>> But still the input box stays visible regardless of the status of the
>>>> checkbox.. :( Any help would be greatly appreciated.
>>>>
>>>> Thanks,
>>>> -j
>>>>
>>>>
>>>> On Fri, Jun 21, 2013 at 2:07 PM, Jordan Ladora 
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have a jQuery script in a view. It has a bug as it's not working
>>>>> (textbox always shown). I think my syntax in the if statement is wrong..
>>>>> here it is-
>>>>>
>>>>> 
>>>>>
>>>>> jQuery(document).ready(
>>>>>   function()
>>>>>   {
>>>>> if( jQuery('#cnd').prop('checked', true) );
>>>>> {
>>>>>   jQuery('#nnd').show();
>>>>> }
>>>>> else
>>>>> {
>>>>>   jQuery('#nnd').hide();
>>>>> }
>>>>>
>>>>>   }
>>>>>   );
>>>>>
>>>>> 
>>>>>
>>>>>
>>>>> The element with id #cnd is a checkbox, and the element #nnd is a
>>>>> textbox. Putting a single line inside the doc ready function, eg
>>>>>
>>>>> jQuery('#nnd').show();
>>>>>
>>>>> hides or shows the box just fine.
>>>>>
>>>>> Thanks for any help!!!
>>

Re: [web2py] jQuery bug in view. Trying to show/hide a textbox based on a checkbox being checked.

2013-07-25 Thread Jordan Ladora
Hi Paolo,

Thanks, but no luck.. I replaced

  if( jQuery('#no_table_cnd').attr('checked') );

with

  if( jQuery('#no_table_cnd').prop('checked') );

..but the box is still displayed by default & doesn't change when I
check/uncheck the checkbox..

Cheers,
-j



On Thu, Jul 25, 2013 at 12:39 PM, Paolo Caruccio  wrote:

> Maybe related with
> https://groups.google.com/d/msg/web2py/om58tz-DVOk/Lt5beXcLiH8J
>
> By resuming the api:
>
>  *As of jQuery 1.6*, the .prop() method provides a way to explicitly
>> retrieve property values, while .attr() retrieves attributes.
>
>
> Therefore, you should replace .attr() with .prop() if you are using a
> recent version of jQuery
>
>
>
> Il giorno giovedì 25 luglio 2013 21:05:36 UTC+2, Jordan Ladora ha scritto:
>>
>> Hi,
>>
>> I'm still stuck here.. I tried a few other things. I just want to
>> show/hide #nnd based on whether or not #cnd is checked. This example is in
>> the manual, but I still cannot get it to work..
>>
>> Here's the form-
>>
>>fields = []
>> fields.append( Field( 'cnd', 'boolean', default=True) )
>> fields.append( Field( 'nnd') )
>>
>> form = SQLFORM.factory(*fields)
>>
>>
>> And the view-
>>
>> 
>>
>> jQuery(document).ready(**function()
>>   {
>> jQuery('#no_table_nnd__row').**hide();
>> jQuery('#no_table_cnd').**change(function(){
>>   if( jQuery('#no_table_cnd').attr('**checked') );
>>     jQuery('#no_table_nnd__row').**show();
>>   else
>> jQuery('#no_table_nnd__row').**hide();});
>>   });
>>
>> 
>>
>>
>> But still the input box stays visible regardless of the status of the
>> checkbox.. :( Any help would be greatly appreciated.
>>
>> Thanks,
>> -j
>>
>>
>> On Fri, Jun 21, 2013 at 2:07 PM, Jordan Ladora wrote:
>>
>>> Hi,
>>>
>>> I have a jQuery script in a view. It has a bug as it's not working
>>> (textbox always shown). I think my syntax in the if statement is wrong..
>>> here it is-
>>>
>>> 
>>>
>>> jQuery(document).ready(
>>>   function()
>>>   {
>>> if( jQuery('#cnd').prop('checked', true) );
>>> {
>>>   jQuery('#nnd').show();
>>> }
>>> else
>>> {
>>>   jQuery('#nnd').hide();
>>> }
>>>
>>>   }
>>>   );
>>>
>>> 
>>>
>>>
>>> The element with id #cnd is a checkbox, and the element #nnd is a
>>> textbox. Putting a single line inside the doc ready function, eg
>>>
>>> jQuery('#nnd').show();
>>>
>>> hides or shows the box just fine.
>>>
>>> Thanks for any help!!!
>>>
>>>
>>> -jl
>>>
>>>  --
>>>
>>> ---
>>> 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/EqxNV-LO7oY/**unsubscribe<https://groups.google.com/d/topic/web2py/EqxNV-LO7oY/unsubscribe>
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> 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/EqxNV-LO7oY/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.
>
>
>

-- 

--- 
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] jQuery bug in view. Trying to show/hide a textbox based on a checkbox being checked.

2013-07-25 Thread Jordan Ladora
Hi,

I'm still stuck here.. I tried a few other things. I just want to show/hide
#nnd based on whether or not #cnd is checked. This example is in the
manual, but I still cannot get it to work..

Here's the form-

   fields = []
fields.append( Field( 'cnd', 'boolean', default=True) )
fields.append( Field( 'nnd') )

form = SQLFORM.factory(*fields)


And the view-



jQuery(document).ready(function()
  {
jQuery('#no_table_nnd__row').hide();
jQuery('#no_table_cnd').change(function(){
  if( jQuery('#no_table_cnd').attr('checked') );
jQuery('#no_table_nnd__row').show();
  else
jQuery('#no_table_nnd__row').hide();});
  });




But still the input box stays visible regardless of the status of the
checkbox.. :( Any help would be greatly appreciated.

Thanks,
-j


On Fri, Jun 21, 2013 at 2:07 PM, Jordan Ladora
wrote:

> Hi,
>
> I have a jQuery script in a view. It has a bug as it's not working
> (textbox always shown). I think my syntax in the if statement is wrong..
> here it is-
>
> 
>
> jQuery(document).ready(
>   function()
>   {
> if( jQuery('#cnd').prop('checked', true) );
> {
>   jQuery('#nnd').show();
> }
> else
> {
>   jQuery('#nnd').hide();
> }
>
>   }
>   );
>
> 
>
>
> The element with id #cnd is a checkbox, and the element #nnd is a textbox.
> Putting a single line inside the doc ready function, eg
>
> jQuery('#nnd').show();
>
> hides or shows the box just fine.
>
> Thanks for any help!!!
>
> -jl
>
>  --
>
> ---
> 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/EqxNV-LO7oY/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.
>
>
>

-- 

--- 
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: How to set permissions for db table loaded from flat file

2013-07-03 Thread Jordan Ladora
Hi Alan,

Thanks for the help!

For some reason, I did not have 'auth.define_tables()' in the model. Adding
it fixed the problem.

Thanks again!
-jl

-- 

--- 
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: How to set permissions for db table loaded from flat file

2013-07-02 Thread Jordan Ladora
I should also add that if I add this line-

auth.add_permission(1, 'read', r.id)

so that it reads-

if db(db.man.id > 0).isempty():
for line in open('database.txt', 'rU'):
fieldname1,fieldname2,id1,id2 = line.strip().split('\t')
r = db.man.insert(fieldname1=fieldname1, fieldname2=fieldname2, 
id1=id1, id2=id2)
auth.add_permission(1, 'read', r.id)
 
db.commit()


...I get a ticket w/ 
 'DAL' object has no attribute 
'auth_permission' 

>
>

On Monday, July 1, 2013 5:30:10 PM UTC-7, Jordan Ladora wrote:
>
> Hi,
>
> From a file, I'm loading a table that I would like to make accessible to 
> any logged in user.. 
>
> Here's the model-
>
> db.define_table('man',
> Field('fieldname1', requires=IS_NOT_EMPTY(), label="fieldname1"),
> Field('fieldname2', requires=IS_NOT_EMPTY(), label="fieldname2"),
> Field('id1', requires=IS_NOT_EMPTY(), label="label1"),
> Field('id2', requires=IS_NOT_EMPTY(), label="label1"),
> format = '%(fieldname1)s %(fieldname2)s %(id1)s %(id2)s'
> )
>
>
> At the end of the models file, I have this code to fill the table from a 
> flat file, if it is empty-
>
> if db(db.man.id > 0).isempty(): 
> for line in open('database.txt', 'rU'):
> fieldname1,fieldname2,id1,id2 = line.strip().split('\t')
> r = db.man.insert(fieldname1=fieldname1, 
> fieldname2=fieldname2, id1=id1, id2=id2)
> db.commit()
>
>
> What is the best way now set the permissions for all the records in this 
> table, so any logged in user can access them? 
>
> Thanks for any help!
> -JL
>
>

-- 

--- 
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] How to set permissions for db table loaded from flat file

2013-07-01 Thread Jordan Ladora
Hi,

>From a file, I'm loading a table that I would like to make accessible to 
any logged in user.. 

Here's the model-

db.define_table('man',
Field('fieldname1', requires=IS_NOT_EMPTY(), label="fieldname1"),
Field('fieldname2', requires=IS_NOT_EMPTY(), label="fieldname2"),
Field('id1', requires=IS_NOT_EMPTY(), label="label1"),
Field('id2', requires=IS_NOT_EMPTY(), label="label1"),
format = '%(fieldname1)s %(fieldname2)s %(id1)s %(id2)s'
)


At the end of the models file, I have this code to fill the table from a 
flat file, if it is empty-

if db(db.man.id > 0).isempty(): 
for line in open('database.txt', 'rU'):
fieldname1,fieldname2,id1,id2 = line.strip().split('\t')
r = db.man.insert(fieldname1=fieldname1, fieldname2=fieldname2, 
id1=id1, id2=id2)
db.commit()


What is the best way now set the permissions for all the records in this 
table, so any logged in user can access them? 

Thanks for any help!
-JL

-- 

--- 
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: Chopping up form fields in the view

2013-06-24 Thread Jordan Ladora
Hi Anthony,

Thanks for the note - what prevented me from making the custom layout is 
that the form fields are generated on the fly; I don't know what they are 
or how many up front (there are hundreds or thousands of fields generated 
for this form), so inserting them separately seems tricky(?)

However, the two extra elements are completely static and could be inserted 
separately into the view. I need everything to be submitted together with 
the form.

If I create the form in the controller without those two extra elements, 
how can I insert them and place them so that they are submitted together 
with the form?

Thanks again,
-jl

-- 

--- 
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] Chopping up form fields in the view

2013-06-24 Thread Jordan Ladora

Hello,

I have a form where I want to manipulate a couple of extra elements 
*separately* in the view. 

I'd like to be able to wrap them in a separate  element so they are 
physically on the page somewhere else and not together with the other form 
fields.

In the controller-
form = SQLFORM.factory(fields)

my_extra_element   = TR(LABEL('Element one'), INPUT(_id='e1', 
_type='text'))
my_extra_element2 = TR(LABEL('Element two'), INPUT(_id='e2', 
_type='text'))
form[0].insert(-1, my_extra_element)
form[0].insert(-1, my_extra_element2)

In the view, if I show the form in the usual way-

{{=form}}

..it shows the elements #e1 and #e2 together with the form, by default, but 
I want to take them out of here and put them somewhere else-


{{=form}}   # i want to show the whole form except the #e1 and #e2 elements 
here



#  I want to put the #e1 and #e2 elements here


How can I take #e1 and #e2 out of div #d1 and put them in div #d2?

Thanks for any help!
-J

-- 

--- 
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] jQuery bug in view. Trying to show/hide a textbox based on a checkbox being checked.

2013-06-21 Thread Jordan Ladora
Hi,

I have a jQuery script in a view. It has a bug as it's not working (textbox 
always shown). I think my syntax in the if statement is wrong.. here it is-



jQuery(document).ready(
  function()
  {
if( jQuery('#cnd').prop('checked', true) );
{
  jQuery('#nnd').show();
}
else 
{
  jQuery('#nnd').hide();
}

  }
  );   




The element with id #cnd is a checkbox, and the element #nnd is a textbox. 
Putting a single line inside the doc ready function, eg

jQuery('#nnd').show();

hides or shows the box just fine.

Thanks for any help!!!

-jl

-- 

--- 
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: Can't access databases after copying files to new application

2013-06-05 Thread Jordan Ladora
Ah my bad - thanks!!

-- 

--- 
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: Can't access databases after copying files to new application

2013-06-05 Thread Jordan Ladora
The new application was created from the main menu ('New Simple 
Application'). Then I copied the models, views, and controllers into the 
new app. 

The sql.log file in the new app/databases folder shows the tables were 
created from the models just fine. But I have no access to anything in any 
table from the new application (including through appadmin). 



-- 

--- 
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] Can't access databases after copying files to new application

2013-06-05 Thread Jordan Ladora
Hello,

I just copied a bunch of files from an existing project to a new, empty 
project, and cannot access any databases, even though the 
application/databases folder is fully populated (sqlite). 

When I launched the new application and registered as a new user, all the 
'auth_' databases are empty, the appadmin/index page only shows the 'auth_' 
databases, and I'm getting errors about no databases when I navigate away 
from the home page. 

It's weird that even though I'm logged in, nobody appears in db.auth_users

I've copied the skeleton of an app to a new one before, but not since 
upgrading to 2.3.2, and didn't have any issues previously... 

Thanks for any help,
-jl

-- 

--- 
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: Checking if db query was successful

2013-06-05 Thread Jordan Ladora
Thanks - what about with 

selected_records = db(q1&q2).select() 

..should I use 

if len(selected_records):

..if no records are returned?


Thanks again,
-jl

-- 

--- 
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] Checking if db query was successful

2013-06-04 Thread Jordan Ladora
Hi,

If I set up a query like so,

q1 = auth.accessible_query('read', db.stuff)
q2 = db.stuff.id==3
selected_record = db(q1&q2).select().first() # how to check if 
this successfully got db record?
selected_records = db(q1&q2).select()# how to check if 
this successfully got db records?

...I want to check if my select() or select().first() was successful and 
contains record(s) before executing more code. 

These are some ways I thought of doing it, but they have all created 
problems in one way or another. 

1) if selected_record in locals():  # if query successful, 
returns FALSE
2) if selected_record: # code below still 
executes even if 'selected_record' does not exist
3) if len(selected_record):   # throws row object 
has no len attribute error


Thanks for help,
-JL

-- 

--- 
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: Not good at making ajax calls from a view

2013-05-14 Thread Jordan Ladora
One follow up question-- normally in my controller I would use a SQLFORM 
object, e.g. one named 'form' and then use: 

if form.accepts(request.vars, session):


...to execute code after getting validated form data. I could look for the 
newly created variables in request.vars or is there a better way(?)

Thanks!
-j

-- 

--- 
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: Not good at making ajax calls from a view

2013-05-11 Thread Jordan Ladora
That did it - thanks!



On Friday, May 10, 2013 12:36:54 PM UTC-7, Anthony wrote:
>
> Maybe try:
>
> onchange="{{="jQuery(district_select).remove(); ajax('%s', 
> ['title_select'], 'shadow_clone');" % URL('default', 'maker')}}"
>
> Anthony
>
>

-- 

--- 
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] Not good at making ajax calls from a view

2013-05-10 Thread Jordan Ladora
Hi,

I'm trying to implement a drop-down based on the one at 
http://www.web2pyslices.com/slice/show/1467/cascading-drop-down-lists-with-ajax 


While the example above works great, I don't seem to be making a successful 
ajax call in my adaptation.. Basically, the second dropdown does not reload 
(it gets removed by jQuery .remove(), never to return) when the first 
dropdown changes. if I remove this line from the above w2pslices example:

ajax('maker', ['category_name'], 'shadow_clone');

...then it fails just like my code does, making me think my ajax call does 
not happen. 

The db.district_data simply stores a title and an integer 
('num_districts'). The districts always start at 1 and go up to 
'num_districts' so if 'num_districts' is 3, I want to load the dropdown 
with the three options 1 | 2 | 3

A user selects a title in the first dropdown and selects a district in the 
second. I'm trying to use the ajax call to load the second dropdown based 
on the contents of the first... so when a user selects a title from the 
first dropdown, they should then see the other dropdown updated and loaded 
with 1:num_districts (eg 1 | 2 | 3 ) for the given title. 

Here's my code:

# model:
db.define_table('district_data',
Field('title', readable=False, writable=False),
Field('num_districts', 'integer', default=0, readable=False, 
writable=False, requires=IS_INT_IN_RANGE(0, 1e100)),
auth.signature,
format = '%(title)s')


# controller:
@auth.requires_login()
def td():
titles_list = []
num_districts_list = []
q1 = auth.accessible_query('read', db.district_data)
records = db(q1).select()

for row in records: 
titles_list.append(row.title)
num_districts_list.append( tuple(range(1, row.num_districts+1)) )

return(locals())

@auth.requires_login()
def maker():
with open('/home/JL/Desktop/results_dump.txt', 'w') as file: 
file.write('abc' + '\n')   # file untouched / does not execute.

q1 = auth.accessible_query('read', db.district_data)
q2 = db.district_data.title == request.vars.title_select.replace('_', ' 
')  # not sure if this is necessary(?)
record = db(q1&q2).select().first()

result = ""
district_choices = tuple(range(1, record.num_districts+1))
for dc in district_choices:
result += "" + str(dc) + 
""  
result += ""

return XML(result)


# view
{{extend 'layout.html'}}



{{for title in titles_list:}}
 
{{=title}}

{{pass}}





{{for district in num_districts_list[0]:}}

{{=str(district)}}

{{pass}}



  




Thanks very much for looking at this,
-jl

-- 

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