[web2py] How do I post an image to web2py from HTML5 Canvas

2013-12-02 Thread Michael Hall
If I have the following model:

db.define_table('user_images',
Field('my_image', 'upload',
  label=T('My Image')),
)

and In my rendered html view I have a canvas, the canvas has produced an 
image saved in the variable 
document.getElementById('canvas').src = dataURL;

Underneath the image is an upload button, I wish to POST the canvas image 
to images.myimage when the button is pressed and then move to a new view 
and controller which displays the uploaded image and has some more editing 
options.

What is the best way to achieve this? Is it possible to render a sqlform 
that only has a button which when pressed uploads dataURL and redirects to 
the next controller/view?


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


[web2py] Re: Selecting records that are not referenced by other records.

2013-09-25 Thread Michael Hall
Hey guys this works a treat and I have learned something new. Thanks for 
the help.

On Tuesday, 24 September 2013 11:16:52 UTC+1, Michael Hall wrote:
>
> I am not the most awesome SQL person and as such I am having trouble 
> constructing a query I need.
>
> I have two tables in a database called "old". The parent table is called 
> "members" and there is a child table called "courses".
>
> #
> old.define_table('members',
> Field('id'),
> Field('profile_id','string'),
> Field('title','string'),
> Field('firstname','string'),
> Field('surname','string'),
> Field('memberlevel','string'),
> Field('lawfirm','string'),
> Field('registerdate','date'),
> Field('expirydate','date'),
> Field('email','string'),
> Field('telno','string'),
> Field('address1','string'),
> Field('address2','string'),
> Field('address3','string'),
> Field('town','string'),
> Field('county','string'),
> Field('postcode','string'),
> Field('country','string'),
> Field('notes','text'),
> Field('memberstatus','string'),
> migrate=False)
>
> old.define_table('courses',
> Field('memberid',type='reference members',),
> Field('profile_id','string'),
> Field('course','string'),
> Field('enroldate','string'),
> migrate=False)
>
> I would like to select all records in the members table that are not 
> referenced by records in the courses table. I suppose it could be described 
> as the opposite of a join as I only want to select members that do not have 
> courses attached to them.
>
> Any help would be appreciated.
>
>
>

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


[web2py] Selecting records that are not referenced by other records.

2013-09-24 Thread Michael Hall
I am not the most awesome SQL person and as such I am having trouble 
constructing a query I need.

I have two tables in a database called "old". The parent table is called 
"members" and there is a child table called "courses".

#
old.define_table('members',
Field('id'),
Field('profile_id','string'),
Field('title','string'),
Field('firstname','string'),
Field('surname','string'),
Field('memberlevel','string'),
Field('lawfirm','string'),
Field('registerdate','date'),
Field('expirydate','date'),
Field('email','string'),
Field('telno','string'),
Field('address1','string'),
Field('address2','string'),
Field('address3','string'),
Field('town','string'),
Field('county','string'),
Field('postcode','string'),
Field('country','string'),
Field('notes','text'),
Field('memberstatus','string'),
migrate=False)

old.define_table('courses',
Field('memberid',type='reference members',),
Field('profile_id','string'),
Field('course','string'),
Field('enroldate','string'),
migrate=False)

I would like to select all records in the members table that are not 
referenced by records in the courses table. I suppose it could be described 
as the opposite of a join as I only want to select members that do not have 
courses attached to them.

Any help would be appreciated.


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


[web2py] Re: Trouble Updating to 2.6.4 from 2.5.1

2013-09-24 Thread Michael Hall
What worked for me when this happened was simply to download the latest 
source of the site and unzip it to my web2py folder thus overwriting the 
incomplete upgrade. I restart web2py or in the case of my webfaction server 
I restart apache which restarts web2py and then everything works as normal 
again.

On Sunday, 22 September 2013 21:22:44 UTC+1, arche...@gmail.com wrote:
>
> When I try to update from 2.5.1 to 2.6.4, the admin is no longer 
> operational (shows a ticket that is inaccessible due to the admin no longer 
> being functional). Is there any fix for this? I am not sure where the error 
> logs are held. I'm running Mint x86; not sure what other information might 
> be relevant.
>  
>

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


[web2py] Changelog for 2.6.3?

2013-09-18 Thread Michael Hall
Hiya

Is there a changelog for 2.6.3 I just updated this morning and had an issue 
with an experimental virtual field for sqlform.smartgrid. I removed the 
field and everything worked fine and the overall speed of the app has 
improved. I am interested to know if you have removed this experimental 
support for performance reasons.

Mike

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


[web2py] Re: DAL performance vs executesql

2013-06-24 Thread Michael Hall
Was there ever a fully working solution proposed or discovered for using 
executesql with grid and smartgrid?

On Friday, 22 June 2012 07:54:05 UTC+1, pbreit wrote:
>
> I have an app where I pull down 5,000 records. I started with DAL and 
> db.item.ALL and it was taking around 4 seconds. I added 5 fields to the 
> select() which got it down to around 2 seconds. Then I implemented the same 
> thing with executesql and got it down to 500 ms.
>
> So, selecting only the fields you need is a good optimization. But going 
> with raw SQL is much better.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.Smartgrid and with parent table in Linked Tables

2013-04-29 Thread Michael Hall
Doh did it again, its been a long day, the model with the correct reference 
is 

db.define_table(
'contact',
Field <http://www.web2py.com/examples/global/vars/Field>('name'),
Field <http://www.web2py.com/examples/global/vars/Field>('address'),
format = '%(name)s')

db.define_table(
'courses',
Field 
<http://www.web2py.com/examples/global/vars/Field>('student_id',db.contact),
Field <http://www.web2py.com/examples/global/vars/Field>('course_name'),
Field <http://www.web2py.com/examples/global/vars/Field>('pass_mark', 
'text'),
format = '%(name)s')



On Monday, 29 April 2013 13:32:10 UTC+1, Michael Hall wrote:
>
> I would like to have a smartgrid that references its parent table in 
> linked_tables, what is the web2py way of doing this? I have found some help 
> in this thread: 
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/vDGJdct550Qbut the 
> solution is a bit sketchy due to it modifying sqlhtml.py.
>
> Lets take this model:
>
> db.define_table(
> 'contact',
> Field <http://www.web2py.com/examples/global/vars/Field>('name'),
> Field <http://www.web2py.com/examples/global/vars/Field>('address'),
> format = '%(name)s')
>
> db.define_table(
> 'courses',
> Field 
> <http://www.web2py.com/examples/global/vars/Field>('student_id',db.person),
> Field <http://www.web2py.com/examples/global/vars/Field>('course_name'),
> Field <http://www.web2py.com/examples/global/vars/Field>('pass_mark', 
> 'text'),
> format = '%(name)s')
>
>
>
> I want a smartgrid for courses that shows all the courses records and has 
> the contact table in linked tables. That way I have an easy way to view all 
> course data and easily check out the contact data of the person doing the 
> course. This smartgrid is used by people who mark courses and require quick 
> access to the data in the courses table without having to go via the 
> "contact" table.
>
> In a perfect world I would create this smartgrid like so:
> def courseview():
> form = SQLFORM.smartgrid(db.courses,linked_tables=['contact'])
> return locals()
>
> However this does not work because the contact table is the parent.
>
> What is the best way of achieving my required result?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.Smartgrid and with parent table in Linked Tables

2013-04-29 Thread Michael Hall

My bad, the model in my example should be:

db.define_table(
'contact',
Field <http://www.web2py.com/examples/global/vars/Field>('name'),
Field <http://www.web2py.com/examples/global/vars/Field>('address'),
format = '%(name)s')

db.define_table(
'courses',
Field 
<http://www.web2py.com/examples/global/vars/Field>('student_id',db.person),
Field <http://www.web2py.com/examples/global/vars/Field>('course_name'),
Field <http://www.web2py.com/examples/global/vars/Field>('pass_mark', 
'text'),
format = '%(name)s')


On Monday, 29 April 2013 13:32:10 UTC+1, Michael Hall wrote:
>
> I would like to have a smartgrid that references its parent table in 
> linked_tables, what is the web2py way of doing this? I have found some help 
> in this thread: 
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/vDGJdct550Qbut the 
> solution is a bit sketchy due to it modifying sqlhtml.py.
>
> Lets take this model:
>
> db.define_table(
> 'contact',
> Field <http://www.web2py.com/examples/global/vars/Field>('name'),
> Field <http://www.web2py.com/examples/global/vars/Field>('address'),
> format = '%(name)s')
>
> db.define_table(
> 'courses',
> Field 
> <http://www.web2py.com/examples/global/vars/Field>('student_id',db.person),
> Field <http://www.web2py.com/examples/global/vars/Field>('course_name'),
> Field <http://www.web2py.com/examples/global/vars/Field>('pass_mark', 
> 'text'),
> format = '%(name)s')
>
>
>
> I want a smartgrid for courses that shows all the courses records and has 
> the contact table in linked tables. That way I have an easy way to view all 
> course data and easily check out the contact data of the person doing the 
> course. This smartgrid is used by people who mark courses and require quick 
> access to the data in the courses table without having to go via the 
> "contact" table.
>
> In a perfect world I would create this smartgrid like so:
> def courseview():
> form = SQLFORM.smartgrid(db.courses,linked_tables=['contact'])
> return locals()
>
> However this does not work because the contact table is the parent.
>
> What is the best way of achieving my required result?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 and with parent table in Linked Tables

2013-04-29 Thread Michael Hall
I would like to have a smartgrid that references its parent table in 
linked_tables, what is the web2py way of doing this? I have found some help 
in this thread: 
https://groups.google.com/forum/?fromgroups=#!topic/web2py/vDGJdct550Q but 
the solution is a bit sketchy due to it modifying sqlhtml.py.

Lets take this model:

db.define_table(
'contact',
Field ('name'),
Field ('address'),
format = '%(name)s')

db.define_table(
'courses',
Field 
('student_id',db.person),
Field ('course_name'),
Field ('pass_mark', 
'text'),
format = '%(name)s')



I want a smartgrid for courses that shows all the courses records and has 
the contact table in linked tables. That way I have an easy way to view all 
course data and easily check out the contact data of the person doing the 
course. This smartgrid is used by people who mark courses and require quick 
access to the data in the courses table without having to go via the 
"contact" table.

In a perfect world I would create this smartgrid like so:
def courseview():
form = SQLFORM.smartgrid(db.courses,linked_tables=['contact'])
return locals()

However this does not work because the contact table is the parent.

What is the best way of achieving my required result?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] On a Smartgrid form is it possible to set create to False for parent nodes but true for child nodes

2013-03-11 Thread Michael Hall
My tables are:
t_contact (the parent)
t_paypal
t_paypal_fails
t_paypal_contacted

All the child tables refer to the parents ID.

I have a controller that looks like this:

@auth.requires_login()
def paypal_manage():
form = 
SQLFORM.smartgrid(db.t_contact,linked_tables=['t_paypal','t_paypal_fails', 
't_paypal_contacted'], onupdate=auth.archive,searchable=dict(parent=True, 
child=True,))
return locals()

Using smartgrid I wish to achieve  a grid that allows the user to search by 
contact but not actually add contacts via that controller. Once they have 
found the contact they should be able to create records for the contacts's 
linked tables.

I was thinking that it would be something like this:
create=dict(parent=True, child=False)

Is this possible? If so what is the correct syntax?

Many thanks in advance.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.grid joins and view/edit

2012-12-17 Thread Michael Hall
Just bumping this as I am still struggling with view and edit for joined 
SQLFORM.grid's

On Wednesday, 28 November 2012 11:17:36 UTC, Michael Hall wrote:
>
> I have a SQLFORM.grid with a join, however when I insert, edit or update a 
> record displayed in the grid I am only ever given a form for the parent 
> table.
>
> What is the preferred method for creating insert, update and delete forms 
> for a joined SQLFORM.grid? Common sense tells me that it is the method 
> outlines in chapter 7: "One form for multiple tables" but this uses form 
> factory which to my noobish eyes does not seem to cover updating the same 
> way as vanilla SQLFORM in chapter 7's "SQLFORM and insert/update/delete"
>
> Can I create multi table update forms with either of these?
>
> Thanks in Advance
>
> Mike
>

-- 





[web2py] SQLFORM.grid joins and view/edit

2012-11-28 Thread Michael Hall
I have a SQLFORM.grid with a join, however when I insert, edit or update a 
record displayed in the grid I am only ever given a form for the parent 
table.

What is the preferred method for creating insert, update and delete forms 
for a joined SQLFORM.grid? Common sense tells me that it is the method 
outlines in chapter 7: "One form for multiple tables" but this uses form 
factory which to my noobish eyes does not seem to cover updating the same 
way as vanilla SQLFORM in chapter 7's "SQLFORM and insert/update/delete"

Can I create multi table update forms with either of these?

Thanks in Advance

Mike

-- 





[web2py] Re: SQLFORM.grid join repeats parent's data in table.

2012-11-23 Thread Michael Hall
Hiya

This works a treat thanks.

Mike

On Thursday, 22 November 2012 14:32:38 UTC, Alan Etkin wrote:
>
> > On Thursday, November 22, 2012 9:07:23 AM UTC-3, Michael Hall wrote:I 
> have the following code for my join in SQLFORM.grid:
>
> Perhaps you can pass something like this to .grid():
>
> fields=[firsttable.field1, secondtable.field2, ...]
>
> to prevent repeating the columns in the form table
>
>

-- 





Re: [web2py] Re: Extracting row id from url using request.args

2012-11-20 Thread Michael Hall
In the end I have used a different slightly more messy approach. I am 
getting the record id from the args by using a conditional to test if it is 
in one of 2 possible positions.

@auth.requires_login()
def contact_manage():
form = 
SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses','t_membership','t_paypal'],
 
onupdate=auth.archive, formname="Contact Manager")
if request.args(2) == 't_contact':
memberId = request.args(3)
else:
memberId = request.args(2)

return locals()

I looked into fetching it using similar code to your link function but it 
seems you can only request the id of the current record using 
db.t_contact.id from within the parameters of your SQLFORM.smartgrid 
request.

Its a dirty hack but it seems to work.

Mike

On Tuesday, 20 November 2012 07:15:22 UTC, Johann Spies wrote:
>
> On 19 November 2012 14:58, Michael Hall >wrote:
>
>> Hi Villas
>>
>> I like the idea of using a var instead of args but I am still uncertain 
>> of how I get the ID of the current record I am viewing/editing in smartgrid.
>>
>>
> Here is an example of code I am using where 'auid' represents the id of 
> the author record:
>
>   links = [lambda row: (A(B(T('Edit')), _target = "_blank",
> _href = URL(r = request,
> c = 'authors',
> f = 'edit_author',
> vars = dict(auid = str(row[
> db.akb_authors.id])]
> query = ...
> fields = [list of fields]
>
> I then call the grid with SQLFORM.grid(query, fields=fields, links=links)
>
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





[web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread Michael Hall
Hi Villas

I like the idea of using a var instead of args but I am still uncertain of 
how I get the ID of the current record I am viewing/editing in smartgrid.

Mike

On Monday, 19 November 2012 08:57:09 UTC, villas wrote:
>
> If you cannot control the order of args,  you could still look for an 
> int,  but that may not always be reliable.  I sometimes decide to use vars 
> instead.  Then you know exactly what you have:  your/url/here?id=1234
> Construction of the url is easy using the URL helper.
>
> On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>>
>> I am using smartgrid for the membership database I am building.
>>
>> I have 3 tables, contact (the members contact details and name), courses 
>> (any courses the member is doing with us) and membership (the users 
>> membership details).
>>
>> I am using conditionals to present customised view of the generated forms 
>> tables and records, basically a little dashboard that will sit above the 
>> contact/member/course details giving an overview of that contact. However I 
>> am struggling to extract the row id for the contact in order to pull up 
>> data for my dashboard.
>>
>> The following is the URL I get when viewing a contact with the id 11: 
>> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>>
>> On this particular url I can get the id using:
>> request.args(2)
>>
>> However the postion of the id is not the same on every page  for example 
>> when I view another contact (12) I get this URL:
>>
>> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>>
>> The argument with the position 2 is t_contact not 12.
>>
>> Is there some voodoo I can use to get the id of the entry in order to use 
>> it to pull up data from other tables?
>>
>> FYI I have included a snippet from the controller and corresponding view.
>>
>> Controller code:
>>
>> @auth.requires_login()
>> def contact_manage():
>> memberId = request.args(2)
>> form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
>> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
>> Manager")
>> return locals()
>>
>> View Code:
>>
>> {{extend 'layout.html'}}
>>
>> {{if 'view' in request.args:}}
>> Do something with {{=memberId}}
>> Manage Contact{{=form}}
>> {{else:}}
>> Manage Contact{{=form}}
>> {{pass}}
>>
>> Thanks in advance.
>>
>> Mike
>>
>

-- 





[web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread Michael Hall
Hi Villas

I like the idea of getting the ID from a var instead of args, however I am 
still not sure how to go about getting the ID of the current record I am 
viewing/editing in smartgrid.

Forgive my noobishness.

M

On Monday, 19 November 2012 08:57:09 UTC, villas wrote:
>
> If you cannot control the order of args,  you could still look for an 
> int,  but that may not always be reliable.  I sometimes decide to use vars 
> instead.  Then you know exactly what you have:  your/url/here?id=1234
> Construction of the url is easy using the URL helper.
>
> On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>>
>> I am using smartgrid for the membership database I am building.
>>
>> I have 3 tables, contact (the members contact details and name), courses 
>> (any courses the member is doing with us) and membership (the users 
>> membership details).
>>
>> I am using conditionals to present customised view of the generated forms 
>> tables and records, basically a little dashboard that will sit above the 
>> contact/member/course details giving an overview of that contact. However I 
>> am struggling to extract the row id for the contact in order to pull up 
>> data for my dashboard.
>>
>> The following is the URL I get when viewing a contact with the id 11: 
>> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>>
>> On this particular url I can get the id using:
>> request.args(2)
>>
>> However the postion of the id is not the same on every page  for example 
>> when I view another contact (12) I get this URL:
>>
>> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>>
>> The argument with the position 2 is t_contact not 12.
>>
>> Is there some voodoo I can use to get the id of the entry in order to use 
>> it to pull up data from other tables?
>>
>> FYI I have included a snippet from the controller and corresponding view.
>>
>> Controller code:
>>
>> @auth.requires_login()
>> def contact_manage():
>> memberId = request.args(2)
>> form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
>> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
>> Manager")
>> return locals()
>>
>> View Code:
>>
>> {{extend 'layout.html'}}
>>
>> {{if 'view' in request.args:}}
>> Do something with {{=memberId}}
>> Manage Contact{{=form}}
>> {{else:}}
>> Manage Contact{{=form}}
>> {{pass}}
>>
>> Thanks in advance.
>>
>> Mike
>>
>

--