[web2py] Re: SQLFORM.grid question

2017-04-26 Thread Jim Russell


On Tuesday, April 25, 2017 at 9:19:59 AM UTC-5, Anthony wrote:
>
> On Tuesday, April 25, 2017 at 3:20:23 AM UTC-4, Jim Russell wrote:
>>
>> I worked around this by setting the wltype field to string and adding 
>> a requires=IS_IN_SET. This makes the editing page have a dropdown with the 
>> set members instead of a free-form text field.
>>
>
> This is not a great idea if wltype is intended to be a reference to the 
> osrwlpooltype table, as you lose the benefits of the foreign key constraint 
> and the mechanisms the DAL provides for managing that.
>
> Anthony
>

Indeed, and I knew it was ugly.

I simplified my table and instead of having it reference another table, I 
just set wltype to a string and then set  the constraints for the field in 
db.py 

db.osrwhitelistpool.wltype.requires=IS_IN_SET(('ALL', 'REBOOT', 'PING))

Thanks very much for your help 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: SQLFORM.grid question

2017-04-25 Thread Jim Russell
I worked around this by setting the wltype field to string and adding 
a requires=IS_IN_SET. This makes the editing page have a dropdown with the 
set members instead of a free-form text field.

So it's working, but it's not the most elegant solution.

-- 
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] SQLFORM.grid question

2017-04-24 Thread Jim Russell
Hi all.

I'm having an issue with an SQLFORM.gird query. I have a table where one of 
the columns references another table. Here are the table definitions:

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='reference osrwlpooltype'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

db.define_table('osrwlpooltype',
Field('id', type='id'),
Field('wtype', type='string', length=32, unique=True))

So osrwhitelistpool field wltype references osrwlpooltype field wtype.

When I run a simple query, just requesting the whole table I get an error Query 
Not Supported: invalid literal for long() with base 10: 'ALL'

I'm not sure why it thinks that field should be a long.

Here are the table definitions directly from the DB:

osrtest=# \d osrwlpooltype
Table "osrtest.osrwlpooltype"
 Column | Type  |Modifiers
+---+--
 id | integer   | not null default 
nextval('osrwlpooltypeseqpk'::regclass)
 wtype  | character varying(32) | not null
Indexes:
"osrwlpooltype_pkey" PRIMARY KEY, btree (id)
"osrwlpooltype_wtype_key" UNIQUE CONSTRAINT, btree (wtype)
Referenced by:
TABLE "osrwhitelistpool" CONSTRAINT "osrwhitelistpool_wltype_fkey" 
FOREIGN KEY (wltype) REFERENCES osrwlpooltype(wtype)

osrtest=# \d osrwhitelistpool
Table "osrtest.osrwhitelistpool"
  Column  |Type |  Modifiers
--+-+-
 id   | integer | not null default 
nextval('osrwhitelistpoolseqpk'::regclass)
 pool | character varying(255)  | not null
 wltype   | character varying   |
 comments | character varying(255)  |
 ctime| timestamp without time zone | default now()
Indexes:
"osrwhitelistpool_pkey" PRIMARY KEY, btree (id)
"osrwhitelistpool_pool_key" UNIQUE CONSTRAINT, btree (pool)
Foreign-key constraints:
"osrwhitelistpool_wltype_fkey" FOREIGN KEY (wltype) REFERENCES 
osrwlpooltype(wtype)



I changed the table definition in db.py to 

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='string'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

and it worked to display it. But then when I edit a record it is just a 
free form text field instead of a dropdown with the wtype field from 
osrwlpooltype.

Any ideas what I'm doing wrong?

Thanks,
Jim

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


[web2py] Re: check boxes with is_in_set

2016-12-12 Thread Jim Russell
In your example, list_chart is not a list of strings, it is a list of 
tuples.

In my code, hostnames is just a list of hostnames.  e.g. 
('hostname1.example.com','hostname2.example.com')

I assume that you are trying to make the checkboxes default to true. For 
me, they defaulted to being checked.

On Monday, December 12, 2016 at 3:50:58 PM UTC-6, 黄祥 wrote:
>
> trying the tricks but got error when the checkbox is empty (1 or all 
> checkbox is empty, when all checkbox is on its work) :
> *e.g.*
> def test_form():
> redirect_url = 'test'
>
> list_chart = [(True, 'line'), 
>  (True, 'pie'), 
>  (True, 'bar') ]
>
> form = SQLFORM.factory(
> Field('chart', 'list:string', 
>  default = list_chart,
>  widget = SQLFORM.widgets.checkboxes.widget, 
>  requires = [IS_IN_SET(list_chart, multiple = True) ] ) )
> if form.process().accepted:
> chart = form.vars.chart
> line = form.vars.line[0]
> pie = form.vars.pie[1]
> bar = form.vars.bar[2]
>
> response.new_window = URL(redirect_url, args = [chart] )
> #response.new_window = URL(redirect_url, args = [line, pie, bar] )
> elif form.errors:
> response.flash = T('Form has errors')
> return dict(form = form)
>
> *Traceback error:*
> line = form.vars.chart[0]
> IndexError: list index out of range
>
> any idea how to face it using web2py way?
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: check boxes with is_in_set

2016-12-08 Thread Jim Russell
Rob,

I used this code to get a list with checkboxes.

form=SQLFORM.factory(
Field('hostnames',"list:string", 
default=hostnames,widget=SQLFORM.widgets.checkboxes.widget,requires=[IS_IN_SET(hostnames,multiple=True),IS_NOT_EMPTY()]))

hostnames is a list containing strings.

-- 
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: returning values from custom form

2016-11-26 Thread Jim Russell
Marlysson,

Thanks for the reply.  I did figure out how to do it the web2py way. It was 
not particularly intuitive, but now that I understand it, it makes sense 
and is pretty powerful.

form=SQLFORM.factory(
Field('hostnames',"list:string", 
default=hostnames,widget=SQLFORM.widgets.checkboxes.widget,requires=[IS_IN_SET(hostnames,multiple=True),IS_NOT_EMPTY()]))
form.add_button('Cancel',URL('index'))

Then the view just has {{==form}}

It works exactly the way I hoped it would.  Perhaps an example of this 
could be put in the examples page.


On Saturday, November 26, 2016 at 5:21:59 PM UTC-6, Marlysson Silva wrote:
>
> I don't used the form.accepted but you could use to validate de submit the 
> form and handle.. but basically it's 
>
> Em sábado, 26 de novembro de 2016 20:20:58 UTC-3, Marlysson Silva escreveu:
>>
>> I created a other version for your code, I created a form html ( the hard 
>> way ) and in the controller get the post vars sent by form:
>>
>> The controller:
>> def form():
>> host_names = ["google","facebook","amazon","localhost"]
>>
>> marcados = request.post_vars["host"]
>>
>> return dict(host_names=host_names,marcados=marcados)
>>
>> The view:
>>
>> 
>> {{for host in host_names:}}
>>  {{=host}} 
>> 
>> {{pass}}
>> 
>> 
>>
>> {{=marcados}}
>>
>>
>> Em sábado, 26 de novembro de 2016 02:03:33 UTC-3, Jim Russell escreveu:
>>>
>>> Hi.
>>>
>>> I have created a form which takes a list of hostnames and shows the 
>>> hostnames with checkboxes next to it. The idea is to be able to uncheck any 
>>> hostnames and pass the still checked hostnames to another function which 
>>> will then act on that list of hostnames. The problem is that it just 
>>> returns an empty list.
>>>
>>> I am new to web2py, this is my first project, so if my thinking is 
>>> wrong, I'm ok with rewriting this part from scratch.
>>>
>>> Here is the code:
>>>
>>> def verify():
>>> hostnames=request.vars.hostnames.split()
>>> num_hosts=len(hostnames)
>>> form=FORM(TABLE(TR("Hostnames")))
>>> for hn in hostnames:
>>> row=XML('>> checked>'+ hn)
>>> form[0].append(row)
>>> form[0].append(XML('>> id="submit">Submit!'))
>>>
>>> if form.accepts(request,session):
>>> redirect(URL('execute',vars=dict(hostnames=form.vars.hostnames)))
>>> return dict(hostnames=hostnames,form=form)
>>>
>>> Thanks in advance for your help.
>>>
>>> Jim
>>>
>>

-- 
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] returning values from custom form

2016-11-25 Thread Jim Russell
Hi.

I have created a form which takes a list of hostnames and shows the 
hostnames with checkboxes next to it. The idea is to be able to uncheck any 
hostnames and pass the still checked hostnames to another function which 
will then act on that list of hostnames. The problem is that it just 
returns an empty list.

I am new to web2py, this is my first project, so if my thinking is wrong, 
I'm ok with rewriting this part from scratch.

Here is the code:

def verify():
hostnames=request.vars.hostnames.split()
num_hosts=len(hostnames)
form=FORM(TABLE(TR("Hostnames")))
for hn in hostnames:
row=XML(''+ hn)
form[0].append(row)
form[0].append(XML('Submit!'))
   
if form.accepts(request,session):
redirect(URL('execute',vars=dict(hostnames=form.vars.hostnames)))
return dict(hostnames=hostnames,form=form)

Thanks in advance for your help.

Jim

-- 
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: 502 Bad Gateway - no tmp/web2py.socket file

2016-11-25 Thread Jim Russell


>
>  $ ps aux | grep "uwsgi"
> richard   1044  0.0  0.1   4276  1824 pts/0S+   10:54   0:00 grep 
> --color=auto uwsgi
>

That is the grep process, not uwsgi.  So uwsgi is not running.

Check in /var/log/nginx/ for any messages about uwsgi 

-- 
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: Email not working

2016-02-19 Thread Tom Russell
Yea I have the user/pw correct, the smtp settings seem pretty straight 
forward as well so not sure what the root cause is.

On Friday, February 12, 2016 at 4:10:20 PM UTC-5, Dave S wrote:
>
>
>
> On Friday, February 12, 2016 at 12:17:57 PM UTC-8, Tom Russell wrote:
>>
>> Yea I am not trying to blame web2py but it just seems I am not having any 
>> luck getting an email to send. I am using a smtp interface on the other 
>> side.
>>
>> I am just at a loss as to what the issue is and how to solve it.
>>
>> Thanks,
>>
>> Tom
>>
>
> FWIW, on my AWS Linux instance, I send email with server "localhost" and 
> user "None" (I'm hoping that only works from local posts), using either 
> auth's mailer or smtplib directly.  From reading this group for a while, 
> the most common problem seems to be getting user/password right, especially 
> with GMail and 2-factor authentication.
>
> /dps
>
>
>
>> On Friday, February 12, 2016 at 2:40:43 PM UTC-5, Niphlod wrote:
>>>
>>> web2py uses smtplib. as long as on the other side there's an 
>>> smtp-compatible interface, there's no reason to blame web2py :P
>>>
>>> On Friday, February 12, 2016 at 8:38:38 PM UTC+1, Tom Russell wrote:
>>>>
>>>> I have since my last time trying to get email sending working with the 
>>>> built in registration process moved to Amazon AWS SES mail services which 
>>>> I 
>>>> know works well with other people. I have put in all the required info in 
>>>> db.py needed but still cannot send an email. I have tried gmail, a few 
>>>> other services and nothing so far seems to work.
>>>>
>>>> Has anyone tried an actual mail service that works, preferably free or 
>>>> close to it. I am beginning to think that web2py has an issue doing this 
>>>> task.
>>>>
>>>> I really need to get past this hurtle for a product launch soon.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>

-- 
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: Email not working

2016-02-12 Thread Tom Russell
Yea I am not trying to blame web2py but it just seems I am not having any 
luck getting an email to send. I am using a smtp interface on the other 
side.

I am just at a loss as to what the issue is and how to solve it.

Thanks,

Tom

On Friday, February 12, 2016 at 2:40:43 PM UTC-5, Niphlod wrote:
>
> web2py uses smtplib. as long as on the other side there's an 
> smtp-compatible interface, there's no reason to blame web2py :P
>
> On Friday, February 12, 2016 at 8:38:38 PM UTC+1, Tom Russell wrote:
>>
>> I have since my last time trying to get email sending working with the 
>> built in registration process moved to Amazon AWS SES mail services which I 
>> know works well with other people. I have put in all the required info in 
>> db.py needed but still cannot send an email. I have tried gmail, a few 
>> other services and nothing so far seems to work.
>>
>> Has anyone tried an actual mail service that works, preferably free or 
>> close to it. I am beginning to think that web2py has an issue doing this 
>> task.
>>
>> I really need to get past this hurtle for a product launch soon.
>>
>> Thanks,
>>
>> Tom
>>
>

-- 
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] Email not working

2016-02-12 Thread Tom Russell
I have since my last time trying to get email sending working with the 
built in registration process moved to Amazon AWS SES mail services which I 
know works well with other people. I have put in all the required info in 
db.py needed but still cannot send an email. I have tried gmail, a few 
other services and nothing so far seems to work.

Has anyone tried an actual mail service that works, preferably free or 
close to it. I am beginning to think that web2py has an issue doing this 
task.

I really need to get past this hurtle for a product launch soon.

Thanks,

Tom

-- 
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] Email Registration

2016-01-12 Thread Tom Russell
I will try that but I also tried doing this locally and not on 
Pythonanywhere and get the same result so not too sure it is Pythonanywhere.

On Monday, January 11, 2016 at 4:35:50 PM UTC-5, Alessio Varalta wrote:
>
> write in the pythonanywhere forum because for example on my server there 
> are a service that web2py use automatic for the email we use our 
> server...but i use also pythonanywhere and i know that have specific 
> services for example for generate pdf ecc..( i don't use pythonanywhere 
> with email) So wirte in pythonanywhere forum and ask what type of service 
> use the site and the problem
>
> Il giorno sabato 9 gennaio 2016 22:52:17 UTC+1, Tom Russell ha scritto:
>>
>> Yea I have a premium account with pythonanywhere.
>>
>> On Saturday, January 9, 2016, Alessio Varalta  wrote:
>>
>>> Maybe is a problem of the server not web2py for example with 
>>> pythonanywhere you have to have a premium account or on the server there 
>>> aren't a service for the email 
>>>
>>> Il giorno sabato 9 gennaio 2016 21:41:31 UTC+1, Tom Russell ha scritto:
>>>>
>>>>
>>>> Hi,
>>>>
>>>> I have everything in place according to the docs to do the email 
>>>> registration process. However every time I try it in the error log it just 
>>>> says email not sent and then a print out  of what the email would have 
>>>> looked like had it been sent. I have no idea why I cannot get this to work.
>>>>
>>>> I am using web2py version 2.12.3-stable+timestamp.2015.08.19.00.18.03 
>>>> on pythonanywhere.
>>>>
>>>> The server where the email from comes from is godaddy.
>>>>
>>>> Any ideas what to check for with this?
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>> -- 
>>> 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/7X8GFnVHRU8/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] Email Registration

2016-01-09 Thread Tom Russell
Yea I have a premium account with pythonanywhere.

On Saturday, January 9, 2016, Alessio Varalta  wrote:

> Maybe is a problem of the server not web2py for example with
> pythonanywhere you have to have a premium account or on the server there
> aren't a service for the email
>
> Il giorno sabato 9 gennaio 2016 21:41:31 UTC+1, Tom Russell ha scritto:
>>
>>
>> Hi,
>>
>> I have everything in place according to the docs to do the email
>> registration process. However every time I try it in the error log it just
>> says email not sent and then a print out  of what the email would have
>> looked like had it been sent. I have no idea why I cannot get this to work.
>>
>> I am using web2py version 2.12.3-stable+timestamp.2015.08.19.00.18.03 on
>> pythonanywhere.
>>
>> The server where the email from comes from is godaddy.
>>
>> Any ideas what to check for with this?
>>
>> Thanks,
>>
>> Tom
>>
> --
> 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/7X8GFnVHRU8/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] Email Registration

2016-01-09 Thread Tom Russell

Hi,

I have everything in place according to the docs to do the email 
registration process. However every time I try it in the error log it just 
says email not sent and then a print out  of what the email would have 
looked like had it been sent. I have no idea why I cannot get this to work.

I am using web2py version 2.12.3-stable+timestamp.2015.08.19.00.18.03 on 
pythonanywhere.

The server where the email from comes from is godaddy.

Any ideas what to check for with this?

Thanks,

Tom

-- 
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: DAL Select

2014-08-18 Thread Tom Russell
Thanks. I did originally did iterate through the rows but like this 
approach better since I know only one row will always match.

On Monday, August 18, 2014 11:16:25 AM UTC-4, Anthony wrote:
>
> .select() returns a Rows object, even if it contains just a single row. 
> Instead, it should be:
>
> row = db(db.voltrin.startdate == mydate).select()[0]
>
> or better:
>
> row = db(db.voltrin.startdate == mydate).select().first()
>
> .first() returns None in case no records are returned, which would cause 
> an error when using a subscript.
>
> Anthony
>
> On Monday, August 18, 2014 11:09:37 AM UTC-4, Tom Russell wrote:
>>
>> I have some simple code that is suppose to grab data from a row in my db 
>> table.
>>
>> I do it like:
>>
>> row = db(db.voltrin.startdate == mydate).select()
>> vwtrin = row.vw_trin
>>
>> I have run this and verified mydate and whatever other variables I have 
>> are something other than null but I cannot seem to get the data for the 
>> field in my code above. I can see in the pycharm debugger that the row has 
>> the colnames listed but I do not see any records or values.
>>
>> Am I doing this right?
>>
>> Thanks,
>>
>> Tom
>>
>

-- 
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] DAL Select

2014-08-18 Thread Tom Russell
I have some simple code that is suppose to grab data from a row in my db 
table.

I do it like:

row = db(db.voltrin.startdate == mydate).select()
vwtrin = row.vw_trin

I have run this and verified mydate and whatever other variables I have are 
something other than null but I cannot seem to get the data for the field 
in my code above.

Am I doing this right?

Thanks,

Tom

-- 
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] PythonAnywhere Web2py Script

2014-07-16 Thread Tom Russell
I am trying to run a script that I have in my app. While the log files seem 
to show my script ran, it does not update the db I have for my app. On the 
schedule tab in pythonanywhere I have this set up so not sure if it is 
correct:

python2.7 /home/tsrdatatech/web2py/web2py.py -S ttheorydataextractor -M -R /
home/tsrdatatech/web2py/applications/ttheorydataextractor/modules/
voltrin_grabber.py

And a sample output of what the log says when it runs is below:

2014-07-14 23:00:44 -- Completed task, took 17.00 seconds, return code was 0.
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Database drivers available: SQLite(sqlite3), MySQL(pymysql), MySQL(MySQLdb), 
MySQL(mysqlconnector), PostgreSQL(psycopg2), PostgreSQL(pg8000), MSSQL(pyodbc), 
DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), MongoDB(pymongo), IMAP(imaplib)

2014-07-15 23:00:30 -- Completed task, took 11.00 seconds, return code was 0.


It seems like it opens web2py but doesnt really run the script I have I 
think.

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] layout

2014-06-05 Thread Tom Russell
I want to use a few parts from a layout for web2py 
here 
http://www.web2py.com/layouts/static/plugin_layouts/layouts/CorporateOffice/index.html

Mainly I just want the  for my layout.html. I tried 
adding this but it does not seem to work. Is there an easy way to do this?

Thanks.

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


[web2py] Re: Scheduler

2014-06-05 Thread Tom Russell
Well that will work as I already have some stuff running in their schedule 
tab anyways.

On Wednesday, June 4, 2014 9:24:22 PM UTC-4, Michael Beller wrote:
>
> You can't use the web2py scheduler but you can create your own simple 
> version.
>
> Here is more information from the python anywhere forum:
>
> https://www.pythonanywhere.com/forums/topic/179/
>
> Basically you can launch web2py periodically, e.g., once an hour or once 
> per day, and execute a module that can perform anything you want.  You 
> could also process the tasks in the task table and their associated actions.
>
> On Wednesday, June 4, 2014 11:00:06 AM UTC-4, Tom Russell wrote:
>>
>> I have implemented the scheduler per the info and examples in Chapter 4 
>> of the book. I am trying to start the workers but my problem is I am not 
>> sure how to since my app is hosted on pythonanywhere and according to the 
>> book I need to do it from the interface from where you set the ip and port.
>>
>> Is there another way to do this?
>>
>> 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] Scheduler

2014-06-04 Thread Tom Russell
I have implemented the scheduler per the info and examples in Chapter 4 of 
the book. I am trying to start the workers but my problem is I am not sure 
how to since my app is hosted on pythonanywhere and according to the book I 
need to do it from the interface from where you set the ip and port.

Is there another way to do this?

Thanks.

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


[web2py] Re: ValueError: invalid literal for int() with base 10:

2014-05-29 Thread Tom Russell
awesome, worked.

On Thursday, May 29, 2014 3:41:12 PM UTC-4, Niphlod wrote:
>
> drop the table and recreate it. It's a known issue with sqlite.
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#SQLite
>
> On Thursday, May 29, 2014 9:34:28 PM UTC+2, Tom Russell wrote:
>>
>> I am getting the following error when inserting a new record for a table 
>> I have. I cannot seem to pinpoint what the cause is at this time.
>>
>> The error is:
>>
>> Traceback (most recent call last):
>>   File 
>> "/home/tsrdatatech/web2py/applications/ttheorydataextractor/controllers/appadmin.py",
>>  line 270, in select
>> *fields, limitby=(start, stop))
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 10525, in select
>> return adapter.select(self.query,fields,attributes)
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 2458, in select
>> return super(SQLiteAdapter, self).select(query, fields, attributes)
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 1882, in select
>> return self._select_aux(sql,fields,attributes)
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 1847, in _select_aux
>> self.execute(sql)
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 1969, in execute
>> return self.log_execute(*a, **b)
>>   File "/home/tsrdatatech/web2py/gluon/dal.py", line 1963, in log_execute
>> ret = self.cursor.execute(command, *a[1:], **b)
>>   File "/usr/lib/python2.7/sqlite3/dbapi2.py", line 63, in convert_date
>> return datetime.date(*map(int, val.split("-")))
>> ValueError: invalid literal for int() with base 10: '12/02/2013'
>>
>>
>> And my table looks like:
>>
>> db.define_table("daily_data",
>>  Field("startdate","date",requires=IS_DATE(), label="Date", 
>> readable=True, writable=False),
>>  Field("vol_total","double", label="Vol Total", readable=True, 
>> writable=False),
>>  Field("wsj_date","string", label="WSJ Date", readable=True, 
>> writable=False),
>>  Field("trin","double", label="TRIN", readable=True, writable=False),
>>  Field("gold","double", readable=True, writable=False),
>>  Field("vix","double", label="VIX", readable=False, writable=False),
>>  Field("advances","double", readable=True, writable=False),
>>  Field("declines","double", readable=True, writable=False),
>>  Field("adv_vol","double", readable=True, writable=False),
>>  Field("dec_vol","double", readable=True, writable=False),
>>  Field("sp_hi","double", readable=True, writable=False),
>>  Field("sp_low","double", readable=True, writable=False),
>>  Field("sp_close","double", readable=True, writable=False),
>>  Field("spy","double", label="SPY", readable=False, writable=False),
>>  Field("csj","double", label="CSJ", readable=False, writable=False),
>>  Field("bnd","double", label="BND", readable=False, writable=False),
>>  Field("cwb","double", label="CWB", readable=False, writable=False),
>>  Field("bond","double", label="BOND", readable=False, writable=False),
>>  Field("hys","double", label="HYS", readable=False, writable=False),
>>  Field("flot","double", label="FLOT", readable=False, writable=False),
>>  Field("hyg","double", label="HYG", readable=False, writable=False),
>>  Field("bkln","double", label="BKLN", readable=False, writable=False),
>>  Field("emb","double", label="EMB", readable=False, writable=False),
>>  Field("efa","double", label="EFA", readable=False, writable=False),
>>  Field("fex","double", label="FEX", readable=False, writable=False),
>>  Field("mdy","double", label="MDY", readable=False, writable=False),
>>  Field("fnx","double", label="FNX", readable=False, writable=False),
>>  Field("vti","dou

[web2py] ValueError: invalid literal for int() with base 10:

2014-05-29 Thread Tom Russell
I am getting the following error when inserting a new record for a table I 
have. I cannot seem to pinpoint what the cause is at this time.

The error is:

Traceback (most recent call last):
  File 
"/home/tsrdatatech/web2py/applications/ttheorydataextractor/controllers/appadmin.py",
 line 270, in select
*fields, limitby=(start, stop))
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 10525, in select
return adapter.select(self.query,fields,attributes)
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 2458, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 1882, in select
return self._select_aux(sql,fields,attributes)
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 1847, in _select_aux
self.execute(sql)
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 1969, in execute
return self.log_execute(*a, **b)
  File "/home/tsrdatatech/web2py/gluon/dal.py", line 1963, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
  File "/usr/lib/python2.7/sqlite3/dbapi2.py", line 63, in convert_date
return datetime.date(*map(int, val.split("-")))
ValueError: invalid literal for int() with base 10: '12/02/2013'


And my table looks like:

db.define_table("daily_data",
 Field("startdate","date",requires=IS_DATE(), label="Date", 
readable=True, writable=False),
 Field("vol_total","double", label="Vol Total", readable=True, 
writable=False),
 Field("wsj_date","string", label="WSJ Date", readable=True, 
writable=False),
 Field("trin","double", label="TRIN", readable=True, writable=False),
 Field("gold","double", readable=True, writable=False),
 Field("vix","double", label="VIX", readable=False, writable=False),
 Field("advances","double", readable=True, writable=False),
 Field("declines","double", readable=True, writable=False),
 Field("adv_vol","double", readable=True, writable=False),
 Field("dec_vol","double", readable=True, writable=False),
 Field("sp_hi","double", readable=True, writable=False),
 Field("sp_low","double", readable=True, writable=False),
 Field("sp_close","double", readable=True, writable=False),
 Field("spy","double", label="SPY", readable=False, writable=False),
 Field("csj","double", label="CSJ", readable=False, writable=False),
 Field("bnd","double", label="BND", readable=False, writable=False),
 Field("cwb","double", label="CWB", readable=False, writable=False),
 Field("bond","double", label="BOND", readable=False, writable=False),
 Field("hys","double", label="HYS", readable=False, writable=False),
 Field("flot","double", label="FLOT", readable=False, writable=False),
 Field("hyg","double", label="HYG", readable=False, writable=False),
 Field("bkln","double", label="BKLN", readable=False, writable=False),
 Field("emb","double", label="EMB", readable=False, writable=False),
 Field("efa","double", label="EFA", readable=False, writable=False),
 Field("fex","double", label="FEX", readable=False, writable=False),
 Field("mdy","double", label="MDY", readable=False, writable=False),
 Field("fnx","double", label="FNX", readable=False, writable=False),
 Field("vti","double", label="VTI", readable=False, writable=False),
 Field("iwd","double", label="IWD", readable=False, writable=False),
 Field("fta","double", label="FTA", readable=False, writable=False),
 Field("iwm","double", label="IWM", readable=False, writable=False),
 Field("dvy","double", label="DVY", readable=False, writable=False),
 Field("iyr","double", label="IYR", readable=False, writable=False),
 Field("ijr","double", label="IJR", readable=False, writable=False),
 Field("tlt","double", label="TLT", readable=False, writable=False),
 Field("ief","double", label="IEF", readable=False, writable=False),
 Field("vustx","double", label="VUSTX", readable=False, writable=False),
 Field("fagix","double", label="FAGIX", readable=False, writable=False),
 Field("qqq","double", label="QQQ", readable=False, writable=False),
)

I know the error refers to a date and actually I had wsj_date as a date 
field but changed it to a string since I really did not need the date 
requirement for it.

Any suggestions?

Thanks.

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


[web2py] Re: DAL/Decorator for specific data

2014-05-29 Thread Tom Russell
Works perfect, thanks Anthony.

On Wednesday, May 28, 2014 11:10:37 AM UTC-4, Anthony wrote:
>
> You can include logic to set the readable and writable attributes of 
> particular fields to True/False depending on Auth group membership. For 
> example:
>
> db.define_table('mytable', Field('myfield', readable=False, writable=False
> ))
>
> if auth.has_membership('admin'):
> db.mytable.myfield.readable = db.mytable.myfield.writable = True
>
> I suppose you could write a decorator that does that, but it's not clear 
> there would be any benefit over the simple approach above.
>
> Anthony
>
> On Wednesday, May 28, 2014 11:00:13 AM UTC-4, Tom Russell wrote:
>>
>> I have read through the docs but have not come across what I am trying to 
>> do, if its possible.
>>
>> I have a table with 40 columns of data, I want to use a decorator or 
>> similar to only allow some of them viewable while others in a different 
>> membership group can see all of the columns.
>>
>> Is this something that can be done?
>>
>> Thanks,
>>
>> Tom
>>
>

-- 
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] DAL/Decorator for specific data

2014-05-28 Thread Tom Russell
I have read through the docs but have not come across what I am trying to 
do, if its possible.

I have a table with 40 columns of data, I want to use a decorator or 
similar to only allow some of them viewable while others in a different 
membership group can see all of the columns.

Is this something that can be done?

Thanks,

Tom

-- 
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: Redirect to grid page

2014-05-27 Thread Tom Russell
Works great Jim, Thank you very much.

On Tuesday, May 27, 2014 12:52:33 PM UTC-4, Jim S wrote:
>
> I would try something like this:
>
> rows_per_page = 20 # this should be set to whatever the 'paginate' 
> parm is set to on your call to SQLFORM.grid - default is 20
> page_number = int(query).count() / rows_per_page ) + 1#  'query' 
> should be the same query that you pass to SQLFORM.grid
>
> redirect(URL('voltrin_data',vars={'page':page_number),user_signature=True)
>
> NOT TESTED!!
>
> Let me know if this doesn't work and I'll code up a test of my own to see 
> what happens.
>
> Anyone have a more efficient way of doing this?
>
> -Jim
>
>
>
> On Tuesday, May 27, 2014 11:32:28 AM UTC-5, Tom Russell wrote:
>>
>> Jim,
>>
>> Yes I have a grid page in place which is where I go now. The grid though 
>> has a lot of records and I just want to go to that last record in that 
>> grid. Since its pagination thats what I am looking for, is how to go to the 
>> last page in the grid.
>>
>> On Tuesday, May 27, 2014 12:17:02 PM UTC-4, Jim S wrote:
>>>
>>> When you say that you want to go to the 'grid' page, do you mean a page 
>>> with a SQLFORM.grid on it and you want to go into 'edit' mode on a specific 
>>> record on the grid?
>>>
>>> -Jim
>>>
>>>
>>> On Tuesday, May 27, 2014 10:42:31 AM UTC-5, Tom Russell wrote:
>>>>
>>>> I have a simple form where I have a submit button that runs some code. 
>>>> After the code runs and the data is inserted into my table I do a simple 
>>>> redirect like so:
>>>>
>>>> redirect(URL('voltrin_data'))
>>>>
>>>> That just goes to a page I have set up with a grid. I notice if I am 
>>>> editing a record and press submit the next page that gets redirected to is 
>>>> the last record in the grid.
>>>>
>>>> What I want to do is redirect to my grid but go to the page with the 
>>>> l;ast entry and not the first page.
>>>>
>>>> How would I do that? I looked in the book but could not see how I would 
>>>> do this.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>

-- 
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: Redirect to grid page

2014-05-27 Thread Tom Russell
Jim,

Yes I have a grid page in place which is where I go now. The grid though 
has a lot of records and I just want to go to that last record in that 
grid. Since its pagination thats what I am looking for, is how to go to the 
last page in the grid.

On Tuesday, May 27, 2014 12:17:02 PM UTC-4, Jim S wrote:
>
> When you say that you want to go to the 'grid' page, do you mean a page 
> with a SQLFORM.grid on it and you want to go into 'edit' mode on a specific 
> record on the grid?
>
> -Jim
>
>
> On Tuesday, May 27, 2014 10:42:31 AM UTC-5, Tom Russell wrote:
>>
>> I have a simple form where I have a submit button that runs some code. 
>> After the code runs and the data is inserted into my table I do a simple 
>> redirect like so:
>>
>> redirect(URL('voltrin_data'))
>>
>> That just goes to a page I have set up with a grid. I notice if I am 
>> editing a record and press submit the next page that gets redirected to is 
>> the last record in the grid.
>>
>> What I want to do is redirect to my grid but go to the page with the 
>> l;ast entry and not the first page.
>>
>> How would I do that? I looked in the book but could not see how I would 
>> do this.
>>
>> Thanks,
>>
>> Tom
>>
>

-- 
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] Redirect to grid page

2014-05-27 Thread Tom Russell
I have a simple form where I have a submit button that runs some code. 
After the code runs and the data is inserted into my table I do a simple 
redirect like so:

redirect(URL('voltrin_data'))

That just goes to a page I have set up with a grid. I notice if I am 
editing a record and press submit the next page that gets redirected to is 
the last record in the grid.

What I want to do is redirect to my grid but go to the page with the l;ast 
entry and not the first page.

How would I do that? I looked in the book but could not see how I would do 
this.

Thanks,

Tom

-- 
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] Accessing records

2014-05-20 Thread Tom Russell
Woks perfect, thank you.

On Tuesday, May 20, 2014 11:17:12 AM UTC-4, Anthony wrote:
>
> It is a Rows objects, so yes, you can iterate over it.
>
> Anthony
>
> On Tuesday, May 20, 2014 11:06:34 AM UTC-4, Tom Russell wrote:
>>
>> Thanks.
>>
>> What would last_five_records be, a list or something I could iterate over?
>>
>> Tom
>>
>> On Tuesday, May 20, 2014 10:16:54 AM UTC-4, Johann Spies wrote:
>>>
>>>
>>>
>>>
>>> On 20 May 2014 16:11, Tom Russell  wrote:
>>>
>>>> I have a table which I insert data from the internet, just 4 records. 
>>>> Before inserting though I need to get the last 5 rows of data from these 4 
>>>> fields and do a calculation with them. Then when I insert the data I add 
>>>> one more field making it a total of 5 fields I am inserting into the db. 
>>>> These 5 fields exist already so nothing odd there.
>>>>
>>>> My main issue is just getting the last 5 records from the db. Is there 
>>>> a better way to get that data with the DAL? It kind of appears to me that 
>>>> I 
>>>> could possibly use limitby to get these as well?
>>>>
>>>>
>>>
>>> last_five_records = db(db.sometable.id > 
>>> 0).select(db.sometable.the_fields_you_want_to_work_with, orderby=~
>>> db.sometable.id, limitby = (0,4))
>>>
>>> Regards
>>> Johann
>>>
>>> -- 
>>> Because experiencing your loyal love is better than life itself, 
>>> my lips will praise you.  (Psalm 63:3)
>>>  
>>

-- 
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] Accessing records

2014-05-20 Thread Tom Russell
Thanks.

What would last_five_records be, a list or something I could iterate over?

Tom

On Tuesday, May 20, 2014 10:16:54 AM UTC-4, Johann Spies wrote:
>
>
>
>
> On 20 May 2014 16:11, Tom Russell >wrote:
>
>> I have a table which I insert data from the internet, just 4 records. 
>> Before inserting though I need to get the last 5 rows of data from these 4 
>> fields and do a calculation with them. Then when I insert the data I add 
>> one more field making it a total of 5 fields I am inserting into the db. 
>> These 5 fields exist already so nothing odd there.
>>
>> My main issue is just getting the last 5 records from the db. Is there a 
>> better way to get that data with the DAL? It kind of appears to me that I 
>> could possibly use limitby to get these as well?
>>
>>
>
> last_five_records = db(db.sometable.id > 
> 0).select(db.sometable.the_fields_you_want_to_work_with, orderby=~
> db.sometable.id, limitby = (0,4))
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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] Accessing records

2014-05-20 Thread Tom Russell
Anthony,

Thanks for the tips.

I have a table which I insert data from the internet, just 4 records. 
Before inserting though I need to get the last 5 rows of data from these 4 
fields and do a calculation with them. Then when I insert the data I add 
one more field making it a total of 5 fields I am inserting into the db. 
These 5 fields exist already so nothing odd there.

My main issue is just getting the last 5 records from the db. Is there a 
better way to get that data with the DAL? It kind of appears to me that I 
could possibly use limitby to get these as well?

Thanks,

Tom

On Tuesday, May 20, 2014 9:48:23 AM UTC-4, Anthony wrote:
>
> Note, there is no guarantee that the records in the db at any given time 
> have sequential values in the ID field (e.g., when you delete a record, the 
> value of its ID is then absent from the sequence of IDs).
>
> Can you explain in more detail what you are actually trying to do?
>
> Anthony
>
> On Tuesday, May 20, 2014 9:32:27 AM UTC-4, Tom Russell wrote:
>>
>> Thanks for the comments. I read Chapter 6 which is where I got the bit of 
>> code to access the records. Specifically the fetching a row section.
>>
>> I can ensure that there is records with those id's. Its a script that 
>> grabs data off from the internet and inserts that data into that table. 
>> Then I grab the last 5 records including the one it is grabbing to do a 
>> calculation on it.
>>
>> It is not too clear in the book how I should be getting a record by the 
>> id is what I think my problem is.
>>
>> Thanks,
>>
>> Tom
>>
>> On Tuesday, May 20, 2014 4:53:13 AM UTC-4, Johann Spies wrote:
>>>
>>> On 19 May 2014 22:06, Tom Russell  wrote:
>>>
>>> I have some records in my db that I need to access to get them and 
>>>> perform some calculations on.
>>>>
>>>> My code to access the records is:
>>>>
>>>>  rows = db(db.voltrin.id > 0).count()
>>>>
>>>
>>>  Let us assume rows = 100 at this point.
>>>
>>>> 
>>>>  currentrow = rows - 4
>>>>
>>>
>>> currentrow = 96
>>>  
>>>
>>>>
>>>> for x in range(currentrow, rows):
>>>>
>>>range(96, 100) 
>>>
>>>> record = db.voltrin(db.voltrin.id==x)
>>>>
>>> record = db.voltrin(db.voltrin.id = 
>>> 96).select(whateverfieldsyouwantoworkwith)
>>>
>>>  
>>>
>>>> Is this the right way to access the record at a given id?
>>>>
>>>> No.
>>>
>>> I would suggest you read Chapter 6 in the web2py book (
>>> http://web2py.com/book).
>>>
>>> Just a comment about your code: there is no way you can ensure in the 
>>> above example that there will be an id==96 in that database. 
>>>
>>> Regards
>>> Johann
>>>  -- 
>>> Because experiencing your loyal love is better than life itself, 
>>> my lips will praise you.  (Psalm 63:3)
>>>  
>>

-- 
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] Accessing records

2014-05-20 Thread Tom Russell
Thanks for the comments. I read Chapter 6 which is where I got the bit of 
code to access the records.

I can ensure that there is records with those id's. Its a script that grabs 
data off from the internet and inserts that data into that table. Then I 
grab the last 5 records including the one it is grabbing to do a 
calculation on it.

It is not too clear in the book how I should be getting a record by the id 
is what I think my problem is.

Thanks,

Tom

On Tuesday, May 20, 2014 4:53:13 AM UTC-4, Johann Spies wrote:
>
> On 19 May 2014 22:06, Tom Russell >wrote:
>
> I have some records in my db that I need to access to get them and perform 
>> some calculations on.
>>
>> My code to access the records is:
>>
>>  rows = db(db.voltrin.id > 0).count()
>>
>
>  Let us assume rows = 100 at this point.
>
>> 
>>  currentrow = rows - 4
>>
>
> currentrow = 96
>  
>
>>
>> for x in range(currentrow, rows):
>>
>range(96, 100) 
>
>> record = db.voltrin(db.voltrin.id==x)
>>
> record = db.voltrin(db.voltrin.id = 
> 96).select(whateverfieldsyouwantoworkwith)
>
>  
>
>> Is this the right way to access the record at a given id?
>>
>> No.
>
> I would suggest you read Chapter 6 in the web2py book (
> http://web2py.com/book).
>
> Just a comment about your code: there is no way you can ensure in the 
> above example that there will be an id==96 in that database. 
>
> Regards
> Johann
>  -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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] Accessing records

2014-05-19 Thread Tom Russell
Hi,

I have some records in my db that I need to access to get them and perform 
some calculations on.

My code to access the records is:

 rows = db(db.voltrin.id > 0).count()

 currentrow = rows - 4

for x in range(currentrow, rows):
record = db.voltrin(db.voltrin.id==x)
adv_list.append(float(record.adv_issues))
dec_list.append(float(record.dec_issues))
adv_vlist.append(float(record.adv_vol))
dec_vlist.append(float(record.dec_vol))

Is this the right way to access the record at a given id?

The data I seem to get with any of my lists does not match any of the data 
in the tables which is why I am unsure of the proper way to access the data 
for a record.

Thanks,

Tom

-- 
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] Form Action

2014-05-16 Thread Tom Russell
I have a form that is not connected to a db table. Its a simple form:

def getdata_form():
   form=FORM('Start Date:', INPUT(_id='startdate', _name='date', 
_class='date'), 'End Date:', INPUT(_id='enddate', _name='date', 
_class='date'),INPUT(_type='submit'), _action=URL('grabvoltrindata'))
   return dict(form=form)

Then I have a function that runs some code called def grabvoltrindata()

I need to pass in the startdate and enddate, how would I do that?

Thanks,

Tom

-- 
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] AppAdmin Link

2014-05-13 Thread Tom Russell
I have in my default.py this code for a button to call appadmin:

{{=A(T("App Admin"), _href=URL('appadmin', scheme='https'), _class='btn',
 _style='margin-top: 1em;')}}

But when I click on the button it defaults to /default/appadmin instead of 
just appadmin. How do I set this properly?

Also, is there a decorator to hide this button if a user is not in a 
certain group?

Thanks,

Tom

-- 
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] SQLite Data

2014-05-13 Thread Tom Russell
I used csvstudio to process data to the existing sqlite db in web2py. It 
all went very well and now the data is there. The dates however for a date 
column only show up with the word None. Is there something else I am 
missing for the date not to be showing correctly or at all?

Thanks,

Tom

-- 
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] Where to find name of uploaded file during the onvalidation step?

2013-11-06 Thread Russell McMurray
At onvalidation the file is "inside" the form as cStringIO.StringO
instance.  Specifically: form.vars.{{upload_fieldname}}.file.

You can get the contents like this:

contents = form.vars.{{upload_fieldname}}.file.getvalue()

It is then up to you to throw an error (or not as the case may be) with
form.errors.{{upload_fieldname}}.

There's a nice example here:
https://groups.google.com/d/msg/web2py/bu6Q-8slNII/pE3tKOAxjlYJ




On Thu, Nov 7, 2013 at 5:53 AM, weheh  wrote:

> I'm doing a file upload using SQLFORM and a field of type upload. I want
> to intercept the file during onvalidation and do some file manipulation
> before saving. While in the onvalidation routine I can see the original
> filename and form.vars.filename.file, which I can read.
>
> I'm wondering whether web2py has already created a file on the server by
> this point (in the onvalidation validation routine and before the
> form.process(onvalidation=myvalidation).accepted step)? If so, I'd like to
> get that file name at that time (during the validation step). Anybody know
> where I can find 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 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.
>

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


Re: [web2py] updating multiple tables - how to have all updates in the same transaction?

2013-06-28 Thread Tom Russell
I could be wrong and am still new here but maybe SQLFORM.Factory? Thats
what I use on a form that has 2 tables.


On Fri, Jun 28, 2013 at 1:41 PM, Cliff Kachinske  wrote:

> I have two tables something like this:
>
> db.define_table('item',
>   Field('name'),
>   Field('on_hand', integer),
> )
>
> db.define_table('item_batch',
>   Field('item', 'reference db.item' ...),
>   Field('batch_yield', integer),
> )
>
> Every time I insert a item_batch record, I increment the on_hand field of
> the item table by the quantity in tatch_yield.  Easy to do using SQLFORM.
>
> But if I have to update the batch_yield I want to update the item.on_hand
> field as well.  I also use an onvalidation function to make sanity checks
> on the updated batch_yield entry, such as verifying that the new value does
> not make item.on_hand a negative number.
>
> Using SQLFORM, when is the best time to update the item.on_hand field?
>
> I want to make sure all of the updates are in the same transaction, so
> that if one fails, they all get rolled back.  How can I do this?
>
> Thanks,
> Cliff Kachinske
>
> --
>
> ---
> 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.
>
>
>

-- 

--- 
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: confused about db.py settings

2013-06-28 Thread Tom Russell
Nice, I will check that out.


On Fri, Jun 28, 2013 at 1:37 PM, Anthony  wrote:

> Yea thanks I tried that as well with no luck.
>
>
> Then you're doing something else wrong. It might help if you show all of
> the code. If you have a model file that does:
>
> db = DAL(...)
> ...
> auth = Auth(db)
> auth.define_tables()
>
> The db.auth_user will be available in any subsequent model as well as any
> controller and view. If that's not the case, you have an error somewhere
> else.
>
>
>> For new users there should be a guide to setting all of this up correctly.
>
>
> It's not clear what information is needed here. If you have done the
> above, it should work.
>
> Also, note if you need an easy way to manage Auth, in trunk there is some
> new functionality for this:
> https://groups.google.com/d/msg/web2py/HdvSyZCJad4/5y1xQw3D2RgJ. Unlike
> the slice you are using, it doesn't put the user record and a grid of
> memberships in a modal together, but for each user record, it does provide
> a link that lets you directly manage that user's memberships (using
> smartgrid).
>
> 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.
>
>
>

-- 

--- 
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: confused about db.py settings

2013-06-28 Thread Tom Russell
Well whatever the case was it did give me some errors, cant remember which
now but I tried a few things to no avail.

I know its always this way starting out, been around the block a few times
already :)


On Fri, Jun 28, 2013 at 1:34 PM, LightDot  wrote:

> On Friday, June 28, 2013 6:59:19 PM UTC+2, Tom Russell wrote:
>>
>> Yea thanks I tried that as well with no luck.
>>
>
> That's impossible. But never mind, hang in there, after you finish your
> first project, you'll be remembering this beginnings with a smile.
>
>
>> I ended up just creating a new db_wizard.py in my model and this set up
>> works great now. Its mentioned in the book but thats it, just mentioned.
>> For new users there should be a guide to setting all of this up correctly.
>> Maybe there is? I could write something up when I am done sorting it all
>> out.
>>
>> Thanks
>>
>
> Sure, no problem.
>
> Regards,
> Ales
>
>
>>
>> On Fri, Jun 28, 2013 at 12:51 PM, LightDot  wrote:
>>
>>> Well, you have:
>>>
>>>
>>> db = DAL('sqlite://storage.sqlite',**pool_size=1,check_reserved=['**
>>> all'])
>>>
>>> defined, then you initiate auth with:
>>>
>>> auth.define_tables(username=**True, signature=True)
>>>
>>> which sets up auth tables etc. in the above database. But then you
>>> override the previously set db with:
>>>
>>>
>>> db = DAL('sqlite://webform.sqlite')
>>>
>>> in which you define your own tables. So basically you have set up auth
>>> in one database, then you stop using it and use another database, which has
>>> no auth set up. That can't work.
>>>
>>> Simply define db just once, not twice. Use the definition web2py has
>>> suggested for you and change the database name if you want to.
>>>
>>> Regards,
>>> Ales
>>>
>>>
>>>
>>> On Friday, June 28, 2013 5:05:50 PM UTC+2, Tom Russell wrote:
>>>>
>>>> I am confused about how I have my db.py set up for tables etc.
>>>>
>>>> At the top I have what is generated for me:
>>>>
>>>> if not request.env.web2py_runtime_**gae**:
>>>> ## if NOT running on Google App Engine use SQLite or other DB
>>>> db = DAL('sqlite://storage.sqlite',
>>>> pool_size=1,check_reserved=['**a**ll'])
>>>> else:
>>>> ## connect to Google BigTable (optional
>>>> 'google:datastore://namespace')
>>>> db = DAL('google:datastore')
>>>> ## store sessions and tickets there
>>>> session.connect(request, response, db=db)
>>>> ## or store session in Memcache, Redis, etc.
>>>> ## from gluon.contrib.memdb import MEMDB
>>>> ## from google.appengine.api.memcache import Client
>>>> ## session.connect(request, response, db = MEMDB(Client()))
>>>>
>>>> from gluon.tools import Auth, Crud, Service, PluginManager,
>>>> prettydate, Mail
>>>> auth = Auth(db)
>>>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>>> db._common_fields.append(auth.signature) ## adds signature fields
>>>> to all tables
>>>> ## create all tables needed by auth if not custom tables
>>>> auth.define_tables(username=**Tr**ue, signature=True)
>>>>
>>>> And then from examples I have for my db down a ways is:
>>>>
>>>> db = DAL('sqlite://webform.sqlite')
>>>>
>>>> then I define my tables...
>>>>
>>>>
>>>> Problem with this is though I am trying to use http://www.web2pyslices.
>>>> **co**m/slice/show/1542/manage-**users**-and-memebership-in-the-**same-
>>>> **form<http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-form>because
>>>>  I need that feature but when trying to use it I get an error cause
>>>> auth_user doesnt exist. Well it doesnt because I set db =
>>>> DAL('sqlite://webform.sqlite') but in default.py I do have:
>>>>
>>>> def user():
>>>> """
>>>> exposes:
>>>> http:///[app]/default/**user**/login
>>>> http:///[app]/default/**user**/logout
>>>> http:///[app]/default/**user**/register
>>>> http:///[app]/default/**user**/profile
>&

[web2py] Passing an arg

2013-06-28 Thread Tom Russell
I have a smartgrid with a link in it like this:

links = [lambda row: A(T('Create Appointment'),_href=URL("default",
"appointment_create",args=[row.id]))]

And I pass that to this function:

@auth.requires_login()
def appointment_create():
record = db.patient(request.args(0))
db.appointment.patient.default = record
db.appointment.patient.writable = False
form = SQLFORM(db.appointment, next='appointment_select')

return dict(form=form)

And that gives me the whole record but I am looking for just the name of
the patient in this case. IN my db I set format='%(first_name)s
%(last_name)s') expecting to get that returned on the record but not so.

What should I be doing to obtain this correctly?

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.




Re: [web2py] Re: confused about db.py settings

2013-06-28 Thread Tom Russell
Yea thanks I tried that as well with no luck. I ended up just creating a
new db_wizard.py in my model and this set up works great now. Its mentioned
in the book but thats it, just mentioned. For new users there should be a
guide to setting all of this up correctly. Maybe there is? I could write
something up when I am done sorting it all out.

Thanks


On Fri, Jun 28, 2013 at 12:51 PM, LightDot  wrote:

> Well, you have:
>
>
> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>
> defined, then you initiate auth with:
>
> auth.define_tables(username=True, signature=True)
>
> which sets up auth tables etc. in the above database. But then you
> override the previously set db with:
>
>
> db = DAL('sqlite://webform.sqlite')
>
> in which you define your own tables. So basically you have set up auth in
> one database, then you stop using it and use another database, which has no
> auth set up. That can't work.
>
> Simply define db just once, not twice. Use the definition web2py has
> suggested for you and change the database name if you want to.
>
> Regards,
> Ales
>
>
>
> On Friday, June 28, 2013 5:05:50 PM UTC+2, Tom Russell wrote:
>>
>> I am confused about how I have my db.py set up for tables etc.
>>
>> At the top I have what is generated for me:
>>
>> if not request.env.web2py_runtime_**gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite',**pool_size=1,check_reserved=['**
>> all'])
>> else:
>> ## connect to Google BigTable (optional 'google:datastore://namespace'
>> **)
>> db = DAL('google:datastore')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>> ## or store session in Memcache, Redis, etc.
>> ## from gluon.contrib.memdb import MEMDB
>> ## from google.appengine.api.memcache import Client
>> ## session.connect(request, response, db = MEMDB(Client()))
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager,
>> prettydate, Mail
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>> db._common_fields.append(auth.**signature) ## adds signature fields to
>> all tables
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=**True, signature=True)
>>
>> And then from examples I have for my db down a ways is:
>>
>> db = DAL('sqlite://webform.sqlite')
>>
>> then I define my tables...
>>
>>
>> Problem with this is though I am trying to use http://www.web2pyslices.**
>> com/slice/show/1542/manage-**users-and-memebership-in-the-**same-form<http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-form>because
>>  I need that feature but when trying to use it I get an error cause
>> auth_user doesnt exist. Well it doesnt because I set db =
>> DAL('sqlite://webform.sqlite') but in default.py I do have:
>>
>> def user():
>> """
>> exposes:
>> http:///[app]/default/**user/login
>> http:///[app]/default/**user/logout
>> http:///[app]/default/**user/register
>> http:///[app]/default/**user/profile
>> http:///[app]/default/**user/retrieve_password
>> http:///[app]/default/**user/change_password
>> http:///[app]/default/**user/manage_users (requires membership
>> in
>> use @auth.requires_login()
>> @auth.requires_membership('**group name')
>> @auth.requires_permission('**read','table name',record_id)
>> to decorate functions that need access control
>> """
>> return dict(form=auth())
>>
>> So bottom line, how do I get around or use auth_user in my app. If I
>> comment out my
>> db = DAL('sqlite://webform.sqlite') but in default.py, nothing works.
>>
>> Any help?
>>
>> 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.
>
>
>

-- 

--- 
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] confused about db.py settings

2013-06-28 Thread Tom Russell
I am confused about how I have my db.py set up for tables etc.

At the top I have what is generated for me:

if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore')
## store sessions and tickets there
session.connect(request, response, db=db)
## or store session in Memcache, Redis, etc.
## from gluon.contrib.memdb import MEMDB
## from google.appengine.api.memcache import Client
## session.connect(request, response, db = MEMDB(Client()))

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate,
Mail
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
db._common_fields.append(auth.signature) ## adds signature fields to all
tables
## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=True)

And then from examples I have for my db down a ways is:

db = DAL('sqlite://webform.sqlite')

then I define my tables...


Problem with this is though I am trying to use
http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-formbecause
I need that feature but when trying to use it I get an error cause
auth_user doesnt exist. Well it doesnt because I set db =
DAL('sqlite://webform.sqlite') but in default.py I do have:

def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
http:///[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())

So bottom line, how do I get around or use auth_user in my app. If I
comment out my
db = DAL('sqlite://webform.sqlite') but in default.py, nothing works.

Any help?

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.




Re: [web2py] sqlform.factory widget in field problem

2013-06-28 Thread Tom Russell
Actually probably just comment out the line:

fs3=form[0][-1] # submit row (last)

and that I think will put the submit outside the fieldset.


On Fri, Jun 28, 2013 at 2:50 AM, António Ramos  wrote:

> I dont understand how that gets the submit  button out of the last fieldset
>
>
> 2013/6/28 Tom Russell 
>
>> Here's the rest of my code doing what I posted before...
>>
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> #form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>>
>> On Thu, Jun 27, 2013 at 5:31 PM, António Ramos wrote:
>>
>>> Using this suggestion , my submit button is inside the last fieldset.
>>> How do i take it outside?
>>>
>>>
>>> 2013/6/26 Tom Russell 
>>>
>>>> To group inside a field I do something like this with 3 different
>>>> tables:
>>>>
>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>>>> fs0=form[0][:26] #patient rows
>>>> fs1=form[0][26:37]   #emergency contacts
>>>> fs2=form[0][37:41] #dependents
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>> FIELDSET(TAG.legend("Emergency Contact
>>>> Info"),TABLE(fs1),_id="register1"),
>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>> TABLE(fs3))
>>>>
>>>>
>>>> HTH
>>>>
>>>>
>>>> On Wed, Jun 26, 2013 at 11:58 AM, António Ramos 
>>>> wrote:
>>>>
>>>>> Just drafting something but here is the problem
>>>>>
>>>>> My context:
>>>>> I have 3 tables
>>>>>
>>>>> table form
>>>>> table steps
>>>>> table fields
>>>>>
>>>>> A form can have many steps
>>>>> a step can have many fields
>>>>>
>>>>> This way i can have one form with 3 steps, each with some fields and
>>>>> another form with 10 steps , each with some more fields.
>>>>>
>>>>> i read these tables to create a form using factory.
>>>>>
>>>>> i have 2 problems
>>>>>
>>>>>
>>>>> *1 i need to mark the input fields with a "step" tag *
>>>>>
>>>>> here is my code:
>>>>>
>>>>> def my_string_widget(field, value,step):
>>>>>
>>>>> return INPUT(_name=field.name,
>>>>>   _id="%s_%s" % (field._tablename, field.name),
>>>>>   _class=field.type,
>>>>>   _value='',
>>>>>   *_step=step,*
>>>>>   requires=field.requires)
>>>>>
>>>>> def index():
>>>>> cont=0
>>>>> fields=[]
>>>>> formid=db.form(request.args(0) or 1)
>>>>> steps=formid.steps.select()
>>>>> for step in steps:
>>>>> print "step id-",step.id
>>>>> for field in step.fields.select():
>>>>> print "field...",field.step
>>>>> fields.append(Field(field.nome,widget=lambda
>>>>> field,value:my_string_widget(field,value,*step.id*)))
>>>>>
>>>>> form=SQLFORM.factory(*fields)
>>>>> print form
>>>>> if form.process().accepted:
>>>>> response.flash='a gravar registo'
>>>>> return dict(nome=formid.nome,form=form)
>>>>>
>>>>>
>>>>> The problem is:
>>>>> It marks all fields with the same "step" value, the last value in *
>>>>> step.id, why?*
>>>>> *
>>>>> *
>>>>> *2 - sql

Re: [web2py] sqlform.factory widget in field problem

2013-06-27 Thread Tom Russell
Here's the rest of my code doing what I posted before...

if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
#form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))


On Thu, Jun 27, 2013 at 5:31 PM, António Ramos  wrote:

> Using this suggestion , my submit button is inside the last fieldset.
> How do i take it outside?
>
>
> 2013/6/26 Tom Russell 
>
>> To group inside a field I do something like this with 3 different tables:
>>
>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>> fs0=form[0][:26] #patient rows
>> fs1=form[0][26:37]   #emergency contacts
>> fs2=form[0][37:41] #dependents
>> fs3=form[0][-1] # submit row (last)
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>>
>>
>> HTH
>>
>>
>> On Wed, Jun 26, 2013 at 11:58 AM, António Ramos wrote:
>>
>>> Just drafting something but here is the problem
>>>
>>> My context:
>>> I have 3 tables
>>>
>>> table form
>>> table steps
>>> table fields
>>>
>>> A form can have many steps
>>> a step can have many fields
>>>
>>> This way i can have one form with 3 steps, each with some fields and
>>> another form with 10 steps , each with some more fields.
>>>
>>> i read these tables to create a form using factory.
>>>
>>> i have 2 problems
>>>
>>>
>>> *1 i need to mark the input fields with a "step" tag *
>>>
>>> here is my code:
>>>
>>> def my_string_widget(field, value,step):
>>>
>>> return INPUT(_name=field.name,
>>>   _id="%s_%s" % (field._tablename, field.name),
>>>   _class=field.type,
>>>   _value='',
>>>   *_step=step,*
>>>   requires=field.requires)
>>>
>>> def index():
>>> cont=0
>>> fields=[]
>>> formid=db.form(request.args(0) or 1)
>>> steps=formid.steps.select()
>>> for step in steps:
>>> print "step id-",step.id
>>> for field in step.fields.select():
>>> print "field...",field.step
>>> fields.append(Field(field.nome,widget=lambda
>>> field,value:my_string_widget(field,value,*step.id*)))
>>>
>>> form=SQLFORM.factory(*fields)
>>> print form
>>> if form.process().accepted:
>>> response.flash='a gravar registo'
>>> return dict(nome=formid.nome,form=form)
>>>
>>>
>>> The problem is:
>>> It marks all fields with the same "step" value, the last value in *
>>> step.id, why?*
>>> *
>>> *
>>> *2 - sqlformfactory *
>>> how do i group sqlformfactory fields inside a div?
>>> i want to create a section for each step in the form to style with css
>>>
>>> Best regards
>>> António
>>>
>>> --
>>>
>>> ---
>>> 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.
>>>
>>>
>>>
>>
>>  --
>>
>> ---
>> 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.
>>
>>
>>
>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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: JQuery Issue

2013-06-27 Thread Tom Russell
I use chrome but I will have to try that. Thanks.


On Thu, Jun 27, 2013 at 3:31 PM, Jim S  wrote:

> Do you use firefox and firebug?
>
> You can use the javascript console there to display to you any errors that
> might be occurring in your javascript.  You may have an issue earlier on in
> your page (with javascript) that is preventing the execution of your stuff
> later on.
>
> -Jim
>
> On Thursday, June 27, 2013 10:26:56 AM UTC-5, Tom Russell wrote:
>
>> So If I do something like:
>>
>> jAlert('This is a custom alert box', 'Alert Dialog');
>>
>> and nothing shows up, could it be that the jquery lib is not being made
>> available?
>>
>>
>> On Thu, Jun 27, 2013 at 11:00 AM, Tom Russell wrote:
>>
>>> k thanks I will try that
>>>
>>>
>>>
>>> On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:
>>>
>>>> I'd try putting some alert() messages in to try to trace the flow and
>>>> check the values of variables.
>>>>
>>>>
>>>>
>>>> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell wrote:
>>>>
>>>>> Thats weird, now it will not hide the the field but has no effect
>>>>> either when you check the checkbox.
>>>>>
>>>>>
>>>>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>>>>
>>>>>> Try this, you need brackets for your if statements in javascript.
>>>>>>
>>>>>> jQuery(document).ready(functio**n(){
>>>>>>  jQuery('#no_table_mothers_**name__row').hide();
>>>>>>  jQuery('#is_newborn').change(**function(){
>>>>>>if(jQuery('#is_newborn').attr**('checked')) {
>>>>>>  jQuery('#no_table_mothers_**name__row').show();
>>>>>>} else {
>>>>>>  jQuery('#no_table_mothers_**name__row').hide();
>>>>>>});
>>>>>>  });
>>>>>> });
>>>>>>
>>>>>>
>>>>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>>>>
>>>>>>> I cannot seem to get some jquery code to work right and not sure
>>>>>>> why. Basically when I click a checkbox I want another field to appear 
>>>>>>> below
>>>>>>> that one.
>>>>>>>
>>>>>>> This is my form code:
>>>>>>>
>>>>>>> @auth.requires_login()
>>>>>>> def register_patient():
>>>>>>> mark_not_empty(db.patient)
>>>>>>> mark_not_empty(db.**emergencycontacts)
>>>>>>> mark_not_empty(db.dependents)
>>>>>>> db.patient.medical_record_**number.default = 'KND' +
>>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>> db.patient.medical_record_**number.writable = False
>>>>>>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>>>>>>> db.dependents)
>>>>>>>
>>>>>>> fs0=form[0][:27] #patient rows
>>>>>>> fs1=form[0][27:38]   #emergency contacts
>>>>>>> fs2=form[0][38:42] #dependents
>>>>>>> fs3=form[0][-1] # submit row (last)
>>>>>>>
>>>>>>> form[0]=TABLE(
>>>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**
>>>>>>> register0"),
>>>>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>>>>> register1"),
>>>>>>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**
>>>>>>> register2"),
>>>>>>> TABLE(fs3))
>>>>>>> if form.process().accepted:
>>>>>>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>>>>>>> vars))
>>>>>>> form.vars.patient=id
>>>>>>> id = db.emergencycontacts.insert(
>>>>>>> db.emergencycontacts._filter_**fields(form.vars))
>>>>>>> id = db.dependents.insert(**db.**dependents._filter_fields(*
>>>>>>> *form.vars))
>>>

[web2py] Use model in another app

2013-06-27 Thread Tom Russell
I have 2 apps and one I want to use the model/db from it in the other in a
SQLFORM.grid. I have read through and googled and cannot find a way to do
this.

Is this possible and how?

Thanks,

Tom

-- 

--- 
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: JQuery Issue

2013-06-27 Thread Tom Russell
So If I do something like:

jAlert('This is a custom alert box', 'Alert Dialog');

and nothing shows up, could it be that the jquery lib is not being made
available?


On Thu, Jun 27, 2013 at 11:00 AM, Tom Russell  wrote:

> k thanks I will try that
>
>
>
> On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:
>
>> I'd try putting some alert() messages in to try to trace the flow and
>> check the values of variables.
>>
>>
>>
>> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell  wrote:
>>
>>> Thats weird, now it will not hide the the field but has no effect either
>>> when you check the checkbox.
>>>
>>>
>>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>>
>>>> Try this, you need brackets for your if statements in javascript.
>>>>
>>>> jQuery(document).ready(function(){
>>>>  jQuery('#no_table_mothers_name__row').hide();
>>>>  jQuery('#is_newborn').change(function(){
>>>>if(jQuery('#is_newborn').attr('checked')) {
>>>>  jQuery('#no_table_mothers_name__row').show();
>>>>} else {
>>>>  jQuery('#no_table_mothers_name__row').hide();
>>>>});
>>>>  });
>>>> });
>>>>
>>>>
>>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>>
>>>>> I cannot seem to get some jquery code to work right and not sure why.
>>>>> Basically when I click a checkbox I want another field to appear below 
>>>>> that
>>>>> one.
>>>>>
>>>>> This is my form code:
>>>>>
>>>>> @auth.requires_login()
>>>>> def register_patient():
>>>>> mark_not_empty(db.patient)
>>>>> mark_not_empty(db.emergencycontacts)
>>>>> mark_not_empty(db.dependents)
>>>>> db.patient.medical_record_number.default = 'KND' +
>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>> db.patient.medical_record_number.writable = False
>>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts,
>>>>> db.dependents)
>>>>>
>>>>> fs0=form[0][:27] #patient rows
>>>>> fs1=form[0][27:38]   #emergency contacts
>>>>> fs2=form[0][38:42] #dependents
>>>>> fs3=form[0][-1] # submit row (last)
>>>>>
>>>>> form[0]=TABLE(
>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>>> FIELDSET(TAG.legend("Emergency Contact
>>>>> Info"),TABLE(fs1),_id="register1"),
>>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>>> TABLE(fs3))
>>>>> if form.process().accepted:
>>>>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>>>>> form.vars.patient=id
>>>>> id =
>>>>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>>>>> id =
>>>>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>>>>> #form.vars.dependents=id
>>>>> # and get a list of all persons
>>>>> redirect(URL('manage_patients'))
>>>>>
>>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>>
>>>>> return dict(form=DIV(style,form))
>>>>>
>>>>> My html code:
>>>>>
>>>>> {{left_sidebar_enabled=True}}
>>>>> {{extend 'layout.html'}}
>>>>>
>>>>> {{block left_sidebar}}
>>>>>   Home
>>>>>   
>>>>>   Home(Physician)
>>>>>   Home(Front Desk)
>>>>>   Home(Nurse)
>>>>>   Home(Lab)
>>>>>   Home(Radiology)
>>>>>   Home(Pharmacist)
>>>>>   Home(Cashier)
>>>>>   
>>>>>   >>>> href="/patient/default/manage_patients">Patients
>>>>>   Task Lists
>>>>>   Appo

Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
k thanks I will try that



On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:

> I'd try putting some alert() messages in to try to trace the flow and
> check the values of variables.
>
>
>
> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell  wrote:
>
>> Thats weird, now it will not hide the the field but has no effect either
>> when you check the checkbox.
>>
>>
>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>
>>> Try this, you need brackets for your if statements in javascript.
>>>
>>> jQuery(document).ready(function(){
>>>  jQuery('#no_table_mothers_name__row').hide();
>>>  jQuery('#is_newborn').change(function(){
>>>if(jQuery('#is_newborn').attr('checked')) {
>>>  jQuery('#no_table_mothers_name__row').show();
>>>} else {
>>>  jQuery('#no_table_mothers_name__row').hide();
>>>});
>>>  });
>>> });
>>>
>>>
>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>
>>>> I cannot seem to get some jquery code to work right and not sure why.
>>>> Basically when I click a checkbox I want another field to appear below that
>>>> one.
>>>>
>>>> This is my form code:
>>>>
>>>> @auth.requires_login()
>>>> def register_patient():
>>>> mark_not_empty(db.patient)
>>>> mark_not_empty(db.emergencycontacts)
>>>> mark_not_empty(db.dependents)
>>>> db.patient.medical_record_number.default = 'KND' +
>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>> db.patient.medical_record_number.writable = False
>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts,
>>>> db.dependents)
>>>>
>>>> fs0=form[0][:27] #patient rows
>>>> fs1=form[0][27:38]   #emergency contacts
>>>> fs2=form[0][38:42] #dependents
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>> FIELDSET(TAG.legend("Emergency Contact
>>>> Info"),TABLE(fs1),_id="register1"),
>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>> TABLE(fs3))
>>>> if form.process().accepted:
>>>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>>>> form.vars.patient=id
>>>> id =
>>>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>>>> id =
>>>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>>>> #form.vars.dependents=id
>>>> # and get a list of all persons
>>>> redirect(URL('manage_patients'))
>>>>
>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>
>>>> return dict(form=DIV(style,form))
>>>>
>>>> My html code:
>>>>
>>>> {{left_sidebar_enabled=True}}
>>>> {{extend 'layout.html'}}
>>>>
>>>> {{block left_sidebar}}
>>>>   Home
>>>>   
>>>>   Home(Physician)
>>>>   Home(Front Desk)
>>>>   Home(Nurse)
>>>>   Home(Lab)
>>>>   Home(Radiology)
>>>>   Home(Pharmacist)
>>>>   Home(Cashier)
>>>>   
>>>>   >>> href="/patient/default/manage_patients">Patients
>>>>   Task Lists
>>>>   Appointment
>>>>   Order
>>>>   Consumables
>>>>   Prescriptions
>>>>   Immunization
>>>>   Laboratory Orders
>>>>   Radiology Orders
>>>>   Patient
>>>> Accounting
>>>>   Admin
>>>>
>>>> {{end}}
>>>>
>>>>
>>>> Register Patient
>>>>
>>>> {{=form}}
>>>>
>>>> 
>>>> jQuery(document).ready(function(){
>>>>jQuery('#no_tab

Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
Thats weird, now it will not hide the the field but has no effect either
when you check the checkbox.


On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:

> Try this, you need brackets for your if statements in javascript.
>
> jQuery(document).ready(function(){
>  jQuery('#no_table_mothers_name__row').hide();
>  jQuery('#is_newborn').change(function(){
>if(jQuery('#is_newborn').attr('checked')) {
>  jQuery('#no_table_mothers_name__row').show();
>} else {
>  jQuery('#no_table_mothers_name__row').hide();
>});
>  });
> });
>
>
> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>
>> I cannot seem to get some jquery code to work right and not sure why.
>> Basically when I click a checkbox I want another field to appear below that
>> one.
>>
>> This is my form code:
>>
>> @auth.requires_login()
>> def register_patient():
>> mark_not_empty(db.patient)
>> mark_not_empty(db.emergencycontacts)
>> mark_not_empty(db.dependents)
>> db.patient.medical_record_number.default = 'KND' +
>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>> db.patient.medical_record_number.writable = False
>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>>
>> fs0=form[0][:27] #patient rows
>> fs1=form[0][27:38]   #emergency contacts
>> fs2=form[0][38:42] #dependents
>> fs3=form[0][-1] # submit row (last)
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> #form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>> My html code:
>>
>> {{left_sidebar_enabled=True}}
>> {{extend 'layout.html'}}
>>
>> {{block left_sidebar}}
>>   Home
>>   
>>   Home(Physician)
>>   Home(Front Desk)
>>   Home(Nurse)
>>   Home(Lab)
>>   Home(Radiology)
>>   Home(Pharmacist)
>>   Home(Cashier)
>>   
>>   > href="/patient/default/manage_patients">Patients
>>   Task Lists
>>   Appointment
>>   Order
>>   Consumables
>>   Prescriptions
>>   Immunization
>>   Laboratory Orders
>>   Radiology Orders
>>   Patient Accounting
>>   Admin
>>
>> {{end}}
>>
>>
>> Register Patient
>>
>> {{=form}}
>>
>> 
>> jQuery(document).ready(function(){
>>jQuery('#no_table_mothers_name__row').hide();
>>jQuery('#is_newborn').change(function(){
>> if(jQuery('#is_newborn').attr('checked'))
>> jQuery('#no_table_mothers_name__row').show();
>> else jQuery('#no_table_mothers_name__row').hide();});
>> });
>> 
>>
>>
>> And this is the info from the page source showing the id's for what
>> fields I am working with:
>>
>> Is Newborn: 
>> > name="is_newborn" type="checkbox" value="on" />
>> > for="no_table_mothers_name" id="no_table_mothers_name__label">Mothers
>> Name: >
>> I think I have the right code for the jquery but nothing happens when I
>> try this.
>>
>> Any ideas?
>>
>  --
>
> ---
> 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.
>
>
>

-- 

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

2013-06-26 Thread Tom Russell
I cannot seem to get some jquery code to work right and not sure why.
Basically when I click a checkbox I want another field to appear below that
one.

This is my form code:

@auth.requires_login()
def register_patient():
mark_not_empty(db.patient)
mark_not_empty(db.emergencycontacts)
mark_not_empty(db.dependents)
db.patient.medical_record_number.default = 'KND' +
str(date.today().year) + '' + str(random.randrange(1, 999+1))
db.patient.medical_record_number.writable = False
form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)

fs0=form[0][:27] #patient rows
fs1=form[0][27:38]   #emergency contacts
fs2=form[0][38:42] #dependents
fs3=form[0][-1] # submit row (last)

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))
if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
#form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))

My html code:

{{left_sidebar_enabled=True}}
{{extend 'layout.html'}}

{{block left_sidebar}}
  Home
  
  Home(Physician)
  Home(Front Desk)
  Home(Nurse)
  Home(Lab)
  Home(Radiology)
  Home(Pharmacist)
  Home(Cashier)
  
  Patients
  Task Lists
  Appointment
  Order
  Consumables
  Prescriptions
  Immunization
  Laboratory Orders
  Radiology Orders
  Patient Accounting
  Admin

{{end}}


Register Patient

{{=form}}


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



And this is the info from the page source showing the id's for what fields
I am working with:

Is Newborn: 

Mothers Name:
https://groups.google.com/groups/opt_out.




Re: [web2py] Appointment Manager

2013-06-26 Thread Tom Russell
/public/basic</a>
>> ',
>> // className: 'gcal-event',
>> // currentTimezone: 'America/Montreal'},
>> {url:
>> '/your_app_name/your_controller/calendar_json_feed', 'color': 'rgb(84, 132,
>> 237)', cache: true},
>> // you can insert here all the other json feed you want
>> for the stuff you want to display, you can change color to make those
>> differents groups of events distinctive
>> ],
>> // feed by simplejson function
>> //[
>> //{
>> //title: "S-20120215-U219-2p",
>> //allDay: false,
>> //start: "2013-03-22 08:30:00", // Leading zero is
>> important for Firefox, comment 2 in answer :
>> <a  rel="nofollow" href="http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox">http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox</a>
>> //end: "2013-03-22 09:30:00",
>> //url: '/sgddms/lotns/read/lotns_sample/623'
>> //}
>> //],
>> header: {
>> left:   'today prevYear,nextYear prev,next',
>> center: 'title',
>> right:  'month,basicWeek,basicDay'
>> },
>> {{if T.accepted_language.split('-')[0] == 'fr':}}
>> timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
>> {{pass}}
>> monthNames: ["{{=T('January')}}",
>> "{{=T('February')}}",
>> "{{=T('March')}}",
>> "{{=T('April')}}",
>> "{{=T('May')}}",
>> "{{=T('June')}}",
>> "{{=T('July')}}",
>> "{{=T('August')}}",
>> "{{=T('September')}}",
>> "{{=T('October')}}",
>> "{{=T('November')}}",
>> "{{=T('December')}}"],
>> dayNames: ["{{=T('Sunday')}}",
>> "{{=T('Monday')}}",
>> "{{=T('Tuesday')}}",
>> "{{=T('Wednesday')}}",
>> "{{=T('Thursday')}}",
>> "{{=T('Friday')}}",
>> "{{=T('Saturday')}}"],
>> dayNamesShort: ["{{=T('Sun')}}",
>> "{{=T('Mon')}}",
>> "{{=T('Tue')}}",
>> "{{=T('Wed')}}",
>> "{{=T('Thu')}}",
>> "{{=T('Fri')}}",
>> "{{=T('Sat')}}"],
>> buttonText: {
>> prev: '&nbsp;&#9668;&nbsp;',  // left triangle
>> next: '&nbsp;&#9658;&nbsp;',  // right triangle
>> prevYear: '&nbsp;&#9668;&#9668;&nbsp;', // <<
>> nextYear: '&nbsp;&#9658;&#9658;&nbsp;', // >>
>> today:"{{=T('today')}}",
>> month:"{{=T('month')}}",
>> week: "{{=T('week')}}",
>> day:  "{{=T('day')}}"
>> }
>>
>> });
>>
>> });
>> 
>>
>>
>> Since I save you a lot of time you can consider to update the
>> AppointmentManager app with this example to return to community :
>>
>>
>> https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
>>
>> Richard
>>
>>
>>
>> On Wed, Jun 26, 2013 at 1:31 PM, Tom Russell  wrote:
>>
>>> Well I updated to the latest fullcalendar and it seems to work good, but
>>> do not know if the memory leak still exists. By any chance could y

Re: [web2py] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
Another solution can be:

{{extend 'layout.html'}}

 Education CV {{=education_form}}

Student {{=student_form}}

School {{=school_form}}


On Wed, Jun 26, 2013 at 12:47 PM, Tom Russell  wrote:

> Saved mine too, got it originally from
> http://www.web2pyslices.com/slice/show/1457/adding-fieldset-and-legend-to-forms
>
>
> On Wed, Jun 26, 2013 at 12:39 PM, António Ramos wrote:
>
>> That is a very clever solution.
>> Saved my day.
>>
>> Thank you
>>
>>
>>
>>
>> 2013/6/26 Tom Russell 
>>
>>> form[0]=TABLE(
>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>> FIELDSET(TAG.legend("Emergency Contact
>>> Info"),TABLE(fs1),_id="register1"),
>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>> TABLE(fs3))
>>>
>>
>>
>>  --
>>
>> ---
>> 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.
>>
>>
>>
>
>

-- 

--- 
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] Appointment Manager

2013-06-26 Thread Tom Russell
Well I updated to the latest fullcalendar and it seems to work good, but do
not know if the memory leak still exists. By any chance could you share
what you did? Also, any chance you added views for week/day in it?

You can see in the example here http://arshaw.com/fullcalendar/ that it has
buttons for day and week also. I tried fiddling with some examples to get
it to show but am not successful yet.

Thanks.


On Wed, Jun 26, 2013 at 1:22 PM, Richard Vézina  wrote:

> Letting FullCalendar consume the json feed...
>
>
> On Wed, Jun 26, 2013 at 1:21 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>>  Take care, I don't know if it has been solve, but I found a memory leak
>> in this app caused by the way FullCalendar is integrated... I solve the
>> issue for my own need by using the json feed feature of FullCalendar doing
>> a simple json feed function returning a well formatted json object with
>> simplejson dump.
>>
>> Richard
>>
>>
>> On Wed, Jun 26, 2013 at 12:55 PM, Tom Russell  wrote:
>>
>>> I am using the appointment manager from
>>> https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
>>> .
>>>
>>> I have tweaked it to my needs and works well so far but there is an
>>> issue trying to use SQLFORM.grid.
>>>
>>> I get an error
>>>  () takes exactly 1 argument (2
>>> given)
>>>
>>> by doing this:
>>>
>>> def appointment_select():
>>> grid = SQLFORM.grid(db.t_appointment, deletable=True, editable=True,
>>> create=False, maxtextlength=64, paginate=25)
>>>
>>> return dict(grid=grid)
>>>
>>> I cannot figure out why it is doing this.
>>>
>>> Any ideas?
>>>
>>> --
>>>
>>> ---
>>> 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.
>>>
>>>
>>>
>>
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] Appointment Manager

2013-06-26 Thread Tom Russell
I am using the appointment manager from
https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
.

I have tweaked it to my needs and works well so far but there is an issue
trying to use SQLFORM.grid.

I get an error
 () takes exactly 1 argument (2 given)

by doing this:

def appointment_select():
grid = SQLFORM.grid(db.t_appointment, deletable=True, editable=True,
create=False, maxtextlength=64, paginate=25)

return dict(grid=grid)

I cannot figure out why it is doing this.

Any ideas?

-- 

--- 
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] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
Saved mine too, got it originally from
http://www.web2pyslices.com/slice/show/1457/adding-fieldset-and-legend-to-forms


On Wed, Jun 26, 2013 at 12:39 PM, António Ramos wrote:

> That is a very clever solution.
> Saved my day.
>
> Thank you
>
>
>
>
> 2013/6/26 Tom Russell 
>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>>
>
>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] Ref another table in another app

2013-06-26 Thread Tom Russell
How would I do this:

I need to create an appointment for a patient so from my list of patients i
have a link to call another app to do the appointment. I have the link set
so it looks like this:

links = [lambda row: A(T('Create
Appointment'),_href=URL("AppointmentManager","default",
"appointment_create"), args=[row.id])]

In the appointment app how do I let it know what to use for the patient?
Basically I want to pass in the patient info to the other app and have that
displayed in the app. I know you can reference another table but not sure
how to do this in this situation.

Any suggestions?

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.




Re: [web2py] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
To group inside a field I do something like this with 3 different tables:

form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
fs0=form[0][:26] #patient rows
fs1=form[0][26:37]   #emergency contacts
fs2=form[0][37:41] #dependents
fs3=form[0][-1] # submit row (last)

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))


HTH


On Wed, Jun 26, 2013 at 11:58 AM, António Ramos wrote:

> Just drafting something but here is the problem
>
> My context:
> I have 3 tables
>
> table form
> table steps
> table fields
>
> A form can have many steps
> a step can have many fields
>
> This way i can have one form with 3 steps, each with some fields and
> another form with 10 steps , each with some more fields.
>
> i read these tables to create a form using factory.
>
> i have 2 problems
>
>
> *1 i need to mark the input fields with a "step" tag *
>
> here is my code:
>
> def my_string_widget(field, value,step):
>
> return INPUT(_name=field.name,
>   _id="%s_%s" % (field._tablename, field.name),
>   _class=field.type,
>   _value='',
>   *_step=step,*
>   requires=field.requires)
>
> def index():
> cont=0
> fields=[]
> formid=db.form(request.args(0) or 1)
> steps=formid.steps.select()
> for step in steps:
> print "step id-",step.id
> for field in step.fields.select():
> print "field...",field.step
> fields.append(Field(field.nome,widget=lambda
> field,value:my_string_widget(field,value,*step.id*)))
>
> form=SQLFORM.factory(*fields)
> print form
> if form.process().accepted:
> response.flash='a gravar registo'
> return dict(nome=formid.nome,form=form)
>
>
> The problem is:
> It marks all fields with the same "step" value, the last value in *step.id,
> why?*
> *
> *
> *2 - sqlformfactory *
> how do i group sqlformfactory fields inside a div?
> i want to create a section for each step in the form to style with css
>
> Best regards
> António
>
> --
>
> ---
> 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.
>
>
>

-- 

--- 
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] Add button to smartgrid?

2013-06-26 Thread Tom Russell
I need to add a button to the smartgrid but not like doing create=True
because I have a form factory that has 2 other tables associated with the
one. I know in html I can simply add a line for a button but since I am not
using html for this how would I add a button to that page to reference my
own view?

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.




Re: [web2py] Re: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
That is awesome, I did not know that! Just when you think its more
complicated than not, its easy.

So how do I reference that from the dependents table so that in my smart
grid it shows the patients name associated with the dependent?

Thanks


On Wed, Jun 26, 2013 at 10:43 AM, Anthony  wrote:

> db.define_table('patient',
> ...,
> format='%(first_name)s %(last_name)s')
>
> "format" can also be a function that takes a row object and generates the
> desired output.
>
> The "format" attribute is used to create a default "represent" attribute
> for any reference fields that reference this table.
>
> Anthony
>
>
> On Wednesday, June 26, 2013 10:24:32 AM UTC-4, Tom Russell wrote:
>
>> db.define_table('patient',
>> #db.patient.id.readable=False # Since we do not want to expose the id
>> field on the grid
>> Field('alternatepid', label='Alternate PID', writable=False,
>> readable=False),
>> Field('first_name', label='First Name', requires=IS_NOT_EMPTY()),
>> Field('middle_name', label='Middle Name'),
>> Field('last_name', label='Last Name', requires=IS_NOT_EMPTY()),
>> Field('suffix', label='Suffix', requires=IS_IN_SET(['I', 'II', 'III',
>> 'IV', 'V', 'Jr', 'Sr'])),
>> Field('date_of_birth', 'date', label='Date of Birth',
>> required=IS_DATE(), requires=IS_NOT_EMPTY()),
>> Field('gender', label='Gender', requires=IS_IN_SET(['Male', 'Female',
>> 'Other'])),
>> Field('full_name',  label='Full Name', writable=False,
>> readable=False),
>> Field('address1', label='Address1', requires=IS_NOT_EMPTY()),
>> Field('address2', label='Address2'),
>> Field('city',  label='City', requires=IS_NOT_EMPTY()),
>> Field('state',  label='State', requires=IS_NOT_EMPTY()),
>> Field('zipcode',  label='Zip Code', requires=IS_NOT_EMPTY()),
>> Field('addresstype',  label='AddressType'),
>> Field('county',  label='County', ),
>> Field('country',  label='Country', requires=IS_IN_SET(COUNTRIES))**,
>> Field('phone',  label='Phone', ),
>> Field('mobile_phone',  label='Mobile Phone'),
>> Field('emailaddress',  label='Email Address', requires =
>> IS_EMAIL(error_message='**invalid email!')),
>> Field('ethnicity',  label='Ethnicity', requires=IS_IN_SET(['**Caucasian',
>> 'Hispanic', 'Chinese'])),
>> Field('age', label='Age'),
>> Field('marital_status',  label='Marital Status',
>> requires=IS_IN_SET(['Single', 'Married', 'Divorced', 'Separated',
>> 'Widowed'])),
>> Field('comment', 'text', label='Comment'),
>> Field('government_id_number',  label='Government ID Number',
>> requires=IS_NOT_EMPTY()),
>> Field('is_newborn', 'boolean',  label='Is Newborn', ),
>> Field('medical_record_number',  label='MRN', readable=True,
>> requires=IS_NOT_EMPTY()),
>> Field('other_id_type',  label='Other ID Type',
>> requires=IS_IN_SET(['Work', 'Library Card', 'Drivers License', 'School ID',
>> 'Other'])),
>> Field('other_id', label='Other ID'),
>> )
>>
>>
>> db.define_table(
>> 'dependents',
>> #Field('patient name', db.linked patient, represent=lambda c,
>> row:first_name of patient(c), requires=IS_IN_DB(db,'field.id**
>> ','%(patient)s')),
>> Field('patient','reference patient', writable=False, readable=False),
>> Field('dep_firstname', label='First Name'),
>> Field('dep_middlename', label='Middle Name'),
>>     Field('dep_lastname', label='Last Name'),
>> Field('dep_relationship', label='Relationship',
>> requires=IS_IN_SET(['Son', 'Daughter', 'Other'])),
>> )
&

Re: [web2py] Re: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
db.define_table('patient',
#db.patient.id.readable=False # Since we do not want to expose the id
field on the grid
Field('alternatepid', label='Alternate PID', writable=False,
readable=False),
Field('first_name', label='First Name', requires=IS_NOT_EMPTY()),
Field('middle_name', label='Middle Name'),
Field('last_name', label='Last Name', requires=IS_NOT_EMPTY()),
Field('suffix', label='Suffix', requires=IS_IN_SET(['I', 'II', 'III',
'IV', 'V', 'Jr', 'Sr'])),
Field('date_of_birth', 'date', label='Date of Birth',
required=IS_DATE(), requires=IS_NOT_EMPTY()),
Field('gender', label='Gender', requires=IS_IN_SET(['Male', 'Female',
'Other'])),
Field('full_name',  label='Full Name', writable=False, readable=False),
Field('address1', label='Address1', requires=IS_NOT_EMPTY()),
Field('address2', label='Address2'),
Field('city',  label='City', requires=IS_NOT_EMPTY()),
Field('state',  label='State', requires=IS_NOT_EMPTY()),
Field('zipcode',  label='Zip Code', requires=IS_NOT_EMPTY()),
Field('addresstype',  label='AddressType'),
Field('county',  label='County', ),
Field('country',  label='Country', requires=IS_IN_SET(COUNTRIES)),
Field('phone',  label='Phone', ),
Field('mobile_phone',  label='Mobile Phone'),
Field('emailaddress',  label='Email Address', requires =
IS_EMAIL(error_message='invalid email!')),
Field('ethnicity',  label='Ethnicity', requires=IS_IN_SET(['Caucasian',
'Hispanic', 'Chinese'])),
Field('age', label='Age'),
Field('marital_status',  label='Marital Status',
requires=IS_IN_SET(['Single', 'Married', 'Divorced', 'Separated',
'Widowed'])),
Field('comment', 'text', label='Comment'),
Field('government_id_number',  label='Government ID Number',
requires=IS_NOT_EMPTY()),
Field('is_newborn', 'boolean',  label='Is Newborn', ),
Field('medical_record_number',  label='MRN', readable=True,
requires=IS_NOT_EMPTY()),
Field('other_id_type',  label='Other ID Type',
requires=IS_IN_SET(['Work', 'Library Card', 'Drivers License', 'School ID',
'Other'])),
Field('other_id', label='Other ID'),
)


db.define_table(
'dependents',
#Field('patient name', db.linked patient, represent=lambda c,
row:first_name of patient(c), requires=IS_IN_DB(db,'field.id
','%(patient)s')),
Field('patient','reference patient', writable=False, readable=False),
Field('dep_firstname', label='First Name'),
Field('dep_middlename', label='Middle Name'),
Field('dep_lastname', label='Last Name'),
Field('dep_relationship', label='Relationship',
requires=IS_IN_SET(['Son', 'Daughter', 'Other'])),
)

db.define_table(
'emergencycontacts',
Field('patient','reference patient', writable=False, readable=False),
Field('em_first_name', label='First Name'),
Field('em_middle_name', label='Middle Name'),
Field('em_last_name', label='Last Name'),
Field('em_address1', label='Address1'),
Field('em_address2', label='Address2'),
Field('em_city', label='City'),
Field('em_state', label='State'),
Field('em_zipcode', label='Zip Code'),
Field('em_country', label='Country', requires=IS_IN_SET(COUNTRIES)),
Field('em_phone', label='Phone'),
Field('em_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
)

I'd like to reference the first and last name of the patient the record is
associated with.

Thanks.


On Wed, Jun 26, 2013 at 10:20 AM, Anthony  wrote:

> Can you show your three table definitions? The simplest method is just to
> specify a "format" attribute for db.patient, which will be used by any
> referencing fields.
>
> Anthony
>
>
> On Wednesday, June 26, 2013 1:06:03 AM UTC-4, Tom Russell wrote:
>>
>> Another question on the smartgrid.
>>
>> I have linked tables in my smartgrid like:
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=False, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>>
>> When clicking on the linked table it shows the id of patient since thats
>> what reference but how can I show the name of the patient rather than the
>> id of patient?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
Apparently something is not correct as I cannot figure out what the syntax
erro is based on the example you gave here.

This is what I have:

Field('patient name', db.linked patient, represent=lambda c, row:first_name
of patient(c), requires=IS_IN_DB(db,'field.id','%(patient)s')),


On Wed, Jun 26, 2013 at 2:49 AM, Rohitraj Sharma <
rohitraj.sha...@themislexsol.com> wrote:

> You can use labda function in your db
>
> Field('companyField name',db.linked table name, represent=lambda c,
> row:field name of linked table(c), requires=IS_IN_DB(db,'field.id
> ','%(patient)s')),
>
>
> On Wednesday, 26 June 2013 10:36:03 UTC+5:30, Tom Russell wrote:
>>
>> Another question on the smartgrid.
>>
>> I have linked tables in my smartgrid like:
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=False, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>>
>> When clicking on the linked table it shows the id of patient since thats
>> what reference but how can I show the name of the patient rather than the
>> id of patient?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] SQLFORM.smartgrid

2013-06-25 Thread Tom Russell
Another question on the smartgrid.

I have linked tables in my smartgrid like:

grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=False, maxtextlength=64, paginate=25, links=links,
links_in_grid=True, linked_tables=['emergencycontacts','dependents'])

When clicking on the linked table it shows the id of patient since thats
what reference but how can I show the name of the patient rather than the
id of patient?

Thanks,

Tom

-- 

--- 
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: Smartgrid Links

2013-06-25 Thread Tom Russell
Ah I see now, Thanks.


On Tue, Jun 25, 2013 at 1:31 PM, Anthony  wrote:

> If you only provide two positional args to URL, it assumes they are the
> controller and function. In this case, you'll need to specify the
> application, controller, and function:
>
> URL("AppointmentManager", "yourcontroller", "appointment_create", args=[
> row.id])
>
> You can also used keyword arguments "a", "c", and "f" with URL().
>
> Anthony
>
> On Tuesday, June 25, 2013 12:08:57 PM UTC-4, Tom Russell wrote:
>>
>> I have a smartgrid with a link like so:
>>
>> links = [lambda row: A(T('Create Appointment'),_href=URL("**
>> AppointmentManager","**appointment_create",args=[row.**id <http://row.id>
>> ]))]
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=True, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>> return dict(grid=grid)
>>
>> Problem is that AppointmentManager is another app and the url points to
>> /currentapp/**AppointmentManager/ etc, so how do I have it redirect to
>> the other app?
>>
>> I looked in the book but could'nt find this.
>>
>> Thanks
>>
>> Tom
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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: Confused about app

2013-06-25 Thread Tom Russell
Ah, I forgot to add the following line to my consumer app:

auth = Auth(db,cas_provider = '
http://127.0.0.1:8000/welcome/default/user/cas')


On Tue, Jun 25, 2013 at 10:12 AM, Tom Russell  wrote:

> Well agreed, but I set that up in the welcome app so it would seem like
> that should move over to my other app as well?
>
>
> On Tue, Jun 25, 2013 at 2:24 AM, Niphlod  wrote:
>
>> every app has its own auth system. If you want multiple apps to share the
>> same "auth system", look at
>>
>> http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service
>>
>> Il giorno martedì 25 giugno 2013 07:51:08 UTC+2, Tom Russell ha scritto:
>>
>>> So I took and modified the welcome app to my needs and added another
>>> app. If I login with the welcome app and with a link, open the other app
>>> and have it set with auth.requires_login(), it requires the user to login
>>> again. How does one handle this stuff in web2py? Do I need another app the
>>> way I have it now?
>>>
>>> I am in the mindset of how they do things in django.
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>  --
>>
>> ---
>> 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.
>>
>>
>>
>
>

-- 

--- 
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] Smartgrid Links

2013-06-25 Thread Tom Russell
I have a smartgrid with a link like so:

links = [lambda row: A(T('Create
Appointment'),_href=URL("AppointmentManager","appointment_create",args=[
row.id]))]

grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=True, maxtextlength=64, paginate=25, links=links,
links_in_grid=True, linked_tables=['emergencycontacts','dependents'])
return dict(grid=grid)

Problem is that AppointmentManager is another app and the url points to
/currentapp/AppointmentManager/ etc, so how do I have it redirect to the
other app?

I looked in the book but could'nt find this.

Thanks

Tom

-- 

--- 
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: Confused about app

2013-06-25 Thread Tom Russell
But I do like this:

## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=True)

I was using auth.signature for each table but that gave me an error after
setting the CAS stuff. Once commented out it works fine. I was getting
a 'DAL' object has no attribute 'auth_user'


On Tue, Jun 25, 2013 at 11:14 AM, Anthony  wrote:

> On Tuesday, June 25, 2013 11:04:22 AM UTC-4, Tom Russell wrote:
>
>> Yes I customized welcome and then added a new app via the admin
>> interface. I did not directly copy the welcome app, just modified the html
>> etc.
>>
>> Now I am really confused about how this all works. So when I fire up
>> web2py and create a new app via the admin, should that be my only app then?
>>
>
> No, create as many apps as you like. However, each app is separate (a
> web2py app is more like a Django project).
>
>
>>  So I did implement the CAS stuff but now I get an error saying 'DAL'
>> object has no attribute 'auth_user' for the app I have.
>>
>
> Sounds like you didn't call auth.define_tables() in the second app.
>
> 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.
>
>
>

-- 

--- 
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: Confused about app

2013-06-25 Thread Tom Russell
Yes I customized welcome and then added a new app via the admin interface.
I did not directly copy the welcome app, just modified the html etc.

Now I am really confused about how this all works. So when I fire up web2py
and create a new app via the admin, should that be my only app then?

So I did implement the CAS stuff but now I get an error saying 'DAL' object
has no attribute 'auth_user' for the app I have.


On Tue, Jun 25, 2013 at 10:53 AM, Anthony  wrote:

> On Tuesday, June 25, 2013 10:12:32 AM UTC-4, Tom Russell wrote:
>
>> Well agreed, but I set that up in the welcome app so it would seem like
>> that should move over to my other app as well?
>>
>
> Are you saying you customized the welcome app and then used admin to
> create a new app? In that case, note that new apps are not created by
> directly copying the existing welcome app folder. Instead, they are created
> by unpacking the welcome.w2p file in the /web2py root folder.
>
> Even if you did get an exact copy of your custom welcome app, including
> the database with the records in db.auth_user (or a connection to a shared
> database), logging into one app would not log you into the other. The
> reason is that login status is held in the session, and by default,
> sessions are not shared across apps (though they can be shared if desired).
> If you want Auth to work across multiple apps, the best option is probably
> http://web2py.com/books/**default/chapter/29/09#Central-**
> Authentication-Service<http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service>
> .
>
> 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.
>
>
>

-- 

--- 
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] Multi Table Form

2013-06-25 Thread Tom Russell
I have the following form that uses 3 different tables and when I submit
the data it all seems to submit correctly but when I view the data in a
smart grid with linked tables in the columns clicking on the link does not
show any record for the row of linked data.

My smartgrid code:

def manage_patients():
db.patient.id.readable=False # Since we do not want to expose the id
field on the grid
grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=True, maxtextlength=64, paginate=25,
linked_tables=['emergencycontacts','dependents'])
return dict(grid=grid)

My linked tables:

db.define_table(
'dependents',
Field('dep_id',db.patient, writable=False, readable=False),
Field('dep_firstname', label='First Name'),
Field('dep_middlename', label='Middle Name'),
Field('dep_lastname', label='Last Name'),
Field('dep_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
auth.signature)

db.define_table(
'emergencycontacts',
Field('ec_id',db.patient, writable=False, readable=False),
Field('em_first_name', label='First Name'),
Field('em_middle_name', label='Middle Name'),
Field('em_last_name', label='Last Name'),
Field('em_address1', label='Address1'),
Field('em_address2', label='Address2'),
Field('em_city', label='City'),
Field('em_state', label='State'),
Field('em_zipcode', label='Zip Code'),
Field('em_country', label='Country'),
Field('em_phone', label='Phone'),
Field('em_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
auth.signature)

I believe I am doing this correctly but cannot bring up the data for each
row to the linked tables.

Any ideas?

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.




Re: [web2py] Re: Confused about app

2013-06-25 Thread Tom Russell
Well agreed, but I set that up in the welcome app so it would seem like
that should move over to my other app as well?


On Tue, Jun 25, 2013 at 2:24 AM, Niphlod  wrote:

> every app has its own auth system. If you want multiple apps to share the
> same "auth system", look at
>
> http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service
>
> Il giorno martedì 25 giugno 2013 07:51:08 UTC+2, Tom Russell ha scritto:
>
>> So I took and modified the welcome app to my needs and added another app.
>> If I login with the welcome app and with a link, open the other app and
>> have it set with auth.requires_login(), it requires the user to login
>> again. How does one handle this stuff in web2py? Do I need another app the
>> way I have it now?
>>
>> I am in the mindset of how they do things in django.
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] Confused about app

2013-06-24 Thread Tom Russell
So I took and modified the welcome app to my needs and added another app.
If I login with the welcome app and with a link, open the other app and
have it set with auth.requires_login(), it requires the user to login
again. How does one handle this stuff in web2py? Do I need another app the
way I have it now?

I am in the mindset of how they do things in django.

Thanks,

Tom

-- 

--- 
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: Form Field

2013-06-24 Thread Tom Russell
Yes I just tried it and that works fine. That works as expected. Thanks for
the help. Exactly what I was looking for to begin with.


On Tue, Jun 25, 2013 at 1:23 AM, Anthony  wrote:

> Did you try this method (setting these before creating the form):
>
> db.mytable.myfield.default = some_value
> db.mytable.myfield.writable = False
>
> Anthony
>
> On Tuesday, June 25, 2013 1:02:40 AM UTC-4, Tom Russell wrote:
>
>> Yes I understand that. What would be the best way to handle this?
>> Seemingly, the couple of items suggested did not work for me so I am not
>> sure where that leaves me.
>>
>>
>> On Tue, Jun 25, 2013 at 12:35 AM, Anthony  wrote:
>>
>>> Yes that works, though it's not as secure because someone can still
>>> submit a value for that field if they are determined, so you might want to
>>> check for that variable on the server and delete it if submitted.
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, June 25, 2013 12:15:04 AM UTC-4, Tom Russell wrote:
>>>
>>>> I ended up doing this in the controller which works for what I need:
>>>>
>>>> form.element('#no_table_**medica**l_record_number')['_**readonly']**
>>>> =True
>>>>
>>>>
>>>> On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:
>>>>
>>>>> I'm not sure that method will work for readonly fields, so you may
>>>>> have to use the method I showed (i.e., set the default value for the field
>>>>> before creating the form).
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>>>>>
>>>>>> Yes I tried that:
>>>>>>
>>>>>> Field('medical_record_number',  label='MRN', writable=False,
>>>>>> readable=True, requires=IS_NOT_EMPTY()),
>>>>>>
>>>>>> Still just shows none for the field on the form.
>>>>>>
>>>>>> In my controller this is what I am doing:
>>>>>>
>>>>>> form.vars.medical_record_**number = 'KND' +
>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>
>>>>>> If I set both to True then it shows the value no problem.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>>>>>
>>>>>>>  db.mytable.myfield.default = some_value
>>>>>>> db.mytable.myfield.writable = False
>>>>>>>
>>>>>>> Leave readable at True in order to show the value but not allow it
>>>>>>> to be edited.
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>>
>>>>>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>>>>>
>>>>>>>> I have a form and I load a pre existing value that I generate
>>>>>>>> internally before I call the form. What I want to see on the form is 
>>>>>>>> the
>>>>>>>> value shown up but just as plain text so the user cannot modify it. If 
>>>>>>>> I do
>>>>>>>> readable-False then it just shows None for the value rather than the 
>>>>>>>> value.
>>>>>>>>
>>>>>>>> How would I make that happen on the form then?
>>>>>>>>
>>>>>>>> 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+un...@**googlegroups.com.
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/**grou
>>>>>>> ps/opt_out <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+un...@**googlegroups.com.
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<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+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 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.
>
>
>

-- 

--- 
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: Form Field

2013-06-24 Thread Tom Russell
Yes I understand that. What would be the best way to handle this?
Seemingly, the couple of items suggested did not work for me so I am not
sure where that leaves me.


On Tue, Jun 25, 2013 at 12:35 AM, Anthony  wrote:

> Yes that works, though it's not as secure because someone can still submit
> a value for that field if they are determined, so you might want to check
> for that variable on the server and delete it if submitted.
>
> Anthony
>
>
> On Tuesday, June 25, 2013 12:15:04 AM UTC-4, Tom Russell wrote:
>
>> I ended up doing this in the controller which works for what I need:
>>
>> form.element('#no_table_**medical_record_number')['_**readonly']=True
>>
>>
>> On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:
>>
>>> I'm not sure that method will work for readonly fields, so you may have
>>> to use the method I showed (i.e., set the default value for the field
>>> before creating the form).
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>>>
>>>> Yes I tried that:
>>>>
>>>> Field('medical_record_number',  label='MRN', writable=False,
>>>> readable=True, requires=IS_NOT_EMPTY()),
>>>>
>>>> Still just shows none for the field on the form.
>>>>
>>>> In my controller this is what I am doing:
>>>>
>>>> form.vars.medical_record_**numbe**r = 'KND' + str(date.today().year) +
>>>> '' + str(random.randrange(1, 999+1))
>>>>
>>>> If I set both to True then it shows the value no problem.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>>>
>>>>>  db.mytable.myfield.default = some_value
>>>>> db.mytable.myfield.writable = False
>>>>>
>>>>> Leave readable at True in order to show the value but not allow it to
>>>>> be edited.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> I have a form and I load a pre existing value that I generate
>>>>>> internally before I call the form. What I want to see on the form is the
>>>>>> value shown up but just as plain text so the user cannot modify it. If I 
>>>>>> do
>>>>>> readable-False then it just shows None for the value rather than the 
>>>>>> value.
>>>>>>
>>>>>> How would I make that happen on the form then?
>>>>>>
>>>>>> 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+un...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<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+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 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.
>
>
>

-- 

--- 
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: Form Field

2013-06-24 Thread Tom Russell
I ended up doing this in the controller which works for what I need:

form.element('#no_table_medical_record_number')['_readonly']=True


On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:

> I'm not sure that method will work for readonly fields, so you may have to
> use the method I showed (i.e., set the default value for the field before
> creating the form).
>
> Anthony
>
>
> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>
>> Yes I tried that:
>>
>> Field('medical_record_number',  label='MRN', writable=False,
>> readable=True, requires=IS_NOT_EMPTY()),
>>
>> Still just shows none for the field on the form.
>>
>> In my controller this is what I am doing:
>>
>> form.vars.medical_record_**number = 'KND' + str(date.today().year) +
>> '' + str(random.randrange(1, 999+1))
>>
>> If I set both to True then it shows the value no problem.
>>
>> Thanks,
>>
>> Tom
>>
>>
>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>
>>> db.mytable.myfield.default = some_value
>>> db.mytable.myfield.writable = False
>>>
>>> Leave readable at True in order to show the value but not allow it to be
>>> edited.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>
>>>> I have a form and I load a pre existing value that I generate
>>>> internally before I call the form. What I want to see on the form is the
>>>> value shown up but just as plain text so the user cannot modify it. If I do
>>>> readable-False then it just shows None for the value rather than the value.
>>>>
>>>> How would I make that happen on the form then?
>>>>
>>>> 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+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 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.
>
>
>

-- 

--- 
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: Form Field

2013-06-24 Thread Tom Russell
Yes I tried that:

Field('medical_record_number',  label='MRN', writable=False, readable=True,
requires=IS_NOT_EMPTY()),

Still just shows none for the field on the form.

In my controller this is what I am doing:

form.vars.medical_record_number = 'KND' + str(date.today().year) + '' +
str(random.randrange(1, 999+1))

If I set both to True then it shows the value no problem.

Thanks,

Tom


On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:

> db.mytable.myfield.default = some_value
> db.mytable.myfield.writable = False
>
> Leave readable at True in order to show the value but not allow it to be
> edited.
>
> Anthony
>
>
> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>
>> I have a form and I load a pre existing value that I generate internally
>> before I call the form. What I want to see on the form is the value shown
>> up but just as plain text so the user cannot modify it. If I do
>> readable-False then it just shows None for the value rather than the value.
>>
>> How would I make that happen on the form then?
>>
>> 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.
>
>
>

-- 

--- 
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] Form Field

2013-06-24 Thread Tom Russell
I have a form and I load a pre existing value that I generate internally
before I call the form. What I want to see on the form is the value shown
up but just as plain text so the user cannot modify it. If I do
readable-False then it just shows None for the value rather than the value.

How would I make that happen on the form then?

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.




Re: [web2py] Re: SQLForm Factory

2013-06-24 Thread Tom Russell
Ah yes both readable and writable have to be defined. Thanks again


On Mon, Jun 24, 2013 at 6:12 PM, Anthony  wrote:

> Try writable=False.
>
>
> On Monday, June 24, 2013 6:04:43 PM UTC-4, Tom Russell wrote:
>
>> Thanks for the tip.
>>
>> I did set one field to not be readable like this:
>>
>> Field('alternatepid', label='Alternate PID', readable=False),
>>
>> but it still shows on my form.
>>
>> Should'nt be there should it?
>>
>> Thanks.
>>
>>
>> On Mon, Jun 24, 2013 at 1:57 PM, Anthony  wrote:
>>
>>> db.patient(fields=['first_**name'])
>>>
>>> No, the above isn't web2py syntax -- don't know where you saw that. As I
>>> mentioned, to control which fields are shown, you can set the readable and
>>> writable attributes of the fields (check the book), or you can list
>>> individual fields instead of entire tables:
>>>
>>> SQLFORM.factory(db.mytable.myf**ield, db.mytable.myotherfield, db.
>>> wholetable)
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:49:43 AM UTC-4, Tom Russell wrote:
>>>
>>>> I tried doing the specific fields like:
>>>>
>>>> form=SQLFORM.factory(db.**patien**t(fields=['first_name'])**,
>>>> db.emergencycontacts, db.dependents, formstyle = 'table3cols')
>>>>
>>>> but that just throws an error saying no tables selected. I guess what I
>>>> am trying to do is set certain fields to be show for each table and read
>>>> the book but do not see how I would set it in my code as such. All of the
>>>> examples I have seen so far show only 1 table at a time.
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:
>>>>
>>>>> You can set the readable and writable attributes of the fields, or
>>>>> .factory() can take a list of specific fields rather than entire tables.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> If I have a form factory with 3 tables, how would I define the fields
>>>>>> I wanted shown for each?
>>>>>>
>>>>>> This is the code for my controller. I have tried to set it in several
>>>>>> spots but all of them throw an error.
>>>>>>
>>>>>> def register_patient():
>>>>>> mark_not_empty(db.patient)
>>>>>> mark_not_empty(db.**emergencycontacts)
>>>>>> mark_not_empty(db.dependents)
>>>>>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>>>>>> db.dependents, formstyle = 'table3cols')
>>>>>> fs0=form[0][:28] # the first two name rows
>>>>>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>>>>>> fs2=form[0][40:45] # submit row (last)
>>>>>> fs3=form[0][-1] # submit row (last)
>>>>>>
>>>>>> form.vars.medical_record_**number = 'KND' +
>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>
>>>>>> form[0]=TABLE(
>>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**registe
>>>>>> r0"),
>>>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>>>> register1"),
>>>>>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**
>>>>>> register2"),
>>>>>> TABLE(fs3))
>>>>>> if form.process().accepted:
>>>>>> id = db.patient.insert(**db.**patient
>>>>>> ._filter_fields(form.**vars))
>>>>>> form.vars.patient=id
>>>>>> id = db.emergencycontacts.insert(
>>>>>> db.emergencycontacts._filter_**fields(form.vars))
>>>>>> response.flash='Thanks for filling the form'
>>>>>> id = db.dependents.insert(**db.**depe
>>>>>> ndents._filter_fields(**form.**var**s))
>>>>>> form.vars.dependents=id
>>>>>> # and get a list of all pers

Re: [web2py] Re: SQLForm Factory

2013-06-24 Thread Tom Russell
Thanks for the tip.

I did set one field to not be readable like this:

Field('alternatepid', label='Alternate PID', readable=False),

but it still shows on my form.

Should'nt be there should it?

Thanks.


On Mon, Jun 24, 2013 at 1:57 PM, Anthony  wrote:

> db.patient(fields=['first_name'])
>
> No, the above isn't web2py syntax -- don't know where you saw that. As I
> mentioned, to control which fields are shown, you can set the readable and
> writable attributes of the fields (check the book), or you can list
> individual fields instead of entire tables:
>
> SQLFORM.factory(db.mytable.myfield, db.mytable.myotherfield, db.wholetable
> )
>
> Anthony
>
>
> On Monday, June 24, 2013 11:49:43 AM UTC-4, Tom Russell wrote:
>
>> I tried doing the specific fields like:
>>
>> form=SQLFORM.factory(db.**patient(fields=['first_name'])**,
>> db.emergencycontacts, db.dependents, formstyle = 'table3cols')
>>
>> but that just throws an error saying no tables selected. I guess what I
>> am trying to do is set certain fields to be show for each table and read
>> the book but do not see how I would set it in my code as such. All of the
>> examples I have seen so far show only 1 table at a time.
>>
>>
>> On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:
>>
>>> You can set the readable and writable attributes of the fields, or
>>> .factory() can take a list of specific fields rather than entire tables.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>>>
>>>> If I have a form factory with 3 tables, how would I define the fields I
>>>> wanted shown for each?
>>>>
>>>> This is the code for my controller. I have tried to set it in several
>>>> spots but all of them throw an error.
>>>>
>>>> def register_patient():
>>>> mark_not_empty(db.patient)
>>>> mark_not_empty(db.**emergencycon**tacts)
>>>> mark_not_empty(db.dependents)
>>>> form=SQLFORM.factory(db.**patien**t, db.emergencycontacts,
>>>> db.dependents, formstyle = 'table3cols')
>>>> fs0=form[0][:28] # the first two name rows
>>>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>>>> fs2=form[0][40:45] # submit row (last)
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form.vars.medical_record_**numbe**r = 'KND' +
>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**registe**
>>>> r0"),
>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>> registe**r1"),
>>>> FIELDSET(TAG.legend("**Dependent**s"),TABLE(fs2),_id="**register2"*
>>>> *),
>>>> TABLE(fs3))
>>>> if form.process().accepted:
>>>> id = db.patient.insert(**db.**patient**._filter_fields(form.**
>>>> vars))
>>>> form.vars.patient=id
>>>> id = db.emergencycontacts.insert(**
>>>> db.emergencycontacts._filter_**f**ields(form.vars))
>>>> response.flash='Thanks for filling the form'
>>>> id = db.dependents.insert(**db.**depe**ndents._filter_fields(**
>>>> form.**vars))
>>>> form.vars.dependents=id
>>>> # and get a list of all persons
>>>> redirect(URL('manage_patients'))
>>>>
>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>
>>>> return dict(form=DIV(style,form))
>>>>
>>>>
>>>> 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+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 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.
>
>
>

-- 

--- 
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: SQLForm Factory

2013-06-24 Thread Tom Russell
I tried doing the specific fields like:

form=SQLFORM.factory(db.patient(fields=['first_name']),
db.emergencycontacts, db.dependents, formstyle = 'table3cols')

but that just throws an error saying no tables selected. I guess what I am
trying to do is set certain fields to be show for each table and read the
book but do not see how I would set it in my code as such. All of the
examples I have seen so far show only 1 table at a time.


On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:

> You can set the readable and writable attributes of the fields, or
> .factory() can take a list of specific fields rather than entire tables.
>
> Anthony
>
>
> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>
>> If I have a form factory with 3 tables, how would I define the fields I
>> wanted shown for each?
>>
>> This is the code for my controller. I have tried to set it in several
>> spots but all of them throw an error.
>>
>> def register_patient():
>> mark_not_empty(db.patient)
>> mark_not_empty(db.**emergencycontacts)
>> mark_not_empty(db.dependents)
>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>> db.dependents, formstyle = 'table3cols')
>> fs0=form[0][:28] # the first two name rows
>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>> fs2=form[0][40:45] # submit row (last)
>> fs3=form[0][-1] # submit row (last)
>>
>> form.vars.medical_record_**number = 'KND' + str(date.today().year) +
>> '' + str(random.randrange(1, 999+1))
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**register0"),
>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>> register1"),
>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**register2"),
>> TABLE(fs3))
>> if form.process().accepted:
>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>> vars))
>> form.vars.patient=id
>> id = db.emergencycontacts.insert(
>> db.emergencycontacts._filter_**fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id = db.dependents.insert(**db.**dependents._filter_fields(**
>> form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'**))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>>
>> 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.
>
>
>

-- 

--- 
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] SQLForm Factory

2013-06-24 Thread Tom Russell
If I have a form factory with 3 tables, how would I define the fields I
wanted shown for each?

This is the code for my controller. I have tried to set it in several spots
but all of them throw an error.

def register_patient():
mark_not_empty(db.patient)
mark_not_empty(db.emergencycontacts)
mark_not_empty(db.dependents)
form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents,
formstyle = 'table3cols')
fs0=form[0][:28] # the first two name rows
fs1=form[0][28:40]   # the wine data rows (all but the last)
fs2=form[0][40:45] # submit row (last)
fs3=form[0][-1] # submit row (last)

form.vars.medical_record_number = 'KND' + str(date.today().year) +
'' + str(random.randrange(1, 999+1))

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))
if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
response.flash='Thanks for filling the form'
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))


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.




Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Ah, I see now.

Thanks


On Mon, Jun 24, 2013 at 10:50 AM, Anthony  wrote:

> No, 3 columns means:
>
> Col 1   Col 2 Col 3
> label   widget   comment
>
> It's still one field per row. When in doubt, try it out. :-)
>
> Anthony
>
>
> On Monday, June 24, 2013 10:26:08 AM UTC-4, Tom Russell wrote:
>
>> Thanks again for the info.
>>
>> I guess I still do not get it though if I set my formstyle to table3cols
>> would'nt my form at least be laid out like:
>>
>> Name Address City
>> State
>>
>> Or am I not looking at this correctly?
>>
>>
>> On Mon, Jun 24, 2013 at 10:16 AM, Anthony  wrote:
>>
>>> Your best bet is to look at how the built-in ones work, starting here:
>>> https://code.google.com/**p/web2py/source/browse/gluon/**sqlhtml.py#752<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#752>.
>>> Copy the one of those that is closest to what you want and modify it as
>>> necessary.
>>>
>>> def myformstyle():
>>> [custom code here]
>>>
>>> form = SQLFORM(..., formstyle=myformstyle)
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 10:07:49 AM UTC-4, Tom Russell wrote:
>>>
>>>> Thanks for the responses.
>>>>
>>>> The formstyle looks interesting but I cannot make heads or tails out of
>>>> the way to use it. Are there any examples of this some place?
>>>>
>>>> Thanks
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:
>>>>
>>>>> I assume that means you are relying on a generic view to display your
>>>>> table. If so, you can instead create a non-generic view (which you should
>>>>> probably do anyway), or you can build the form DOM on the server using
>>>>> web2py HTML helpers (probably not the way to go). The custom formstyle
>>>>> option also does not require any HTML coding.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>>>>>
>>>>>> Thanks for the response. So now I am really confused because I have
>>>>>> no idea where to put this code if I am using a SQLFORM.factory?
>>>>>>
>>>>>> Basically I just want to add row fluid to make the layout a little
>>>>>> easier to navigate. I do not have a html file to set this code in for 
>>>>>> this
>>>>>> form.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>
>>>>>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>>>>>
>>>>>>> http://web2py.com/books/**default/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>>>>>
>>>>>>> I don't think it's in the book yet, but you can also create a custom
>>>>>>> formstyle if you need to use the layout in multiple places:
>>>>>>> https://groups.google.**com/d/msg/web2py/QmoRmapiOwA/**t
>>>>>>> ZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>>
>>>>>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>>>>>
>>>>>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>>>>>> really want. Rather than having just one column with all of the fields
>>>>>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>>>>>
>>>>>>>> For example:
>>>>>>>>
>>>>>>>> Name  Address  City  State
>>>>>>>>
>>>>>>>> Instead of:
>>>>>>>>
>>>>>>>> Name
>>>>>>>> Address
>>>>>>>> City
>>>>>>>> State
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>  --
>>>>>>>
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "we

Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Thanks again for the info.

I guess I still do not get it though if I set my formstyle to table3cols
would'nt my form at least be laid out like:

Name Address City
State

Or am I not looking at this correctly?


On Mon, Jun 24, 2013 at 10:16 AM, Anthony  wrote:

> Your best bet is to look at how the built-in ones work, starting here:
> https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#752. Copy
> the one of those that is closest to what you want and modify it as
> necessary.
>
> def myformstyle():
> [custom code here]
>
> form = SQLFORM(..., formstyle=myformstyle)
>
> Anthony
>
>
> On Monday, June 24, 2013 10:07:49 AM UTC-4, Tom Russell wrote:
>
>> Thanks for the responses.
>>
>> The formstyle looks interesting but I cannot make heads or tails out of
>> the way to use it. Are there any examples of this some place?
>>
>> Thanks
>>
>>
>> On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:
>>
>>> I assume that means you are relying on a generic view to display your
>>> table. If so, you can instead create a non-generic view (which you should
>>> probably do anyway), or you can build the form DOM on the server using
>>> web2py HTML helpers (probably not the way to go). The custom formstyle
>>> option also does not require any HTML coding.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>>>
>>>> Thanks for the response. So now I am really confused because I have no
>>>> idea where to put this code if I am using a SQLFORM.factory?
>>>>
>>>> Basically I just want to add row fluid to make the layout a little
>>>> easier to navigate. I do not have a html file to set this code in for this
>>>> form.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>>>
>>>>> http://web2py.com/books/**defaul**t/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>>>
>>>>> I don't think it's in the book yet, but you can also create a custom
>>>>> formstyle if you need to use the layout in multiple places:
>>>>> https://groups.google.com/d/msg/web2py/QmoRmapiOwA/**t**
>>>>> ZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>>>> really want. Rather than having just one column with all of the fields
>>>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>>>
>>>>>> For example:
>>>>>>
>>>>>> Name  Address  City  State
>>>>>>
>>>>>> Instead of:
>>>>>>
>>>>>> Name
>>>>>> Address
>>>>>> City
>>>>>> State
>>>>>>
>>>>>> 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+un...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<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+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 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.
>
>
>

-- 

--- 
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: Change form layout

2013-06-24 Thread Tom Russell
Thanks for the responses.

The formstyle looks interesting but I cannot make heads or tails out of the
way to use it. Are there any examples of this some place?

Thanks


On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:

> I assume that means you are relying on a generic view to display your
> table. If so, you can instead create a non-generic view (which you should
> probably do anyway), or you can build the form DOM on the server using
> web2py HTML helpers (probably not the way to go). The custom formstyle
> option also does not require any HTML coding.
>
> Anthony
>
>
> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>
>> Thanks for the response. So now I am really confused because I have no
>> idea where to put this code if I am using a SQLFORM.factory?
>>
>> Basically I just want to add row fluid to make the layout a little easier
>> to navigate. I do not have a html file to set this code in for this form.
>>
>> Thanks.
>>
>>
>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>
>>> http://web2py.com/books/**default/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>
>>> I don't think it's in the book yet, but you can also create a custom
>>> formstyle if you need to use the layout in multiple places:
>>> https://groups.google.**com/d/msg/web2py/QmoRmapiOwA/**tZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>
>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>> really want. Rather than having just one column with all of the fields
>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>
>>>> For example:
>>>>
>>>> Name  Address  City  State
>>>>
>>>> Instead of:
>>>>
>>>> Name
>>>> Address
>>>> City
>>>> State
>>>>
>>>> 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+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 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.
>
>
>

-- 

--- 
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: Change form layout

2013-06-24 Thread Tom Russell
Thanks for the response. So now I am really confused because I have no idea
where to put this code if I am using a SQLFORM.factory?

Basically I just want to add row fluid to make the layout a little easier
to navigate. I do not have a html file to set this code in for this form.

Thanks.


On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:

> http://web2py.com/books/default/chapter/29/07#Custom-forms
>
> I don't think it's in the book yet, but you can also create a custom
> formstyle if you need to use the layout in multiple places:
> https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ
>
> Anthony
>
>
> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>
>> I have a SQLForm and use the formset DIV for it but its not what I really
>> want. Rather than having just one column with all of the fields required to
>> be filled out, how do I set it so its like 3-4 columns?
>>
>> For example:
>>
>> Name  Address  City  State
>>
>> Instead of:
>>
>> Name
>> Address
>> City
>> State
>>
>> 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.
>
>
>

-- 

--- 
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 form layout

2013-06-24 Thread Tom Russell
I have a SQLForm and use the formset DIV for it but its not what I really
want. Rather than having just one column with all of the fields required to
be filled out, how do I set it so its like 3-4 columns?

For example:

Name  Address  City  State

Instead of:

Name
Address
City
State

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.




Re: [web2py] Re: SmartGrid

2013-06-19 Thread Tom Russell
aha that would be it.


On Wed, Jun 19, 2013 at 5:26 PM, Niphlod  wrote:

> are you logged-in ?
> For security reasons any modification to tables in grids is prevented on
> anonymous access.
> You can still give "write permissions" using user_signature=False, but
> it's highly discouraged
>
> On Wednesday, June 19, 2013 5:25:58 PM UTC+2, t...@caregointl.com wrote:
>>
>> I have a smartgrid set up like this:
>>
>> def manage_patients():
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=True, linked_tables=['**emergencycontacts','**dependents'])
>> return dict(grid=grid)
>>
>>
>> It displays fine but only has a view button to the far right. How do I
>> have the add, edit and delete buttons as well?
>>
>> 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.
>
>
>

-- 

--- 
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: 3 forms in 1

2013-06-18 Thread Tom Russell
Yes I am using smartgrid elsewhere, very nice. I did do the 3 forms but
used the factory to do it. Works nicely so far.


On Tue, Jun 18, 2013 at 1:24 PM, villas  wrote:

> I don't believe you can use SQLFORM in that way,  you'll have to create
> your own form - maybe try SQLFORM.factory.  Better still,  try
> SQLFORM.smartgrid which could allow you a very flexible way to manage all
> three tables.
>
>
>
> On Tuesday, 18 June 2013 16:40:40 UTC+1, t...@caregointl.com wrote:
>>
>> I have one page where I want to show 3 forms. I have a main table with 2
>> tables that are related to it.
>>
>> So in my models file I have:
>>
>> db.define_table(
>> 'dependents',
>> Field('dep_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('relationship', 'text'))
>>
>> db.define_table(
>> 'emergencycontacts',
>> Field('ec_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('address1'),
>> Field('address2'),
>> Field('city'),
>> Field('state'),
>> Field('zipcode'),
>> Field('country'),
>> Field('phone'),
>> Field('relationship'))
>>
>> And db.patient is another table.
>>
>> So in my form I have:
>>
>> def register_patient():
>> form=SQLFORM.factory(db.**patient,db.emergencycontacts,
>> db.dependents)
>> if form.process().accepted:
>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>> vars))
>> form.vars.patient=id
>> id = db.emergencycontacts.insert(
>> db.emergencycontacts._filter_**fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id = db.dependents.insert(**db.**dependents._filter_fields(**
>> form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> records = SQLTABLE(db().select(db.**patient.ALL),headers='**
>> fieldname:capitalize')
>>
>> return dict(form=form, records=records)
>>
>> So the form displays correctly but I was expecting that the other fields
>> for dependents and emergencycontacts would be there for input as well but I
>> only get the id fields showing up for input.
>>
>> Am I doing what I want to do incorrectly?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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] 3 forms in 1

2013-06-18 Thread Tom Russell
Yes I was just reading and understood that the reason for my fields not
showing up was because the fields in many of the tables have the same
names. Changing that resolved that issue.

It's actually a great book too, just wished I could read faster.

Thanks.


On Tue, Jun 18, 2013 at 1:04 PM, Richard Vézina  wrote:

> I think you have 1 form for 3 tables...
>
> You should package a dummy app with the code above to help us helping
> you...
>
> As far as I understand you got the id only because you didn't set requires
> in your model. Read the book about validators and search for "requires" in
> the book.
>
> Richard
>
>
> On Tue, Jun 18, 2013 at 11:40 AM,  wrote:
>
>> I have one page where I want to show 3 forms. I have a main table with 2
>> tables that are related to it.
>>
>> So in my models file I have:
>>
>> db.define_table(
>> 'dependents',
>> Field('dep_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('relationship', 'text'))
>>
>> db.define_table(
>> 'emergencycontacts',
>> Field('ec_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('address1'),
>> Field('address2'),
>> Field('city'),
>> Field('state'),
>> Field('zipcode'),
>> Field('country'),
>> Field('phone'),
>> Field('relationship'))
>>
>> And db.patient is another table.
>>
>> So in my form I have:
>>
>> def register_patient():
>> form=SQLFORM.factory(db.patient,db.emergencycontacts, db.dependents)
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> records =
>> SQLTABLE(db().select(db.patient.ALL),headers='fieldname:capitalize')
>>
>> return dict(form=form, records=records)
>>
>> So the form displays correctly but I was expecting that the other fields
>> for dependents and emergencycontacts would be there for input as well but I
>> only get the id fields showing up for input.
>>
>> Am I doing what I want to do incorrectly?
>>
>> Thanks,
>>
>> Tom
>>
>> --
>>
>> ---
>> 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.
>>
>>
>>
>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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: nyroModal

2011-11-06 Thread Russell McMurray
Hi Kenneth,

nyroModalRemove() is a standard nyroModal call.  What version of nyroModal
are you using?  I'm using 1.6.2, which I see has been replaced by version
2, so maybe the call is depreciated?  My only other thought is...are you
opening nyroModal in an iframe?  I initiate the modal window from the
parent view like this:

  $('.nyroEdit').click(function(e) {
e.preventDefault();
$.nyroModalManual({
  url: $(this).attr('href'),
  forceType: 'iframe'
});
return false;
  });
With links that look like this...

name_goes_here

It works for me.

2011/11/5 Kenneth Lundström 

> Hi Russell,
>
> Have you defined nyroModalRemove somewhere? I'm getting
> "parent.$.nyroModalRemove is not a function" when using your suggested
> three lines.
>
>
> Kenneth
>
> return_script = ['parent.$.nyroModalRemove();'**]
>> return_script.append('parent.**window.location.reload();')
>> return HTML(BODY(SCRIPT(''.join(**return_script.xml()
>>
>
>


[web2py] Re: Strange Error: Field does not belong to the table

2011-06-16 Thread Russell
Looks like the form.accepts is trying to update the database with the
is_administrator value.  You may need to deal with the update
explicitly.  Have you tried form.accepts(request.vars, session,
dbio=False)?


On Jun 14, 1:21 pm, Ross Peoples  wrote:
> I am trying to provide an editor for auth_user using SQLFORM. I also am
> trying to add a checkbox to the bottom of the form to set whether or not the
> user is an administrator. If so, then the user gets added to an
> Administrators group when calling form.accepts().
>
> The strange part is, the code works fine if you check the box, then click
> submit, but if you try to uncheck the box, that's when you get the following
> traceback:
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
>
> Traceback (most recent call last):
>   File "/media/psf/Python/web2py/gluon/restricted.py", line 192, in restricted
>     exec ccode in environment
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 650, in 
>   File "/media/psf/Python/web2py/gluon/globals.py", line 137, in 
>     self._caller = lambda f: f()
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/tools.py", line 
> 2485, in f
>     return action(*a, **b)
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 148, in security
>     return update()
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 143, in update
>     return user_form(user)
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 120, in user_form
>     if form.accepts(request.vars, session):
>   File "/media/psf/Python/web2py/gluon/sqlhtml.py", line 1203, in accepts
>     self.table._db(self.table._id == self.record.id).update(**fields)
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/dal.py", line 
> 5401, in update
>     fields = self.db[tablename]._listify(update_fields,update=True)
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/dal.py", line 
> 4677, in _listify
>     raise SyntaxError, 'Field %s does not belong to the table' % name
> SyntaxError: Field is_administrator does not belong to the table
>
> And here is the controller that is adding the checkbox:
>
>         form = SQLFORM(db.auth_user, user, showid=False)
>         form[0].insert(-1, TR((
>             TD(LABEL('Is Administrator',
> _for='auth_user_is_administrator')),
>             TD(INPUT(_type='checkbox', _name='is_administrator',
> _id='auth_user_is_administrator'))
>         )))
>
>         form.vars.is_administrator = False
>         if user:
>             if auth.has_membership(user_id=user.id, role='Administrators'):
>                 form.vars.is_administrator = True
>
>         if form.accepts(request.vars, session):
>             admin_group =
> db(db.auth_group.role=='Administrators').select().first()
>             db((db.auth_membership.user_id==user.id) &
> (db.auth_membership.group_id==admin_group.id)).delete()
>
>             if form.vars.is_administrator:
>                 db.auth_membership.insert(group_id=admin_group.id,
> user_id=user.id)
>
>             return 'OK'
>
>         return dict(form=form)
>
> The thing that is driving me nuts is that I am doing exactly what the book
> says to do:
>
> http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-...
>
> Any thoughts? Thanks.


[web2py] Re: Need advice on Cron in production

2011-05-17 Thread Russell
Yes, I have two lines in the crontab.  A five minute one, and a daily
one...


*/5 * * * * python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/scripts/cron_fivemin.py
1 22 * * 1-5 python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/scripts/cron_daily.py


On May 18, 12:13 pm, pbreit  wrote:
> Cool, thanks or the examples. So do you have one line in our system crontab
> for each job? And then one cronXX.py file on modules for each task?
>
> I have some tasks that go every minute and some that go daily.
>
> There's no way to specify a function through the command line, correct?


[web2py] Re: Need advice on Cron in production

2011-05-17 Thread Russell
This works for me.  I have a system crontab like this...

*/5 * * * * python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/cron.py

And cron.py runs just like it should.  Here's a basic layout that you
can use to test it's working...

==modules/cron.py==
#!/usr/bin/env python
# coding: utf8

import os
import sys
import datetime
message_log = ['Started at %s' % datetime.datetime.now()]

try:
# Put your processing stuff here

db.commit()
message_log.append('Process good')
except:
import traceback
message_log.append('Cron Failure: %s' % traceback.format_exc())

message_log.append('Ended at %s' % datetime.datetime.now())
mail.send(settings.system_email, "Cron Report",
'\n'.join(message_log))





On May 17, 12:42 pm, pbreit  wrote:
> I'm still struggling with how to deploy cron in production.
>
> I currently have a crontab on my production server set up with:
>
> 0-59/1 * * * * cd /var/web2py && python web2py.py -C -D 1 >>
> /tmp/cron.output 2>&1
>
> And a couple tasks in my web2py crontab:
> */1 * * * * root *cron/email_watchlist
> 0 2 * * * root *cron/google_feed
>
> It seems like the */1 tasks get run but not the 0 2 one.
>
> I'm about to give up and just wget URLs:
> */1 * * * * wgethttp://localhost/cron/email_watchlist>/dev/null 2>&1
> 00 2 * * * wgethttp://localhost/cron/google_feed>/dev/null 2>&1
>
> Is this how external cron is supposed to work? What are other people doing
> that works? Any suggestions?


[web2py] Re: Best practice to start background process

2011-04-27 Thread Russell
I think that a simple system cron is the most reliable (per minute,
per hour, per day).  Then use some type of locking mechanism in your
web2py script (either database or file).  For example:

locked = db((db.report_queue.status=='SystemLock')).select().first()
if not locked:
locked = db.report_queue.insert(status='SystemLock')
db.commit()
# and so on


On Apr 28, 5:04 am, teemu  wrote:
> Hi,
>
> I would like to know what would be the best way to start background
> process in production environment. I have implemented background
> process by using the web2py book chapter as a template 
> ("http://www.web2py.com/book/default/chapter/04#Background-Processes-and-Task-...";).
> I start background process manually on my development machine
> (Winddows 7, web2py webserver) and it works great. Now it is time to
> publish my app on production server (debian linux, apache2, mod_wsgi).
> I was wondering what would be the best and the most simple way to
> start this background process together with apache/mod_wsgi? Ideal
> solution would be cross-platform compatible but this is not
> mandatory.
>
> As far as i know there are several different options but I do not know
> what is the best and what are advantages and disadvantages of
> different methods:
>
> 1) manually from shell:
> - laborious and should be done upon every server reboot
>
> 2) init script:
> - good option and can be integrated with apache2 init script
>
> 3) web2py-cron-@reboot:
> - is this even possible or recommended? However, this would be the
> only cross-platform alternative
>
> 3) system cron:
> - cron job could check if background process is still running and
> restart process if it has been crashed
>
> How have you guys done this? Any suggestions?
>
> Teemu


[web2py] Re: SQLFORM.factory - RuntimeError: you must specify a Field(...,uploadfolder=...)

2011-03-29 Thread Russell
I've just been struck by the same issue when upgrading to Version
1.94.6 (2011-03-27 18:20:38).

To be clear, this used to work, but does NOT work anymore:
form=SQLFORM.factory(Field('document', 'upload'))

This works on the current version:
form=SQLFORM.factory(Field('document', 'upload',
uploadfolder=os.path.join(request.folder,'uploads')))

The problem is dal.py around line 4900.  With SQLFORM.factory there is
no db._adapter.folder and, therefore, no path to specify a default
upload folder.  It also seems that dal.py doesn't assume, nor have,
access to the request?  Is there a way to restore the default for
SQLFORM.factory and maintain backward compatability?


On Mar 2, 11:23 am, Lisandro  wrote:
> Hi Carlos.
> Your solution worked perfectly. Though, I think this is a bug that has
> to be fixed in next version.
>
> Regards,
>   Lisandro.
>
> On 23 feb, 19:28, Carlos  wrote:
>
> > Hi Lisandro,
>
> > A workaround is to manually assign the following 'uploadfolder' value for
> > the 'upload' type fields in the 'define_table' statements:
>
> >    os.path.join(request.folder,'uploads')
>
> > I hope that helps.
>
> >    Carlos
>
>


[web2py] Re: prevent post on reload

2011-01-16 Thread Russell
This JavaScript will refresh the page without reposting the data:
window.location = window.location;


On Jan 17, 4:04 am, weheh  wrote:
> I'm using components, not typical web2py way of doing things.
>
> On Jan 16, 3:51 am, Kenneth Lundström 
> wrote:
>
> > But isn t web2py taking care of this already. Have you tried this double
> > posting? If you answer yes on browsers question do you get two sets of
> > answer in your database?
>
> > Kenneth
>
> > > That is my suspicion, too.
>
> > > On Jan 16, 2:59 am, Robby O'Connor  wrote:
> > >> I believe (somebody can correct me if i'm wrong) that this is a browser
> > >> issue.
> > >> On 1/16/2011 2:22 AM, weheh wrote:
>
> > >>> Anyone know how to prevent posting on reload? Right after submitting a
> > >>> form, if I reload, I'm always asked whether or not I want to re-post
> > >>> the previous form values. Is there a way to override this behavior?
> > >>> It's probably not a web2py issue, but maybe I'll get lucky ...
>
>


[web2py] Re: postgresql error ... (relation "auth_user" already exists)

2010-11-16 Thread Russell
Hi,

I've had this problem come up quite a few times.  It appears to be a
migration issue and is usually fixed by this...

auth.define_tables(migrate=False)

Thanks
Russell


On Nov 17, 8:48 am, Carlos  wrote:
> Hi Massimo,
>
> I'll send you the requested files if/when I get the error again (I
> deleted the previous ones).
>
> Btw it was not a custom auth_user.
>
> Johann, please send the files when you get this error too.
>
> Thanks,
>
>    Carlos
>
> On Nov 16, 7:06 am, mdipierro  wrote:
>
> > The error you are getting:
>
> > ProgrammingError: relation "auth_user" already exists
>
> > This is not a migration problem. The DB is not complaining about an
> > ALTER TABLE but about a CREATE TABLE.
>
> > This means your database/*_auth_user.table is either missing or
> > corrupted.
> > It would be useful to have steps to reproduce the problem.
>
> > Check in your database folder. You should have two of those files (one
> > for sqlite and one for postgresql). Can you send them to me? I am
> > assuming you have a custom auth_user. Can you send me that too?
>
> > Massimo
>
> > On Nov 16, 6:57 am, Carlos  wrote:
>
> > > So, based on Johann's confirmation, then this is a problem, isn't it?.
>
> > > Regards,
>
> > >    Carlos
>
> > > On Nov 16, 12:05 am, Johann Spies  wrote:
>
> > > > On 15 November 2010 18:17, Carlos  wrote:
>
> > > > > From what Johann said, I understood the table definitions were changed
> > > > > in web2py (using postgresql as the backend), not in postgresql
> > > > > directly ... or did I misunderstand it?.
>
> > > > Yes, that is what I meant.
>
> > > > Regards
> > > > Johann
> > > > --
> > > >  May grace and peace be yours in abundance through the full knowledge 
> > > > of God
> > > > and of Jesus our Lord!  His divine power has given us everything we 
> > > > need for
> > > > life and godliness through the full knowledge of the one who called us 
> > > > by
> > > > his own glory and excellence.
> > > >                                                     2 Pet. 1:2b,3a
>
>


[web2py] Re: build a row base questionnaire

2010-08-23 Thread Russell
A much more sophisticated solution Massimo!  I completely missed the
orderby='' functionality.

Going back to the original question, the point here is that when you
have a 'normalised' table of question/answers, you need to decouple
from SQLFORM (with SQLFORM.factory) and handle the db interactions
more explicitly.

On Aug 23, 2:31 pm, mdipierro  wrote:
> We need to clarify the goal. The goal is not to propose questions to
> the user. the goal is to check if he answers correctly. Should each
> correct answer be recorded for each user? should incorrect answers be
> recorded? Should the list of proposed questions be recored? Should a
> score be computed? What is the answer is "Darwin" and he answers
> "darwin" or "Charles Darwin"?
>
> Anyway, the above code can be simplified in:
>
> db.define_table('q_and_a',
>     Field('question'),
>     Field('answer'))
>
> def check(correct_answer,answer):
>     if correct_answer.lower() in answer.lower(): return 1
>     return 0
>
> def ask():
>     asked =
> db(db.q_and_a.id>0).select(orderby='',limitby=(0,3))
>     form=SQLFORM.factory(*[Field('a%s'%i, label = a.question) for i,a
> in enumerate(asked)])
>     if form.accepts(request.vars,session):
>            score = sum((check(a.answer,request.vars.get('a%s'%i,''))
> for i,a in enumerate(asked))
>            # do something with score
>     return dict(form=form)
>
> On Aug 22, 6:04 pm, Russell  wrote:
>
> > In my experience, it is a bit awkward to do this using SQLFORM.  You
> > could try something like this:
>
> > db.define_table('q_and_a',
> >     Field('question'),
> >     Field('answer'))
>
> > rows = db(db.q_and_a.id>0).select()
>
> > import random
> > random.seed()
> > asked = random.sample(rows, 3))
>
> > form=SQLFORM.factory(
> >     Field('asked_0', label = asked [0]['question']),
> >     Field('asked_1 ', label = asked [1]['question']),
> >     Field('asked_2 ', label = asked [2]['question']))
>
> > But this can create more problems than it solves.  Ultimately it might
> > be easier to put your questions in a wide table and use something like
> > Massimo proposed here:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/d0093fa190...
>
> > On Aug 20, 1:10 pm, dlin  wrote:
>
> > > Tks, Bruno.
> > > I seems haven't describe the 'row base' questionaire.
>
> > > That is:
>
> > > I've already a table like:
> > > Question Answer
> > > Q1...           A1
> > > Q2...           A2
> > > Q3...           A3
> > > ...
> > > Q13...           A1
>
> > > Then, I'll random choose three(or by customized) questions to ask.
>
> > > Question  Answer
> > > Q3.      
> > > Q8.      
> > > Q9.      
> > >  [submit]
>
> > > sometimes, it
> > > Question  Answer
> > > Q7.      
> > > Q9.      
> > > Q13.      
> > >  [submit]
>
> > > I think it is not proper to save it fixed on 3 field on table.
>
> > > I'm thinking should I use following steps:
> > > 1. SQLTABLE to select some random rows from my question and answer .
> > > 2. try to form a FORM() (I haven't idea now)
> > > 3. when user submit form, then try to compare the answer and store the
> > > scores of user in another table.
>
> > > On Aug 19, 7:54 am, Bruno Rocha  wrote:
>
> > > > You can use FORM(), and also use the table configuration to define
> > > > questions,
> > > > you can use the arguments "label" and "comment" on field definition.
>
> > > > After that, you can use CSS to improve the form layout.
>
> > > > You can't create a new field to store the login info and putting by 
> > > > default
> > > > the auth.user value?
>
> > > > 2010/8/18 dlin 
>
> > > > > I want a form like:
>
> > > > > Question  Answer
> > > > > Q1.      
> > > > > Q2.      
> > > > > Q3.      
> > > > > [submit]
>
> > > > > Q1,Q2,Q3 and correct answer is stored in a table.
> > > > > But the 'Answer' field should combined with login user's answer.
>
> > > > > What's the best way to display the form to user?
> > > > > Do you suggest use FORM() in control or use  in view?
>
> > > > --
>
> > > >http://rochacbruno.com.br


[web2py] Re: build a row base questionnaire

2010-08-22 Thread Russell
In my experience, it is a bit awkward to do this using SQLFORM.  You
could try something like this:

db.define_table('q_and_a',
Field('question'),
Field('answer'))

rows = db(db.q_and_a.id>0).select()

import random
random.seed()
asked = random.sample(rows, 3))

form=SQLFORM.factory(
Field('asked_0', label = asked [0]['question']),
Field('asked_1 ', label = asked [1]['question']),
Field('asked_2 ', label = asked [2]['question']))


But this can create more problems than it solves.  Ultimately it might
be easier to put your questions in a wide table and use something like
Massimo proposed here:

http://groups.google.com/group/web2py/browse_thread/thread/d0093fa1901b565e/ca664f76800cfbd7



On Aug 20, 1:10 pm, dlin  wrote:
> Tks, Bruno.
> I seems haven't describe the 'row base' questionaire.
>
> That is:
>
> I've already a table like:
> Question Answer
> Q1...           A1
> Q2...           A2
> Q3...           A3
> ...
> Q13...           A1
>
> Then, I'll random choose three(or by customized) questions to ask.
>
> Question  Answer
> Q3.      
> Q8.      
> Q9.      
>  [submit]
>
> sometimes, it
> Question  Answer
> Q7.      
> Q9.      
> Q13.      
>  [submit]
>
> I think it is not proper to save it fixed on 3 field on table.
>
> I'm thinking should I use following steps:
> 1. SQLTABLE to select some random rows from my question and answer .
> 2. try to form a FORM() (I haven't idea now)
> 3. when user submit form, then try to compare the answer and store the
> scores of user in another table.
>
> On Aug 19, 7:54 am, Bruno Rocha  wrote:
>
> > You can use FORM(), and also use the table configuration to define
> > questions,
> > you can use the arguments "label" and "comment" on field definition.
>
> > After that, you can use CSS to improve the form layout.
>
> > You can't create a new field to store the login info and putting by default
> > the auth.user value?
>
> > 2010/8/18 dlin 
>
> > > I want a form like:
>
> > > Question  Answer
> > > Q1.      
> > > Q2.      
> > > Q3.      
> > > [submit]
>
> > > Q1,Q2,Q3 and correct answer is stored in a table.
> > > But the 'Answer' field should combined with login user's answer.
>
> > > What's the best way to display the form to user?
> > > Do you suggest use FORM() in control or use  in view?
>
> > --
>
> >http://rochacbruno.com.br


[web2py] Re: Weird Behavior - Query returning zero rows when it should return all rows

2010-08-18 Thread Russell
Use 'T' or 'F' rather than 'True' of 'False'.  Web2py saves boolean
data as 'char' with length 1.

On Aug 19, 1:49 am, Narendran  wrote:
> Hi,
> I added a new boolean field to a table. And I manually updated the
> value of the field outside web2py. Now, I get zero rows for any
> condition I put on that field. Please see the following shell output
> for an idea:
>
> In [7]:  offers = db(db.OFFER.IS_PRICE_COMPARED == False).select()
>    ...:
>
> In [8]: len(offers)
> Out[8]: 0   #<-- This is not expected. It should return all the
> rows
>
> In [9]:  offers = db(db.OFFER.IS_PRICE_COMPARED == True).select()
>    ...:
>
> In [10]: len(offers)
> Out[10]: 0
>
> In [11]:  offers = db().select(db.OFFER.IS_PRICE_COMPARED)
>    :
>
> In [12]: len(offers)
> Out[12]: 668
>
> In [13]: offers[0]
> Out[13]:  ##<-- Notice the value
> being False here
>
> In [14]: offers[1]
> Out[14]: 


[web2py] Re: upload bug in filename

2010-06-24 Thread Russell
As an aside, the mixing of \\ and  / is unsightly but does not seem to
cause a problem on widows.  If you want to tidy it up, it's around
line 786 of main.py:

request.folder = os.path.join(request.env.web2py_path,
'applications', request.application) + '/'



On Jun 25, 11:15 am, Yarko Tymciurak 
wrote:
> By the way -
>
> The filename in the upload directory was 194 characters --- it's
> entirely possible that windows was having trouble with this.
>
> Here is the listing of my test  uploads directory (the first was just
> a 'normal' length file):
>
> -rw-r--r--  1 yarko  staff   2642 Jun 24 17:33 test.file.
> 880c7c46ee30a1ad.696e6465782e68746d6c.html
> -rw-r--r--  1 yarko  staff  16624 Jun 24 17:40 test.file.
> 96aded454eba1b88.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e6a7067.jpg
> -rw-r--r--  1 yarko  staff  16624 Jun 24 17:45
> test.file.a500ba489526de41.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e6a7067.jpg
>
> Here's the paths to the links from web2py db admin (as you can see -
> all the paths are correctly formed):
>
> http://localhost:8000/test/appadmin/download/db/test.file.880c7c46ee3...http://localhost:8000/test/appadmin/download/db/test.file.96aded454eb...http://localhost:8000/test/appadmin/download/db/test.file.a500ba48952...
>
> Regards,
> - Yarko
>
> On Jun 23, 3:15 am, Swell  wrote:
>
> > Ok
> > I will post some code here to show as much as possible
>
> > here is the db definition:
>
> > db.define_table('papers',
> >   Field('title','string'),
> >   Field('author','string'),
> >   Field('file','upload'),
> >   )
>
> > then if i try to use the database administration tool available in
> > Models section and try to insert a file like
> > "The Pricing of Options and Corporate Liabilities_Journal of Political
> > Economy.pdf" i then get a ticket complaining about
>
> > IOError: [Errno 2] No such file or directory:
> > C:\\Users\\M\\Desktop\\web2py_src\\web2py\\applications\\Library/
> > databases\\..\\uploads\
> > \papers.file.a33b16f5af29f6d8.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e706466.pdf'
>
> > i also checked the file actually has never been properly uploaded ( it
> > is not present in the upload directory). Nothing special about size of
> > the file ( if i just  change manually the filename it works ). So it
> > seems that the bug is when we receiving the file .
>
> > hope we can sort this out
> > Thx all
> > M


[web2py] Re: dynamically growing form?

2010-06-23 Thread Russell
I would create a form with all 10 rows, hide all but the first 2 rows,
and then use jquery to progressively display the rest of the rows.
Add something like this to each of the rows...

form.element(_id=this_reference_id).append( A(' add', _href='#',
_onclick="jQuery('#%s').show()" % next_reference_id))



On Jun 23, 1:38 pm, Doug Warren  wrote:
> I started writing this a few times but I kept deleting it as I wasn't
> very clear so I'll try again.
>
> I'm looking to create a form that has some tabular data in it, 2
> columns, but the trick is that each submission of the form will have
> between 2-10 rows.  Each submission represents a single working set
> that can be edited later to have rows added/deleted.  And the rows
> have an order.  What I'm looking for basically is a table that starts
> out with 2 rows, 2 columns and a submit button, next to each row is a
> +/- button, if you hit the + button a new row will be added to the
> table below the row you hit the + on.  If you hit - the row you hit
> the - on would be removed from the form.  On submission all the rows
> would be added to the database and a crud form could be used to go
> back and edit the table again even deleting/adding rows.
>
> Is there any slice or best practice that will do this?  I was thinking
> something with JQuery tabular plugin but not sure how to handle the
> creation/deletion of rows part.


  1   2   >