[web2py] Re: 1215 Cannot add foreign key constraint

2019-09-11 Thread Steve
Hi Dave,

Thanks for your reply.
When starting web2py again the DAL tries to create the tables but none of 
the tables are being created due to this error.
Using a clean new version of a web2py app the tables are created and are  
of type innodb  storage engine( as mentioned in the page you sent).

I am still no step further with solving this issue.

Steve

Op woensdag 11 september 2019 10:35:22 UTC+2 schreef Dave S:
>
>
>
> On Tuesday, September 10, 2019 at 2:58:06 PM UTC-7, Steve wrote:
>>
>> Goodevening,
>>
>> I am trying to migrate from Sqite to MySQL.
>> Unfortunatly when restoring the field in the DB tables i get the 
>> following error: 
>>  (1215, u'Cannot add 
>> foreign key constraint')
>> location of issue: Field('Insurance',db.insurance,label=T('Insurance')),
>>
>> When i look this up in google  this could be caused by  a Field which 
>> has the reuirement= Not NULL but has no Default value set.
>> I tested this but not able to get passed the error.
>>
>> *first table with field in db1.py*
>>
>> db.define_table('insurance',
>> 
>> Field('Company',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Company')),
>> Field('Insurance_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),  
>> label=T('Insurance Number')),
>> Field('Street_name', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Street 
>> Name')),
>> Field('House_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('House 
>> Number')),
>> Field('Postal_code','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),label=T('Postal 
>> Code')),
>> Field('City','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('City')),
>> Field('Region','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Region')),
>> Field('Country','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Country')),
>> Field('Telephone_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Telephone 
>> Number')),
>> Field('Mobile','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Mobile')),
>> Field('Email','string', 
>> requires=IS_EMAIL(error_message='invalid email! Please fill in a correct 
>> e-mail address.'), label=T('Email')),
>> auth.signature, format='%(Company)s',fake_migrate=True)
>>
>> *Second table which in a db2.py:*
>>
>> db.define_table('client',
>> 
>> Field('Debtor_nr',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Debtor number')),
>> Field('Insurance',db.insurance,label=T('Insurance')), --> 
>> this 
>> is where the first issue takes place
>>
>> Where should i add a default value ? to et this issue fixed
>>
>> Hope you can help me with this
>>
>> Steve
>>
>
> This page has different diagnoses than you mention:
>  https://www.rathishkumar.in/2016/01/solved-how-to-solve-mysql-error-code.html
> >
>
> There, the issue with NULL is that the foreign key can't be NULL if it is 
> part of the child table's primary key.
>
> Another way to get the error is to use a different mysql storage engine 
> than innodb.
>
> Yet another way is to not have a unique key in the table, but since you're 
> using a model file to describe the parent table, the DAL should have 
> handled that, and also made sure that the parent and child agree on what 
> the key is.
>
> As a first step, use your mysql console or dbclient to display the schema 
> used for the insurance table.  (I can't tell you how to do that, because 
> I use sqlite and postgres, not mysql, so I know two incantations but they 
> probably don't match what you need).
>
> Good luck!
>
> /dps
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2e2fc51b-5120-47e6-99a8-dd0fbca276a4%40googlegroups.com.


[web2py] Re: 1215 Cannot add foreign key constraint

2019-09-11 Thread Steve
Hi Dave,

After performing a Fake_migration_all=True the Db files where created in de 
app/databases folder.
So, in de admin i can see all of the tables.

But, unfortunatly the tables where NOT created in the MySQL database.
I can't find ou why not or how to fix this.

Already went to the document about broken migrations but no luck yet.
The exact error: ProgrammingError: (1146, u"Table 'abc' doesn't exist")

Any idea's how to fix this

regards,

Steve
Op woensdag 11 september 2019 10:35:22 UTC+2 schreef Dave S:
>
>
>
> On Tuesday, September 10, 2019 at 2:58:06 PM UTC-7, Steve wrote:
>>
>> Goodevening,
>>
>> I am trying to migrate from Sqite to MySQL.
>> Unfortunatly when restoring the field in the DB tables i get the 
>> following error: 
>>  (1215, u'Cannot add 
>> foreign key constraint')
>> location of issue: Field('Insurance',db.insurance,label=T('Insurance')),
>>
>> When i look this up in google  this could be caused by  a Field which 
>> has the reuirement= Not NULL but has no Default value set.
>> I tested this but not able to get passed the error.
>>
>> *first table with field in db1.py*
>>
>> db.define_table('insurance',
>> 
>> Field('Company',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Company')),
>> Field('Insurance_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),  
>> label=T('Insurance Number')),
>> Field('Street_name', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Street 
>> Name')),
>> Field('House_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('House 
>> Number')),
>> Field('Postal_code','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),label=T('Postal 
>> Code')),
>> Field('City','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('City')),
>> Field('Region','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Region')),
>> Field('Country','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Country')),
>> Field('Telephone_number','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Telephone 
>> Number')),
>> Field('Mobile','string', 
>> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Mobile')),
>> Field('Email','string', 
>> requires=IS_EMAIL(error_message='invalid email! Please fill in a correct 
>> e-mail address.'), label=T('Email')),
>> auth.signature, format='%(Company)s',fake_migrate=True)
>>
>> *Second table which in a db2.py:*
>>
>> db.define_table('client',
>> 
>> Field('Debtor_nr',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
>> label=T('Debtor number')),
>> Field('Insurance',db.insurance,label=T('Insurance')), --> 
>> this 
>> is where the first issue takes place
>>
>> Where should i add a default value ? to et this issue fixed
>>
>> Hope you can help me with this
>>
>> Steve
>>
>
> This page has different diagnoses than you mention:
>  https://www.rathishkumar.in/2016/01/solved-how-to-solve-mysql-error-code.html
> >
>
> There, the issue with NULL is that the foreign key can't be NULL if it is 
> part of the child table's primary key.
>
> Another way to get the error is to use a different mysql storage engine 
> than innodb.
>
> Yet another way is to not have a unique key in the table, but since you're 
> using a model file to describe the parent table, the DAL should have 
> handled that, and also made sure that the parent and child agree on what 
> the key is.
>
> As a first step, use your mysql console or dbclient to display the schema 
> used for the insurance table.  (I can't tell you how to do that, because 
> I use sqlite and postgres, not mysql, so I know two incantations but they 
> probably don't match what you need).
>
> Good luck!
>
> /dps
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/3a3f9919-0ced-491f-9a89-6e5db99059da%40googlegroups.com.


[web2py] Re: Whats the best way to create an Android or iOS app for web2py project

2019-09-11 Thread Pbop
Suggest you google NSB/App Studio. A simple easy to use tool to create 
native iphone/droid apps. Other tools out there of course, but this has a 
manageable learning curve, Use Web2Py or Py4Web for server side back-end. 

On Friday, September 6, 2019 at 7:28:30 AM UTC-4, Rahul wrote:
>
> Hey Everyone,
>  I have some interesting questions (It might have been asked before) I 
> want to know - 
>
> 1) Whats the best way to create an Android or iOS app for web2py project? 
>
> 2) How can we access a postgres database residing on linux server for a 
> web2py application from such an application?
>
> 3) Can we use python to write such apps?
>
> 4) Has anyone written any apps that do the above successfully?
>
>
> Rahul
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e4c72007-22b1-4d50-a663-77e097e31114%40googlegroups.com.


[web2py] Re: How to stopped redirection to user/login.html

2019-09-11 Thread Patito Feo
Hi,

I had done tests using a new empty application and this works. 
My current application uses a customdb auth table and its using 

auth.settings.on_failed_authentication = lambda url: redirect(url)


but with custom tables settings do not apply.


Regards,



El jueves, 22 de agosto de 2019, 19:01:04 (UTC-5), Dave S escribió:
>
> On Thursday, August 22, 2019 at 4:32:02 PM UTC-7, Patito Feo wrote:
>>
>> Hi,
>>
>> This does not worked.
>> Redirecting still goes to user/login.html.
>>
>> Any ideas?
>>
>> Cheers,
>>
>
>
> For a little more context, here's a larger quote form the book:
>
> If the visitor is not logger in, and calls a function that requires 
>> authentication, the user is redirected to auth.settings.login_url which 
>> defaults to URL('default', 'user/login'). One can replace this behavior by 
>> redefining:
>>
>> auth.settings.on_failed_authentication = lambda url: redirect(url)
>> This is the function called for the redirection. The argument url` passed 
>> to this function is the url for the login page.
>>
>> If the visitor does not have permission to access a given function, the 
>> visitor is redirect to the URL defined by
>>
>> auth.settings.on_failed_authorization = URL('user', 
>> args='on_failed_authorization')
>> You can change this variable and redirect the user elsewhere.
>>
>> Often on_failed_authorization is a URL but it can be a function that 
>> returns the URL and it will be called on failed authorization.
>>
>
>
> from  http://web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages
> >
>
> Good luck!
>
> /dps
>  
>
>>
>> El jueves, 22 de agosto de 2019, 0:44:39 (UTC-5), Annet escribió:
>>>
>>> What about:
>>>
>>> auth.settings.on_failed_authentication = lambda url: redirect(url)
>>>
>>>
>>> That is what the book says changing the default behaviour.
>>>
>>>
>>> Kind regards,
>>>
>>> Annet
>>>
>>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/547cb1b3-0856-4dce-93d0-42340edf13fa%40googlegroups.com.


[web2py] Re: How can I update the record in one table with value entry of another table as soon as the value is entered?

2019-09-11 Thread Dave S


On Tuesday, September 10, 2019 at 2:54:43 AM UTC-7, mostwanted wrote:
>
> I figured if I could update the amount field in db.product within the buy 
> functiontion just around the same time i'm saving inside the db.sale table 
> when purchasing then it should be easy but I am having a really hard time 
> identifying only the purchased items by their ids & subtracting their 
> quantities from similar items in db.product!
>

Don't you record the id of the item in your shopping cart?
 

>
> The code below is able to update the amount in db.product but it updates 
> for all products which is not what i want
> CODE SAMPLE 1:
> for item1 in item1:
> diff=item1.amount-value
>

I don't think you want this line:   

> db(db.product.amount).update(amount=diff)
>
I think it is selecting everything in db.product that has an amount.

Once you figure out how to get the id from your shopping cart, the line 
should probably be

db(db.product.id == cart_item.id).update(amount=diff)




 

> Then i made another desperate attempt with the code below but it is not 
> updating anything at all!
> for item1 in item1:
> for id, k in session.cart.items():
> if item1.id==k:
> diff=item1.amount-value
> db(db.product.amount).update(amount=diff)
>
> Anyone who can do this better please help.
>
> Regards;
>
> Mostwanted
>

/dps
 

>
> On Thursday, September 5, 2019 at 8:21:56 AM UTC+2, Dave S wrote:
>>
>>
>>
>> On Wednesday, September 4, 2019 at 10:59:21 PM UTC-7, mostwanted wrote:
>>>
>>> I have a website where I am selling items, what I desperately want to 
>>> achieve is to be able to show the buyers the remaining number of each item. 
>>> I have 2 tables, the table that has all the items being sold & has a field 
>>> amount which is the current number of items in stock and the other 
>>> table which records sales as customers buy and has a field quantity 
>>> which is the quantity of items purchased. After a customer has made a 
>>> purchase I want to be able to subtract quantity from amount and have 
>>> difference update and be the new value for amount.
>>>
>>> I wrote some controller code which is not achieving this, it is instead 
>>> updating the amount field for all items with the same figure.
>>>
>>>
>>> THE VIEW
>>>
>>> {{extend 'layout.html'}}
>>>
>>> 
>>> {{for p in products:}}
>>> {{if p.product_type=="Earrings":}}
>>> 
>>> {{=p.name}}
>>> {{=p.amount}} available in stock
>>> 
>>> {{=MoneyFormat(p.price)}}
>>> 
>>> >> height="200px"/>
>>> 
>>> {{=session.cart.get(p.id,0)}} in cart - {{=A('add to 
>>> cart',callback=URL('cart_callback',vars=dict(id=p.id,action='add')),target='item%s'%p.id,_class='button
>>>  pill')}}
>>> 
>>> Click 
>>> the image to enlarge
>>> 
>>> 
>>> {{pass}}
>>>
>>> {{pass}}
>>> 
>>>
>>>
>>> THE CART_CALLBACK FUNCTION
>>>
>>>
>>> def cart_callback():
>>> id = int(request.vars.id)
>>> if request.vars.action == 'add':
>>> session.cart[id]=session.cart.get(id,0)+1
>>> if request.vars.action == 'sub':
>>> session.cart[id]=max(0,session.cart.get(id,0)-1)
>>> return str(session.cart[id])
>>>
>>>
>>> MY FUNCTION FOR UPDATING AFTER PURCHASES
>>>
>>> def index():
>>> if not auth.user:
>>> response.flash=T('PLEASE LOG IN FIRST TO BE ABLE TO GET THE MENU 
>>> AND BUY')
>>> products = db(db.product).select(orderby=db.product.name)
>>> num=db(db.sale).select()
>>> for n in num:
>>> quantity=n.quantity
>>> if quantity is None:
>>> quantity=0
>>> for p in products:
>>> amount1=p.amount-quantity
>>> db(db.product.amount).update(amount=amount1)
>>> return locals()
>>>
>>>
>>> What should happen is that every time a customer buys whatever number of 
>>> items a new figure showing reduction in number of items should be displayed.
>>>
>>>
>>> Regards;
>>>
>>>
>>> Mostwanted
>>>
>>>
>>>
>> index() looks like it spends a great deal of time subtracting everything 
>> in sales from everything in products.
>>
>> I think you are recording the product id in the cart.  Are you then (on 
>> check-out, I presume) recording the product id in db.sales?
>>
>> if so , then you don't need the select() on all products.
>> Instead, use the product id in each row of db.sales to select the product 
>> entry to update.
>>
>> You probably want a way to identify which rows in db.sales have already 
>> been processed (that is, which quantities have already been subtracted from 
>> the the available in the corresponding product entry).
>>
>> /dps
>>
>>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To 

[web2py] Re: Can I use SQLFORM for get id row (only read)?

2019-09-11 Thread Константин Комков
It's work:
if form.validate():
form.vars.id = db((db.tt_main.MODULE == form.vars.MODULE) & 
(db.tt_main.GROUP_ID 
== form.vars.GROUP_ID)).select(db.tt_main.id).first().id

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4b5f1d90-3403-4446-8adc-7e26961b960d%40googlegroups.com.


[web2py] Re: PythonAnywhere to AWS

2019-09-11 Thread Dave S

On Tuesday, September 10, 2019 at 12:47:40 AM UTC-7, Ian Ryder wrote:
>
> Hi all, I asked a question a while back about AWS and Nginx but didn't get 
> a reply so trying a different path!
>
> I've got an app I need to move over to AWS - does anyone know the easiest 
> way to get web2py up and running on Amazon? I tried the old scripts for 
> nginx but they seem to be out of date.
>
> Any help appreciated.
>

By AWS do you mean AWS Linux, or some other guest on AWS?

I use Nginx on AWS Linux.  I think I hacked on the Centos-7 version of the 
script, because AWS Linux is similar to Centos 7, mostly.  Requests going 
to web2py are routed through Uwsgi via file system sockets.  I'm using 
Uwsgi in Master mode rather than Emperor, mainly because I understood that 
part quicker.  (On my local machine, I have permanently open browser tabs 
for Nginx and Uwsgi, but I'm no longer looking at them constantly.)   I 
started with sqlite3, and that still runs some things, but I switched my 
largest data store to Postgres.  This is a very simple setup ... all 
contained on 1 EC2 instance, with some extra disk space for files sent to 
the server.

Oh, and I'm using certbot even though LetsEncrypt doesn't officially 
support AWS Linux.

Is that enough to get you started?  If not, details can probably be prised 
out of me slowly.  Some details may be sitting around in some of my own 
question posts.

Good luck!

/dps

/dps



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d92d1031-2771-457d-a1c8-774d80c15295%40googlegroups.com.


[web2py] Re: How do I solve this error: NameError: name 'person_id' is not defined in KPax2

2019-09-11 Thread Dave S


On Tuesday, September 10, 2019 at 1:31:11 PM UTC-7, Maurice Waka wrote:
>
> I'm trying out a surveys app from KPax2/surveys/take_survey..
>
>
> but got this error:
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "/home/mauricewaka/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/mauricewaka/web2py/applications/KPax2/controllers/surveys.py" 
> , line 
> 370, in 
>   File "/home/mauricewaka/web2py/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/home/mauricewaka/web2py/gluon/tools.py", line 3869, in f
> return action(*a, **b)
>   File "/home/mauricewaka/web2py/applications/KPax2/controllers/surveys.py" 
> , line 
> 93, in take_survey
> survey,sa=thissurvey()
>   File "/home/mauricewaka/web2py/applications/KPax2/models/db_surveys.py" 
> , line 
> 95, in thissurvey
> if not has_access(person_id,'survey',survey_id,'take'):#if not 
> has_access(person_id,'survey',survey_id,'take'):
> NameError: name 'person_id' is not defined
>
>
> Was there a table that was not created/defined?
>
> How do I solve this
>
> Kind regards
>
>
It appears that this is in one of your model files ... does that file tell 
you what it expects person_id to be or to come from?

"has_access()" sounds like a Flask decorator, based on a quick Google 
search.

/dps



/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8b37f831-8a82-4d96-b69a-5d9cf74a154c%40googlegroups.com.


[web2py] Re: Display value on a web page

2019-09-11 Thread Dave S


On Friday, September 6, 2019 at 7:17:29 PM UTC-7, Fabio Gubler wrote:
>
> I've realized the scheduler example shown on Vimeo video by M. Di Pierro 
> and it works properly.
> Now I'd like to show the time value on the web page (with a view).
> Could somebody give me an idea about how should I proceed?
> Should I create a Python module? and how to pass the time value from Model 
> to controller function?
> Thanks in advance for any help.
> Fabio
>

I shouldn't be answering this question without taking the time to see the 
video, because I don't really know where you're statring at,  but I'll see 
what I can do.

1.  In web2py, you need a controller function to respond to user requests.

2.  The controller function is invoked with a context that includes the 
request and the globals from the model files.
The globals include the DAL object specified (named "db" in all the 
examples) and the Scheduler object.  In the controller, you use the 
scheduler object to queue tasks or to check the task status.

3.  What the controller function returns is used to display things in the 
view.  If you query the task status in the controller, then you can return 
the values from the status.

What time is it that you want to display?  Do you want to know when it last 
ran or when it will next run?  Those times are in the status.

BTW, I recommend looking over Chapter 3 of the book.  Simple examples, 
probably simpler than the video, but it will help you keep in mind how the 
pieces go together.
http://web2py.com/books/default/chapter/29/03/overview>

/dps





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/307ffc03-545a-4856-8631-05b4a5770add%40googlegroups.com.


[web2py] Re: 1215 Cannot add foreign key constraint

2019-09-11 Thread Dave S


On Tuesday, September 10, 2019 at 2:58:06 PM UTC-7, Steve wrote:
>
> Goodevening,
>
> I am trying to migrate from Sqite to MySQL.
> Unfortunatly when restoring the field in the DB tables i get the following 
> error: 
>  (1215, u'Cannot add 
> foreign key constraint')
> location of issue: Field('Insurance',db.insurance,label=T('Insurance')),
>
> When i look this up in google  this could be caused by  a Field which 
> has the reuirement= Not NULL but has no Default value set.
> I tested this but not able to get passed the error.
>
> *first table with field in db1.py*
>
> db.define_table('insurance',
> 
> Field('Company',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
> label=T('Company')),
> Field('Insurance_number','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),  
> label=T('Insurance Number')),
> Field('Street_name', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Street 
> Name')),
> Field('House_number','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('House 
> Number')),
> Field('Postal_code','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),label=T('Postal 
> Code')),
> Field('City','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('City')),
> Field('Region','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Region')),
> Field('Country','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
> label=T('Country')),
> Field('Telephone_number','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Telephone 
> Number')),
> Field('Mobile','string', 
> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Mobile')),
> Field('Email','string', 
> requires=IS_EMAIL(error_message='invalid email! Please fill in a correct 
> e-mail address.'), label=T('Email')),
> auth.signature, format='%(Company)s',fake_migrate=True)
>
> *Second table which in a db2.py:*
>
> db.define_table('client',
> 
> Field('Debtor_nr',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), 
> label=T('Debtor number')),
> Field('Insurance',db.insurance,label=T('Insurance')), --> 
> this 
> is where the first issue takes place
>
> Where should i add a default value ? to et this issue fixed
>
> Hope you can help me with this
>
> Steve
>

This page has different diagnoses than you mention:
https://www.rathishkumar.in/2016/01/solved-how-to-solve-mysql-error-code.html
>

There, the issue with NULL is that the foreign key can't be NULL if it is 
part of the child table's primary key.

Another way to get the error is to use a different mysql storage engine 
than innodb.

Yet another way is to not have a unique key in the table, but since you're 
using a model file to describe the parent table, the DAL should have 
handled that, and also made sure that the parent and child agree on what 
the key is.

As a first step, use your mysql console or dbclient to display the schema 
used for the insurance table.  (I can't tell you how to do that, because I 
use sqlite and postgres, not mysql, so I know two incantations but they 
probably don't match what you need).

Good luck!

/dps

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7eb2aa7f-0d0f-48b3-882d-6837b555cd1b%40googlegroups.com.


[web2py] Re: Whats the best way to create an Android or iOS app for web2py project

2019-09-11 Thread Dave S

On Friday, September 6, 2019 at 4:28:30 AM UTC-7, Rahul wrote:
>
> Hey Everyone,
>  I have some interesting questions (It might have been asked before) I 
> want to know - 
>
> 1) Whats the best way to create an Android or iOS app for web2py project?
>

What's the goal?  Do you want web2py running as a server on the portable 
device?  Do you want to display on the portable device pages served by a 
[remote] webserver?  Do you want to access a [remote] web2py server from a 
native app on the portable device?

Note that a remote web2py server using the view tools that come with it 
produces pages that are mobile-friendly (er, "responsive") in the sense of 
adapting to the screen size in various ways.
 

> 2) How can we access a postgres database residing on linux server for a 
> web2py application from such an application?
>

Can't answer this one without knowing more about what #1 means.  A quick 
note that a remote web2py server could be running on the linux server with 
the database, or on a separate server, just as for any "normal"  web2py 
installation.
 

> 3) Can we use python to write such apps?
>

See above.  I think I've seen mention of native python on mobile devices, 
but perhaps not included in any of the development tools for the device.
 

> 4) Has anyone written any apps that do the above successfully?
>
>
> Rahul
>


Good luck!

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/76f02897-1f23-4503-919e-3df81cfee1eb%40googlegroups.com.


[web2py] Re: Can I use SQLFORM for get id row (only read)?

2019-09-11 Thread Dave S


On Wednesday, September 11, 2019 at 12:04:16 AM UTC-7, Константин Комков 
wrote:
>
> It's work:
> if form.validate():
> form.vars.id = db((db.tt_main.MODULE == form.vars.MODULE) & (db.
> tt_main.GROUP_ID == form.vars.GROUP_ID)).select(db.tt_main.id).first().id
>

I'm glad you were able to find an answer.  I'm spoiled by having 
form.accepts()  set that value, but of course that doesn't work for 
read-only.

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a1a86e55-2c73-412b-9694-ecab2f928de1%40googlegroups.com.


[web2py] Re: Overiding the auth table ID fields to allow for release over pillars (Development, Acceptance, Production)

2019-09-11 Thread Davidiam
Thanks for your reply.

Maybe override was not the best term.  We can create the users using the 
userid and groupid as the ids in the user, group and membership tables, but 
as Web2Py out of the box creates an id (sequentially incremented) we are 
concerned that specifying a different id might have repercussions down the 
line.
Also because the automatically generated ids in the other auth tables may 
be different between pillars.

I have been looking into this further and I don't think we will have a 
problem if we create the user and group tables using our own unique id's in 
the id fields.  

On Tuesday, September 10, 2019 at 8:16:00 PM UTC+2, Val K wrote:
>
> why do you have to override ids? You can just create users with the 
> required ids.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/fa52405e-f587-4948-b712-42e4b8f599b4%40googlegroups.com.


Re: [web2py] Re: How do I solve this error: NameError: name 'person_id' is not defined in KPax2

2019-09-11 Thread Lovedie JC
I got this from web2py appliances apps.
Just trying it out.
Regards

On Wed, 11 Sep 2019, 11:04 Dave S  wrote:

>
>
> On Tuesday, September 10, 2019 at 1:31:11 PM UTC-7, Maurice Waka wrote:
>>
>> I'm trying out a surveys app from KPax2/surveys/take_survey..
>>
>>
>> but got this error:
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>>
>> Traceback (most recent call last):
>>   File "/home/mauricewaka/web2py/gluon/restricted.py", line 219, in 
>> restricted
>> exec(ccode, environment)
>>   File "/home/mauricewaka/web2py/applications/KPax2/controllers/surveys.py" 
>> , 
>> line 370, in 
>>   File "/home/mauricewaka/web2py/gluon/globals.py", line 421, in 
>> self._caller = lambda f: f()
>>   File "/home/mauricewaka/web2py/gluon/tools.py", line 3869, in f
>> return action(*a, **b)
>>   File "/home/mauricewaka/web2py/applications/KPax2/controllers/surveys.py" 
>> , 
>> line 93, in take_survey
>> survey,sa=thissurvey()
>>   File "/home/mauricewaka/web2py/applications/KPax2/models/db_surveys.py" 
>> , line 
>> 95, in thissurvey
>> if not has_access(person_id,'survey',survey_id,'take'):#if not 
>> has_access(person_id,'survey',survey_id,'take'):
>> NameError: name 'person_id' is not defined
>>
>>
>> Was there a table that was not created/defined?
>>
>> How do I solve this
>>
>> Kind regards
>>
>>
> It appears that this is in one of your model files ... does that file tell
> you what it expects person_id to be or to come from?
>
> "has_access()" sounds like a Flask decorator, based on a quick Google
> search.
>
> /dps
>
>
>
> /dps
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/8b37f831-8a82-4d96-b69a-5d9cf74a154c%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAAcHJF8S8ERXJOms6RBwx3o1One%3D%2BJPcHnRz%2BdL1f5z7Sarmww%40mail.gmail.com.