[web2py] Re: web2py 2.24.1 released

2023-05-07 Thread Peter
Thanks

četvrtak, 23. mart 2023. u 06:20:20 UTC+1 Massimo Di Pierro je napisao/la:

> Hello everybody,
>
> web2py 2.24.1 has been released.
>
> Thanks to Leonel, Cem, and Mark for bug fixes including:
> - handling corrupt disk cache
> - broken application packaging
> - compare function logic
>
>
>

-- 
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/fd5b9cc8-f61a-4d28-813a-fe9c9f474be6n%40googlegroups.com.


[web2py] Re: Unable to calculate values of a selected Index

2023-03-27 Thread Peter
To be clear I didn't come up with this (see my previous post)...

Based on the provided code, it seems that the quantity variable is being 
assigned the same value every time, which is the value of 
details.quantities[index] for the first item in the list. 
This is because the details.quantities list is being passed to the view as 
a list of strings, and the parseInt() function is being used to convert the 
string value to an integer.

To rectify this issue, you should ensure that the details.quantities list 
is being passed to the view as a list of integers instead of a list of 
strings. You can do this by modifying the quantities field in your 
db.define_table() statement to use the list:integer type instead of 
list:string.

Here's an updated version of the model definition:
db.define_table('client_order', 
 Field('quoted_item', 'list:string', required=True),
 Field('quantities', 'list:integer', required=True)) 

After making this change, the details.quantities list will be passed to the 
view as a list of integers, 

and the parseInt() function will no longer be needed in the 
calculateSubtotal() function. 

You can simply access the quantity value using details.quantities[index].

Here's the updated calculateSubtotal() function:
function calculateSubtotal(input, index) { var price = parseFloat(input.value); 

var quantity = details.quantities[index]; 
var subtotal = parseFloat(price * quantity); 
document.getElementById("subtotal" + index).innerHTML = subtotal.toFixed(2);
updateGrandTotal(); } 

With this change, the quantity variable should now be assigned the correct 
value for each item in the list, allowing the subtotal to be calculated 
correctly.

On Sunday, 26 March 2023 at 15:04:29 UTC+1 mostwanted wrote:

> I want to be able to calculate subtotal by multiplying quantity and price 
> but I cant because 
> *var quantity = parseInt("{{=details.quantities[index]}}");* in the 
> code below carries the value of 1 and it does not change. Please assist me 
> identify what could be wrong here and how can i rectify it?
>
> *Model:*
> db.define_table('client_order'),
> Field('quoted_item','list:string', required=True),
> Field('quantities','list:string', required=True))
>
> *View:*
> {{for index, (item, qty) in enumerate(zip(details.quoted_item, 
> details.quantities)):}}
> 
> {{=item}}
> 
> {{=qty}}
> 
> 
> {{pass}}
>
> 
> function calculateSubtotal(input, index) {
> var price = parseFloat(input.value);
> *var quantity = parseInt("{{=details.quantities[index]}}");*
> var subtotal = parseFloat(price * quantity);
> document.getElementById("subtotal" + index).innerHTML = 
> subtotal.toFixed(2);
> updateGrandTotal();
> console.log(parseFloat("{{=details.quantities[index]}}"));
> }
> 
>
> Regards
>

-- 
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/d0d7e924-c12c-4403-aebb-ff63a7762a6fn%40googlegroups.com.


[web2py] Re: Unable to calculate values of a selected Index

2023-03-27 Thread Peter

Try...
Field('quantities', 'list:integer', required=True))

On Sunday, 26 March 2023 at 15:04:29 UTC+1 mostwanted wrote:

> I want to be able to calculate subtotal by multiplying quantity and price 
> but I cant because 
> *var quantity = parseInt("{{=details.quantities[index]}}");* in the 
> code below carries the value of 1 and it does not change. Please assist me 
> identify what could be wrong here and how can i rectify it?
>
> *Model:*
> db.define_table('client_order'),
> Field('quoted_item','list:string', required=True),
> Field('quantities','list:string', required=True))
>
> *View:*
> {{for index, (item, qty) in enumerate(zip(details.quoted_item, 
> details.quantities)):}}
> 
> {{=item}}
> 
> {{=qty}}
> 
> 
> {{pass}}
>
> 
> function calculateSubtotal(input, index) {
> var price = parseFloat(input.value);
> *var quantity = parseInt("{{=details.quantities[index]}}");*
> var subtotal = parseFloat(price * quantity);
> document.getElementById("subtotal" + index).innerHTML = 
> subtotal.toFixed(2);
> updateGrandTotal();
> console.log(parseFloat("{{=details.quantities[index]}}"));
> }
> 
>
> Regards
>

-- 
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/3861cc89-7af0-4ce2-bbb5-48eb240caff6n%40googlegroups.com.


[web2py] ChatGPT's advice re adding a table to an existing db

2023-03-25 Thread Peter
I had a 'conversation' with ChatGPT about adding a table and found it 
enlightening maybe others will...



*I want to add a new table to existing web2py DAL db what migrate setting 
should i use*

Web2py's DAL (Database Abstraction Layer) supports migrations, which are 
used to apply database schema changes in a safe and consistent manner. To 
add a new table to an existing Web2py DAL database, you'll need to create a 
new model representing the table, and then create a migration to apply the 
changes to the database.

Here's an example of how you can add a new table to an existing Web2py DAL 
database:

   1. Create a new model file (e.g., mynewtable.py) in your application's 
   models/ directory. In this file, define the new table using the DAL 
   syntax. For example:

python
# models/mynewtable.py db.define_table('my_new_table', Field('id', 'id'), 
Field('name', 'string', required=True), Field('age', 'integer'), migrate=
'my_new_table.table' # Optional - this sets the table name in the database 
) 

In this example, we've defined a new table called my_new_table with three 
columns: id, name, and age. Note that the migrate parameter is optional - 
it sets the table name in the database. If you don't provide a value for 
migrate, Web2py will use the name of the table as defined in the model.

   1. Run the web2py.py -S myapp -M command from the command line to 
   generate a migration file that will create the new table in the database. 
   For example:

web2py.py -S myapp -M -n create_my_new_table 

In this example, we're generating a migration file called 
create_my_new_table.py. The -n option specifies the name of the migration.

   1. Open the generated migration file (e.g., 
   applications/myapp/private/migrations/0001_create_my_new_table.py) in a 
   text editor. You should see a skeleton migration file that looks something 
   like this:

python
# -*- coding: utf-8 -*- from gluon import * SQL = [] def upgrade(): pass def 
downgrade(): pass 

   1. In the upgrade() function, add the code to create the new table. For 
   example:

scss
def upgrade(): db.define_table('my_new_table', Field('id', 'id'), Field(
'name', 'string', required=True), Field('age', 'integer'), migrate=
'my_new_table.table' ) 

In this example, we're creating the my_new_table table using the same DAL 
syntax as in step 1. Note that you should not include the db.commit() 
statement in the upgrade() function, as Web2py will handle that 
automatically.

   1. 
   
   Save the migration file and exit the text editor.
   2. 
   
   Run the migration by executing the web2py.py -S myapp -M command again:
   
web2py.py -S myapp -M 

Web2py will detect the new migration and prompt you to apply it to the 
database. Type y and press Enter to apply the migration.

   1. Check that the new table has been created by inspecting your database 
   using a database management tool or by using Web2py's built-in database 
   administration interface.

That's it! You've successfully added a new table to an existing Web2py DAL 
database using migrations. Note that if you make changes to the table 
schema in the future, you can create a new migration to update the database 
accordingly.
[image: perr...@proton.me]
*That is elaborate but all i had to do was add 'migrate=True' to the end of 
the new table definition, refresh a view and remove the migrate line *

That's correct, adding migrate=True to the new table definition is the 
simplest way to create a new table in Web2py's DAL without using 
migrations. This will automatically create the table in the database the 
first time the application is launched.

However, note that this approach has a few drawbacks:

   1. 
   
   If you need to change the schema of the table in the future, you will 
   need to manually modify the database schema using a database management 
   tool, which can be error-prone and difficult to maintain.
   2. 
   
   If you are deploying your application to multiple environments (e.g., 
   development, staging, production), you will need to manually create the 
   table in each environment using a database management tool.
   3. 
   
   If you are working with a team of developers, you will need to ensure 
   that everyone is aware of the manual steps required to create the new table 
   in the database.
   
Using migrations, on the other hand, allows you to safely and consistently 
apply database schema changes across all environments and developers. This 
approach can save you time and reduce the risk of errors or inconsistencies 
in your database schema.

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

[web2py] Re: pyCharm

2022-11-22 Thread Peter
Thanks for the reply Jim!

For the record I just got py4web running in an Oracle Ubuntu instance and 
it was relatively painless
it complained about email aliases - but created what it needed
it asked what services to restart - I just restarted them all
The dashboard is up and running so it's a whole new world!
Thanks again to the web2py community and now to py4web community for their 
great work and thanks to Luca de Alfaro for his youtube videos which will 
help get me started. 

On Wednesday, 16 November 2022 at 14:15:46 UTC Jim S wrote:

> I too am a PyCharm user.  Disappointed the web2py support was dropped.
>
> I have switched to py4web for all new development and it works great in 
> PyCharm.
>
> I think a lot of others use VS Code.  You just need to incorporate the 
> import-trick at the top of each file
>
> try:
> import your web2py objects here
> except:
> pass
>
> That way you'll be able to use the code completion in web2py - should work 
> with VS Code, PyCharm or any modern IDE.
>
> -Jim
>
>
> On Wednesday, November 16, 2022 at 7:18:57 AM UTC-6 Peter wrote:
>
>> Have been out of the loop for a while but while getting back in to things 
>> upgrading and migrating a web2py app to Python 3 (all went well!). In the 
>> process I renewed a subscription with JetBrains PyCharm and am discovering 
>> (see below) they have dropped support for web2py. The only reason for using 
>> it was the support for web2py.
>>
>> *Has anyone got suggestions for an alternate editor?  *
>> *I mainly use python/web2py but some support for html and css framework/s 
>> would be useful.*
>>
>> *Where/how can I donate to the web2py (or preferred) cause?*
>>
>>
>>
>> *"From *
>> *https://intellij-support.jetbrains.com/hc/en-us/community/posts/36585024-Web2py-Gutter-Icons
>>  
>> <https://intellij-support.jetbrains.com/hc/en-us/community/posts/36585024-Web2py-Gutter-Icons>*
>> Created January 21, 2022 01:31 
>> <https://intellij-support.jetbrains.com/hc/en-us/community/posts/36585024/comments/4415898178834>
>>  
>> * Comment actions web2py support was deprecated and there are no plans to 
>> support it in the future (at the moment)."*
>>
>>
>>

-- 
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/1fac575d-54ce-41bd-8980-5a802928957dn%40googlegroups.com.


[web2py] pyCharm

2022-11-16 Thread Peter
Have been out of the loop for a while but while getting back in to things 
upgrading and migrating a web2py app to Python 3 (all went well!). In the 
process I renewed a subscription with JetBrains PyCharm and am discovering 
(see below) they have dropped support for web2py. The only reason for using 
it was the support for web2py.

*Has anyone got suggestions for an alternate editor?  *
*I mainly use python/web2py but some support for html and css framework/s 
would be useful.*

*Where/how can I donate to the web2py (or preferred) cause?*



*"From *
*https://intellij-support.jetbrains.com/hc/en-us/community/posts/36585024-Web2py-Gutter-Icons
 
*
Created January 21, 2022 01:31 

 
* Comment actions web2py support was deprecated and there are no plans to 
support it in the future (at the moment)."*


-- 
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/803feaf8-626d-44ff-86f2-9420f50a912bn%40googlegroups.com.


Re: [web2py] QR code generation from markmin

2021-03-03 Thread Peter Woolf
Thanks!  I was hoping that Web2py had this function already based on the 
documentation for MARKMIN Links:

http://web2py.com/books/default/chapter/29/05/the-views#MARKMIN
--

Adding a link with the qr: prefix such as
qr:http://web2py.com 

results in the corresponding QR code being embedded and linking the said 
URL.
--
I can write custom code to do it, but didn't want to reinvent the wheel if 
Web2py already had it! 

Thanks!
--Peter

On Wednesday, March 3, 2021 at 2:38:31 AM UTC-5 kell...@gmail.com wrote:

> Hey Peter!
>
> I don't see any code in the markmin python script that could generate qr 
> codes. 
>
> I think the ones that are there are static. 
>
> You can use a qr code generator lib with python and combine with markmin 
> qr Syntax though. 
>
> I think. 
>
>
>
> On Mon, Mar 1, 2021, 15:59 Peter Woolf  wrote:
>
>> Hello,
>> I see that web2py has documentation for generating QR codes from links 
>> using markmin, but it isn't working in my hands.  Am I doing it incorrectly 
>> or is there a bug?
>>
>> Here is a minimal example of code in a view:
>> ---
>> {{from gluon.contrib.markmin.markmin2html import markmin2html}}
>> {{=XML(markmin2html("Hello **world** [[link qr:http://web2py.com]];))}}
>> {{=markmin2html("Hello **world** [[link qr:http://web2py.com]];)}}
>> 
>> This just creates a normal link:
>>
>> ---
>>
>> Hello *world* link
>> Hello world http://web2py.com
>> ">link
>>
>> --
>>
>> Thoughts?  Seems a useful feature if it really exists in there! :)
>>
>> Thanks,
>>
>> --Peter
>>
>> -- 
>> 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+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/57f0ea98-db5a-4211-9e24-e8ce3d7271fbn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/57f0ea98-db5a-4211-9e24-e8ce3d7271fbn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/39e3873c-243d-4032-b68d-e47e1fed3ae2n%40googlegroups.com.


[web2py] QR code generation from markmin

2021-03-01 Thread Peter Woolf
Hello,
I see that web2py has documentation for generating QR codes from links 
using markmin, but it isn't working in my hands.  Am I doing it incorrectly 
or is there a bug?

Here is a minimal example of code in a view:
---
{{from gluon.contrib.markmin.markmin2html import markmin2html}}
{{=XML(markmin2html("Hello **world** [[link qr:http://web2py.com]];))}}
{{=markmin2html("Hello **world** [[link qr:http://web2py.com]];)}}

This just creates a normal link:

---

Hello *world* link
Hello world http://web2py.com;>link

--

Thoughts?  Seems a useful feature if it really exists in there! :)

Thanks,

--Peter

-- 
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/57f0ea98-db5a-4211-9e24-e8ce3d7271fbn%40googlegroups.com.


[web2py] Re: File Manager plugin

2020-12-20 Thread Peter
Work fine on python 2.7 but on python 3.6 or python 3.7 I have an error:

ERROR:Rocket.Errors.Thread-4:Traceback (most recent call last):

  File "/web2py/gluon/rocket.py", line 1319, in run
self.run_app(conn)

  File "/web2py/gluon/rocket.py", line 1812, in run_app
self.environ = environ = self.build_environ(sock_file, conn)

  File "/web2py/gluon/rocket.py", line 1632, in build_environ
request = self.read_request_line(sock_file)

  File "/web2py/gluon/rocket.py", line 1370, in read_request_line
d = sock_file.readline()

  File "/usr/local/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)

ConnectionResetError: [Errno 104] Connection reset by peer

ERROR:Rocket.Errors.Thread-4:Tried to send "500 Server Error" to client but 
received socket error

Any idea?

ponedeljak, 14. decembar 2020. u 14:27:53 UTC+1 villas je napisao/la:

> One idea included in the framework is this:  
> http://www.web2py.com/books/default/chapter/29/14/other-recipes?search=expose#Publishing-a-folder
>
> On Saturday, 12 December 2020 at 17:37:46 UTC veron.p...@gmail.com wrote:
>
>>
>> Hello i'm new to web2py , and it is really a fabulous framework. From the 
>> web2py site i am not able to connect on the link given for the plugin web 
>> server, Kaspersky tells me that the site is not secured ???
>>
>> Can anyone tell me where i can find a folder of existing web2py plugins 
>> and also is there a stable plugin which allows a user to have a file 
>> manager to manage his files in his web directory , like this project using 
>> php :
>>
>> https://github.com/prasathmani/tinyfilemanager
>>
>> Thanks a lot.
>>
>

-- 
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/307f6b8b-1a30-4384-91e1-c55f44f8f290n%40googlegroups.com.


[web2py] Re: [py4web] - how to disable some auth actions?

2020-03-30 Thread Peter
This is exactly what I need/ do. One vote for this request.

субота, 28. март 2020. 21.55.06 UTC+1, Paolo Caruccio је написао/ла:
>
> In my case I only need login and logout.
> The creation of an account will be done by other users with privileges 
> established by the administrators. The modification of the profile will 
> also be done partially by the user himself (change password, change email, 
> add / change personal data etc) who has the account enabled and is already 
> logged in.
> Obviously I can delete all links and specific functions from the frontend, 
> as well as I can require to approve any registration made from the outside 
> but it would be more secure to also do a server-side prevention by 
> disabling actions that do not need.
>
>
> Translated with www.DeepL.com/Translator (free version)
>
> Il giorno sabato 28 marzo 2020 20:30:48 UTC+1, Massimo Di Pierro ha 
> scritto:
>>
>> not possible yet. I can implement it easily but I would like to 
>> understand some use cases.
>>
>> On Saturday, 28 March 2020 10:12:32 UTC-7, Paolo Caruccio wrote:
>>>
>>> In py4web is there any way to disable some auth actions? I can't find 
>>> anything in the code about this.
>>>
>>> In web2py this is possible via auth.settings.action_disabled
>>>
>>> For example:
>>>
>>> auth.settings.action_disabled=['register']
>>>
>>> prevents the "register" action from working.
>>>
>>> Tank you.
>>>
>>

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


[web2py] email form

2020-03-17 Thread Peter Hendriks
I am a newbie. I have forms on my website with a send button. Actually they 
work fine without an error, but there is a significant problem. I do not 
receive the by clients filled out forms in my G-mailbox.

-- 
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/f2680180-9002-4b77-83a8-448d8b826b21%40googlegroups.com.


[web2py] Changes to stripe

2019-09-14 Thread peter
According to stripe, we need to change the checkout methodology for stripe, 
at least in Europe.

The example they give now is.

client.html

https://js.stripe.com/v3";>Pay

client.js

var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
var checkoutButton = document.querySelector('#checkout-button');
checkoutButton.addEventListener('click', function () {
  stripe.redirectToCheckout({
items: [{
  // Define the product and SKU in the Dashboard first, and use the SKU
  // ID in your client-side code.
  sku: 'sku_123',
  quantity: 1
}],
successUrl: 'https://www.example.com/success',
cancelUrl: 'https://www.example.com/cancel'
  });});


Has anyone had any experience with this they could share?


Is there any docs on how I might integrate client.js into web2py.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/cc760675-9c57-47bf-ac4d-d74907620b8e%40googlegroups.com.


Re: [web2py] download for mac not working

2019-07-25 Thread Peter Woolf
Ah, thanks Nico!  I’ll check over there!

-- 
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/18572c3b-e94d-4c68-a3b0-a5ac91fb43d2%40googlegroups.com.


[web2py] download for mac not working

2019-07-24 Thread Peter Woolf
Hi All,

I've been using web2py for a few years now, but was just downloading a 
fresh version (as of 7.24.2019) and I get an error window that just says 
"web2py Error".   It gives two buttons "open console" or "terminate". I 
tried both the developer version and the normal users version, and in both 
cases I get the same error.

I'm running on a macbook air with  macOS 10.12.6.

I've got older versions of web2py (v 2.17.2) that I downloaded in the same 
way, and these work fine on this same machine.

Thoughts?

Thanks!

--Peter



-- 
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/2ab767e4-815f-40ec-9de3-7a53ec621fc7%40googlegroups.com.


[web2py] Re: SQLFORM.smartgrid exportclasses

2018-12-10 Thread Peter
This is little bit tricky but works. 

Thanks for help and useful explanation.


On Sunday, December 9, 2018 at 7:22:03 PM UTC+1, Anthony wrote:
>
> There is a shortcoming in the smartgrid code where if an argument is a 
> dictionary, it expects each of the keys to be table names -- it then 
> attempts to extract the item matching the current table name and pass that 
> as the relevant argument to SQLFORM.grid. Of course, this approach breaks 
> down when the argument itself is intended to be a dictionary. The only 
> workaround is to provide a dictionary that includes a copy of your 
> export_classes dict for every table you want to include in smartgrid:
>
> export_classes = dict(json=False, html=False, tsv=False, xml=False,
>   csv_with_hidden_cols=False, tsv_with_hidden_cols=
> False)
> grid = SQLFORM.smartgrid(..., exportclasses=dict(table1=export_classes, 
> table2=export_classes, ...))
>
> Or you could do something like this:
>
> class SingleItemDict(dict):
> def __init__(self, value):
> self.value = value
> 
> def __getitem__(self, key):
> return self.value
>
> def __contains__(self, key):
> return True
>
> export_classes = SingleItemDict(dict(json=False, html=False, tsv=False, 
> xml=False,
>  csv_with_hidden_cols=False, tsv_with_hidden_cols=False))
> grid = SQLFORM.smartgrid(..., exportclasses=export_classes)
>
> The idea of the SingleItemDict class is to store just a single value and 
> allow it to be accessed via any key (the __contains__ method ensures the 
> "in" operator will work as well). Essentially, it is tricking the smartgrid 
> code into finding what it is looking for.
>
> Anthony
>
>
> On Tuesday, November 14, 2017 at 12:57:25 AM UTC-5, Peter wrote:
>>
>> I need only csv export method from  SQLFORM.smartgrid so I want to 
>> disable default export methods. Seems to me that 
>> SQLFORM.smartgrid(exportclasses=dict(json=False)) doesn't work in newer 
>> versions of web2py (2.14.6). 
>>
>> My code:
>>
>> export_classes = dict(json=False, html=False,
>>   tsv=False, xml=False, csv_with_hidden_cols=False,
>>   tsv_with_hidden_cols=False)
>>
>> table = SQLFORM.smartgrid(db.tableexample, user_signature=False, 
>> showbuttontext=False,
>> links=links, linked_tables=[],
>> editable = True, deletable = True,
>> exportclasses=export_classes)
>>
>>
>>
>>
>> Am I  wrong?
>>
>> In version 2.10.3 this works just fine.
>>
>

-- 
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: Problem with wsgihandler.py Apache/Python3

2018-12-08 Thread Peter
In my environment this work. Of course, after that you should enable admin 
through http or configure https. This correction only enable to see what is 
problem.

web2py/applications/admin/models/access.py


# original code
elif not request.is_local and not DEMO_MODE:
raise HTTP(200, T('Admin is disabled because insecure channel'))


# corrected
elif not request.is_local and not DEMO_MODE:
raise HTTP(200, 'Admin is disabled because insecure channel')



On Friday, December 7, 2018 at 2:50:16 PM UTC+1, Carl Petersen wrote:
>
> Hello,
>
> I'm having a similar issue.  I'm using Python 3.6.6, mod_wsgi 4.6.5, 
> Apache 2.4.6 with web2py 2.17.2.
>
> I can get to the welcome screen, but as soon as I try to access the admin 
> application I get the following on my screen:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
>
> Please contact the server administrator at root@localhost to inform them 
> of the time this error occurred, and the actions you performed just before 
> this error.
>
> More information about this error may be available in the server error log.
>
>
> And this in my apache error_log:
>
>  [Fri Dec 07 08:32:14.626246 2018] [mpm_prefork:notice] [pid 30005] 
> AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips 
> mod_wsgi/4.6.5 Python/3.6 configured -- resuming normal operations
>
> [Fri Dec 07 08:32:33.572686 2018] [wsgi:error] [pid 30007] [remote 
> 10.20.100.133:56416] mod_wsgi (pid=30007): Exception occurred processing 
> WSGI script '/opt/web-apps/web2py/wsgihandler.py'.
>
> [Fri Dec 07 08:32:33.572836 2018] [wsgi:error] [pid 30007] [remote 
> 10.20.100.133:56416] TypeError: sequence of byte string values expected, 
> value of type str found
>
> Any assistance would be greatly appreciated.
>
>
>
> On Sunday, September 2, 2018 at 1:03:30 PM UTC-5, motionbutterfly wrote:
>>
>> Hello, I was wondering if anyone here could help me. I've been migrating 
>> a web2py application from Python2.7 to Python3.4, this application was 
>> already being hosted in a webserver with Apache2.4 following the steps in 
>> the Deployment Recipes chapter of the web2py book. I reconfigured apache to 
>> run with python 3, and reinstalled mod_wsgi using pip. My problem is that 
>> as soon as I load my application I get an internal error, and when I click 
>> on the ticket it shows me "500 Internal Server Error", and when I look up 
>> the error log for apache this is what comes up: 
>>
>> [Thu Aug 23 22:42:17.748139 2018] [wsgi:warn] [pid 2268:tid 
>> 139927378876288] mod_wsgi: Compiled for Python/3.4.2rc1+.
>> [Thu Aug 23 22:42:17.748154 2018] [wsgi:warn] [pid 2268:tid 
>> 139927378876288] mod_wsgi: Runtime using Python/3.4.2.
>> [Thu Aug 23 22:42:17.896498 2018] [mpm_event:notice] [pid 2268:tid 
>> 139927378876288] AH00489: Apache/2.4.10 (Debian) OpenSSL/1.0.1t 
>> mod_wsgi/4.3.0 Python/3.4.2 mod_perl/2.0.9dev Perl/v5.20.2 configured -- 
>> resuming normal operations
>> [Thu Aug 23 22:42:17.896584 2018] [core:notice] [pid 2268:tid 
>> 139927378876288] AH00094: Command line: '/usr/sbin/apache2'
>> [Thu Aug 23 22:45:29.528373 2018] [wsgi:error] [pid 2272:tid 
>> 139927187830528] 
>> [Thu Aug 23 22:45:29.528468 2018] [wsgi:error] [pid 2272:tid 
>> 139927187830528] 10
>> [Thu Aug 23 22:45:29.968522 2018] [wsgi:error] [pid 2272:tid 
>> 139927213033216] Loads pas\xc3\xb3
>> [Thu Aug 23 22:45:35.289112 2018] [wsgi:error] [pid 2272:tid 
>> 139927179421440] [remote 186.89.23.145:25178] mod_wsgi (pid=2272): 
>> Exception occurred processing WSGI script 
>> '/home/www-data/web2py/wsgihandler.py'.
>> [Thu Aug 23 22:45:35.289293 2018] [wsgi:error] [pid 2272:tid 
>> 139927179421440] [remote 186.89.23.145:25178] TypeError: sequence of 
>> byte string values expected, value of type str found
>>
>> Which seems to suggest that the problem is inside the wsgihandler.py 
>> script, but doesn't point out where. Has this happened to anyone else 
>> before?
>>
>> Thanks in advance for any help.
>>
>

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


[web2py] Re: SQLFORM.smartgrid exportclasses

2018-12-08 Thread Peter
Thank you. I will consider this option on next project :)

On Wednesday, December 5, 2018 at 1:16:52 PM UTC+1, Tomasz Wrona wrote:
>
> Maybe this information will help you. If you use SQLFORM.grid it will 
> 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.


[web2py] Re: Problem with wsgihandler.py Apache/Python3

2018-12-08 Thread Peter
Similar situation can happen when you try to access admin page through 
simple http protocol over network. Web2py will raise exception and we got 
that error:

TypeError: sequence of byte string values expected, value of type str found

Code responsible for that error is:

if request.is_https:
session.secure()
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1") and \
(request.function != 'manage'):
raise HTTP(200, T('appadmin is disabled because insecure channel'))

One solution is to erase all of this and just put session.secure() but this 
is not good idea and can be use only for testing.

Source of problem is combination of T() and HTTP() helper. In production I 
just remove T() helper like this:

raise HTTP(200, 'appadmin is disabled because insecure channel')

and that solve my problem. Maybe someone have beter solution for that 
problem?

Of course, this will happen in all situation when web2py raise HTTP() with 
T() as argument. So to avoid that I just use string as argument without T() 
helper.

On Friday, December 7, 2018 at 2:50:16 PM UTC+1, Carl Petersen wrote:
>
> Hello,
>
> I'm having a similar issue.  I'm using Python 3.6.6, mod_wsgi 4.6.5, 
> Apache 2.4.6 with web2py 2.17.2.
>
> I can get to the welcome screen, but as soon as I try to access the admin 
> application I get the following on my screen:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
>
> Please contact the server administrator at root@localhost to inform them 
> of the time this error occurred, and the actions you performed just before 
> this error.
>
> More information about this error may be available in the server error log.
>
>
> And this in my apache error_log:
>
>  [Fri Dec 07 08:32:14.626246 2018] [mpm_prefork:notice] [pid 30005] 
> AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips 
> mod_wsgi/4.6.5 Python/3.6 configured -- resuming normal operations
>
> [Fri Dec 07 08:32:33.572686 2018] [wsgi:error] [pid 30007] [remote 
> 10.20.100.133:56416] mod_wsgi (pid=30007): Exception occurred processing 
> WSGI script '/opt/web-apps/web2py/wsgihandler.py'.
>
> [Fri Dec 07 08:32:33.572836 2018] [wsgi:error] [pid 30007] [remote 
> 10.20.100.133:56416] TypeError: sequence of byte string values expected, 
> value of type str found
>
> Any assistance would be greatly appreciated.
>
>
>
> On Sunday, September 2, 2018 at 1:03:30 PM UTC-5, motionbutterfly wrote:
>>
>> Hello, I was wondering if anyone here could help me. I've been migrating 
>> a web2py application from Python2.7 to Python3.4, this application was 
>> already being hosted in a webserver with Apache2.4 following the steps in 
>> the Deployment Recipes chapter of the web2py book. I reconfigured apache to 
>> run with python 3, and reinstalled mod_wsgi using pip. My problem is that 
>> as soon as I load my application I get an internal error, and when I click 
>> on the ticket it shows me "500 Internal Server Error", and when I look up 
>> the error log for apache this is what comes up: 
>>
>> [Thu Aug 23 22:42:17.748139 2018] [wsgi:warn] [pid 2268:tid 
>> 139927378876288] mod_wsgi: Compiled for Python/3.4.2rc1+.
>> [Thu Aug 23 22:42:17.748154 2018] [wsgi:warn] [pid 2268:tid 
>> 139927378876288] mod_wsgi: Runtime using Python/3.4.2.
>> [Thu Aug 23 22:42:17.896498 2018] [mpm_event:notice] [pid 2268:tid 
>> 139927378876288] AH00489: Apache/2.4.10 (Debian) OpenSSL/1.0.1t 
>> mod_wsgi/4.3.0 Python/3.4.2 mod_perl/2.0.9dev Perl/v5.20.2 configured -- 
>> resuming normal operations
>> [Thu Aug 23 22:42:17.896584 2018] [core:notice] [pid 2268:tid 
>> 139927378876288] AH00094: Command line: '/usr/sbin/apache2'
>> [Thu Aug 23 22:45:29.528373 2018] [wsgi:error] [pid 2272:tid 
>> 139927187830528] 
>> [Thu Aug 23 22:45:29.528468 2018] [wsgi:error] [pid 2272:tid 
>> 139927187830528] 10
>> [Thu Aug 23 22:45:29.968522 2018] [wsgi:error] [pid 2272:tid 
>> 139927213033216] Loads pas\xc3\xb3
>> [Thu Aug 23 22:45:35.289112 2018] [wsgi:error] [pid 2272:tid 
>> 139927179421440] [remote 186.89.23.145:25178] mod_wsgi (pid=2272): 
>> Exception occurred processing WSGI script 
>> '/home/www-data/web2py/wsgihandler.py'.
>> [Thu Aug 23 22:45:35.289293 2018] [wsgi:error] [pid 2272:tid 
>> 139927179421440] [remote 186.89.23.145:25178] TypeError: sequence of 
>> byte string values expected, value of type str found
>>
>> Which seems to suggest that the problem is inside the wsgihandler.py 
>> script, but doesn't point out where. Has this happened to anyone else 
>> before?
>>
>> Thanks in advance for any help.
>>
>

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

[web2py] Re: Problem with wsgihandler.py Apache/Python3

2018-11-20 Thread Peter
Check if you have in your application in file appadmin.py code:
try:
  ...
except Exception, e:
  ...

except Exception, e: is python 2 and should be changed to:

except Exception as e:


On Sunday, November 18, 2018 at 7:46:35 PM UTC+1, Dave wrote:
>
> I'm having the same troubles after upgrading to python3 using Apache 
> with libapache2-mod-wsgi-py3 4.5.17-1 on Ubuntu.
>
> I did delete all session files, and I am using fresh source code of web2py 
> (R-2.17.2).
>
> I'm running several applications in web2py, and when i restart Apache they 
> work for a while. Then at some point later, and I haven't figured out what 
> initiates the problem, I am getting:
>
> Traceback (most recent call last):
>   File "/home/ubuntu/mnt/web2py/gluon/main.py", line 445, in wsgibase
> serve_controller(request, response, session)
>   File "/home/ubuntu/mnt/web2py/gluon/main.py", line 207, in 
> serve_controller
> raise HTTP(response.status, page, **response.headers)
> gluon.http.HTTP: 200 OK
>  
> During handling of the above exception, another exception occurred:
>  
> Traceback (most recent call last):
>   File "/home/ubuntu/mnt/web2py/gluon/main.py", line 472, in wsgibase
> BaseAdapter.close_all_instances('commit')
>   File "/home/ubuntu/mnt/web2py/gluon/packages/dal/pydal/connection.py", 
> line 121, in close_all_instances
> db._adapter.close(action)
>   File "/home/ubuntu/mnt/web2py/gluon/packages/dal/pydal/connection.py", 
> line 98, in close
> if len(pool) < self.pool_size:
> TypeError: '<' not supported between instances of 'int' and 'str'
>
>
> In my apache error log I see this:
>
> [Thu Nov 15 04:02:26.546712 2018] [wsgi:error] [pid 9117] [client 
> XXX.XXX.XXX.AA:56599] Timeout when reading response headers from daemon 
> process 'web2pydefault': /home/ubuntu/mnt/web2py/wsgihandler.py
> [Thu Nov 15 04:08:52.161152 2018] [wsgi:error] [pid 9111] [client 
> XXX.XXX.XXX.AB:40713] Timeout when reading response headers from daemon 
> process 'web2pydefault': /home/ubuntu/mnt/web2py/wsgihandler.py
> [Thu Nov 15 04:26:51.746340 2018] [wsgi:error] [pid 8081] [client 
> XXX.XXX.XXX.AC:2960] Timeout when reading response headers from daemon 
> process 'web2pydefault': /home/ubuntu/mnt/web2py/wsgihandler.py
> [Thu Nov 15 04:38:41.429260 2018] [wsgi:error] [pid 8081] [client 
> XXX.XXX.XXX.AD:48360] Timeout when reading response headers from daemon 
> process 'web2pydefault': /home/ubuntu/mnt/web2py/wsgihandler.py
> [Thu Nov 15 04:44:56.502509 2018] [wsgi:error] [pid 7466] [remote 
> XXX.XXX.XXX.AE:7339] mod_wsgi (pid=7466): Exception occurred processing 
> WSGI script '/home/ubuntu/mnt/web2py/wsgihandler.py'.
> [Thu Nov 15 04:44:56.502575 2018] [wsgi:error] [pid 7466] [remote 
> XXX.XXX.XXX.AE:7339] TypeError: sequence of byte string values expected, 
> value of type str found
> [Thu Nov 15 04:50:20.030220 2018] [wsgi:error] [pid 8081] [client 
> XXX.XXX.XXX.AF:33766] Timeout when reading response headers from daemon 
> process 'web2pydefault': /home/ubuntu/mnt/web2py/wsgihandler.py
> [Thu Nov 15 05:00:40.384970 2018] [ssl:warn] [pid 9665] AH01909: 
> XXX.XXX.XXX.AG:443:0 server certificate does NOT include an ID which 
> matches the server name
> [Thu Nov 15 05:00:40.407686 2018] [ssl:warn] [pid 9667] AH01909: 
> XXX.XXX.XXX.AG:443:0 server certificate does NOT include an ID which 
> matches the server name
> [Thu Nov 15 05:03:10.875058 2018] [wsgi:error] [pid 9668] [remote 
> XXX.XXX.XXX.AF:34126] 
> /home/ubuntu/mnt/web2py/gluon/contrib/pymysql/cursors.py:166: Warning: 
> (3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be 
> removed in a future release.")
> [Thu Nov 15 05:03:10.875093 2018] [wsgi:error] [pid 9668] [remote 
> XXX.XXX.XXX.AF:34126]   result = self._query(query)
>
> Is it possibly related to this?:
>
> stackoverflow: TypeError: sequence of byte string values expected, value 
> of type str found 
> <https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found>
>
>
>
> On Saturday, 8 September 2018 12:22:49 UTC-7, Peter wrote:
>>
>> Try to remove all session files. I think that problem is in pickle which 
>> is different in python 2 and python 3 (data type is not same in python 2 
>> and python 3).
>>
>> Use fresh source code of web2py with your application. Don't start web2py 
>> with python 3 after use with python 2. 
>>
>

-- 
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: Problem with wsgihandler.py Apache/Python3

2018-09-08 Thread Peter
Try to remove all session files. I think that problem is in pickle which is 
different in python 2 and python 3 (data type is not same in python 2 and 
python 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] Re: Ubuntu web2py

2018-08-02 Thread Peter
No pressure! but Ubuntu 9.04 is unsupported at this stage and probably not 
even getting security updates.   
There may be good reason not to (e.g. impact on other apps/requirements) 
but I would recommend a fresh install of Ubuntu 18.04 LTS (or Linux Mint 18 
which is based on Ubuntu ) rather than running through a load of time 
consuming downloads and distribution updates.* If there is no good reason 
not to! * it's a relatively painless exercise, you can get your hands on a 
Live CD (usually found with Linux Magazines) or download the ISO and write 
it to a CD - loads of instructions out there.  

-- 
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: heroku, web2py and gunicorn

2018-08-02 Thread Peter

In case it's of any benefit.
Just installed LinuxMint 18 on my laptop, installed gunicorn from the 
software manager

python anyserver.py -s gunicorn
starting gunicorn on 127.0.0.1:8000...
[2018-08-03 02:09:42 +] [31660] [INFO] Starting gunicorn 19.4.5
[2018-08-03 02:09:42 +] [31660] [INFO] Listening at: http://127.0.0.1:8000 
(31660)
[2018-08-03 02:09:42 +] [31660] [INFO] Using worker: sync
[2018-08-03 02:09:42 +] [31665] [INFO] Booting worker with pid: 31665

web2py opens without issue...
2.14.6-stable+timestamp.2016.05.10.00.21.47 
(Running on gunicorn/19.4.5, Python 2.7.12)

I have some python dependencies to sort (after new install) before I can 
dig much deeper but, on a cursory look, apps with no missing dependencies 
appear to be working fine.
  

-- 
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: web2py internal error

2018-07-17 Thread Peter Hendriks
When web2py generates an error like that, the ticket that it links to 
contains details of what is causing the error. That ticket is also written 
to disk somewhere. You can check the web2py documentation for where the 
ticket is stored so you can look at it to determiner what is wrong.

Thanks
Glenn

the answer above I have got from pythonanywhere. my hosting is overthere.


Op dinsdag 17 juli 2018 00:18:34 UTC+2 schreef Anthony:
>
> On Monday, July 16, 2018 at 3:18:44 PM UTC-4, Peter Hendriks wrote:
>>
>> Ticket issued: 
>> malta_advies/141.8.9.39.2018-07-16.13-01-34.2270ef94-db9a-47a5-8866-f081bdf9715f
>>  
>> <https://www.malta-advies.nl/admin/default/ticket/malta_advies/141.8.9.39.2018-07-16.13-01-34.2270ef94-db9a-47a5-8866-f081bdf9715f>
>>
>> Since this morning the above I see when I type my website.
>>
>> for info : my website is https://www.malta-advies.nl
>>
>> With admin I can go into the admin, but not further then that. After that 
>> clicking any link again the same ticket ... .
>>
>> Anyone experience with this one?
>>
>
> When you click on the ticket link and then log into the admin app, what 
> happens next? You can copy on of the error ticket files from your server 
> (in the /errors folder) to a development machine and view it in admin on 
> the development machine.
>
> 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: web2py internal error

2018-07-17 Thread Peter Hendriks
I can go in to the admin by typing https://www.maltaa-advies.nl/admin

then I get the login screen for admin.

Op dinsdag 17 juli 2018 00:12:29 UTC+2 schreef Dave S:
>
>
>
> On Monday, July 16, 2018 at 12:18:44 PM UTC-7, Peter Hendriks wrote:
>>
>> Ticket issued: 
>> malta_advies/141.8.9.39.2018-07-16.13-01-34.2270ef94-db9a-47a5-8866-f081bdf9715f
>>  
>> <https://www.malta-advies.nl/admin/default/ticket/malta_advies/141.8.9.39.2018-07-16.13-01-34.2270ef94-db9a-47a5-8866-f081bdf9715f>
>>
>> Since this morning the above I see when I type my website.
>>
>> for info : my website is https://www.malta-advies.nl
>>
>> With admin I can go into the admin, but not further then that. After that 
>> clicking any link again the same ticket ... .
>>
>> Anyone experience with this one?
>>
>
> Does "clicking any link again the same ticket" mean that you get a ticket 
> from any link the *admin* app displays?That's my first thought about 
> what "not further than that" means.  That usually means a problem with some 
> resource the admin app depends on.  Sometimes it means you're out of space, 
> though creating a ticket does require space so the error handler usually 
> ends up with a message about "ticket unavailable".
>
> Do you have console access to your host?  If so, you can read the error 
> ticket as a text file, although the formatting will be horrible.
>
> /dps
>
>
>

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


[web2py] web2py internal error

2018-07-16 Thread Peter Hendriks
Ticket issued: 
malta_advies/141.8.9.39.2018-07-16.13-01-34.2270ef94-db9a-47a5-8866-f081bdf9715f
 


Since this morning the above I see when I type my website.

for info : my website is https://www.malta-advies.nl

With admin I can go into the admin, but not further then that. After that 
clicking any link again the same ticket ... .

Anyone experience with this one?

-- 
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] Payment integration documentation needs update

2018-07-11 Thread Peter Woolf
Hello,

I'm exploring ways to integrate a payment option into a web2py application 
and see that part of the documentation is quite outdated.

http://web2py.com/books/default/chapter/29/14?search=payment#Accepting-credit-card-payments

In particular, the section on Level 2 integration with Google Checkout. 
 Google Checkout was discontinued in 2013:

https://en.wikipedia.org/wiki/Google_Checkout

I'm hunting for an easy way to charge for a web service--seems a basic 
function of many web2py sites.  I'm a bit frustrated that the first way the 
documentation directed me to was shuttered years ago, but hopefully some of 
the other paths will be more fruitful!

Thanks,
--Peter

--Peter


-- 
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: VIEW NAME NOT ID

2018-05-21 Thread Peter
instead of this code:

{{=row[db.product_input.product]}}

try this (not tested) 
{{=row.product.SOME_FIELD_NAME_FROM_PRODUCT_TABLE}}



On Monday, April 30, 2018 at 7:53:20 PM UTC+2, Ayron Rangel wrote:
>
>  I have this:
>
> db.py:
> db.define_table('product_input',
> Field('product', db.product, notnull=True),
> Field('total_price','decimal(7,2)', readable=False,writable=False),
> Field('amount', 'integer', readable=False,writable=False),
> Field('supplier', db.supplier, notnull=True),
> Field('location', db.location, notnull=True),
> Field('input_type', 'string'),
> auth.signature,
> format = lambda r: '%s %s %s %s  [%s]' % (r.product.model.model, 
> r.product.manufacturer.manufacturer, r.product.part_number, 
>r.product.serial_number, r.product.expiration_date)
> 
> )
>
> default.py: 
> def stock():
> count = db.product_input.id.count()
> results = db(db.product_input).select(db.product_input.product, count, 
> groupby=db.product)
> return locals()
>
> view: 
> {{for row in results:}}
> 
> {{=row[db.product_input.product]}}
> {{=row[count]}}
> 
> {{pass}}
>
>
> APPEARS JUST THIS:
>
> Product in Stock [Model]Amount
> 6 2
> 7 2
>
> HOW CAN APPEARS THE NAME NOT THE ID ON DE LINE?
>
>
>
>
>

-- 
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: Import application from staging to production server

2017-11-19 Thread Peter

I don't understand the 'local_import'  in this line

pygal = local_import('pygal')
>
>
Can't find it in the documentation for web2py, pygal or  searching  python 
local_import... 


but pygal works for me using just... 

import pygal
>

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

2017-11-13 Thread Peter
I need only csv export method from  SQLFORM.smartgrid so I want to disable 
default export methods. Seems to me that 
SQLFORM.smartgrid(exportclasses=dict(json=False)) doesn't work in newer 
versions of web2py (2.14.6). 

My code:

export_classes = dict(json=False, html=False,
  tsv=False, xml=False, csv_with_hidden_cols=False,
  tsv_with_hidden_cols=False)

table = SQLFORM.smartgrid(db.tableexample, user_signature=False, 
showbuttontext=False,
links=links, linked_tables=[],
editable = True, deletable = True,
exportclasses=export_classes)




Am I  wrong?

In version 2.10.3 this works just fine.

-- 
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: back button

2017-09-03 Thread Peter


Hi Andrea,

The solution is probably in this post ...

https://groups.google.com/forum/#!topic/web2py/z6lOXNgGws8

Hope this helps!

-- 
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: Parent - Child (multiple rows / grid) form development

2017-07-12 Thread Peter

Correct Ramesh,

That is for viewing the invoice details on screen after the Invoice has 
been created (taking information from an Invoice_header table and related 
records in the Line_items)
but the Invoice Preview provided to the user appears identical (although 
the information comes from the Company and Line_items tables). 
(If I understand it correctly, this is where web2py Components, mentioned 
by Dave, would come in useful, allowing re-use of code. With a bit of 
tweaking I think the same code could provide both views). 


Regards
Peter


On Wednesday, 12 July 2017 13:55:46 UTC+1, Ramesh Meda wrote:
>
> Peter, 
>
> Thank you, that could work for reading invoice.  I guess it might require 
> a bit more for accepting / creating new invoice... or do I get this wrong. 
>
> Regards,
> Ramesh.
>
>
>

-- 
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: Parent - Child (multiple rows / grid) form development

2017-07-11 Thread Peter
Thanks for correcting this Dave.

(Will have to read up on components).

 Peter




-- 
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: Parent - Child (multiple rows / grid) form development

2017-07-11 Thread Peter
Hi Ramesh,

I return a crud.read() for the invoice header and a separate query output 
for the invoice lines.

My approach is to store all Invoice Header info in a separate table on 
Invoice creation. (This is to ensure that an exact copy invoice 
can be reproduced at any later date and is not affected if company name, 
phone number, email or anything that could change 
down road does change. I also ensure that anything material to invoice 
lines is locked down once invoiced so user cannot change 
affect the invoice line details) 

I'm not saying this is best practice but it works for me.

so, the simplified versions of my controller and view would be something 
like...

def view_invoice():
invoice_id = request.args(0)

invoice_header = crud.read(db.invoice[invoice_id])

query = db(query to filter the required invoice lines)
invoice_lines = query.select(tables & fields to represent the invoice 
lines)))

return dict(invoice_header=invoice_header, invoice_lines=invoice_lines)


and the view...

{{extend 'layout.html'}}

{{=invoice_header}}

{{=invoice_lines}}


Hope this helps!

Peter


On Monday, 10 July 2017 20:56:58 UTC+1, Ramesh Meda wrote:
>
> What would be the best approach to develop Parent-Child forms in Web2Py 
> please...
>
> Case in point... lets say, simple invoice application (over simplified for 
> the sake of discussion) 
> Invoice Header (Parent), with invoice information and 
> Invoice Items (Chid), with multiple line items (grid) 
>
> Thanks in advance... 
>

-- 
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: change login page layout

2017-07-06 Thread Peter

Hi Anthony,

I wasn't sure if what I was doing was just a hack or how far it might 
impact. 
e.g if the application included some function with 'user' in the name like 
'def ..user..()'  
it too would pick up the alternate layout (I think).
  
Peter

-- 
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 to debug via admin?

2017-07-05 Thread Peter

Hi Ramos

That is potentially a huge question and maybe I am misunderstanding, 
apologies if so.

I usually use print statements to output and track variable values or 
args/vars  and that is usually sufficient for my needs, 
but surely you just need to insert a breakpoint (trial and error) just 
before the error occurs (or several breakpoints).
then use 'Step' (or the other options) to step/skip through the code and 
observe whats happening on the lead up to the break.

Hadn't looked at debug before but it's cool!


Regards 
Peter

-- 
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: change login page layout

2017-07-05 Thread Peter

Hi Pierre,

I don't know the recommended method and I have not tested to see exactly 
how many pages are affected by this 
(so I'm happy to be corrected) but this worked for me at least on the login 
page...


edit user.html

and replace first line...

{{extend 'layout.html'}}

with

{{if not 'user' in request.env.path_info:}}
{{extend 'layout.html'}}
{{else:}}
{{extend 'mylayout.html'}}


Regards
Peter

-- 
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 long() with base 10:

2017-07-05 Thread Peter

Hi BlueShadow,

Are you using routes.py? (Which I know nothing about)

Can you redirect errors to a custom error_handler function that parses the 
error out and redirects to a valid page...

from the book...

In "routes.py" you can also specify an action in charge of error handling:
> error_handler = dict(application='error',
>  controller='default',
>  function='index')
>
 

> If the error_handler is specified the action is called without user 
> redirection and the handler action will be in charge of dealing with the 
> error. 

In the event that the error-handling page itself returns an error, web2py 
> will fall back to its old static responses.
>


Peter 

-- 
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: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-04 Thread Peter

Glad you got something out of it Matt!

I decided to try and follow it through to the end but couldn't.  (I did get 
the grid check-boxes working but only if I selected just one report at a 
time).

Your solution with the links is more user friendly (one click generates the 
report) if you haven't thought of it... using right click on the link might 
be a good 
option (keeps the reports list in its own tab for subsequent requests) 

In my case selecting multiple reports doesn't work, probably because 
control passes to the first report_function and the calling function is 
simply 
dropped so the loop in the calling function doesn't continue to any 
subsequent request)

I would be interested to here if "buttons_placement = 'right' " does what I 
think it is is supposed to...
Did the check-boxes, in your initial coding, appear on right?


Regards
Peter


  

-- 
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: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-04 Thread Peter


Based on previous code, the companies query/function would look something 
like...


def csv_companies():
# assumes there is a table called 'company'with field 'name'
query = db.company.id > 0
companies = db(query).select(db.company.id,
  db.company.name,
  # ...
  # the list of 'company' fields you want in your query
  # you can join other tables and include fields from 
them here as well  
  # ...
 )

return dict(companies=companies)





The view (csv_companies.html) would be something like...

{{
import cStringIO
stream = cStringIO.StringIO()
companies.export_to_csv_file(stream)
response.headers['Content-Type'] = 'application/vnd.ms-excel'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 
your_file_name
response.write(stream.getvalue(), escape=False)
}}


Note it doesn't have 

{{extend 'layout.html'}} 

as it pushes the output to a user dialogue asking if they want to open/save 
it somewhere on their machine. 
(You may want to do something different like simply write it to a directory 
or create a db entry referencing 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/d/optout.


[web2py] Re: SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-07-03 Thread Peter

Hi Matt,

I'm no expert (only discovered the wonders of the grid in the last couple 
of weeks) and maybe others 
will have a better way but I have tested this and it might get you going...

(Also you might want to give a little more information on the 
requirements... 
Where have you got to? 
Do the reports require further interaction/parameters when selected? 
Have you developed the reports themselves?)  

# So as far as I understand it, the grid requires a table (or possibly a 
dummy table? I went with a real one)

db.define_table('reports',
Field('report_name',),
Field('report_function',)
)

and added two records...
1, Activities Report, csv_activities
2, Companies Report, csv_companies


The report_functions should point to valid report functions/views 
that you have created (I can provide some info on this if needed)


def output_reports():
print "output reports: received vars %s" % request.vars
for record_id in request.vars.id:
print "run report %s" % db.reports[record_id].report_function
redirect(URL('report_factory',[]))


def report_factory():
query = db.reports.id > 0
fields = (db.reports.id, db.reports.report_name)
grid = SQLFORM.grid(query,
field_id= db.reports.id,
fields=fields,
searchable=False,
create=False,
selectable=lambda ids: redirect(URL('default', 
'output_reports', vars=dict(id=ids))),
editable=False,
deletable=False,
details=False,
buttons_placement='right',
csv=False
)

return dict(grid=grid)



The print output below shows what is happening and simulates 'running 
report/s'  
after selecting each report separately and then the two together


output reports: received vars 
run report csv_activities

output reports: received vars 
run report csv_companies

output reports: received vars 
run report csv_activities
run report csv_companies


Hope this helps!
Peter

-- 
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: FPDF "ne commence pas par '%PDF-' "

2017-06-28 Thread Peter

Usually I'm the one getting the help J-Michel, 

So I'm very happy to have helped someone out for a change!

Regards
Peter

-- 
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: FPDF "ne commence pas par '%PDF-' "

2017-06-25 Thread Peter

Have been outputting pdfs for a while and this is what works for me ...
  
note, I don't close the pdfpdf.close? but this allows the user to 
either open or save the file anywhere on their machine (Linux and Windows)



pdf.cell( ln=0, h=9.0, align='R', w=178.0, txt="%s %s" % (euro(), 
'{:10,.2f}'.format(inv_tot)), border=0 )

import os
import sys
if session.inv_print_type == 'ORIGINAL':
invc_filename = "INVC_%s_%s.pdf" % 
(session.inv_number,session.inv_company)
else:
invc_filename = "INVC_%s_%s_COPY.pdf" % (session.inv_number, 
session.inv_company)

invc_filename = invc_filename.replace(' ','_')
invc_filename = invc_filename.replace( '&', 'and')

s_io = pdf.output(dest='S')
response.headers['Content-Type']='application/pdf'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 
invc_filename
raise HTTP(200, s_io, **response.headers)

>
>
>

-- 
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 to use FORM, INPUT to create a field with dropdown list?

2017-06-25 Thread Peter

Almost straight from the book but using my own db fields - tested and 
works...

This controller in default.py

def from_factory():
form = SQLFORM.factory(Field('your_name', requires = 
IS_IN_DB(db,db.person.id,'%(first_name)s')))
if form.process().accepted:
response.flash = 'form accepted'
session.your_name = form.vars.your_name
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)


with this view 'from_factory.html'

{{extend 'layout.html'}}
{{=form}}


gives a drop down list of person's first_names.

The selected name is now held in the cookie  'session.your _name'

but if you want the table id then,

replace...session.your_name = form.vars.your_name

with something like ...   session.person_id = form.vars.id

Hope this helps.

Peter





-- 
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: query re grid signature

2017-06-12 Thread Peter
That sorted it Stefan - Thanks !
(one more thing to remember when I'm migrating the app to the cloud or I 
might just leave it as it as doesn't seem to get in the way of anything).

Regards
Peter

On Tuesday, 13 June 2017 02:16:25 UTC+1, 黄祥 wrote:
>
> i think it's normal, seems you didn't put user_signature=False during 
> define SQLFORM.grid (the default and recommended user_signature=True)
> for session_secure(), i think it's not related with user_signature, it's 
> just set the session cookie to be secure cookie and ensure web app using 
> https.
>
> ref:
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid
> http://web2py.com/books/default/chapter/29/04/the-core#session
>
> 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] query re grid signature

2017-06-12 Thread Peter

This comes up in the url for a page with a grid...
 
*default/apply_payment_to_multiple?_signature=8f626b099c6cd28faa2a6e91c8b86e5ab2d3f2ce*

The '_signature' is something I have not seen before and maybe its 
something I accidentally caused.

The book says

When generating a URL, you have the option to digitally sign it. This will
> append a _signature GET variable that can be verified by the server.
>


web2py is running on my local machine with no HTTPS 

but I may have inadvertently enabled

#session.secure()


around the first time the grid was used - is that the reason?
or is it just normal with a grid?


Regards
Peter 

-- 
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: Trying to use a variable as a field name in a table insert

2017-06-12 Thread Peter


> I don't think I said anything was "non pythonic" (I identified some *invalid 
> *code -- but that code literally doesn't work at all, it is not merely 
> non-Pythonic).
>
The above code was my suggested (working) alternative, and I think the use 
> of dictionary unpacking would be considered Pythonic.
>
 
Absolutely no argument from me Anthony. 
I simply didn't fully understand - that's on me - but thanks to you, taking 
the time to explain, I understand more now.  

If I haven't said it before... 
*I really do appreciate the time and effort you and others give to the 
forum and noobs like me - I'd be lost without it!*

Incidentally, I may have another query to post, so hoping for some more 
support shortly!

Regards
Peter






-- 
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: Trying to use a variable as a field name in a table insert

2017-06-12 Thread Peter

Re:
What's wrong with this approach
db.payment_allocations.insert(**{'payment_ref': payment.id,
 ref_field: record.id,
 'amount_allocated': allocation})

To be honest I was trying to up my game with a bit of abstraction but 
haven't used the ** kwargs much (I don't think at all in web2py), 
so with my limited understanding I thought it fell into the 'non pythonic' 
category you mentioned, though I do understand it is passing 
a dictionary of values as opposed to over-riding an expected variable as in 
my earlier case.

Will give it a go so, thanks Anthony!

Thanks 
Peter







-- 
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: Trying to use a variable as a field name in a table insert

2017-06-08 Thread Peter

I see...  
>
>  TypeError: some_function() got an unexpected keyword argument 
> 'parameter_name'
>


I was trying to avoid the if else but if it's the better way, so be it 
and I have changed the code using a session cookie...

if session.allocations_table_name == 'task': 

db.payment_allocations.insert(payment_ref=payment.id,   
 


  task_ref=record.id,

  amount_allocated=allocation)


elif session.allocations_table_name == 'invoice':

db.payment_allocations.insert(payment_ref=payment.id,

  invoice_ref=record.id,

  amount_allocated=allocation)

Thanks for talking the time to explain Anthony! 

Peter





-- 
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: Trying to use a variable as a field name in a table insert

2017-06-08 Thread Peter

Thanks for that Anthony!   (I have a feeling of deja vu about that one)

If you have time can you tell me what you mean...

That's not valid Python code


I'm not sure what it refers to and would like understand where I am doing 
something wrong.


Regards
Peter

-- 
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] Trying to use a variable as a field name in a table insert

2017-06-07 Thread Peter

Good Morning.

I'm hoping there is a way to solve this...

This works fine for me...

db.payment_allocations.insert(payment_ref=payment.id, 
task_ref=record.id,
amount_allocated=allocation) 

but I want to add a little abstraction like this...

ref_field = '%s_ref'  %  table_name# where resulting field name 
will be either  'task_ref' or 'invoice_ref' (both fields are valid in the 
insert table).  
db.payment_allocations.insert(payment_ref=payment.id, 
ref_field=record.id,
  amount_allocated=allocation)

which currently gives an Attribute Error (taking ref_field literally and 
not substituting the variable's assigned value)

Is this possible to achieve what I want?
Any pointers would be appreciated.

Thanks
Peter

-- 
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 to access selected fields/objects in SQLFORM.grid as opposed to grid row ids

2017-06-06 Thread Peter
STOP PRESS!

As has happened more than once - documenting the problem opened my mind to 
other possibilities.

I was wrong in saying...  "One post indicated this was a list of the task 
ids but not from what I can see, instead it appears to me to be returning 
the grid row ids for checked items."

IT IS RETURNING THE task.id

There was a one to one mapping of row position to actual task.ids and for 
reasons too long to go into at this hour
I wasn't expecting the tasks to be in their natural .id order - reversing 
the sort order highlighted that it is in fact the task ids)
 
Peter
 

> Regards
> Peter
>
>
>
>
>

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


[web2py] How to access selected fields/objects in SQLFORM.grid as opposed to grid row ids

2017-06-06 Thread Peter

Good morning all,

I am using SQLFORM.grid for the first time and I'm baffled (not for the 
first time).
Related posts don't illuminate my issue and at least one seems to 
contradict what I'm seeing.

This is the controller - with some dross removed...

tasks = (db.task.person == person.id)

fields = (db.task.id, db.task.charge, db.task.start_time, db.task.person, 
db.task.title, db.task.task_status)

selectable = [('Allocate Payment',  lambda ids: 
redirect(URL('new_payment_allocation', vars=dict(ids=ids]

grid = SQLFORM.grid(db(billable_tasks),
orderby=myorder, all
fields=fields,
selectable=selectable,
deletable=False,
editable=True,
searchable=False,
create=False,
sortable=True,
maxtextlength=150,
paginate=task_count,
details=True,
csv=False)



When I list the selected ids (returned by the lambda)  in my 
new_payment_allocation view I can see a list of ids. 
One post indicated this was a list of the task ids but not from what I can 
see, instead it appears to me to be returning 
the grid row ids for checked items.

My problem is that I can't see how to convert/relate this list of selected 
grid row ids to the required task objects or db.task.id field?

As always any help would be appreciated.

Regards
Peter




-- 
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 - trying to limit search filter to queried items not entire table items

2017-05-31 Thread Peter
Thanks again Anthony, 

To be honest that's a bit beyond my abilities at the moment though plenty 
of food for thought! 
I think I have a work around... essentially by doing the person search 
before building the list for the grid. 
i.e I can identify the person first and add person.id it to the query 
filter, 
my view will only present activities belonging to the person negating any 
need to search by person.

Peter  


The simplest alternative might be to use a computed field. Alternatively, 
> you could further develop your approach of adapting the db.task.person 
> field for your purposes. For that to work, you would have to implement 
> custom search functionality (the "searchable" argument can be a function 
> that generates a custom search query, and the "search_widget" argument can 
> be a custom search widget for the UI). If you want proper sorting, you 
> would also have to intercept sorting requests and override with a custom 
> "orderby" argument.
>
> 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] SQLFORM.grid - trying to limit search filter to queried items not entire table items

2017-05-31 Thread Peter


I have a person table and a task table, every task references some person.

Both tables have a virtual field 'display_name' that constructs a 
meaningful coded name returned 
as a string to display on screen if person is a 'client'.  
 
SQLFORM.grid is used to provide a selectable list of entries filtered from 
the task table.

*I want to use the coded display_names in the grid and to be able to search 
within the field content (as text) for filtering*.
   
Using task.display_name (virtual field) in the grid creates issues 
because... 
the field it is not available to add to any search criteria. (note: It's 
not made readable=False anywhere)
it's not sortable, 
it looks different - the title header is shown in plain black 
so not being handled in the same way as 'normal' fields 
.



Trying a work around with task.person

db.task.person.represent = lambda id, row: row.display_name

results in other issues - 

the person field is available to search 



but when trying to add any search criteria (a name) it shows the default 
 table  'format='  (i.e. not the coded names) in the drop down,
sorting works but is done on hidden id and not by visible 
name/alphabetically.
the list of available names to choose from is a complete list of all names 
in the person table i.e. not filtered to the available names in the grid 
entries 
also the choice is selectable as an id (= or !=) as opposed to searchable 
as text.

So after all that (sorry if it's long winded)...

Is it possible to get the display_name (virtual field) to appear/behave as 
a 'normal' field in the grid? 
Ideally making it available as an option in the field drop down list and 
available to search as text  with appropriate 
selectors ('starts with', 'contains'  etc  and not as an id field like the 
person field with an extended drop down list of names).


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: List reference counting elements

2017-05-29 Thread Peter

Have not tested this but it think something like adding the last line 
below... 

{{for row in formListar:}}

{{=row.movies.title}}
{{=row.movies.categories}} 
{{=len(row.movies.categories)}}



On Tuesday, 30 May 2017 02:38:01 UTC+1, Winter Kryz wrote:
>
> Hello everybody,
>
> I have a table like this
>
> Movie = db.define_table('movies',
>  Field('title','string', label = 'Title'),
>  Field('date_release','integer', label = 'Date Release'),
>  Field('duraction','integer', label = 'Duraction'),
>  Field('category','string','list:reference categories', label = 'Category'),
>  Field('actor','list:reference actors', label = 'Actor'),
>  Field('director','list:reference directors', label = 'Diretor'),
>  )
>
>
> on the views
> 
> 
> Title
> Number of categories
> 
> 
> {{for row in formListar:}}
> 
> {{=row.movies.title}}
> {{=row.movies.categories}}
>
> So, I would like to display the number of elements that the list:reference 
> categories has on it. 
> So for example: Category: 3 elements.
>
> There is a particular function to do that?
>
> Please, someone can help me I will appreciate that.
>
> 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: Can't get compute field or virtiual field to work for me

2017-05-28 Thread Peter


STOP PRESS - Got it!

So I've learned something new - *thanks again Anthony!*

Still not paying enough attention to the tracebacks - subsequent errors 
were a different problem.


for the record this virtual field definition...

db.person.display_name = Field.Virtual('display_name', get_user_short_name)




with this function...

def get_user_short_name(row):
display_name = "NAME ERROR - unknown person type"

if row.person.person_type == 'CLIENT':
if row.person.referrer_ref:
display_name = '%s %s' % (row.person.referrer_ref, 
row.person.first_name)
else:
display_name = 'PAP/%s %s' % (row.person.id, row.person.first_name)

elif row.person.person_type == 'CONTACT':
display_name = '%s, %s' % (row.person.last_name, row.person.first_name)

print 'get_user_short_name(): returning name: >%s< for id >%s<' % 
(display_name, row.person.id)
return display_name




produces the varied name format I was looking for

DisplayName: PAP/10 Evelyn 
DisplayName: PH 345562 Margaret

DisplayName: PAP/24 Matt

DisplayName: Gilmore, David 















-- 
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: Can't get compute field or virtiual field to work for me

2017-05-28 Thread Peter
Thanks Anthony 

I would like to get the later suggestion working but not sure how to pass 
the row object from a field or if this is what you mean the signature it 
needs?


My function is updated to this...   # There were typos in the filed name 
which weren't helping 
(e.g. person.type should have been person.person_type - I know it's not 
good practice but was trying to avoid restricted words like 'type') 

def get_user_short_name(row):
display_name = "NAME ERROR - unknown person type"

if row.person.person_type == 'CLIENT':
if row.person.referrer_ref:
display_name = '%s %s' % (row.person.referrer_ref, 
row.person.first_name)
else:
display_name = 'PAP/%s %s' % (row.person.id, row.person.first_name)

elif row.person.person_type == 'CONTACT':
display_name = '%s, %s' % (row.person.last_name, row.person.first_name)
print 'get_user_short_name(): returning name: >%s< for id >%s<' % 
(display_name, row.person.id)
return display_name




and have tried various formats for the Virtual field definition...

db.person.display_name = Field.Virtual('display_name', get_user_short_name)
db.person.display_name = Field.Virtual('display_name', get_user_short_name())
db.person.display_name = Field.Virtual('display_name', get_user_short_name(row))

 
but none are working for me.






On Monday, 29 May 2017 03:01:49 UTC+1, Anthony wrote:
>
>
> When I add code to display the contents'Shortname: %s' % 
>> person.short_name 
>> (even after I have edited the table - which I understand should trigger 
>> the shortname update)
>>
>
> Updating the record will only trigger the compute field update if *all* 
> the fields needed by the function are included in the updated fields. The 
> compute function will not fetch non-updated fields from the database in 
> order to calculate the computed value.
>  
>
>> and for the seond method'DisplayName: %s' % person.display_name
>>
>> I get an attribute error...
>>
>> Traceback (most recent call last):
>>   File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File 
>> "/home/peter/web2py/applications/PAPILLON_AIM/controllers/default.py", line 
>> 2256, in 
>>   File "/home/peter/web2py/gluon/globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File "/home/peter/web2py/gluon/tools.py", line 4241, in f
>> return action(*a, **b)
>>   File 
>> "/home/peter/web2py/applications/PAPILLON_AIM/controllers/default.py", line 
>> 305, in view_person
>> 'DisplayName: %s' % person.display_name
>>   File "/home/peter/web2py/gluon/packages/dal/pydal/objects.py", line 90, 
>> in __getattr__
>> raise AttributeError
>> AttributeError
>>
>
> When defining a virtual field, inside the function, you must use 
> row.tablename.fieldname to refer to each field, not just row.fieldname.
>
> As an aside, why not change the get_user_short_name function to take a 
> single row object rather than each of the individual field values? That 
> way, instead of having to do:
>
> Field.Virtual('display_name', lambda row: get_user_short_name(...))
>
> you can simply do:
>
> Field.Virtual('display_name', get_user_short_name)
>
> In other words, as long as you are creating a function solely for this 
> purpose, just give it the signature it needs without having to wrap it in a 
> lambda.
>
> 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: how to compare date time in web2py?

2017-05-28 Thread Peter
I had some fun with this

max_age_allowed = 20 * 60  # total seconds in 20 minutes
update_age = request.now - person.created_on  # Duration in datetime format 
since record created
update_age = update_age.total_seconds()   # Duration converted to seconds
print "It is %s seconds since record created (threshold is %s seconds)" % 
(update_age,max_age_allowed )
if update_age > max_age_allowed:
print 'Do something'
else:
print 'Nothing to do here'



output

It is 2102030.41814 seconds since record created (threshold is 1200 seconds)
Do something

Hope this helps.





On Thursday, 19 July 2012 10:05:41 UTC+1, Amit wrote:
>
> Hi,
> I have some records in a table and each record is having one field of type 
> datetime [fromat : 2012-07-19 23:12:0 (-MM-DD HH:MM:SS)], table 
> structure is:
>
> Emp_ID
> Emp_Name
> Emp_Address
> Emp_Salary
> updated_on(Type: datetime)
>
> periodically getting data against each Emp_ID and updating to the 
> particular record, every 20 mins data has to be updated for each Emp_ID, 
> for e.g : suppose for one Emp_ID data has updated on 2012-07-19 10:10:00 
> then again it has to update on 2012-07-19 10:30:00 etc...
>
> and if data is not updated in 20 mins then one scheduler will verify 
> against the updated_on column value and inform user that data has not 
> updated  for particular employee.
>
> Problem facing:
> How to compare current datetime with updated_on coulmn value in web2py? 
> can anybody please share me the code to achieve the same?
>

-- 
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] Can't get compute field or virtiual field to work for me

2017-05-28 Thread Peter

I'm trying to build a default display name from the table/fields below 
depending on person.type and
whether or not the person.referrer_rf is populated and I am trying two 
different methods 

1> a compute field and 
2> a virtual field

Either would probably suffice if can get one to work...


e.g. Database content
idfirst_namelast_nameperson_typereferrer_refshort_name
1JohnDoe  CLIENT  TH/256  Null  

2JaneDoe  CLIENT  7845 Null 
  
3JackDoe  CLIENT  
Null
4Jill   Doe  CONTACT  
Null


Required output - Expected Shortname (or Displayname)
id
1TH/256 John
27845 Jane
3PAP/3 Jack
4Doe, Jill 






I have this function in the model

def get_user_short_name(id, type, referrer_ref, first_name, last_name):

display_name = "NAME ERROR - unknown person type"

if type == 'CLIENT':
if referrer_ref:
display_name = '%s %s' % (referrer_ref, first_name)
else:
display_name = 'PAP/%s %s' % (id, first_name)

elif type == 'CONTACT':
display_name = '%s, %s' % (last_name, first_name)

return display_name


and this person table

db.define_table('person',
Field('person_type', 
requires=IS_IN_SET(PERSON_TYPES),default='CLIENT',
  label='ContactType',
  comment="* CLIENT for Clients otherwise CONTACT."),
Field('first_name', requires=IS_NOT_EMPTY(), comment="*", 
label='FirstName'),
Field('last_name', requires=IS_NOT_EMPTY(), comment="*", 
label='LastName'),
Field('short_name',
  compute=lambda row: get_user_short_name(row.id, 
  
row.person_type, 
  
row.referrer_ref, 
  
row.first_name, 
  
row.last_name),
  label='ShortName',
  comment="Computed",
  writable=False),
[...]
Field('referrer_ref', 'string', default=None, 
label="ReferrersCode",
  comment="Referring Company's Client ID if provided, 
otherwise leave blank"),
[...]
Field('date_of_birth', 'date', 
requires=IS_EMPTY_OR(IS_DATE(format='%d-%m-%Y',
  error_message = 'must be in DD-MM- format'))),
[...]
format='%(last_name)s %(first_name)s %(referrer_ref)s')


db.person.virtual_age = Field.Virtual('virtual_age',
  lambda row: 
age_in_years(row.person.date_of_birth))

db.person.display_name = Field.Virtual('display_name',
   lambda row: 
get_user_short_name(row.id,
   
row.person_type,
   
row.referrer_ref,
   
row.first_name,
   
row.last_name))




When I add code to display the contents'Shortname: %s' % 
person.short_name 
(even after I have edited the table - which I understand should trigger the 
shortname update)
I get 'ShortName: None'



and for the seond method'DisplayName: %s' % person.display_name

I get an attribute error...

Traceback (most recent call last):
  File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File 
"/home/peter/web2py/applications/PAPILLON_AIM/controllers/default.py", line 
2256, in 
  File "/home/peter/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/home/peter/web2py/gluon/tools.py", line 4241, in f
return action(*a, **b)
  File 
"/home/peter/web2py/applications/PAPILLON_AIM/controllers/default.py", line 
305, in view_person
'DisplayName: %s' % person.display_name
  File "/home/peter/web2py/gluon/packages/dal/pydal/objects.py", line 90, 
in __getattr__
raise AttributeError
AttributeError

 
No idea why the compute one is not working as it is similar to the 
person.virtual_age that works fine.

The only other thing I can think to add is that I am developing using an 
SQLite database and the short_name 
field was pre-existing before I decided to usurp it for this method. 
Perhaps there is a migrate issue? 


Any ideas on what I am doing wrong would be very welcome!

-- 
Resources:
- http://web2py.com
- http://web2p

[web2py] How to import google-api-python-client in web2py?

2017-03-20 Thread Peter Weicher
Hello, 

I am trying to use web2py to build an application that requests data from 
various google APIs.

Using my local install of Python 3 or Python 2, I am able to import the 
necessary modules and query the api. 

I have tried the following, restarting the webserver between each action:

1) copying google-api-python-client modules 
into C:\web2py\web2py\site-packages

   - This does not work, I get  'module' 
   object has no attribute 'DEFAULT_MAX_REDIRECTS'
   - package httplib2 definitely has a value called 'DEFAULT_MAX_REDIRECTS'
   - see Traceback #1

2) delete files and then cmd: python -m pip install --target= 
google-api-python-client

   - same result as first action
   - see Traceback #1

3) Copy or pip files to C:\web2py\web2py\applications\ping\modules


   - This does not work either, I get error:  cannot import name discovery
   - See Traceback #2


Has anyone successfully imported google-api-python-client into a web2py 
local instance?
Is there a setup step I am missing?

Full list of modules I am talking about is below, and the google 
instructions are here: 
https://developers.google.com/api-client-library/python/start/installation


Thank you!

Peter

___

Traceback #1

Traceback (most recent call last):
  File "C:\web2py\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "C:/web2py/web2py/applications/ping/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/ping/models/db.py>, line 10, in 

from apiclient import discovery
  File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "C:\web2py\web2py\site-packages\apiclient\__init__.py", line 19, in 

from googleapiclient import discovery
  File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "C:\web2py\web2py\site-packages\googleapiclient\discovery.py", line 56, 
in 
from googleapiclient import _auth
  File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "C:\web2py\web2py\site-packages\googleapiclient\_auth.py", line 27, in 

import oauth2client.client
  File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "C:\web2py\web2py\site-packages\oauth2client\client.py", line 39, in 

from oauth2client import transport
  File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "C:\web2py\web2py\site-packages\oauth2client\transport.py", line 255, in 

redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'




Traceback #2

Traceback (most recent call last):
  File "C:\web2py\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "C:/web2py/web2py/applications/ping/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/ping/models/db.py>, line 10, in 

from apiclient import discovery
  File "C:\web2py\web2py\gluon\custom_import.py", line 95, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
  File "applications\ping\modules\apiclient\__init__.py", line 19, in 
from googleapiclient import discovery
ImportError: cannot import name discovery


List of Modules

03/14/2017  11:57 AM  apiclient
03/14/2017  11:57 AM  googleapiclient
03/14/2017  11:57 AM 
 google_api_python_client-1.6.2.dist-info
03/14/2017  11:57 AM  httplib2
03/14/2017  11:57 AM  httplib2-0.10.3-py2.7.egg-info
03/14/2017  11:57 AM  oauth2client
03/14/2017  11:57 AM  oauth2client-4.0.0.dist-info
03/14/2017  11:57 AM  pyasn1
03/14/2017  11:57 AM  pyasn1-0.2.3.dist-info
03/14/2017  11:57 AM  pyasn1_modules
03/14/2017  11:57 AM  pyasn1_modules-0.0.8.dist-info
03/14/2017  11:57 AM  rsa
03/14/2017  11:57 AM  rsa-3.4.2.dist-info
03/14/2017  11:57 AM  six-1.10.0.dist-info
03/14/2017  11:49 AM30,098 six.py
03/14/2017  11:57 AM  tests
03/14/2017  11:57 AM  uritemplate
03/14/2017  11:57 AM  uritemplate-3.0.0.dist-info

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

[web2py] Re: 'Column table.id not found (SQLTABLE)'

2017-03-20 Thread Peter Weicher
@LoveWeb2py

Two questions:

1) Are you running web2py from windows distribution binary or source?
2) can you view ANY other tables besides my_table in that application?

I have seen this error too, and my steps to reproduce are below. Still 
analyzing the root cause.

Here is how I reproduced this error:

1) bad install of web2py source from git. See Exhibit A. 
2) Create an application and then use signup form to add a user to the 
auth_user table.
3) try to view any table after that, I get the same KeyError citing that 
column auth_user.id does not exist in table. 
4) try the same steps from windows compiled distribution of web2py and 
everything works fine. 

I am guessing that there is some missing or misversioned library that 
creates a bad insert statement screwing up the db. 

Thanks, 
Peter 


Exhibit A - my install from source had problems.

Here is how I installed web2py from source. Because the git submodule 
update --init --recursive failed (still researching why), I instead pip'd 
pydal in and got the server running.

*Windows Command Prompt*

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>c:\python27\python.exe c:\web2py-master\web2py.py
Traceback (most recent call last):
  File "c:\web2py-master\web2py.py", line 21, in 
import gluon.widget
  File "c:\web2py-master\gluon\__init__.py", line 31, in 
"You can also download a complete copy from http://www.web2py.com.;
RuntimeError: web2py depends on pydal, which apparently you have not 
installed.
Probably you cloned the repository using git without '--recursive'
To fix this, please run (from inside your web2py folder):

 git submodule update --init --recursive

You can also download a complete copy from http://www.web2py.com.

C:\>cd c:\web2py-master

c:\web2py-master>git submodule update --init --recursive
fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?

c:\web2py-master>c:\python27\python.exe -m pip install pydal
Collecting pydal
  Using cached pyDAL-17.3-py2.py3-none-any.whl
Installing collected packages: pydal
Successfully installed pydal-17.3

On Sunday, March 12, 2017 at 6:27:08 PM UTC-5, LoveWeb2py wrote:
>
> Keep getting this error for all of my tables!! What is going on?
>
> What information would be helpful for me to post to get help?
>

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


Re: [web2py] Re: https causes site to be in text

2016-12-05 Thread peter
I was pretty stumped as to how to go about solving the problem, so the 
support I got was great.

Putting

location ~* /(\w+)/static/ {
root /opt/web2py_apps/web2py/applications/;
}


in the 'listen 443' just as it is in the 'listen 80' section did indeed 
solve the problem. I will suggest that the script for nginx and uswgi on 
centos 7 is updated.

Thanks for your positive feedback Dave S.

Thanks for you help everyone.

Peter

>
>>

-- 
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: https causes site to be in text

2016-12-01 Thread peter hutchinson
In my nginx.conf I have

.

server {
listen   80 default_server;
listen   [::]:80 default_server;
server_name  explorejazz.com;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location ~* /(\w+)/static/ {
root /opt/web2py_apps/web2py/applications/;
}

location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/web2py.sock;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

server {
listen 443;
server_name explorejazz.com;

ssl on;
ssl_certificate /etc/nginx/ssl/web2py.crt;
ssl_certificate_key /etc/nginx/ssl/web2py.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;

location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/web2py.sock;
}
}

Maybe I should copy the
location ~* /(\w+)/static/ {
root /opt/web2py_apps/web2py/applications/;
}
bit to  the listen 443 section?

This looks like it is routing directly to the static folde, and so appears
like it could cause the difference between the http and https behaviour.

Peter

On Thu, Dec 1, 2016 at 8:23 AM, Dave S <snidely@gmail.com> wrote:

>
>
> On Thursday, December 1, 2016 at 12:23:26 AM UTC-8, Dave S wrote:
>>
>>
>>
>> On Tuesday, November 29, 2016 at 9:35:10 AM UTC-8, peter wrote:
>>>
>>> In my routes.py I have
>>>
>>> routes_in = ((r'.*://spinjazz.net:\w* /static/$anything',
>>> r'/new_spin2/static/$anything'),
>>>
>>> presumably this is routing only http correctly can anyone tell me how I
>>> can get it to work for https
>>>
>>> Thanks
>>> Peter
>>>
>>>
>> I see you're using nginx ... can you show us some of the config?
>>
>>
> The http version indicates you have a nice-looking site, BTW.
>
>
>> /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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/zQRFXsmMD5A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: https causes site to be in text

2016-11-29 Thread peter
In my routes.py I have

routes_in = ((r'.*://spinjazz.net:\w* /static/$anything', 
r'/new_spin2/static/$anything'),

presumably this is routing only http correctly can anyone tell me how I can 
get it to work for https

Thanks
Peter

-- 
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: https causes site to be in text

2016-11-29 Thread peter
Thanks Leonel
I am not missing the http equivalents, so where is routing different for 
https to http in web2py?

Peter



On Tuesday, 29 November 2016 17:05:35 UTC, Leonel Câmara wrote:
>
> You are missing a bunch of files
>
> (index):19 GET https://spinjazz.net/new_spin2/static/js/jquery.js 
> (index):19 GET https://spinjazz.net/new_spin2/static/css/calendar.css 
> (index):19 GET https://spinjazz.net/new_spin2/static/js/calendar.js 
> (index):19 GET https://spinjazz.net/new_spin2/static/js/web2py.js 
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/ui/css/redmond/jquery-ui-1.8.5.custom.css
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/ui/js/jquery-ui-1.8.5.custom.min.js
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/jqgrid/ui.jqgrid.css 
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/jqgrid/i18n/grid.locale-en.js
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/jqgrid/jquery.jqGrid.min.js
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/slideshow/jquery.cycle.min.js
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/multiselect/jquery.multiselect.css
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/multiselect/jquery.multiselect.js
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/rating/jquery.rating.css
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_wiki/rating/jquery.rating.js 
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_layout_coffeecup/layouts/CupofCoffee/default.css
>  
> (index):19 GET 
> https://spinjazz.net/new_spin2/static/plugin_layout_coffeecup/superfish.js 
> 404 (NOT FOUND)
> (index):33 GET https://spinjazz.net/new_spin2/static/images/bigspin.jpg 
> 404 (NOT FOUND).
>
> All those got a 404
>

-- 
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] https causes site to be in text

2016-11-29 Thread peter
I have a site written in web2py, spinjazz.net. It works fine. I have bought 
an ssl certificate for the site, which works. However when I access the 
site via https, it appears as a text only site. I am sure there is a simple 
explanation for this, but I do not know what it is.

Any ideas?

Thanks

Peter

-- 
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: problem with sqleditable

2016-10-29 Thread Peter
Hi Vic,

I'm a noob and don't want to waste your time so up front I'm saying you 
might want to ignore this entirely!

It's not clear (to me) where your 'editable' gets used after it is assigned?
To a noob it looks like the non standard SQLEDITABLE could be bypassing 
web2pys inbuilt methods?
but then it all looks non standard/advanced to me...
 
Replacing the table's auth.signature to what I think is the older format of 
two lines

Field( 'created_by'  , db.auth_user , default=me , writable=False , 
readable=False),
Field( 'created_on'  , 'datetime' , default=request.now , writable=False , 
readable=False )


might work if you remove the read/write protection...

Field( 'created_by'  , db.auth_user , default=me ),
Field( 'created_on'  , 'datetime' , default=request.now)


or leave auth.signature as it is and try making the fields read/writable
db.purchase_order_product.created_by.readable=db.purchase_order_product.created_by.writable=True
db.purchase_order_product.created_on.readable=db.purchase_order_product.created_on.writable=True


Peter

-- 
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 to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-24 Thread Peter

Just to close this off.

I think I am in a bit of a catch 22.. 

Because the behaviour *is exactly what I want   *i.e. stream goes straight 
to download option, I don't get the open/save dialogue so can't change the 
setting and after reading this (possibly related Firefox bug report)*   
https://bugzilla.mozilla.org/show_bug.cgi?id=1109420*  I'm more than happy 
to leave well enough alone and not go down the rabbit hole.

Thanks again Niphlod & Paolo for your inputs! 

-- 
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 to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Peter

Hi Niphlod,   (& Paolo read this!)

halt. downloading is something the browser can decide. opening the saved 
> file is something your operating system does.
> The browser can only send the response which gives the user a choice 
> between saving and opening directly the file.
> If the user chooses "open" instead of "save" ... nothing can prevent that.
>

At this point the user has only clicked on the request (above code) in the 
browser and has not responded to the os open/save dialogue which 
subsequently opens.
i.e. the file has not yet been saved by the user (though a version has been 
written 'earlier' to static/temp on the local machine for use 'later' when 
the user clicks/calls response.stream() 
this is because I am developing on localhost. In production obviously the 
static/temp directory will be on a remote server. 

The code above appears to kick off two separate events, one being the 
'open/save dialogue' and the other being  'open in adobe' event.

Having said that...* I went back and looked again and I think I Paolo had 
it right .*..



import os
import sys

pdf = receipt_PDF()
pdf.add_page()

rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, session.rcpt_recipient)
rcpt_filename = rcpt_filename.replace( ' ', '_' )
rcpt_filename = rcpt_filename.replace( '&', 'and' ) # TODO read somewhere 
there is a 'clean' option in web2py for filepath?

rcpt_filepath = request.folder + 'static/temp/%s'%(rcpt_filename)# Note I 
have removed leading '/' - long story!

s_io = pdf.output(dest='S')
response.headers['Content-Type']='application/pdf'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 
rcpt_filename
raise HTTP(200, s_io, **response.headers)


This is doing exactly what I want - the difference being I have removed the 
xdg open request (no static/temp file creation needed if dealing with a 
stringio object ).

I need to play with it a bit more because it is now opening a 'download 
dialogue' which is perfect! (as opposed to 'open/save' dialogue) 
This is probably because I changed the system download options while 
investigating, so I need to go back over it to be sure.

It does raise another question - did I not read that downloading a stringio 
is not recommended or was it just response.stream a stringio objectis not 
recommended - is there a diff?

When I have finished checking it out I will post to confirm this is the 
solution and thanks again guys for your assistance!  

Peter

 



 

-- 
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 to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Peter

Many thanks for response Paolo!

I have tried your suggestion...


# pdf.output(rcpt_filepath,dest='S')
# response.headers['Content-Type'] = 'application/pdf'
# return response.stream(rcpt_filepath, chunk_size=4096, request=request, 
attachment=True, filename=rcpt_filename)

s_io = pdf.output(dest='S')
response.headers['Content-Type']='application/pdf'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 
rcpt_filename
raise HTTP(200, s_io, **response.headers



but the behaviour appears identical to the original code (commented out 
above)...

   - browser page doesn't change (Good!)
   - opens the File Open/Save dialogue for downloading the PDF (Good!)
   - also automatically opens the PDF in Adobe (Not Wanted!)
   


Without setting the 'Content-disposition' the pdf will be opened in the 
> browser.
>

Apologies if it wasn't clear but this particular issue had already been 
fixed. 

If I understand it correctly I believe that, 

response.stream (,attachment=True, filename=rcpt_filename)

i.e. the assignment of the headers 'attachment'  and 'filename',  is 
functionally equivalent to  

response.headers['Content-Disposition'] = 'attachment; filename="%s"' % 
rcpt_filename


To summarise the issue, 
It is sufficient that the user is prompted to download and save the PDF - 
and this is working!. 
The only change that is needed now is how to prevent Adobe automatically 
opening the PDF as well?


Regards
Peter 

-- 
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 to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-16 Thread Peter


On Sunday, 16 October 2016 05:24:10 UTC+1, Peter wrote:
>
>
>
> I have this code that doesn't work too well...
>
>
> import os
> import sys
> pdf = receipt_PDF()
> pdf.add_page()
> rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, 
> session.rcpt_recipient)
> rcpt_filename = rcpt_filename.replace( ' ', '_' )
> if sys.platform.startswith( "linux" ) :
> os.system( "xdg-open ./%s" %(rcpt_filename) )
> else :
> os.system( "./%s" %(rcpt_filename) )
> #print " inv_filename=%s" %(inv_filename)
> response.headers['Content-Type'] = 'application/pdf'
> #response.headers['Content-disposition'] = 'attachment; filename=%s' % 
> rcpt_filename
> pdf.output( rcpt_filename, dest='F' )
>
>
> as it stands the code... 
>
>- writes the PDF to disk with the required filename (path is simply 
>the web2py directory) - this file can be readily opened later in Adobe 
>Reader 9
>- it also opens a *blank* document in a browser reader (with 
>information message - this PDF doc may not be displayed correctly) (user 
>has lost Nav bar options)
>- finally it opens the requested document in Adobe Reader 9 (appears 
>perfect i.e. no error messages)
>- the user has to use Adobe's 'page save as'  to save the file in 
>their desired location
>- the user has to close Adobe and use 'Go Back' in the browser to 
>clear the browser reader and return to viewing the original request page 
>
> what I would like it to do is... 
>
>- leave the browser on the original page used to call the function
>- open the o/s' download/open dialogue box prompting the user to save 
>the file (wherever they desire)
>- once the file is downloaded the user simply returns to the browser 
>where they left off (without using 'Go Back')
>
>
> FPDF is a brilliant contribution to the web2py armoury and again I am 
> chuffed to have gotten this far with it. The blockage for me is that the 
> documentation is somewhat disconnected in that none of the examples are in 
> the context of web2py environment e.g.whether and how to use  pdf.output vs 
> response.stream 
>
>
> I have been reading as much as I can find but nothing seems to match 
> exactly what I want to do and despite trying dozens of variations nothing 
> gets me closer without breaking something else.
>
> It seems I need to drop the xdg portion, that the header's content type = 
> attachment will force the download dialogue, and,  I think, I need to be 
> using file-like object (but is the FPDF object not this?) with Stringio in 
> the mix?
>
>
> Any assistance with the specifics needed to accomplish what I am looking 
> for above would be appreciated!  
>
>
>
> Peter
>
>
>
>
>
>
>
>

-- 
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 to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-16 Thread Peter

So this is better (thanks to Paul Rykiel's post 
<https://groups.google.com/forum/#!searchin/web2py/fpdf|sort:relevance/web2py/OZkBWOtwtdQ/gBFdrmMmdOMJ>
 
re labels and responders including one Mariano Reingart)...
and hope it helps someone else down the road.


pdf = receipt_PDF()
pdf.add_page()

rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, session.rcpt_recipient)
rcpt_filename = rcpt_filename.replace( ' ', '_' )

rcpt_filepath = request.folder + '/static/temp/%s'%(rcpt_filename)

if sys.platform.startswith( "linux" ) :
os.system( "xdg-open %s" %(rcpt_filepath) )
else :
os.system( "%s" %(rcpt_filepath) )

pdf.output(rcpt_filepath,dest='S')
response.headers['Content-Type'] = 'application/pdf'
return response.stream(rcpt_filepath, chunk_size=4096, request=request, 
attachment=True, filename=rcpt_filename)


so this code... 

   - no longer opens the browser pdf reader,  user page does not change! 
   - opens the open/save dialogue box with required filename and allowing 
   users to save wherever desired!
   
but it still has one issue...
   
   - as well as opening the open/save dialogue box it automatically opens 
   Adobe Reader as well and displays the file (a little overkill!)

(It also creates temp files on the system that may/may not need to be 
cleaned up - but that's for another day.)


*Can I stop it automatically opening the file in Adobe and if so how?*


Peter  




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


[web2py] How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-15 Thread Peter


I have this code that doesn't work too well...


import os
import sys
pdf = receipt_PDF()
pdf.add_page()
rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, session.rcpt_recipient)
rcpt_filename = rcpt_filename.replace( ' ', '_' )
if sys.platform.startswith( "linux" ) :
os.system( "xdg-open ./%s" %(rcpt_filename) )
else :
os.system( "./%s" %(rcpt_filename) )
#print " inv_filename=%s" %(inv_filename)
response.headers['Content-Type'] = 'application/pdf'
#response.headers['Content-disposition'] = 'attachment; filename=%s' % 
rcpt_filename
pdf.output( rcpt_filename, dest='F' )


as it stands the code... 

   - writes the PDF to disk with the required filename (path is simply the 
   web2py directory) - this file can be readily opened later in Adobe Reader 9
   - it also opens a *blank* document in a browser reader (with information 
   message - this PDF doc may not be displayed correctly) (user has lost Nav 
   bar options)
   - finally it opens the requested document in Adobe Reader 9 (appears 
   perfect i.e. no error messages)
   - the user has to use Adobe's 'page save as'  to save the file in their 
   desired location
   - the user has to close Adobe and use 'Go Back' in the browser to clear 
   the browser reader and return to viewing the original request page 
   
what I would like it to do is... 

   - leave the browser on the original page used to call the function
   - open the o/s' download/open dialogue box prompting the user to save 
   the file (wherever they desire)
   - once the file is downloaded the user simply returns to the browser 
   where they left off (without using 'Go Back')


FPDF is a brilliant contribution to the web2py armoury and again I am 
chuffed to have gotten this far with it. The blockage for me is that the 
documentation is somewhat disconnected in that none of the examples are in 
the context of web2py environment e.g.whether and how to use  pdf.output vs 
response.stream 


I have been reading as much as I can find but nothing seems to match 
exactly what I want to do and despite trying dozens of variations nothing 
gets me closer without breaking something else.

It seems I need to drop the xdg portion, that the header's content type = 
attachment will force the download dialogue, and,  I think, I need to be 
using file-like object (but is the FPDF object not this?) with Stringio in 
the mix?


Any assistance with the specifics needed to accomplish what I am looking 
for above would be appreciated!  



Peter







-- 
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: Help needed to understand/utilise a CSS element

2016-10-03 Thread Peter


On Monday, 3 October 2016 16:08:32 UTC+1, Marlysson Silva wrote:
>
> 1. Have how you provide this project in github? Stay easier handle with 
> code , or it's private project?
>

I have a github account but I haven't figured out how to use it properly 
yet.
 

> 2. A good practice it's generate data in web2py controller and at view 
> just use the data.
> Ex: the "for" in the js code. But have how improve . after.
>

I would have said that is what the code is doing...

   today = request.now
   calendar_start = today - datetime.timedelta(days=31)   #TODO May need to 
reduce this lookback
   rows=db(db.task.start_time >= calendar_start).select( db.task.id,
  db.task.start_time,
  db.task.title,
  db.task.person,
  db.task.task_type,
  db.task.task_status,
  db.person.fullname,
  left = 
(db.person.on(db.person.id == db.task.person))
 )

return dict(rows=rows,person=person)


*But it may also be that the versions of calendar.css and fullcalendar.css* 
 are old versions (that came with a template application I used)
(this has caused me other issues and maybe I should go and look at those)

It seems close though :-(

*Thank you again for your time/support *Marlysson *and I don't expect you 
to spend anymore time on this given that *
*I **am probably confusing the issue by using out of date css files and who 
knows what else.*

The colouring is a 'nice to have'.  If I can't figure it out in the next 
day or two I can shelve it until I am using up to date version of 
everything.


-- 
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: Help needed to understand/utilise a CSS element

2016-10-03 Thread Peter
Just to be clear 

This code (with 'type' being assigned)

> {  type: '{{=row.task.task_type}}',
>   title: '{{=row.task.task_status}} {{=row.task.task_type}} 
> {{=row.person.fullname.replace("'","\\'")}} ',
>  allDay: false,
>   start: new Date('{{=row.task.start_time.strftime('%B %d, %Y %H:%M:%S')}}'),
> url: '{{=URL('view_task',args=row.task.id)}}'
>
>
Gives me  



 

and this code (without 'type' being assigned)

{  
 title: '{{=row.task.task_status}} {{=row.task.task_type}} 
{{=row.person.fullname.replace("'","\\'")}} ',
 allDay: false,
  start: new Date('{{=row.task.start_time.strftime('%B %d, %Y %H:%M:%S')}}'),
url: '{{=URL('view_task',args=row.task.id)}}'
  },




Data is all randomly generated!

-- 
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: Help needed to understand/utilise a CSS element

2016-10-03 Thread Peter

This is what my code looks like now but is still not working (page displays 
but there is no calendar)
Can you explain using line reference numbers where it is wrong or where 
something is missing?





-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter

Thanks again Marlysson!


Okay, I've tried a few configurations  (a lot actually) and came up with 
this which doesn't work (but it doesn't crash either - it breaks the view 
by showing no calendar entries)  
  
It's probably too influenced by my python formatting and flow*! Regardless, 
I can't figure out what I should be passing to  'element'* anyway (see 
?)



$(document).ready(function() {

var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();

$('#calendar').fullCalendar({
eventRender: eventRenderCallback,

function eventRenderCallback(event, element){
if (event.type == "TRAINING"){
element.classList.add('training');
}else if (event.type == "MEETING"){
element.classList.add('meeting');
}else if (event.type == 'PROJECT_WORK'){
element.classList.add('project_work');
}
}

editable: false,
events: [
{{for row in rows:}}
event = {  type: '{{row.task.task_type.lower()}}',
  title: '{{=row.task.task_status}} 
{{=row.task.task_type}}  {{=row.person.fullname.replace("'","\\'")}} ',
 allDay: false,
  start: new Date('{{=row.task.start_time.strftime('%B 
%d, %Y %H:%M:%S')}}'),
url: '{{=URL('view_task',args=row.task.id)}}'
  },
 eventRenderCallback(event, ???)
   {{pass}}
]
});
 });





  
*Should I even be wrapping up the attributes of each event (in the rows 
loop) assigning them to a variable 'event' and passing that to 
eventRenderCallback? *


I am really in the dark here!

Peter

 

-- 
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: Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter

Thanks Marlysson,



Assuming   row.task_typecan be  one of   [ 'TRAINING' , 'MEETING'  , 
'PROJECT_WORK'']

I want to the event background to be RED GREEN or BLUE respectively.


Do I add code something like this to the CSS file 

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass TRAINING {
background-color: black;
border-color: black;
color: red;
 }

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass MEETING {
 background-color: black;
 border-color: black;
 color: green;
 }

 .myclass,
 .fc-agenda .myclass .fc-event-time,
 .myclass PROJECT_WORK {
 background-color: black;
 border-color: black;
 color: blue;
 }


 
then how to I call it from the calendar view included (see original post)?


Peter


-- 
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] Help needed to understand/utilise a CSS element

2016-10-02 Thread Peter


Would anyone haver time to explain briefly how to utilise this CSS code.

/* Global Event Styles
*/

.fc-event,
.fc-agenda .fc-event-time,
.fc-event a {
   border-style: solid; 
   border-color: #36c; /* default BORDER color (probably the same as 
background-color) */
   background-color: #36c; /* default BACKGROUND color */
   color: #fff;/* default TEXT color */
   }
   
   /* Use the 'className' CalEvent property and the following
* example CSS to change event color on a per-event basis:
*
* .myclass,
* .fc-agenda .myclass .fc-event-time,
* .myclass a {
* background-color: black;
* border-color: black;
* color: red;
* }
*/



I know some python & html but know little about CSS so I need to take a 
course or two...

In the mean time I would appreciate any help with this...

The calendar view has this code

$('#calendar').fullCalendar({
editable: false,
events: [
{{for row in rows:}}
{  .myclass, .fc-agenda .myclass .fc-event-time, .myclass a { 
background-color: black; border-color: black; color: red;  }
title: '{{=row.task.task_status}} {{=row.task.task_type}}  
{{=row.person.fullname.replace("'","\\'")}} ',
allDay: false,
start: new Date('{{=row.task.start_time.strftime('%B %d, %Y 
%H:%M:%S')}}'),
url: '{{=URL('view_task',args=row.task.id)}}'
},
{{pass}}
]
});


This works to display the calendar events but they all have the same 
background colour of blue

How do I implement the CSS so each event background colour changes 
depending on {{=row.task.task_type}}


Many thanks,
 
Peter

-- 
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 key error on simple table with one record

2016-10-01 Thread Peter

Never stop asking me to post anything Anthony!

format='%(invoice_number)s -  %(company)s - %(status)s - %(date)s')


changed to 

format='%(invoice_number)s -  %(company)s - %(status)s - %(issue_date)s')


problem sorted!

I must have looked at that table a dozen times and had, at least 
temporarily, moved on to other things, I never saw that until I had to 
'expose' the code by posting it and forced me to check it again but perhaps 
more carefully!

Very happy it's sorted and I'm not in the least surprised it's my own error 
as web2py seems extremely robust!

Thanks for not losing interest in the issue!

Peter


 



-- 
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 key error on simple table with one record

2016-10-01 Thread Peter


If there is anything stupid here Anthony, please remember I am a novice at 
this!



db.define_table('invoice',
Field( 'invoice_number'  , 'integer' , writable=False),
Field( 'company' , writable=False),
Field( 'amount'  , 'decimal(6,2)' , writable=False),
Field( 'issue_date'  , 'datetime' , writable=False),
Field( 'status'  , 
default='ISSUED',requires=IS_IN_SET(INVOICE_STATUS)),
Field( 'payment_ref' , writable=False),
Field( 'payment_amount'  , 'double'),
Field( 'notes'   , 'text',default=None ),
Field( 'created_by'  , db.auth_user , default=me , readable=False , 
writable=False),
Field( 'created_on'  , 'datetime' , default=request.now , 
readable=False , writable=False),
format='%(invoice_number)s -  %(company)s - %(status)s - %(date)s')

db.define_table('task',
Field( 'task_type'  , default='COUNSELLING' , 
requires=IS_IN_SET(TASK_TYPES) , comment="*" ),
Field( 'task_status', default='CLIENT CONFIRMED' , 
requires=IS_IN_SET(TASK_STATUS) , comment="*"),
Field( 'start_time' , 'datetime' , default=request.now 
,requires=IS_NOT_EMPTY() , comment="*"),
Field( 'duration'   , default='1Hr' ),
Field( 'title'  , default="Session ##" , requires=IS_NOT_EMPTY() , 
comment="*"),
Field( 'person' , 'reference person' , comment="*"),
Field( 'details', 'text' ,default=None ),
Field( 'charge' , 'double' , default=0.0),
Field( 'charge_to'  , default='COMPANY'  , 
requires=IS_IN_SET(CHARGE_TO)  , comment="* [COMPANY for Invoicing, CONTACT 
for Receipting]"),
Field( 'payment_status' , default='BILLABLE' , 
requires=IS_IN_SET(PAYMENT_STATUS) , comment="* [BILLABLE for Invoicing & 
Receipting]"),
Field( 'invoice_number' , 'integer' , default=None , writable=False ),
Field( 'payment_ref', 'integer',default=None , writable=False ),
Field( 'created_by' , db.auth_user , default=me , writable=False , 
readable=False ),
Field( 'created_on' , 'datetime' , default=request.now , writable=False 
, readable=False ),
format= '%(person)s / %(start_time)s / %(title)s / € %(charge)s')

-- 
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 key error on simple table with one record

2016-09-30 Thread Peter


> ...you should just remove the version of pydal you have in the 
> dist-packages folder on your system.



That did it.

   - renamed the system installed dal directory  
   - restored the table definition to the version originally causing 
   Traceback 
   - the form now opens without Traceback :-)


for the record
The default dal version with the web2py install is Version 16.03 
and list open files confirms the dal in use is the web2py one. 
  
That got me out of a big hole Anthony! 
Go raibh mile maith agat! (*Thank you very much!*) 

Peter  
 

-- 
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 key error on simple table with one record

2016-09-29 Thread Peter



On Friday, 30 September 2016 03:04:17 UTC+1, Anthony wrote:
>>
>> Yes, noticed that in the traceback -- that's why I asked -- assumed you 
>> were using that version intentionally (web2py defaults to the system 
>> installed pydal, as seen here 
>> <https://github.com/web2py/web2py/blob/master/gluon/__init__.py#L19>). I 
>> think the current web2py is using an earlier version of pydal, so maybe try 
>> to use the correct pydal.
>>
>> Anthony
>>
>

I'm guessing thisis because the DAL development was "decoupled into a 
separate code-base (PyDAL)" ?
I found the link to the git repository and downloaded the latest version (I 
think),  the CHANGES file refers to Version 16.09  

I hope I'm not pushing my luck with these last few questions (if you have 
time)...

   - Can I just copy those files into relevant app folder/s?  And if so... 
   - Will the gluon <https://github.com/web2py/web2py/tree/master/gluon>/
   *__init__.py*  code you highlighted still ignore it? And if so...
   - How do I force web2py to use its own versions?

Thanks again for the interest and assistance Anthony 

Peter

-- 
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 key error on simple table with one record

2016-09-29 Thread Peter
I created a duplicate table db.payment2  which gave the same error so I 
went through the fields one by one... 

This one change in the table definition avoids the Traceback and the form 
displays as expected!


Field( 'invoice_ref' ),



Applied the same change to the original and it now opens the form without 
error. 
I will have to work on it some more to see if I can figure out why or use a 
work around. 

-- 
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 key error on simple table with one record

2016-09-29 Thread Peter

Just realised that the traceback shows web2py is using the system installed 
python pydal

/usr/local/lib/python2.7/dist-packages/pydal

all the files under this are dated May 17

 

-- 
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 key error on simple table with one record

2016-09-29 Thread Peter

Thanks Anthony,


Not sure how to confirm that but what I can say, 

web2py is running on Linux and I found...

   - The file ~/web2py/gluon/packages/dal/CHANGESrefers to 'Version 
   16.03'


The web2py site reports...

   - 2.14.6-stable+timestamp.2016.05.10.00.21.47  (Running on Rocket 1.2.6, 
   Python 2.7.3) 


Is there another way to check and report on this?

Peter



-- 
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 key error on simple table with one record

2016-09-29 Thread Peter
I'm punch drunk from looking at this one!

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 "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 
717, in 
  File "/home/peter/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/home/peter/web2py/gluon/tools.py", line 4241, in f
return action(*a, **b)
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 
492, in view_payment
form=SQLFORM(db.payment,payment)
  File "/home/peter/web2py/gluon/sqlhtml.py", line 1260, in __init__
inp = represent(field, default, record)
  File "/home/peter/web2py/gluon/sqlhtml.py", line 68, in represent
return f(value)
  File "/usr/local/lib/python2.7/dist-packages/pydal/helpers/methods.py", line 
265, in __call__
return value if value is None else _fieldformat(self.ref, value)
  File "/usr/local/lib/python2.7/dist-packages/pydal/helpers/methods.py", line 
253, in _fieldformat
return r._format % row
  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 76, in 
__getitem__
raise KeyError
KeyError



Table definition...


db.define_table('payment',
Field( 'received_date'   , 'date', requires=IS_NOT_EMPTY(), 
default=request.now.date() , writable=False,comment="*"),
Field( 'amount'  , 'decimal(6,2)' , 
default=0.00,requires=IS_NOT_EMPTY() ,writable=False, comment="*"),
Field( 'payment_type', 
requires=IS_IN_SET(['INVOICE','ACTIVITY']),writable=False,),
Field( 'invoice_ref' , 'reference invoice' , default=None , 
writable=False,),
Field( 'activity_ref', 'reference task' , default=None,  
writable=False,),
Field( 'method'  , requires=IS_IN_SET( PAYMENT_METHODS )),
Field( 'notes'   , 'text',default=None ),
format='%(received_date)s %(amount)s ')



Function definition...


def view_payment():
payment_id=request.args(0)
payment=(db.payment[payment_id]) or redirect(error_page)

# print info for sanity check
p = payment
print type(p)
print " id:%s  amount:%s  type:%s  inv ref:%s  task_ref:%s" 
%(p.id , p.amount, p.payment_type , p.invoice_ref, p.activity_ref)

form=SQLFORM(db.payment,payment)
return dict(form=form)



Called with
.../default/view_payment/1


print output shows the code is retrieving a valid row type and record with 
id=1... 

 id:1  amount:80.00  type:INVOICE  inv ref:1  task_ref:None



I have tried as much as I can think of including 

   - dropped/rebuilt the payment table
   - recreated the record manually
   - replaced request.args(0) with physical 1
   - replaced SQLFORM with crud.update(...)   
   


The record does exist as shown here in SQLite

<https://lh3.googleusercontent.com/-nJMpBGRB8ac/V-01kiWwB6I/AIE/IfpGByy4YrEncNnczZO8NxajwLl1q2iVgCLcB/s1600/SQLFORM%2Bkey%2Berror.png>






When I remove the record/id from the SQLFORM call 


form=SQLFORM(db.payment)
return dict(form=form)

It opens a create form as expected 



It just won't accept an id parameter?
  
Can anyone see an obvious problem with the code? 

Many thanks 
Peter










-- 
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: pysqlite2.dbapi2.OperationalError'> near "<": syntax error

2016-09-19 Thread Peter
The double db reference was definitely part of the problem but wasn't the 
whole story.

I made a mistake in one of the field names... 
specifically
AND (task.*task_status* = 'BILLABLE')  
should have been 
AND (task.*payment_status*="BILLABLE"));  
I actually had it correct in the SQL code above because I didn't use copy 
and paste for that.
 
Then I looked over some of joecodeswell has references for info about joins

 https://joecodeswell.wordpress.com/web2py-notes/#Validators

(cant get the editor to remove the formatting on this or create the link as 
I did above?)

Then I took a break from the small screen and went to the big screen and 
found a youtube video 
by Giovanni Barillari called pyDal a pure database abstraction layer 

it's still sitting there paused at 22:52 where it hints at the final part 
of my solution.

So after much playing around I got to this

def generate_inv_details():

session.inv_details = []
session.inv_total = 0
session.inv_record_count=0

today = datetime.date.today()

query=db(db.task.person.belongs(session.company_persons))

rows = query( (db.task.start_time <= today)
& (db.task.charge_to=='COMPANY')
& (db.task.payment_status=='BILLABLE'))\
.select(db.task.person,
db.person.id,
db.person.name,
db.person.referrer_ref,
db.task.title,
db.task.start_time,
db.task.duration,
db.task.task_type,
db.task.task_status,
db.task.charge_to,
db.task.charge,
db.task.payment_status,
left=db.person.on(db.person.id==db.task.person)
)
session.inv_details=rows

for row in session.inv_details:
session.inv_record_count += 1
session.inv_total += row.task.charge


and IT WORKS! I can call anything I want from the person table.


Many thanks for your responses Anthony, without you guys I might as well be 
looking into a hedge!
   

-- 
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: pysqlite2.dbapi2.OperationalError'> near "<": syntax error

2016-09-19 Thread Peter
Error after changing 
.select()to._select()

Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Traceback (most recent call last):
  File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 
566, in 
  File "/home/peter/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/home/peter/web2py/gluon/tools.py", line 4241, in f
return action(*a, **b)
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 
347, in preview_invoice
generate_inv_details()
  File "/home/peter/web2py/applications/PAPAIM/models/extras.py" 
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/models/extras.py>, line 31, in 
generate_inv_details
session.inv_total += row.task.charge
AttributeError: 'str' object has no attribute 'task'



Because this error highlighted

 session.inv_total += row.task.charge  

as a problem, I changed it to 


session.inv_total += 1



the code now runs through and outputs this using generic view in which the 
session information provides.. 




 
company_id : 
1
company_persons : 
id
28
37
46
51
52
63
70
81
87
95
flash : 
None
inv_details : 
SELECT task.person, person.name, task.title, task.start_time, 
task.duration, task.task_type, task.task_status, task.charge_to, 
task.charge, task.payment_status FROM task, person WHERE ;
inv_total : 
366




The length of company persons (10) matches the actual number of db.person  
entries that reference db.company.id=1
however the inv_total (366)  which is now a simple count of tasks found is 
wrong - it appears none of the filters have been applied ?

This may be totally spurious but for what it's worth...
I don't know much SQL but using SQLite manager in Firefox I stripped down 
the SQL from the inv_details extract provided above and ran it as 

Original stripped of its 'Set<((()))>' 

SELECT task.person, person.name, task.title, task.start_time, 
task.duration, task.task_type, task.task_status, task.charge_to, 
task.charge, task.payment_status FROM task, person WHERE  ((task.person IN 
(28,37,46,51,52,63,70,81,87,95)) 
AND (task.start_time <= '2016-09-19 00:00:00') 
AND (task.charge_to = 'COMPANY') 
AND (task.task_status = 'BILLABLE') 
AND (person.id = task.person));

returns nothing or never ends?
 
  
whereas 

SELECT task.id ,task.start_time
FROM task
WHERE ( task.start_time <= '2016-09-19 00:00:00')  
AND (task.person IN(28,37,46,51,52,63,70,81,87,95) 
AND (task.charge_to="COMPANY") 
AND (task.payment_status="BILLABLE"));
 
returns 19 rows matchinig the criteria 

-- 
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: pysqlite2.dbapi2.OperationalError'> near "<": syntax error

2016-09-19 Thread Peter Errity
Thanks for your response Anthony!

I have obviously misunderstood a reference I read somewhere saying that
reference fields were given special attributes and gave an example
something like db.fieldname.name I assumed the trailing .name came from the
referenced table attributes.

So I have modified the code ...

def generate_inv_details():

session.inv_details = []
session.inv_total = 0
today = datetime.date.today()

query = db( (db.task.person.belongs( session.company_persons))
  & (db.task.start_time <= today )
  & (db.task.charge_to == 'COMPANY' )
  & (db.task.task_status == 'BILLABLE')
  & (db.person.id==db.task.person))

rows=db(query).select( db.task.person,
   db.person.name,
   db.task.title,
   db.task.start_time,
   db.task.duration,
   db.task.task_type,
   db.task.task_status,
   db.task.charge_to,
   db.task.charge,
   db.task.payment_status )

session.inv_details=rows

for row in session.inv_details:
session.inv_total += row.task.charge


   - added the join (I hope correctly) in the query
   - used full "tablename.fieldname" format to reference the person.name
   in the select statement
   - removed the newline slashes




The relevant table excerpts...



db.define_table('person',

Field( 'name'  , requires=IS_NOT_EMPTY() , comment="*"),
Field( 'status', requires=IS_IN_SET(PERSON_STATUS) , comment="*") ,
Field( 'type'  , requires=IS_IN_SET(PERSON_TYPES)  , comment="*") ,
Field( 'company'   , 'reference company' , comment="*"),
Field( 'role'  , 'string' , comment='for CONTACTS not CLIENTS'),
Field( 'address'   , comment="Use ',' to seperate address lines"),
Field( 'mobile_phone'  , label='Mobile' ,
requires=IS_EMPTY_OR(is_phone), comment="Can use '-' to separate
prefix for clarity" ),
Field( 'office_phone'  , label='Office' ,
requires=IS_EMPTY_OR(is_phone), comment="Can use '-' to separate
prefix for clarity" ),
Field( 'home_phone', label='Home'   ,
requires=IS_EMPTY_OR(is_phone), comment="Can use '-' to separate
prefix for clarity" ),
Field( 'email' , requires=IS_EMPTY_OR(IS_EMAIL()) ),
Field( 'date_of_birth' , 'date' ),
Field( 'referrer_ref'  , 'string' , default=None),
Field( 'notes' , 'text' ),
Field( 'created_by', db.auth_user , default=me ,
writable=False , readable=False ),
Field( 'created_on', 'datetime' , default=request.now ,
writable=False , readable=False ),
format=' %(type) %(name)s Referrer Ref %(referrer_ref)s')

db.define_table('task',

Field( 'task_type'  , requires=IS_IN_SET(TASK_TYPES) , comment="*" ),
Field( 'task_status', requires=IS_IN_SET(TASK_STATUS) , comment="*"),
Field( 'start_time' , 'datetime' , default=request.now
,requires=IS_NOT_EMPTY() , comment="*"),
Field( 'duration'   , default='1Hr' ),
Field( 'title'  , default="Session ##" ,
requires=IS_NOT_EMPTY() , comment="*"),
Field( 'person' , 'reference person' , comment="*"),
Field( 'description', 'text' ),
Field( 'charge' , 'double' , default=0.0),
Field( 'charge_to'  , default='COMPANY'  ,
requires=IS_IN_SET(CHARGE_TO)  , comment="* [COMPANY for
Invoicing, CONTACT for Receipting]"),
Field( 'payment_status' , default='BILLABLE' ,
requires=IS_IN_SET(PAYMENT_STATUS) , comment="* [BILLABLE for
Invoicing or Receipting]"),
Field( 'invoice_number' , 'integer' , default=None , writable=False ),
Field( 'invoice_date'   , 'date', default=None , writable=False ),
Field( 'created_by' , db.auth_user , default=me ,
writable=False , readable=False ),
Field( 'created_on' , 'datetime' , default=request.now ,
writable=False , readable=False ),
format= '%(person)s %(start_time)s  %(task_type)s  %(task_status)s
 %(charge)s')



with the modified code I am still getting the same error

Traceback

Traceback (most recent call last):
  File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>,
line 566, in 
  File "/home/peter/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/home/peter/web2py/gluon/tools.py", line 4241, in f
return action(*a, **b)
  File "/home/peter/web2py/applications/PAPAIM/controllers/default.py"

[web2py] pysqlite2.dbapi2.OperationalError'> near "<": syntax error

2016-09-18 Thread Peter

I got the error above while trying to rewrite and tidy up some code that I 
had working but didn't do everything I wanted.
This is a lot neater but it doesn't work yet I think I am close!
 
I have a person table and a task table where task.person is type 
'references person' 

This is the code (not working and has never worked) so all I can say is I 
know it's wrong... 

def generate_inv_details():

session.inv_details = []
session.inv_total = 0
today = datetime.date.today()

query = db( (db.task.person.belongs( session.company_persons)\
  & (db.task.start_time <= today )\
  & (db.task.charge_to == 'COMPANY' )\
  & (db.task.task_status == 'BILLABLE')))

rows=db(query).select( db.task.person,\
   db.task.person.name,\
   db.task.title,\
   db.task.start_time,\
   db.task.duration,\
   db.task.task_type,\
   db.task.task_status,\
   db.task.charge_to,\
   db.task.charge,\
   db.task.payment_status )

session.inv_details=rows

for row in session.inv_details:
session.inv_total += row.task.charge

 
Is this totally off the wall and not even close?  
Is there a problem with the format of the select statement? (which I 
suspect is the issue)  or 
Is there a glaring problem elsewhere?

You will have to trust me when I say I have put hours of frustration and 
reading into this and I only post here as a last resort!

Many thanks for your consideration!

Peter

-- 
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 to get dropdown options working on nav-bar

2016-09-14 Thread Peter


> That may be from the Bootstrap2 days.
>

I put some time in last night trying to understand the how/why and think I 
have a handle on it, thanks again for the pointers Dave.

It may be useful to other noobs so my lessons learned...

I started to develop using an existing Free CSS Template (that is 
apparently from years back).
It was of huge benefit to me in getting started quickly because I could 
largely see much of how it worked and was able to copy the approach for new 
models views and controllers keeping the look and feel consistent.

Then this issue regarding menu dropdowns came up... and sure enough the 
Free CSS Template has its own Oxidation/*.css files 

My 'old' Free css Template is has/uses...

   

   - base.css
   - calendar.css
   - demo_table.css
   - fullcalendar.css
   - jqModal.css
   - Oxidation/base.css
   - Oxidation/calendar.css
   - Oxidation/demo_table.css
   - Oxidation/fullcalendar.css
   - Oxidation/jqModal.css

whereas the latest version of web2py by default has/uses 
   
   - bootstrap.min.css
   - calendar.css
   - web2py-bootstrap3.css
   - web2py.css 

I went a step further and migrated some of my existing MVC code to a new 
clean default web2py app and the menu code worked without change i.e. the 
dropdowns appeared as originally intended/expected.  (lots of other things 
broke though).

For now I will work with what I have but v2 if I ever get there will be a 
migration to a build using the latest defaults in web2py and maybe even 
stupid.css!

Thanks again Dave!








 

-- 
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 to get dropdown options working on nav-bar

2016-09-13 Thread Peter

Thanks Dave,
stupid.css doesn't look so stupid! but there will be a learning curve for 
me to understand it and the more I look at the more I need to understand 
css better.


The change to Bootstrap3 limited the nesting levels of submenus ... only 1 
> sub-level now, I believe.  This was a reflection of the popularity of 
> portable devices, where a tree of menus runs out of screen space.
>

If I understand the terminology correctly I am only looking for 1 sub level.

Something like

MenuItem1  MenuItem2MenuItem3MenuItem4
  SubItem3.1
  SubItem3.2
  SubItem3.3

and I may be wrong but the bootstrap section in gluon/tools.py seems to 
support it 

else:
self.bar = LI(Anr(T('Log In'),
  _href='#', _class="dropdown-toggle",
  data={'toggle': 'dropdown'}), self.bar,
  _class='dropdown')


Any other clues on how to invoke this? 
i.e. get the sub items to appear (vertically under MenuItem3) on mouse over 
or click to toggle on MenuItem3 ?

P

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


[web2py] How to get dropdown options working on nav-bar

2016-09-13 Thread Peter
I am trying to get a menu item to display additional selectable drop down 
options...



















*default.pyif auth.user:response.menu=[   ( 'Home' 
  , False , url( 'index'  ) , []),   ( 'Companies' 
 , False , url( 'list_companies' ) , []),   ( 'Contacts'   
, False , url( 'list_persons'   ) , []),   ( 'Activities' , 
False , url( 'list_tasks' ) , []),   ( 'Invoices'   , 
False , url( 'list_invoices'  ) , []),   ( 'Payments'   , 
False , url( 'list_payments' ) , [ ( 'Activity' 
  , False , url( 'list_unpaid_activities' ) , []),  
   ( 'Invoice', False , url( 'list_unpaid_invoices' ) , []),
  ]),  
 ( 'Reports', False , url( 'list_reports' ) , [])  
]layout.html*
  
   {{=MENU(response.menu)}}
  


The result form above code produces the the submenu options permanently 
below the parent option and horizontally aligned (see attached).


I have read through the online doc but the references are not helping me, I 
can see gluon.tools auth has navbar with methods ''menu'', ''bootstrap3'' 
and ''bare'' but I have no idea how to assign response.menu (or invoke the 
MENU wrapper) correctly?

Does the menu need to be custom coded (as per the comments section under 
the 'bare' function in navbar) or is there something I am doing wrong in 
the code above?   

any help would be appreciated! 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: Preserving objects sort order between controller and view

2016-09-08 Thread Peter
Some times you just have to laugh!

I have totally screwed things up (I have a backup but was hoping not to use 
it)

I dropped the invoice table and started getting this...
 table invoice already exists
on investigation the error, I discovered I had not included  a db.commit() 
after the drop

Found somewhere (athough a bit drastic) I could just delete the 
storage.sqlite and start afresh
So I deleted storage.sqlite and on refresh I got
*PicklingError: Can't pickle : attribute lookup 
__builtin__.instancemethod failed* 
<https://phadmin.pythonanywhere.com/admin/default/errors/PCPAIM/new#>

On investigation I found I must have assigned a function to a session 
object so had a look back over some code from today
and sure enough there was one so changed that and now I'm getting
* no such table: main.auth_user*

  
I decided to follow your link as a distraction from all of above
https://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#generated-text 
<https://www.google.com/url?q=https%3A%2F%2Fwww.w3.org%2FTR%2F2011%2FREC-CSS2-20110607%2Fgenerate.html%23generated-text=D=1=AFQjCNG4nYu7lukSqQx-K0R7O_obm58pug>
The page fails to open, but wait, it gets better...
www.w3.org is not even responding to pings

Re your comment...

> Okay, we'll keep an eye out for a follow-up.  Perhaps there was a browser 
> glitch involved.

you are being very kind, I think in reality it's a Peter Glitch :-) but hey 
I'm learning!

I've given up (for today) *but I will be back! *
 

-- 
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: Preserving objects sort order between controller and view

2016-09-07 Thread Peter

Thanks for the response Dave,

I haven't got the hang of this editor yet so I hope this doesn't appear as 
a total mess...  

My view code...

 {{ line=0 }}
 {{=inv_lines  }}
 {{ for item in inv_lines: }}
 {{ line+=1}}
  
 
{{ =line   }}  
{{ =item.start_time.date() }}  
{{ =item.duration  }}  
PAP{{ =item.person+1000   }}/ {{ =
item.task_type }}/ {{ =item.title }}/ {{=item.task_status}}
  € {{ =item.charge}}  
{{ =button('edit' , 'edit_task' , 
(item.task.id)) }} 

 {{ pass }}


which is similar to your last example   
(however the  wrapper screws with my formatting by forcing bullet 
points)

*The weird thing is the problem seems to be gone.   *
I set up some new transactions, out of sequence by datetime, like 

1st/Aug...  
23rd/Aug..  
7th/Aug...  
15th/Aug...  

So these would have transaction table ids in sequence e.g. 5,6,7,8 
respectively  
When I run the view now (with these newly created transactions) it ignores 
the id sequence and preserves the 'orderby=start_time'.  

The old transactions that I was working are still there but currently not 
available until I do some adjustments to let them   
invoice again - so I will try them again tomorrow just to see if there was 
something in there that I am missing.  

Thanks again!
Peter


-- 
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] First Post so not a question

2016-09-07 Thread Peter
Hi I'm Peter from Ireland,  I've just joined this mailing list and I want 
to say thank you, before 
I start asking questions!

So a huge thank to Massimo for web2py and Guido for Python!  As a wannabe 
programmer I 
have spent considerable time over the last two or three years doing online 
Python courses and 
while looking for a suitable (read as 'user friendly') web framework I 
found web2py and between 
the two they have opened up a whole new world to me and I'm loving it.

Also, many thanks to all the advisers and problem solvers on this forum who 
have already 
answered many of my unasked questions and I don't mean to exclude others 
but I have to acknowledge 
the one name that keeps cropping up (besides Massimo) and that's Anthony!  
Much of the technical 
detail behind both Python and web2py is beyond me and it will probably be 
another year or two before I 
can contribute in any meaningful way by answering any questions but if/when 
I can I will.   

-- 
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] Preserving objects sort order between controller and view

2016-09-07 Thread Peter
My first question and I hope it's not a dumb one!

My controller retrieves a number of rows from a table and I use *orderby= 
'start_time' *to sort the list into date order.
I can see this produces the desired result because when I output the rows 
to the log file the dates appear in the required order

'start_time': datetime.datetime(2016, 8, 1, 19, 0) 
> 'start_time': datetime.datetime(2016, 8, 8, 19, 0), 
> 'start_time': datetime.datetime(2016, 8, 15, 15, 0) 
> 'start_time': datetime.datetime(2016, 9, 6, 15, 52, 20) 
>

The rows object is then passed to a view.html

> return dict( inv_lines=inv_lines )*(along with two other objects 
> omitted for clarity)*
>

However in the view, looping through the view's inv_lines object the date 
order has changed 
and it produces this output...

'start_time': datetime.datetime(2016, 8, 1, 19, 0)
> 'start_time': datetime.datetime(2016, 8, 8, 19, 0)
> 'start_time': datetime.datetime(2016, 8, 15, 15, 0) 
> 'start_time': datetime.datetime(2016, 9, 6, 15, 52, 20)
> 'start_time': datetime.datetime(2016, 8, 2, 16, 0)  
>
  
 I can see that the view is actually sorting the rows by id but I can't 
figure out how to override it?

Is there an easy way to do so?

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 not finding module

2016-04-25 Thread peter
I am afraid I have one of those horrible intermittent problems. The system 
used to work fine, and then this problem arose when it was moved from one 
node to another. I have rebooted and the system remained. I tried your two 
tests and it passed both. I rebooted, and the problem has disappeared. I 
hate not getting to the bottom of problems even when they appear to go 
away. 

Thanks again for your help Niphlod. Clearly it could well   be an envelope 
issue. I had hoped that by explicitly using 'python2.6' the same python 
would always be used.

Peter 

-- 
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 not finding module

2016-04-17 Thread peter
I am in the wilds of France with very little access to Internet.  Will continue 
in one week. Great support as ever Niphlod. Thanks
Peter

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


  1   2   3   4   5   >