[web2py] Re: Object not found

2018-09-28 Thread 'Matthew J Watts' via web2py-users
Looks like you are not sending/recieving your args properly (

For example You need to send args=Customer.id ,  from a button or redirect 
for example

You then need to request the Customer.id in the 'Client_Update' function

So you'd need 

def Client_Update():
client=request.args(0,cast=int)






On Friday, September 28, 2018 at 8:04:57 AM UTC+2, mostwanted wrote:
>
> I have 3 table, Items, Client & Purchases, the Client table stores the 
> details of the customer, the items table has a list of sold items and 
> Purchases stores what the customer purchased on what day. I have a function 
> in the controller that allows the editing of Customer and Purchases details 
> in one view by clicking on the owner's name but i keep getting the *Object 
> not found *message caused an attempt at opening an edit for the Purchases 
> table, what am i doing wrong, is there a better way of doing this?
>
> Regards
>
> Mostwanted
>
> *MODELS*
> db.define_table('Customer',
> Field('Name', requires=IS_NOT_EMPTY(), label=SPAN('First 
> Name', _style="font-weight: bold;")),
> Field('Surname', requires=IS_NOT_EMPTY(), label=SPAN('Last 
> Name', _style="font-weight: bold;")),
> Field('ID_Number', requirs=IS_NOT_EMPTY(), label=SPAN('Client 
> ID No', _style="font-weight: bold;")),
> Field('Company', requirs=IS_NOT_EMPTY(), label=SPAN(
> 'Company', _style="font-weight: bold;")),format='%(Surname)s ),
>
> db.define_table('Items',
> Field('Item', requires=IS_NOT_EMPTY()),
> format='%(Item)s')
>
> db.define_table('Purchases',
> Field('Client', 'reference Customer', label=SPAN('Client', 
> _style="font-weight: bold")),
> Field('Item', 'reference Item', unique=True, label=SPAN('
> Item Purchased', _style="font-weight: bold;")),
> Field('Booking_Date', 'datetime', default=request.now, 
> writable=False, label=SPAN('Date of Registration', _style="font-weight: 
> bold;")),
> Field('Serviced_By', 'reference auth_user', 
> default=auth.user_id, writable=False, label=SPAN('Serviced By', 
> _style="font-weight: bold;")))
>
>
> *CONTROLLER*
> def Client_Update():
> client=db.Customer(request.args(0))
> clientDetails=SQLFORM(db.Customer, client.id, deletable=True, showid=
> False).process()
> addRooms=SQLFORM(db.Purchases, client.id, deletable=True, showid=False
> ).process()
> return locals()
>
> *VIEW*
> {{extend 'layout.html'}}
>
> 
> VIEW & UPDATE CLIENT DETAILS
> {{=clientDetails}}
> 
> VIEW & UPDATE CLIENT PURCHASES
> {{=addRooms}}
> 
> {{pass}}
>
>
>

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


[web2py] Re: Object not found

2018-09-28 Thread mostwanted
Hey Matthew, i have another view called viewPurchases that has a link that 
sends my args to the client_update controller, i didnt include it in the 
above code i thought is wasn't important it looks like this:

*viewPurchases VIEW*


Client Surname
Booked Room
Reservation / Booking Status
Booked By
{{for purchase in purchase:}}



{{=A(purchase.Surname, _href=URL('Client_Update', args=purchase.id))}} 
{{=purchase.Name}}



 Room {{=purchase.Items.Item}}


{{=purchase.Booked_By.first_name}} {{=bookings.Booked_By.last_name}}



{{pass}}


*viewPurchases CONTROLLER*




*def viewPurchases():purchase=db(db.Customer).select(db.Customer.ALL, 
orderby=db.Customer.Surname)return locals()*

On Friday, September 28, 2018 at 12:13:04 PM UTC+2, Matthew J Watts wrote:
>
> Looks like you are not sending/recieving your args properly (
>
> For example You need to send args=Customer.id ,  from a button or 
> redirect for example
>
> You then need to request the Customer.id in the 'Client_Update' function
>
> So you'd need 
>
> def Client_Update():
> client=request.args(0,cast=int)
>
>
>
>
>
>
> On Friday, September 28, 2018 at 8:04:57 AM UTC+2, mostwanted wrote:
>>
>> I have 3 table, Items, Client & Purchases, the Client table stores the 
>> details of the customer, the items table has a list of sold items and 
>> Purchases stores what the customer purchased on what day. I have a function 
>> in the controller that allows the editing of Customer and Purchases details 
>> in one view by clicking on the owner's name but i keep getting the *Object 
>> not found *message caused an attempt at opening an edit for the 
>> Purchases table, what am i doing wrong, is there a better way of doing this?
>>
>> Regards
>>
>> Mostwanted
>>
>> *MODELS*
>> db.define_table('Customer',
>> Field('Name', requires=IS_NOT_EMPTY(), label=SPAN('First 
>> Name', _style="font-weight: bold;")),
>> Field('Surname', requires=IS_NOT_EMPTY(), label=SPAN('Last 
>> Name', _style="font-weight: bold;")),
>> Field('ID_Number', requirs=IS_NOT_EMPTY(), 
>> label=SPAN('Client 
>> ID No', _style="font-weight: bold;")),
>> Field('Company', requirs=IS_NOT_EMPTY(), label=SPAN(
>> 'Company', _style="font-weight: bold;")),format='%(Surname)s ),
>>
>> db.define_table('Items',
>> Field('Item', requires=IS_NOT_EMPTY()),
>> format='%(Item)s')
>>
>> db.define_table('Purchases',
>> Field('Client', 'reference Customer', label=SPAN('Client', 
>> _style="font-weight: bold")),
>> Field('Item', 'reference Item', unique=True, label=SPAN('
>> Item Purchased', _style="font-weight: bold;")),
>> Field('Booking_Date', 'datetime', default=request.now, 
>> writable=False, label=SPAN('Date of Registration', _style="font-weight: 
>> bold;")),
>> Field('Serviced_By', 'reference auth_user', 
>> default=auth.user_id, writable=False, label=SPAN('Serviced By', 
>> _style="font-weight: bold;")))
>>
>>
>> *CONTROLLER*
>> def Client_Update():
>> client=db.Customer(request.args(0))
>> clientDetails=SQLFORM(db.Customer, client.id, deletable=True, showid=
>> False).process()
>> addRooms=SQLFORM(db.Purchases, client.id, deletable=True, showid=
>> False).process()
>> return locals()
>>
>> *VIEW*
>> {{extend 'layout.html'}}
>>
>> 
>> VIEW & UPDATE CLIENT DETAILS
>> {{=clientDetails}}
>> 
>> VIEW & UPDATE CLIENT PURCHASES
>> {{=addRooms}}
>> 
>> {{pass}}
>>
>>
>>

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


[web2py] Re: Object not found

2018-09-28 Thread mostwanted



On Friday, September 28, 2018 at 1:40:56 PM UTC+2, mostwanted wrote:
>
> Hey Matthew, i have another view called viewPurchases that has a link that 
> sends my args to the client_update controller, i didnt include it in the 
> above code i thought is wasn't important it looks like this:
>
> *viewPurchases VIEW*
> 
> 
> Client Surname
> Booked Room
> Reservation / Booking Status
> Booked By
> {{for purchase in purchase:}}
> 
> 
> 
> {{=A(purchase.Surname, _href=URL('Client_Update', args=purchase.id))}} 
> {{=purchase.Name}}
> 
> 
> 
>  Room {{=purchase.Items.Item}}
> 
> 
> {{=purchase.Booked_By.first_name}} {{=purchase.Serviced_By.last_name}}
>
> 
> 
> {{pass}}
> 
>
> *viewPurchases CONTROLLER*
>
>
>
>
> *def viewPurchases():purchase=db(db.Customer).select(db.Customer.ALL, 
> orderby=db.Customer.Surname)return locals()*
>
> On Friday, September 28, 2018 at 12:13:04 PM UTC+2, Matthew J Watts wrote:
>>
>> Looks like you are not sending/recieving your args properly (
>>
>> For example You need to send args=Customer.id ,  from a button or 
>> redirect for example
>>
>> You then need to request the Customer.id in the 'Client_Update' function
>>
>> So you'd need 
>>
>> def Client_Update():
>> client=request.args(0,cast=int)
>>
>>
>>
>>
>>
>>
>> On Friday, September 28, 2018 at 8:04:57 AM UTC+2, mostwanted wrote:
>>>
>>> I have 3 table, Items, Client & Purchases, the Client table stores the 
>>> details of the customer, the items table has a list of sold items and 
>>> Purchases stores what the customer purchased on what day. I have a function 
>>> in the controller that allows the editing of Customer and Purchases details 
>>> in one view by clicking on the owner's name but i keep getting the *Object 
>>> not found *message caused an attempt at opening an edit for the 
>>> Purchases table, what am i doing wrong, is there a better way of doing this?
>>>
>>> Regards
>>>
>>> Mostwanted
>>>
>>> *MODELS*
>>> db.define_table('Customer',
>>> Field('Name', requires=IS_NOT_EMPTY(), label=SPAN('First 
>>> Name', _style="font-weight: bold;")),
>>> Field('Surname', requires=IS_NOT_EMPTY(), label=SPAN('Last 
>>> Name', _style="font-weight: bold;")),
>>> Field('ID_Number', requirs=IS_NOT_EMPTY(), 
>>> label=SPAN('Client 
>>> ID No', _style="font-weight: bold;")),
>>> Field('Company', requirs=IS_NOT_EMPTY(), label=SPAN(
>>> 'Company', _style="font-weight: bold;")),format='%(Surname)s ),
>>>
>>> db.define_table('Items',
>>> Field('Item', requires=IS_NOT_EMPTY()),
>>> format='%(Item)s')
>>>
>>> db.define_table('Purchases',
>>> Field('Client', 'reference Customer', label=SPAN('Client', 
>>> _style="font-weight: bold")),
>>> Field('Item', 'reference Item', unique=True, 
>>> label=SPAN('Item Purchased', _style="font-weight: bold;")),
>>> Field('Booking_Date', 'datetime', default=request.now, 
>>> writable=False, label=SPAN('Date of Registration', _style="font-weight: 
>>> bold;")),
>>> Field('Serviced_By', 'reference auth_user', 
>>> default=auth.user_id, writable=False, label=SPAN('Serviced By', 
>>> _style="font-weight: bold;")))
>>>
>>>
>>> *CONTROLLER*
>>> def Client_Update():
>>> client=db.Customer(request.args(0))
>>> clientDetails=SQLFORM(db.Customer, client.id, deletable=True, showid
>>> =False).process()
>>> addRooms=SQLFORM(db.Purchases, client.id, deletable=True, showid=
>>> False).process()
>>> return locals()
>>>
>>> *VIEW*
>>> {{extend 'layout.html'}}
>>>
>>> 
>>> VIEW & UPDATE CLIENT DETAILS
>>> {{=clientDetails}}
>>> 
>>> VIEW & UPDATE CLIENT PURCHASES
>>> {{=addRooms}}
>>> 
>>> {{pass}}
>>>
>>>
>>>

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


Re: [web2py] Connect DAL to Azure Postgres Instance

2018-09-28 Thread Javier Pepe
Try this:

db = DAL("postgres://xw@dbname-postgres:
p...@dbname-postgres.postgres.database.azure.com/dbname")

El vie., 28 de sep. de 2018 a la(s) 02:17, gb (gregb...@gmail.com) escribió:

> Trying to connect to Azure-hosted postgres on version
> 2.17.1-stable+timestamp.2018.08.06.01.02.56
>
> If I try and connect with:
>
> db = DAL("postgres://dbname@dbname-postgres:
> p...@dbname-postgres.postgres.database.azure.com/dbname")
>
> I get this:
> Invalid URI string in DAL
>
> I thought it might have to do with the @ so I encoded it:
>
> db = DAL("postgres://
> dbname%40dbname-postgres:p...@dbname-postgres.postgres.database.azure.com/dbname
> ")
>
> OperationalError: could not create SSL context: library has no ciphers
> FATAL: Invalid Username specified. Please check the Username and retry
> connection. The Username should be in  format.
>
> Connecting like this works totally fine:
> import psycopg2
>
> conn = psycopg2.connect("dbname='dbname' user='xw@dbname-postgres' host='
> dbname-postgres.postgres.database.azure.com' password='pass'")
>
> cur = conn.cursor()
>
>
> Any ideas?
>
> Thanks so much
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] routes.py Python 3 regex error

2018-09-28 Thread Bryan Chance
I'm working to switch my web2py application to Python 3. However, I now get 
errors when loading due to my routes.py:

  File "/usr/lib/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \g at position 35


My routes.py is posted below, and the idea behind it is that 
myurl.com/client_name gets routed to myurl.com/myappname?client=client_name:

routes_app = ((r'/(?Padmin|app)\b.*', r'\\g'),
  (
  r'/(?Papp_to_be_excluded)\b.*',
  r'\g')
  )

routes_in = [
# make sure you do not break admin
('/admin', '/admin'),
('/admin/$anything', '/admin/$anything'),
# make sure you do not break appadmin
('/$app/appadmin', '/$app/appadmin'),
('/$app/appadmin/$anything', '/$app/appadmin/$anything'),
('/static/$anything', '/myappname/static/$anything'),
('/$domain(?P.*)$', '/myappname\\g?client=$domain'),
]

routes_out = [(a, b) for (b, a) in routes_in]

Does anyone have any ideas how I can update this regex to work?

-- 
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] routes.py Python 3 regex error

2018-09-28 Thread Bryan Chance
one correction, the \\g's are actually \g

On Fri, Sep 28, 2018 at 12:20 PM Bryan Chance  wrote:

> I'm working to switch my web2py application to Python 3. However, I now
> get errors when loading due to my routes.py:
>
>   File "/usr/lib/python3.6/sre_parse.py", line 401, in _escape
> raise source.error("bad escape %s" % escape, len(escape))
> sre_constants.error: bad escape \g at position 35
>
>
> My routes.py is posted below, and the idea behind it is that
> myurl.com/client_name gets routed to
> myurl.com/myappname?client=client_name:
>
> routes_app = ((r'/(?Padmin|app)\b.*', r'\\g'),
>   (
>   r'/(?Papp_to_be_excluded)\b.*',
>   r'\g')
>   )
>
> routes_in = [
> # make sure you do not break admin
> ('/admin', '/admin'),
> ('/admin/$anything', '/admin/$anything'),
> # make sure you do not break appadmin
> ('/$app/appadmin', '/$app/appadmin'),
> ('/$app/appadmin/$anything', '/$app/appadmin/$anything'),
> ('/static/$anything', '/myappname/static/$anything'),
> ('/$domain(?P.*)$', '/myappname\\g?client=$domain'),
> ]
>
> routes_out = [(a, b) for (b, a) in routes_in]
>
> Does anyone have any ideas how I can update this regex to work?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: routes.py Python 3 regex error

2018-09-28 Thread Leonel Câmara
You probably need to use raw strings in routes_in too if that \\g is indeed 
just \g

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


Re: [web2py] Re: routes.py Python 3 regex error

2018-09-28 Thread Bryan Chance
Added those, but the underlying issue is still there.

On Fri, Sep 28, 2018 at 12:32 PM Leonel Câmara 
wrote:

> You probably need to use raw strings in routes_in too if that \\g is
> indeed just \g
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: How can i select an item from the database only once?

2018-09-28 Thread Dave S


On Thursday, September 27, 2018 at 10:24:00 PM UTC-7, mostwanted wrote:
>
> Thank you Dave but this URL  https://web2py.com/boobs/default/29/07/forms-and-validators#SQLFORM-and-insert-update-delete
>  
> >
>  
> is not working, its giving  an Invalid Request error
>

I see I made a rather embarrassing typo.  Instead of great auks, the URL 
should be accessing .../books/...

/dps
 

>
> On Wednesday, September 26, 2018 at 10:15:44 PM UTC+2, Dave S wrote:
>>
>>
>>
>> On Wednesday, September 26, 2018 at 1:07:51 PM UTC-7, Dave S wrote:
>>>
>>> [...]
>>>
>>  
>>
>>> (controllers/myhotel.py)
>>> [...]
>>>
>>  
>>
>>> define assignroom():
>>> [...]
>>>
>>  
>>
>>>db(db.rooms.id == roomid).update(available=F, client = 
>>> form.vars.id)
>>> [...]
>>>
>>>
>> I just noticed the book (at least the version currently at 
>> web2py.com/books/default) has at
>> > https://web2py.com/boobs/default/29/07/forms-and-validators#SQLFORM-and-insert-update-delete
>> >
>> an example that says "Assuming form=SQLFORM(db.test)" and then say the 
>> id is "accessible in myform.vars.id".
>> I haven't checked to see if the master has corrected this or not, and I'm 
>> not sure when I would get around to doing a PR
>> (the smaller the change, the longer it waits, no?), but I can advertise 
>> the blip.
>>
>> /dps
>>
>>

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