[web2py] Auth - overlapping permissions problem

2020-07-16 Thread Paul Ellis
the situation is that I have permissions associated with auth_groups. 

eg. user, team leader, business leader, oversight

now I need a "secretary" or "accounts" group which has access to some 
business leader features i.e reports.
Some team leader features ie. price maintainence.
But does not have access to the basic features of normal users.

I can't see how to make an auth_group which has permissions which are 
already associated with another group.

I am hoping for a solution which does not involve hard coding access to 
these features using @auth.has_membership('accounts') as I don't expect 
this to be last case of overlapping permissions.

Ideally I can make an interface where business leaders can make a custom 
permission group and assign it to their employees. Without creating a 
situation where each new employee needs to have a permission allocated for 
every little thing.
i.e. customer maintenence, customer delete, product related permissions, 
product permissions where special knowledge is required...

Is this possible with the Web2py Auth System?

-- 
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/e5b39f90-7aa7-4634-b4f9-83fa56e1cdb7o%40googlegroups.com.


[web2py] Accessing Postgres server from a secondary docker container without db.py

2019-12-17 Thread Paul Ellis
How do I do connect to a prostgres server using PyDAL but without a db.py 
in the secondary container or having all the tables drop when I connect 
without a db definition?

I have a server running docker with containers for the nginx proxy, lets 
encrypt, web2py and postgres.

one docker_compose.yml brings up nginx and lets encrypt and makes a docker 
network.
version: '3'

services:
  nginx:
image: nginx:1.13.1
container_name: nginx-proxy
ports:
  - "80:80"
  - "443:443"
  - "8080:8080"
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
labels:
  - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"

  dockergen:
image: jwilder/docker-gen:0.7.3
container_name: nginx-proxy-gen
depends_on:
  - nginx
command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/
templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
  - /var/run/docker.sock:/tmp/docker.sock:ro
  - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro

  letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-proxy-le
depends_on:
  - nginx
  - dockergen
environment:
  NGINX_PROXY_CONTAINER: nginx-proxy
  NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
  - /var/run/docker.sock:/var/run/docker.sock:ro

volumes:
  conf:
  vhost:
  html:
  certs:

# Do not forget to 'docker network create nginx-proxy' before launch, and 
to add '--network nginx-proxy' to proxied containers. 

networks:
  default:
external:
  name: nginx-proxy


the 'web2py' docker_compose.yml brings up the db and web2py container and 
connects to the nginx network.
version: '3'

services:

  db:
image: postgres:11 
restart: always
env_file:
./config/db/db_env
expose:
- 5432
volumes:
  - db_volume:/var/lib/postgresql/data
  
  angebotstool:
build: .
volumes:
  - web2py_apps:/home/act/web2py/applications
expose:
  - 80
  - 443

environment:
  VIRTUAL_HOST: foo.barr.com
  LETSENCRYPT_HOST: foo.barr.com
  LETSENCRYPT_EMAIL: f...@bar.com
depends_on:
  - db

  
volumes:
db_volume:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/act/databases/'
web2py_apps:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/act/web2py-gunicorn/web2py/applications'

networks:
default:
external:
name: nginx-proxy


This was mostly configured with luck and trial and error. I am still 
learning in this area.

Now I would like to have a container running Scrapy or similar which will 
periodically log into a site and update the product information (when 
required).

I want to use PyDAL to connect to the existing database. The Scrapy 
container will be configured in the 'web2py' docker_compose.yml.

How do I do this without having to maintain another db.py in the secondary 
container or having all the tables drop when I connect without a db 
definition?

-- 
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/ea3bdba5-2c26-43cf-960f-2f36f1c1038d%40googlegroups.com.


[web2py] Smartgrid with multiple references between tables - Undocumented - Solved

2019-12-09 Thread Paul Ellis
When using Smartgrid and there are multiple links between two tables. For 
example a user_id might appear multiple times in db.offer because of 
created_by, updated_by, belongs_to fields.

db.define_table(
'offer',
Field('offer_number', unique=True, label = T('Offer Number')),
Field('user_id','reference auth_user', label = T('Belongs to'), 
ondelete = 'SET NULL'),   # <- HERE
Field('customer_id','reference customer', requires=IS_NOT_EMPTY(), 
label = T('Customer Name')),
Field('reseller_id','reference reseller', requires=IS_NOT_EMPTY(), 
label = T('Business Name')),
Field('created_on', 'datetime', default=request.now, writable=False, 
label=T('Created On')),
Field('created_by', 'reference auth_user', label=T('Created By')),  
  # <- HERE
Field('updated_on', 'datetime', update=request.now, writable=False, 
label=T('Updated On')),
Field('updated_by', 'reference auth_user', writable=False),
   # <- HERE
format = '%(offer_number)s',
singular = T('Offer'),
plural = T('Offers'),
)


When viewing *db.auth_user* Smartgrid makes a button for each relationship 
i.e Customers(Belongs To), Customers(Created By), Customers(Updated By). 
This can clutter the grid a bit.

This is not in the book but it is possible for the *linked_tables *argument, 
rather than a List, to be a Dict of:
{'tablename' : [Fields]}

an empty list allows all references to be used. This is handy for tables 
where there is already only one reference. The Table still needs to be 
included in the dict. Otherwise Smartgrid will exclude it entirely.

linked_tables = {
'reseller' : [
db.auth_user.reseller_id,
db.customer.reseller_id,
db.offer.reseller_id
],
'auth_user' : [
db.customer.created_by,
db.offer.user_id,
db.auth_membership.user_id,
],
'auth_membership' : [],
'customer' : [
db.offer.customer_id,
],
'offer' : [],
},

Source: Web2Py Version 2.18.5 gluon/sqlhtml.py Lines [3316 : 3353]

-- 
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/f9afd091-3a6c-4259-a1d0-39e61bab30ef%40googlegroups.com.


[web2py] Re: Tempfile not found when uploading images with the Add function in a Grid

2019-11-04 Thread Paul Ellis
Actually I was looking at the wrong controller function. I have a utility 
function which returns part of the UI. Somehow when the form is submitted 
and this is run the tempfile for the image is closed. So by doing this at 
the end, after the form processing is complete, the problem is solved.

@auth.requires_login()
def add_custom():

#check if there is an offer selected
# if not session.quote or not session.quote.number:
# session.flash = T('Please select an offer first')
# redirect(URL('default', 'offer_landing'))

try:
offerId = request.args[0]
except IndexError:
offerId = 0
offerDetails = offer.authorise(offerId)

pagetitle = H3(T('Custom Product'))
buttongroup = [btn.back()]

try:
record = db.custom_product[request.args[1]] or None
except [IndexError, KeyError, TypeError]:
record = None

if session.custom_copy:
db.custom_product.productname.default = session.custom_copy.
productname
db.custom_product.description.default = session.custom_copy.
description
db.custom_product.purchasecost.default = session.custom_copy.
purchasecost
db.custom_product.monthlycost.default = session.custom_copy.
monthlycost
#db.custom_product.smallimage.default = 
session.custom_copy.smallimage
session.custom_copy = None

db.custom_product.created_on.readable = False
db.custom_product.updated_on.readable = False

form = SQLFORM(db.custom_product, record, showid = False)

if form.process().accepted:
#do this for insert but not update
if not record:
# need to get the max priorites from the offer table
pp = mp = None
# offerDetails = db.offer[session.quote.number]

# increment whichever needs to be used and save it to the offer 
table
if form.vars.purchasecost:
if offerDetails.offer.maxpurchasepriority:
offerDetails.offer.maxpurchasepriority += 1
else:
offerDetails.offer.maxpurchasepriority = 1
pp = offerDetails.offer.maxpurchasepriority
if form.vars.monthlycost or (not form.vars.purchasecost and not 
form.vars.monthlycost):
if offerDetails.offer.maxmonthlypriority:
offerDetails.offer.maxmonthlypriority += 1
else:
offerDetails.offer.maxmonthlypriority = 1
mp = offerDetails.offer.maxmonthlypriority
offerDetails.offer.update_record()

# insert record into product_offer_item
db.product_offer_item.insert(
offer_id = offerDetails.offer.id,
custom_pid = form.vars.id,
quantity = 1,
purchasepriority = pp,
monthlypriority = mp,
)
else:
# only do this for updates
# check if a price change also needs a priority change
poiRecord = record.product_offer_item.select().first()
pp = copy.copy(poiRecord.purchasepriority)
mp = copy.copy(poiRecord.monthlypriority)
#poi_set = db(db.product_offer_item.custom_pid == poiRecord.id)
if pp and (not form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 0)
if not pp and (form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 99.5)
if mp and (form.vars.purchasecost > 0 and not form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 0)
if not mp and\
((not form.vars.purchasecost > 0 and not 
form.vars.monthlycost 
> 0) or\
not form.vars.purchasecost > 0 and form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 99.5)
offer.position_check(offerDetails.offer.id)
session.flash = T('Success')
redirect(btn.EditOffer(offerDetails.offer.id,
dict(custId = offerDetails.customer.id)).url)

elif form.errors:
response.flash = T('Errors in form')
else:
pass
status = roo.status(offerDetails) # <- Moved this line from the top to 
down here
response.view = 'core.html'
return dict(
pagetitle = pagetitle,
pagecontent = form,
buttongroup = buttongroup,
status = status,
)


-- 
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/c051466f-ac1a-4ded

[web2py] Re: SQLFORM.grid search with fields readable = False

2019-11-01 Thread Paul Ellis
If you want the fields to be searchable. Then instead of setting readable = 
false. 

Hide the fields with:

db.table.field.represent = lambda value, row: DIV(value, _class='hidden')

and the column heading with:

grid = SQLFORM.grid(
headers = {
 'table.field' : DIV(_style = "display:None"),
}
)


-- 
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/2d4d200a-56f5-4a9b-b66f-91a5e7748e9c%40googlegroups.com.


[web2py] Tempfile not found when uploading images with the Add function in a Grid

2019-11-01 Thread Paul Ellis
I am getting this error when users upload an image with the Add function of 
a grid. As background, it is adding a product which can only be seen by 
users in a particular group (belong to the same company).

Traceback

1.
2.
3.
4.
5.
6.
7.

Traceback (most recent call last):
  File "/home/act/web2py/gluon/main.py", line 505, in wsgibase
request.body.close()
  File "/usr/local/lib/python2.7/tempfile.py", line 431, in close
self.unlink(self.name)
OSError: [Errno 2] No such file or directory: '/tmp/tmpGdGmPE'



Error snapshot

([Errno 2] No such file or directory: 
'/tmp/tmpGdGmPE')
  

I have been banging my head against this one for a while and I am not 
getting anywhere. 

I have another function which uses a simple form to add products which can 
be seen by everyone (admin form) and this has no issues with images.

Can anyone give me a tip or an idea or a direction to continiue searching 
for a solution?

I am happy to post code but the grid is reasonably complex at 450 lines.


-- 
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/aeb4da21-7c47-442e-aa1b-01e90d84148c%40googlegroups.com.


[web2py] Upload field causing a temp file issue

2019-08-21 Thread Paul Ellis
I have 2 similar controller functions using SQLFORM() with an upload field. 
One works and one is giving an error online (not when testing locally). I 
suspect a file system permission problem but I am not sure.
The error only occurs if an image is uploaded. 
The extra processing after the form is submitted is not the cause. I 
removed it as a test and the error remains.

The error:
Traceback

1.
2.
3.
4.
5.
6.
7.

Traceback (most recent call last):
  File "/home/act/web2py/gluon/main.py", line 505, in wsgibase
request.body.close()
  File "/usr/local/lib/python2.7/tempfile.py", line 431, in close
self.unlink(self.name)
OSError: [Errno 2] No such file or directory: '/tmp/tmp2PXnS0'

The Function:
@auth.requires_login()
def add_custom():

try:
offerId = request.args[0]
except IndexError:
offerId = 0
offerDetails = offer.authorise(offerId)
status = roo.status(offerDetails)

pagetitle = H4(T('Custom Product'))
buttongroup = [btn.back()]

try:
record = db.custom_product[request.args[1]] or None
except [IndexError, KeyError, TypeError]:
record = None

if session.custom_copy:
db.custom_product.productname.default = session.custom_copy.
productname
db.custom_product.description.default = session.custom_copy.
description
db.custom_product.purchasecost.default = session.custom_copy.
purchasecost
db.custom_product.monthlycost.default = session.custom_copy.
monthlycost
#db.custom_product.smallimage.default = 
session.custom_copy.smallimage
session.custom_copy = None

db.custom_product.created_on.readable = False
db.custom_product.updated_on.readable = False

form = SQLFORM(db.custom_product, record, showid = False)

if form.process().accepted:
#do this for insert but not update
if not record:
# need to get the max priorites from the offer table
pp = mp = None
# offerDetails = db.offer[session.quote.number]

# increment whichever needs to be used and save it to the offer 
table
if form.vars.purchasecost:
if offerDetails.offer.maxpurchasepriority:
offerDetails.offer.maxpurchasepriority += 1
else:
offerDetails.offer.maxpurchasepriority = 1
pp = offerDetails.offer.maxpurchasepriority
if form.vars.monthlycost or (not form.vars.purchasecost and not 
form.vars.monthlycost):
if offerDetails.offer.maxmonthlypriority:
offerDetails.offer.maxmonthlypriority += 1
else:
offerDetails.offer.maxmonthlypriority = 1
mp = offerDetails.offer.maxmonthlypriority
offerDetails.offer.update_record()

# insert record into product_offer_item
db.product_offer_item.insert(
offer_id = offerDetails.offer.id,
custom_pid = form.vars.id,
quantity = 1,
purchasepriority = pp,
monthlypriority = mp,
)
else:
# only do this for updates
# check if a price change also needs a priority change
poiRecord = record.product_offer_item.select().first()
pp = copy.copy(poiRecord.purchasepriority)
mp = copy.copy(poiRecord.monthlypriority)
#poi_set = db(db.product_offer_item.custom_pid == poiRecord.id)
if pp and (not form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 0)
if not pp and (form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 99.5)
if mp and (form.vars.purchasecost > 0 and not form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 0)
if not mp and\
((not form.vars.purchasecost > 0 and not 
form.vars.monthlycost 
> 0) or\
not form.vars.purchasecost > 0 and form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 99.5)
offer.position_check(offerDetails.offer.id)
session.flash = T('Success')
redirect(btn.EditOffer(offerDetails.offer.id, 
dict(custId = offerDetails.customer.id)).url)

elif form.errors:
response.flash = T('Errors in form')
else:
pass
response.view = 'core.html'
return dict(
pagetitle = pagetitle,
pagecontent = form,
buttongroup = buttongroup,
status = status,
)

The Table definition:
db.define_table(
'custom_product',
Field('productname', label=T('Product Name')),
Field('description', 'text', label=T('Description')),
Field('purchasecost', 'double', default = 0, label = T('Purchase Cost'
)),
Field('monthlycost', 'double', default = 0, label = T('Monthly Cost')),
Field('created_on', 'dat

[web2py] Colleagues, how can I generate an identification code automatically?

2019-06-20 Thread Paul Arsenio Blanco Reyes
It turns out that I have a company table, in turn, the company can be 
classified as a client, as a supplier or both together. How to assign a 
consecutive to the company according to its classification?

-- 
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/4f886637-5029-4f2d-a494-31bc4fd686f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Generating graph with chartjs

2019-06-08 Thread Paul Arsenio Blanco Reyes
Recently I found the theme "AdminLTE" 
(https://adminlte.io/themes/AdminLTE/index.html)
I have already implemented it in my application. I would like to generate some 
graphics like those that appear in the preview but I don't know how yo do it. 
Would any of you can help me with any example to understand how I can generate 
them. I will thank you infinitely.

-- 
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/213e07a1-8992-4d07-b536-0f75c69982c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to convert my view to pdf

2019-05-07 Thread Paul Ellis
I had a look at xhtml2pdf and I am not sure how to implement it in my
web2py application.

Do you save the PDF as a file or output it to the browser?

Do you use the html generated by the web2py view and have the function
calls in a view or do you generate the HTML another way in a controller
function?

On Fri, May 3, 2019 at 2:55 PM  wrote:

> I use xhtml2pdf.
>
>
> quarta-feira, 14 de Novembro de 2018 às 10:52:36 UTC, mostwanted escreveu:
>>
>> I have been researching this topic alot because i am trying to achieve
>> this, i want to convert my view exactly as it to PDF, i came across some
>> information on web2py-appreport but I don't understand exactly how it
>> works, maybe its my slow mind, i followed the examples in
>> https://github.com/lucasdavila/web2py-appreport/wiki/Docs-and-examples
>> but the results are not what i want.
>>
>> I wanna have a button on my view which when i click converts that view in
>> to pdf straight away and have it saved. Is this possible and if so how can
>> i achieve it?
>>
>> (Smiles :)
>>
>> Mostwanted.
>>
>> --
> 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/y73g4sctURs/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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAMiH80yfJpjGbcCDBGdg5pBKNq8JB_6M%3DvUfgVz80DJ2qmHKeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Receiving JSON via AJAX in controller function

2019-05-02 Thread Paul Ellis
I have some JS which sends data from a row in a grid to the server as JSON.

The controller function receives the JSON in a request.vars key (not a 
value). This is awkward to find if there are other request.vars. Currently 
I am testing for lengths over 10. This was a quick hot fix because I added 
a request.var which is passed around the app and broke all of the ajax.

Is there a way I can change the JS that the JSON is either:
1 - received as a value in request.vars with a given key so I know exactly 
where it will be.
2 - received in another way that the goal is still achieved.

I tried to use the JS FormData object type but can't find it server side.

The web2py ajax function almost does what I want, but:
1 - I have to give it a Name rather than an ID. I guess this is because it 
was built to be used with forms.
2 - What the page does with the returned JSON will become more complex in 
future.

lastly. I will have to add the code via Email as it is not working in the 
google groups interface.

-- 
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 convert my view to pdf

2019-04-29 Thread Paul Ellis
This is really hard to answer because a PDF has a set page size and a HTML 
file (view) does not. 

Plus getting the css used in a HTML file to translate into css is also a 
challenge. Just print the page you are talking about with a pdf printer 
driver to see. You probably won't be happy with the results, and if you 
are. The next person to print this way won't be.

I have PDF output from my webapp but I have put a lot of work into the 
formatting of the output and it is not a direct swap from a html. I 
actually have no HTML input into my PDF view.

On Wednesday, 14 November 2018 11:52:36 UTC+1, mostwanted wrote:
>
> I have been researching this topic alot because i am trying to achieve 
> this, i want to convert my view exactly as it to PDF, i came across some 
> information on web2py-appreport but I don't understand exactly how it 
> works, maybe its my slow mind, i followed the examples in 
> https://github.com/lucasdavila/web2py-appreport/wiki/Docs-and-examples 
> but the results are not what i want.
>
> I wanna have a button on my view which when i click converts that view in 
> to pdf straight away and have it saved. Is this possible and if so how can 
> i achieve it?
>
> (Smiles :) 
>
> Mostwanted.
>
>

-- 
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: MARKMIN - Sanitizing

2019-04-29 Thread Paul Ellis
Hey Villas,

thanks. I actually thought that the XML sanitization would break the
MARKMIN conversion but it doesn't.

I probably should have tested that first.

Regards

On Mon, Apr 29, 2019 at 7:06 PM villas  wrote:

> Hi Paul
>
> If you are worried about saving dodgy text in the DB,  you could sanitize
> it first using XML()
>
> e.g.
>
> XML('dodgy();**Hello**',sanitize=True).xml()
>
> *<script></script>**Hello***
>
>
> On Thursday, 25 April 2019 12:19:44 UTC+1, Paul Ellis wrote:
>>
>> I am using an editable span with some js to submit the input via ajax to
>> the server. The span is only editable by admins.
>>
>> To give them some formatting options they can use MARKMIN in the span.
>>
>> The problem is it only seems to be one directional.
>> How can I take the processed HTML and turn it back into MARKMIN in order
>> to allow editing?
>>
>> or at least sanitize it that I can be sure no malicious code has been
>> submitted so I can save the MARKMIN in the db.
>>
>>  js that sends the span contents.
>> $("document").ready(function() {
>>
>> // set the event listeners on the edit button
>> $("button[name='buttonedit']").click(function() {
>> var panel = $(this)[0].previousSibling
>> panel.innerText = panel.getAttribute("data-raw")
>> panel.setAttribute("contenteditable", "true")
>> // console.log(panel)
>> $(this).hide()
>> $(this)[0].nextSibling.setAttribute("style", "display:true")
>> })
>> $("button[name='buttonsave']").click(function() {
>> $(this).disabled = true
>> var xhttp = new XMLHttpRequest();
>> xhttp.open('POST', '/assist/update_info_panel', true);
>> xhttp.setRequestHeader("Content-type",
>> "application/x-www-form-urlencoded");
>> var panel = $(this)[0].previousElementSibling.
>> previousElementSibling
>> var body = {
>> 'pid': panel.id,
>> 'body': panel.innerText,
>> };
>> // console.log(body);
>> xhttp.onreadystatechange = function() {
>> // debug code
>> // if (this.readyState == 4) {
>> // console.log(this);
>> // };
>> if (this.readyState == 4 && this.status == 200) {
>> var rObj = JSON.parse(this.responseText);
>> $("span#"+rObj.pid).replaceWith(rObj.body)
>> $("span#"+rObj.pid)
>> .next().attr("style", "display:true")
>> .next().attr("style", "display:None")
>> $("span#"+rObj.pid).find("a").attr("target", "_blank")
>>
>> }
>> };
>> xhttp.send(JSON.stringify(body));
>> })
>> })
>>
>> the controller function that receives the markmin (via json) and returns
>> the HTML.
>>
>> In order to allow editing the raw markmin is stored in a data attribute.
>> I feel this is very unsafe which is why I am asking for help.
>> def update_info_panel():
>> if auth.has_membership('assistant_admin', cached=True):
>> raw_json = None
>> for key in request.vars.keys():
>> if len(key) > 10:
>> raw_json = key
>> inData = Storage(json.loads(raw_json))
>> pid = inData.pid[5:]
>> record = db.product[pid]
>> assist_info = inData.body
>> if record:
>> record.update_record(assist_info=assist_info)
>> body = {
>> 'pid': inData.pid,
>> 'body': SPAN(MARKMIN(assist_info),
>> _id=inData.pid,
>> _name='info_panel',
>> _contenteditable='false',
>> data = {'raw': assist_info}
>> ).__str__()
>> }
>> return json.dumps(body)
>> else:
>> pass
>>
>> The section of the view which holds the span and edit buttons.
>> 
>> {{try:}}
>> {{for item in extra_info:}}
>> {{=DIV(
>> SP

[web2py] MARKMIN - Sanitizing

2019-04-25 Thread Paul Ellis
I am using an editable span with some js to submit the input via ajax to 
the server. The span is only editable by admins. 

To give them some formatting options they can use MARKMIN in the span.

The problem is it only seems to be one directional. 
How can I take the processed HTML and turn it back into MARKMIN in order to 
allow editing?

or at least sanitize it that I can be sure no malicious code has been 
submitted so I can save the MARKMIN in the db.

 js that sends the span contents.
$("document").ready(function() {

// set the event listeners on the edit button
$("button[name='buttonedit']").click(function() {
var panel = $(this)[0].previousSibling
panel.innerText = panel.getAttribute("data-raw")
panel.setAttribute("contenteditable", "true")
// console.log(panel)
$(this).hide()
$(this)[0].nextSibling.setAttribute("style", "display:true")
})
$("button[name='buttonsave']").click(function() {
$(this).disabled = true
var xhttp = new XMLHttpRequest();
xhttp.open('POST', '/assist/update_info_panel', true);
xhttp.setRequestHeader("Content-type", 
"application/x-www-form-urlencoded");
var panel = $(this)[0].previousElementSibling.previousElementSibling
var body = {
'pid': panel.id, 
'body': panel.innerText,
};
// console.log(body);
xhttp.onreadystatechange = function() {
// debug code
// if (this.readyState == 4) {
// console.log(this);
// };
if (this.readyState == 4 && this.status == 200) {
var rObj = JSON.parse(this.responseText);
$("span#"+rObj.pid).replaceWith(rObj.body)
$("span#"+rObj.pid)
.next().attr("style", "display:true")
.next().attr("style", "display:None")
$("span#"+rObj.pid).find("a").attr("target", "_blank")

}
};
xhttp.send(JSON.stringify(body));
})
})

the controller function that receives the markmin (via json) and returns 
the HTML.

In order to allow editing the raw markmin is stored in a data attribute. I 
feel this is very unsafe which is why I am asking for help.
def update_info_panel():
if auth.has_membership('assistant_admin', cached=True):
raw_json = None
for key in request.vars.keys():
if len(key) > 10:
raw_json = key
inData = Storage(json.loads(raw_json))
pid = inData.pid[5:]
record = db.product[pid]
assist_info = inData.body
if record:
record.update_record(assist_info=assist_info)
body = {
'pid': inData.pid,
'body': SPAN(MARKMIN(assist_info),
_id=inData.pid,
_name='info_panel',
_contenteditable='false',
data = {'raw': assist_info}
).__str__()
}
return json.dumps(body) 
else:
pass

The section of the view which holds the span and edit buttons.

{{try:}}
{{for item in extra_info:}}
{{=DIV(
SPAN(MARKMIN(item['info']),
_id= 'info_{0}'.format(item['pid']),
_name= 'info_panel', 
_contenteditable= 'false',
_style="display:block",
data= {
'raw':item['info'] if 
auth.has_membership('assistant_admin') else '',
},
),
BUTTON(SPAN(_class="glyphicon glyphicon-pencil"), 
_class='btn btn-sm btn-default', 
_name='buttonedit')\
if auth.has_membership('assistant_admin') 
else '',
BUTTON(SPAN(_class='glyphicon 
glyphicon-floppy-disk'),
_class="btn btn-sm btn-primary", 
_name="buttonsave",
_style="display:none")\
if auth.has_membership('assistant_admin') 
else '',
_id= 'box_{0}'.format(item['id']),
_style='display:none', 
)}}
{{pass}}
{{except Exception as e:}}
{{print e}}
{{pass}}


The function looks and works great. Apart from the Italic formatting 
cutting the JSON string short, resulting in invalid JSON and me being very 
uneasy about saving raw user input into the db and then letting it back out 
again. 

As a side question. Is there different way to add the JSON string to the 
ajax request in js so that it is accessible from somwhere other than as a 
key in request.vars?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Docum

[web2py] Re: Don't allow textarea to contain html tags

2019-04-23 Thread Paul Ellis
you could use XML(input_text, sanitize=True) as part of your form 
processing.

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

if form.process().accepted:
form.vars.text_input = XML(form.vars.text_input, sanitze=True)


-- 
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: Asynchronous submission of request.vars values to Controller for calculations using Ajax

2019-04-17 Thread Paul Ellis
Which controller is displaying the view you have posted? It looks like the 
ajax function is calling the same controller which returns the index page.

The controller function called by the ajax function should return a string.
The string can be jquery which will be evaluated if you use ':eval'. Or it 
could be some text, like: 'The answer: xxx' which you can dump into a div 
without refreshing the page.

*VIEW for default/index:*
{{extend 'layout.html'}}

The answer: {{=answer}}


 



$('document').ready(function(){
$('#myform').submit(function() {
ajax("{{=URL('default', 'new_answer')}}",['name'], 'answer_location');
return false;
});
});


*CONTROLLER:*
def index():
answer=0
return locals()

def new_answer():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):
info = request.vars.get('name', 0)
if info:
try:
return 'The answer: {0}'.format(int(info)-200)
except ValueError:
return 'Bugger... should have better form validation.'
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

 

-- 
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: mysql import from csv problem

2019-03-03 Thread Paul Ellis
Which python and web2py version are you using?

Do you mean you don't have the csv file anymore?

Do you have a backup of the old database to make another one from?

On Tuesday, 19 February 2019 22:13:24 UTC+1, Andrea Fae' wrote:
>
> Hello, when I import with this procedure 
> https://www.pythonanywhere.com/forums/topic/1288/ from csv to mysql, it 
> alter the ids of some related tables and I have data not corresponding to 
> the original exported csv. What can I do?
> What is my error? is it depending on charset or something related? thank 
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: dict values error in python 3.6

2019-03-03 Thread Paul Ellis
https://github.com/web2py/web2py/issues/2126

done

On Sat, Mar 2, 2019 at 12:16 PM Kevin Keller  wrote:

> Can someone file an issue on github and also attach the solution please?
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/KwYsKUWgYnw/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: custom_auth_table TypeError: a bytes-like object is required, not 'str'

2019-03-01 Thread Paul Ellis
I have solved this by deleting errors. I think there was some errors 
pickled while running Python 2 still in the directory. 

Is it possible your /databases/*.table files were pickled while running 
under Python 2?

Might need to export the data and start a fresh database with python 3 and 
then import the data.

-- 
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: custom_auth_table TypeError: a bytes-like object is required, not 'str'

2019-03-01 Thread Paul Ellis




web2py™Version 2.17.2-stable+timestamp.2018.10.06.11.34.06
PythonPython 3.7.0:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:/web2py/applications/admin/controllers/default.py" 
, line 2012, in 

  File "C:\web2py\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:/web2py/applications/admin/controllers/default.py" 
, line 1618, in 
errors
error = pickle.load(fullpath_file)
  File "C:\web2py\gluon\html.py", line 668, in XML_unpickle
return XML(marshal.loads(data))
TypeError: a bytes-like object is required, not 'str'


Me too. I am getting this from an Ajax callback. But it seems to be pickle 
related.

-- 
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: dict values error in python 3.6

2019-03-01 Thread Paul Ellis
This is a issue with generic.html. In Python 3 dict.values() does not 
return a list it returns a dict_values object.

On line 10 of Generic.html wrap the values method call in list() and it 
works.

{{=BEAUTIFY(list(response._vars.values())[0])}}




-- 
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: Issue with db.export_to_csv_file and Python 3.7

2019-03-01 Thread Paul Ellis
 I have been having a similar problem with importing from csv file and the 
same solution works.

db.import_from_csv_file(open(path, 'r', encoding='utf-8', newline=''))Enter 
code here...



On Saturday, 2 March 2019 00:53:29 UTC+1, jim kaubisch wrote:
>
> been looking around some more. turns out this is a duplicate of this open 
> item - https://github.com/web2py/web2py/issues/2013
>
> Have looked more closely at the 3.x docs for csv and open as well as the 
> code for export_to_csv_file in pydal. 
>
> - the csv docs say 'w' only as Leonel suggested (not surprising),  and say 
> to specify "newline = ''. 
> - adding the encoding as suggested by Dave results in 
>   
>   with open(session.db_backup_name, 'w', encoding='utf-8', newline='') 
> as backup_file:
>
> which results in - SUCCESS at least so it seems. The claim is that the 
> backup is successful. I haven't yet tried to restore the saved backup 
>
> On Friday, March 1, 2019 at 1:41:25 PM UTC-8, Dave S wrote:
>>
>>
>>
>> On Friday, March 1, 2019 at 12:43:21 PM UTC-8, jim kaubisch wrote:
>>>
>>> Thanks, Leonel,
>>>
>>> In a different app (not web2py) I hit this issue pickle and the change 
>>> you suggest solved the problem
>>> Unfortunately, in the web2py and db.export_to_csv_file context, when I 
>>> make the change you suggest, the error message just changes to
>>>
>>> 01/Mar/2019-12:32:27: INFO : backups  : 303   | backing 
>>> db up as 
>>> "applications/MFMCurrAssetMgr/private/_backups/bup_010319_123226/MFMCurrAssetMgr-db.csv"
>>> 01/Mar/2019-12:32:27: WARNING : backups : 309   | - db 
>>> backup Failed: exception: "'ascii' codec can't encode character '\u2019' in 
>>> position 12: ordinal not in range(128)"
>>>
>>
>>
>> You probably need to specify an encoding in the open(), look at
>> https://docs.python.org/3/library/functions.html#open>
>>
>> (which is also where the 'wb' -> 'w' is really explained)
>>
>> /dps
>>
>>
>>>
>>> On Friday, March 1, 2019 at 11:43:26 AM UTC-8, Leonel Câmara wrote:

 You actually have to open it using only 'w' instead of 'wb' in python 3 
 so change it to:

 with open(session.db_backup_name, 'w', newline=''):

 See:
 https://docs.python.org/3/library/csv.html?highlight=csv#csv.writer




-- 
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 - docker - sending email

2019-03-01 Thread Paul Ellis
Naturally the one thing I didn't post. The Email configuration. Was not 
correct. 

The appconfig.ini, correctly, is not the same on the new server as the old 
one and still had fake email settings.

Copied the working settings in, restarted and it works.

Note: Exposing the email ports is not required for outgoing mail.


On Friday, 1 March 2019 05:46:10 UTC+1, Paul Ellis wrote:
>
> I am moving an app to a new server. Previously on pythonanywhere and could 
> send email for password resets. So the email settings are correct.
>
> New server is using docker. web2py + nginx
>
> Trying to send email I am getting the following error: 
> web2py:Mail.send failure:[SSL: WRONG_VERSION_NUMBER]
>
> from googling it looks like this is often due to using the wrong port but 
> I am using 465 which was working before.
>
> Dockerfile:
> FROM python:2.7
>
> RUN apt update && \
>  apt install -y  python-pip gcc python-dev libpq-dev && \
>  pip install --upgrade pip && \
>  pip install gunicorn && \
>  pip install eventlet && \
>  pip install psycopg2 && \
>  pip install pillow
>
> RUN addgroup act && useradd -rm -d /home/act -s /bin/bash -g act -G sudo -u 
> 1000 act
>
> # USER act 
>
> COPY ./web2py /home/act/web2py
>
> WORKDIR /home/act/web2py
>
> EXPOSE 80 465 # not sure if port 465 needs to be exposed
>
> CMD gunicorn -b 0.0.0.0:80 -w 3 wsgihandler
>
> .yml file:
> version: '3'
>
> services:
>
>   adminer:
> image: adminer
> restart: always
> ports:
>   - 8080:8080
>
>   db:
> image: postgres:11 
> restart: always
> env_file:
> ./config/db/db_env
> expose:
> - 5432
> volumes:
>   - db_volume:/var/lib/postgresql/data
>   
>   angebotstool:
> build: .
> volumes:
>   - web2py_apps:/home/act/web2py/applications
> expose:
>   - 80
>   - 443
> ports:
>   - 465:465 # not sure if this is correct / required
> environment:
>   VIRTUAL_HOST: my.host.com
>   LETSENCRYPT_HOST: my.host.com
>   LETSENCRYPT_EMAIL: m...@email.com
> depends_on:
>   - db
>
>   
> volumes:
> db_volume:
> driver: local
> driver_opts:
> type: 'none'
> o: 'bind'
> device: '/home/act/databases/'
> web2py_apps:
> driver: local
> driver_opts:
> type: 'none'
> o: 'bind'
> device: '/home/act/web2py-gunicorn/web2py/applications'
> 
> networks:
> default:
> external:
> name: nginx-proxy
>
> nginx .yml file
> version: '3'
>
> services:
>   nginx:
> image: nginx:1.13.1
> container_name: nginx-proxy
> ports:
>   - "80:80"
>   - "443:443"
> volumes:
>   - conf:/etc/nginx/conf.d
>   - vhost:/etc/nginx/vhost.d
>   - html:/usr/share/nginx/html
>   - certs:/etc/nginx/certs
> labels:
>   - 
> "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
>
>   dockergen:
> image: jwilder/docker-gen:0.7.3
> container_name: nginx-proxy-gen
> depends_on:
>   - nginx
> command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-
> gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
> volumes:
>   - conf:/etc/nginx/conf.d
>   - vhost:/etc/nginx/vhost.d
>   - html:/usr/share/nginx/html
>   - certs:/etc/nginx/certs
>   - /var/run/docker.sock:/tmp/docker.sock:ro
>   - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
>
>   letsencrypt:
> image: jrcs/letsencrypt-nginx-proxy-companion
> container_name: nginx-proxy-le
> depends_on:
>   - nginx
>   - dockergen
> environment:
>   NGINX_PROXY_CONTAINER: nginx-proxy
>   NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
> volumes:
>   - conf:/etc/nginx/conf.d
>   - vhost:/etc/nginx/vhost.d
>   - html:/usr/share/nginx/html
>   - certs:/etc/nginx/certs
>   - /var/run/docker.sock:/var/run/docker.sock:ro
>
> volumes:
>   conf:
>   vhost:
>   html:
>   certs:
>
> # Do not forget to 'docker network create nginx-proxy' before launch, and 
> to add '--network nginx-proxy' to proxied containers. 
>
> networks:
>   default:
> external:
>   name: nginx-proxy
>
>
> What am I missing here?
>

-- 
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: Cannot import modules

2019-02-28 Thread Paul Ellis
I know this sounds odd. But this worked for me recently. It can be caused 
by a corrupt .pyc file.

Try deleting the .pyc files and see if the problem remains.

On Thursday, 28 February 2019 20:54:24 UTC+1, Ben Duncan wrote:
>
> Getting the following errors when trying to import a module
> Module directory looks like:
>
> [web2py@su-postgres-ben-3 Book]$ ls -la modules/
> total 16
> drwxr-xr-x  2 web2py web2py 4096 Feb 28 13:49 .
> drwxrwxr-x 15 web2py web2py 4096 Feb 25 14:33 ..
> -rw-rw-r--  1 web2py web2py  256 Jan 30 10:48 emptysample.py
> -rw-rw-r--  1 web2py web2py0 Feb 28 13:32 __init__.py
> -rw-rw-r--  1 web2py web2py  250 Feb 28 13:49 *testmod.py*
> [web2py@su-postgres-ben-3 Book]$
>
> controller looks like:
>
> def login():
> *from testmod import **
> FRM_ERR = 'N'
> CHOOSE_COMPANY = 'N'
> print 
> "-\n"
> print "Doing the LOGIN form ...\n"
> print "LOGIN: default frm-err: \n ", FRM_ERR
> 
>
> What gives, book says it should work fine ...
> Restarted several times and tried various name changes ...
>
> Thanks ...
> Error ticket for "Book" Ticket ID 
>
> 10.13.69.144.2019-02-28.13-47-50.cf8b0622-c9d2-457d-be0d-93c11fb1251c
>  (ImportError('No module named 
> Book.modules.testmod',), ) Version 
> web2py™ Version 2.17.2-stable+timestamp.2018.10.06.11.34.06 
> Python Python 2.7.13: /usr/bin/python (prefix: /opt/rh/python27/root/usr) 
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "/data/web2py/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/data/web2py/web2py/applications/Book/controllers/default.py" 
> , line 
> 510, in 
>   File "/data/web2py/web2py/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/data/web2py/web2py/applications/Book/controllers/default.py" 
> , line 
> 109, in login
> from testmod import *
>   File "/data/web2py/web2py/gluon/custom_import.py", line 104, in 
> custom_importer
> raise ImportError(e1, import_tb)  # there an import error in the module
> ImportError: (ImportError('No module named Book.modules.testmod',), 
> )
>
> Error snapshot [image: help] 
> 
>  
>
> ((ImportError('No module named 
> Book.modules.testmod',), )) 
> *Ben Duncan*
> DBA / Chief Software Architect 
> Mississippi State Supreme Court
> Electronic Filing Division
>

-- 
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 - docker - sending email

2019-02-28 Thread Paul Ellis
I am moving an app to a new server. Previously on pythonanywhere and could 
send email for password resets. So the email settings are correct.

New server is using docker. web2py + nginx

Trying to send email I am getting the following error: 
web2py:Mail.send failure:[SSL: WRONG_VERSION_NUMBER]

from googling it looks like this is often due to using the wrong port but I 
am using 465 which was working before.

Dockerfile:
FROM python:2.7

RUN apt update && \
 apt install -y  python-pip gcc python-dev libpq-dev && \
 pip install --upgrade pip && \
 pip install gunicorn && \
 pip install eventlet && \
 pip install psycopg2 && \
 pip install pillow

RUN addgroup act && useradd -rm -d /home/act -s /bin/bash -g act -G sudo -u 
1000 act

# USER act 

COPY ./web2py /home/act/web2py

WORKDIR /home/act/web2py

EXPOSE 80 465 # not sure if port 465 needs to be exposed

CMD gunicorn -b 0.0.0.0:80 -w 3 wsgihandler

.yml file:
version: '3'

services:

  adminer:
image: adminer
restart: always
ports:
  - 8080:8080

  db:
image: postgres:11 
restart: always
env_file:
./config/db/db_env
expose:
- 5432
volumes:
  - db_volume:/var/lib/postgresql/data
  
  angebotstool:
build: .
volumes:
  - web2py_apps:/home/act/web2py/applications
expose:
  - 80
  - 443
ports:
  - 465:465 # not sure if this is correct / required
environment:
  VIRTUAL_HOST: my.host.com
  LETSENCRYPT_HOST: my.host.com
  LETSENCRYPT_EMAIL: m...@email.com
depends_on:
  - db

  
volumes:
db_volume:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/act/databases/'
web2py_apps:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/act/web2py-gunicorn/web2py/applications'

networks:
default:
external:
name: nginx-proxy

nginx .yml file
version: '3'

services:
  nginx:
image: nginx:1.13.1
container_name: nginx-proxy
ports:
  - "80:80"
  - "443:443"
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
labels:
  - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"

  dockergen:
image: jwilder/docker-gen:0.7.3
container_name: nginx-proxy-gen
depends_on:
  - nginx
command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/
templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
  - /var/run/docker.sock:/tmp/docker.sock:ro
  - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro

  letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-proxy-le
depends_on:
  - nginx
  - dockergen
environment:
  NGINX_PROXY_CONTAINER: nginx-proxy
  NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
volumes:
  - conf:/etc/nginx/conf.d
  - vhost:/etc/nginx/vhost.d
  - html:/usr/share/nginx/html
  - certs:/etc/nginx/certs
  - /var/run/docker.sock:/var/run/docker.sock:ro

volumes:
  conf:
  vhost:
  html:
  certs:

# Do not forget to 'docker network create nginx-proxy' before launch, and 
to add '--network nginx-proxy' to proxied containers. 

networks:
  default:
external:
  name: nginx-proxy


What am I missing here?

-- 
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] Fresh install - ImportError: cannot import name Cookie

2019-02-28 Thread Paul Ellis
with a fresh install of web2py by running

git clone --recursive https://github.com/web2py/web2py.git



and then running:
 
python web2py.py

I am getting:
Traceback (most recent call last):
  File "web2py.py", line 21, in 
import gluon.widget
  File "C:\w2p\gluon\__init__.py", line 47, in 
from .globals import current
  File "C:\w2p\gluon\globals.py", line 16, in 
from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, 
PY2, iteritems, to_unicode, to_native, \
ImportError: cannot import name Cookie


-- 
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() buttons have no names? 2.17.2-stable

2018-12-30 Thread Paul Ellis
Seems to me that it would as simple as using the buttonclass key as a name 
or id in the gridbutton function. But I am not a professional so I don't 
know if this is a good idea. 

def gridbutton(buttonclass='buttonadd', buttontext=T('Add'),
   buttonurl=url(args=[]), callback=None,
   delete=None, trap=True, noconfirm=None, title=None):
if showbuttontext:
return A(SPAN(_class=ui.get(buttonclass)), CAT(' '),
 SPAN(T(buttontext), _title=title or T(buttontext),
  _class=ui.get('buttontext')),
 _href=buttonurl,
 callback=callback,
 delete=delete,
 noconfirm=noconfirm,
 _class=ui.get('button'),
 cid=request.cid,
 _name=buttonclass) # added this line
else:
return A(SPAN(_class=ui.get(buttonclass)),
 _href=buttonurl,
 callback=callback,
 delete=delete,
 noconfirm=noconfirm,
 _title=title or T(buttontext),
 _class=ui.get('button'),
 cid=request.cid,
 _name=buttonclass) # added this 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] SQLFORM.grid() buttons have no names? 2.17.2-stable

2018-12-30 Thread Paul Ellis
Is there a reason there are no names or ids attached to the grid buttons?
Like addBtn, deleteBtn and so on. 

There's no identifying information on the buttons to make it easy to change 
the text or colour, for example. I don't want 'Add record' I want something 
more contextual depending on the grid.

I want to change the colour of the delete button. 

The edit button is only visible to admins and only for some records. I want 
them to see it is an admin function so they are careful with it. It doesn't 
always have the same index location in the "row-buttons" div. 

I can give a dict() to the ui argument and change the colour of all of the 
buttons, but that's not ideal.

I am pretty sure the buttons used to be named.


-- 
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: removing / hiding SQLFORM.grid links in the view, edit, add forms?

2018-12-12 Thread Paul Ellis
After reading the sqlhtml.py for a while last night. I decided to use the 
same method.

Before creating the grid:
if request.args(-3) in ('edit', 'view'):




On Wednesday, 12 December 2018 00:10:02 UTC+1, Paul Ellis wrote:
>
> I have a grid with some links. One of the buttons is a placeholder which 
> some Jquery attaches to (useless in a the subforms). How do I stop this 
> button from appearing in the subforms Edit and View.
> I don't really want or need any of the links to appear in the subforms.
>
> grid = SQLFORM.grid(query,
> links = [
> lambda row: 'returns a button',
> lambda row: 'returns another button',
> ]
> )
>
> The only thing I can think of is something like this before the grid and 
> the links = links in the grid:
> if 'view' in request.args:
> links = []
> else:
> links = [lambda, lambda, lambda]
> Is there something already in the SQLFORM.grid which can do this?
>
> ** The links do not appear in the Add form. Just in the Edit and View form.
>
>

-- 
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] removing / hiding SQLFORM.grid links in the view, edit, add forms?

2018-12-12 Thread Paul Ellis
@Sandeep
That will disable the view, edit, create forms completely. I want to use
the forms. I just don't want the extra buttons (links) which I use in the
grid to appear in these forms.

On Wed, Dec 12, 2018 at 6:23 AM sandeep patel 
wrote:

> @Paul,
> You can do this way,
> grid = SQLFORM.grid(query,  editable=False,details=False,create=False,..)
>
> Thanks
> SP
>
>
> On Wed, Dec 12, 2018 at 4:40 AM Paul Ellis  wrote:
>
>> I have a grid with some links. One of the buttons is a placeholder which
>> some Jquery attaches to. How do I stop this button from appearing in the
>> subforms add, view etc.
>> I don't really want or need any of the links to appear in the subforms.
>>
>> grid = SQLFORM.grid(query,
>> links = [
>> lambda row: 'returns a button',
>> lambda row: 'returns another button',
>> ]
>> )
>>
>> The only thing I can think of is something like this before the grid and
>> the links = links in the grid:
>> if 'view' in request.args:
>> links = []
>> else:
>> links = [lambda, lambda, lambda]
>> Is there something already in the SQLFORM.grid which can do this?
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/FcnXZz5dRqo/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] removing / hiding SQLFORM.grid links in the view, edit, add forms?

2018-12-11 Thread Paul Ellis
I have a grid with some links. One of the buttons is a placeholder which 
some Jquery attaches to. How do I stop this button from appearing in the 
subforms add, view etc.
I don't really want or need any of the links to appear in the subforms.

grid = SQLFORM.grid(query,
links = [
lambda row: 'returns a button',
lambda row: 'returns another button',
]
)

The only thing I can think of is something like this before the grid and 
the links = links in the grid:
if 'view' in request.args:
links = []
else:
links = [lambda, lambda, lambda]
Is there something already in the SQLFORM.grid which can do this?


-- 
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] Broken/Changed Link on Web2py.com

2018-09-26 Thread Paul Ellis
Hey Contributors,

The link behind the 3rd picture on web2py.com goes to paktpub.com and shows 
a book about 'Internet Marketing with WordPress'. Looks like the site is 
correct, not sure about the book.

Just thought you would like to know.

Best 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to select row based on item ID or name

2018-01-04 Thread Paul Ellis
You would still get a Rows Object though, even though there is only 1 row 
in it. 
You would need .first() .last() or [0] at the end to get just the row.
Or use the shortcut method.

db.table[id]



On Thursday, 4 January 2018 18:24:26 UTC+1, Dave S wrote:
>
>
>
> On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka wrote:
>>
>>
>>
>>
>>
>>
>>
>> I have the following code for my DB:
>> dbmyhealth.define_table("health", 
>> Field('name', 'string'),
>> Field('definition', 'text', length= 100,),
>> Field('abnval', 'text', length= 100,),
>> Field('normval', 'text', length= 100,),
>> Field('administration', 'text', length= 
>> 100,),
>> Field('screening', 'text', length= 100,),
>> Field('causes', 'text', length= 100,),
>> migrate = False)
>>
>> rows  = dbmyhealth().select(dbmyhealth.health.ALL)
>> for row in rows: 
>> location0 = row.name
>> location1 = row.definition
>> location2 = row.abnvalinterpret
>> location3 = row.normvalinterpret
>> location4 = row.administration
>> location5 = row.screening
>> location6 = row.causes
>> corpus = [location1 , location2, location3, location4, location5, 
>> location6]
>>
>> I want to select an item, including all the fields from the abnval to the 
>> causes,not randomly but based on the ID or the name. If I use the limitby 
>> constraint,I can get either the first, second, or last item based on the 
>> selection used. If I use the below code, I get only the first item, which 
>> is everything based on obesity. I want to select any item with every query 
>> using either an ID or the names below e.g.
>> A code like: 
>> for row in rows:
>> if id == 2
>> code..
>>corpus = [location1 , location2, location3, location4, 
>> location5, location6]in this case my corpus will have everything on 
>> cardiomyopathy using the table details below.
>>
>> id name
>> 0. diabetes
>> 1. hypertension
>> 2. cardiomyopathy
>> 3. copd
>> 4. obesity
>>
>> So how do I code it to obtain my answer
>> Kind regards
>>
>>
> Wouldn't that be either of
>
>   rows = dbmyhealth(dbmyhealth.health.id == 2).select()
>
>
>
> or (if you were doing more with the query)
>
>   query = dbmyhealth.health.id == 2
>   rows  = dbmyhealth(query).select()
>
>
> ?
> (I didn't put in a first() because there's only 1 row with id == 2.)
>
>  http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Query--Set--Rows
> >
>
> /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] Requesting button names for grid and smartgrid

2018-01-04 Thread Paul Ellis
Would it be possible to name the grid buttons and smartgrid table links?

This would make it pretty easy to tweak the buttons.
For example. I would like to change the Delete button to red.
I can do it like this:
rowBtns = grid.elements('div', _class = 'row_buttons')
if rowBtns:
   for row in rowBtns:
  row[-1].update(_class = 'button btn btn-danger')

But when I am changing a table link in a smartgrid there needs to be extra 
code to change the table link in the grid and in any forms which are 
created by it.

It could be something like this:
delBtns = grid.elements('a', _name = deleteBtn)
if delBtns:
for delBtn.update(_class = 'button btn btn-danger')

and then whenever this button is being used by the grid / forms etc it will 
appear correctly. Also highlighting a specific button becomes easier. 
Select TR by id and button by name.

names for the table links could be:
if multi_links:
name = [tablename]_[fieldname] + 'Btn'
else:
name = [tablename] + 'Btn'

the other grid button names, I think, should hold roughly with the function 
argument names that control them.
'createBtn', 'detailsBtn', 'editBtn'

-- 
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: smartgrid - limit dropdown menu items in edit form

2018-01-04 Thread Paul Ellis
Your assumption is correct and the solution worked perfectly. I didn't
realise I could use the requires method in that way. I have now read more
about it.

Thanks

On Tue, Jan 2, 2018 at 3:25 PM, Jim S  wrote:

> I'm assuming you have a company_id added to your auth_user table to
> identify which company a user belongs to.
>
> If that is correct, then I'd add the following ahead of the
> SQLFORM.smartgrid call
>
> db.offer.user_id.requires = IS_IN_DB(db(db.auth_user.company_id == auth.
> user.company_id), db.auth_user, '%(first_name)s %(last_name)s', zero='Select
> User...')
>
> ...or something like that.  I didn't test the solution.  Read more about
> it here http://web2py.com/books/default/chapter/29/07/forms-
> and-validators#Database-validators
>
>
> Another option would be to add a common filter, possibly in your db.py
> file to apply this rule to the entire site.
>
> http://web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer?search=common+filter#Common-filters
>
>
>
> On Monday, January 1, 2018 at 4:51:33 PM UTC-6, Paul Ellis wrote:
>>
>> I want to start using a smartgrid to browse a couple of tables as an
>> admin tool.
>> There are a couple of companies using the same database.
>> When an admin edits an 'Offer' I want them to be able to change the
>> user_id. Effectively assigning the offer to a different staff member in the
>> event of staff changes or holidays etc.
>>
>> The problem is the drop down menu shows all users in the database, not
>> just the users which belong to the company in question.
>>
>> db.define_table(
>> 'offer',
>> Field('offer_number', 'integer', unique=True, label = T('Offer
>> Number')),
>> Field('user_id','reference auth_user', label = T('Created By'),
>> ondelete = 'SET NULL'),
>> Field('customer_id','reference customer', requires=IS_NOT_EMPTY(),
>> label = T('Customer Name')),
>> Field('reseller_id','reference reseller', requires=IS_NOT_EMPTY(),
>> label = T('Business Name')),
>> Field('created_on', 'datetime', default=request.now, writable=False,
>> label=T('Created On')),
>> Field('updated_on', 'datetime', default=request.now, writable=False,
>> label=T('Updated On')),
>> singular = T('Offer'),
>> plural = T('Offers'),
>> )
>>
>> db.define_table(
>> 'remarks',
>> Field('offer_id', 'reference offer', requires=IS_NOT_EMPTY()),
>> Field('remorder', 'integer', label=T('Postion')),
>> Field('remark', 'text', label=T('Remarks')),
>> singluar = T('Remark'),
>> plural = T('Remarks'),
>> )
>>
>>
>> and the grid:
>> @auth.requires_membership('business leader')
>> def offers():
>> pagetitle = 'offers'
>> buttongroup = []
>>
>>
>> db.offer.offer_number.writable = False
>> db.offer.reseller_id.writable = False
>> db.offer.reseller_id.readable = False
>> # db.offer.user_id.writable = False
>>
>> pagecontent = SQLFORM.smartgrid(
>> db.offer,
>> details = False,
>> constraints = {
>> 'offer' : db.offer.reseller_id == session.auth.user.
>> reseller_id,
>> },
>> linked_tables = [
>> 'offer',
>> 'remarks',
>> ],
>> fields = {
>> 'offer' : [
>> db.offer.offer_number,
>> db.offer.user_id,
>> db.offer.customer_id,
>> db.offer.created_on,
>> db.offer.updated_on,
>> ],
>> },
>> )
>>
>> response.view = 'tooladmin_core.html'
>> return dict(
>> pagetitle = pagetitle,
>> buttongroup = buttongroup,
>> pagecontent = pagecontent,
>> )
>>
>>
>>
>>
>> --
> 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/3VwXtWiCqP8/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] smartgrid - limit dropdown menu items in edit form

2018-01-01 Thread Paul Ellis
I want to start using a smartgrid to browse a couple of tables as an admin 
tool.
There are a couple of companies using the same database.
When an admin edits an 'Offer' I want them to be able to change the 
user_id. Effectively assigning the offer to a different staff member in the 
event of staff changes or holidays etc.

The problem is the drop down menu shows all users in the database, not just 
the users which belong to the company in question.

db.define_table(
'offer',
Field('offer_number', 'integer', unique=True, label = T('Offer Number'
)),
Field('user_id','reference auth_user', label = T('Created By'), 
ondelete = 'SET NULL'),
Field('customer_id','reference customer', requires=IS_NOT_EMPTY(), 
label = T('Customer Name')),
Field('reseller_id','reference reseller', requires=IS_NOT_EMPTY(), 
label = T('Business Name')),
Field('created_on', 'datetime', default=request.now, writable=False, 
label=T('Created On')),
Field('updated_on', 'datetime', default=request.now, writable=False, 
label=T('Updated On')),
singular = T('Offer'),
plural = T('Offers'),
)

db.define_table(
'remarks',
Field('offer_id', 'reference offer', requires=IS_NOT_EMPTY()),
Field('remorder', 'integer', label=T('Postion')),
Field('remark', 'text', label=T('Remarks')),
singluar = T('Remark'),
plural = T('Remarks'),
)


and the grid:
@auth.requires_membership('business leader')
def offers():
pagetitle = 'offers'
buttongroup = []


db.offer.offer_number.writable = False
db.offer.reseller_id.writable = False
db.offer.reseller_id.readable = False
# db.offer.user_id.writable = False

pagecontent = SQLFORM.smartgrid(
db.offer,
details = False,
constraints = {
'offer' : db.offer.reseller_id == session.auth.user.reseller_id,
},
linked_tables = [
'offer',
'remarks',
],
fields = {
'offer' : [
db.offer.offer_number,
db.offer.user_id,
db.offer.customer_id,
db.offer.created_on,
db.offer.updated_on,
],
},
)

response.view = 'tooladmin_core.html'
return dict(
pagetitle = pagetitle,
buttongroup = buttongroup,
pagecontent = pagecontent,
)




-- 
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] Small correction to the manual

2017-08-30 Thread Paul Furber
In this section of the manual: 
http://www.web2py.com/books/default/chapter/29/10/services#parse_as_rest--experimental-

There is a paragraph explaining how to use cURL to test a restful API as 
follows:

If you have the "curl" utility installed you can try:

$ curl -d "name=Tim" http://127.0.0.1:8000/myapp/default/api/friend.json
{"errors": {}, "id": 1}

---
That example (it's the first one) won't work because the code for POST 
above doesn't do any pattern matching. It should be:

$ curl -d "name=Tim" http://127.0.0.1:8000/myapp/default/api/person.json
{"errors": {}, "id": 1}

so it passes the table name directly. 


-- 
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] SQLFORM.grid search type error reduce()

2017-08-15 Thread Paul Ellis
ok no more errors.

If I search for a name (John) for example in the table i get everything, Or
for his ID (11) I get everything.

I realise this is a join table (Many to Many) so it's no big deal but the
search here is not very useful.

I will need to implement special grids for these situations.

Thanks for the fix.

On Tue, Aug 1, 2017 at 10:46 AM, Paul Ellis  wrote:

> I am getting this error only when searching the auth_membership table
>
> I have put in a basic 'appadmin' in my webapp. I call it 'tooladmin' to
> differentiate from the built in stuff.
>
> I use this function to edit any database table:
> def manage_table():
> tablename = request.args(0)
> pagetitle = H4('{0} {1}'.format(T('Manage'), tablename))
> buttongroup = [_btn_index()]
> table = db[tablename]
> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>
>
> response.view = 'tooladmin_core.html'
> return dict(pagetitle=pagetitle, buttongroup=buttongroup,
> pagecontent=pagecontent)
>
> The search feature on the SQLFORM.grid is throwing this error when
> searching the auth_membership table:
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "E:\web2py\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
> <http://127.0.0.1:8000/admin/edit/OfferTool/controllers/tooladmin.py>, line 
> 262, in 
>   File "E:\web2py\gluon\globals.py", line 417, in 
> self._caller = lambda f: f()
>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
> <http://127.0.0.1:8000/admin/edit/OfferTool/controllers/tooladmin.py>, line 
> 136, in manage_table
> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>   File "E:\web2py\gluon\sqlhtml.py", line 2526, in grid
> subquery = SQLFORM.build_query(sfields, keywords)
>   File "E:\web2py\gluon\sqlhtml.py", line 1827, in build_query
> ) for k in key.split()])
> TypeError: reduce() of empty sequence with no initial value
>
>
>
> --
> 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/UnN6AyOh2Lg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: SQLFORM.grid search type error reduce()

2017-08-07 Thread Paul Ellis
I will gladly test. But I can't do it until next week. 

⁣Sent from TypeApp ​

On 4 Aug. 2017, 17:58, at 17:58, Massimo Di Pierro  
wrote:
>Just fixed in trunk. Can you please help test the fix?
>
>On Tuesday, 1 August 2017 03:46:13 UTC-5, Paul Ellis wrote:
>>
>> I am getting this error only when searching the auth_membership table
>>
>> I have put in a basic 'appadmin' in my webapp. I call it 'tooladmin'
>to 
>> differentiate from the built in stuff.
>>
>> I use this function to edit any database table:
>> def manage_table():
>> tablename = request.args(0)
>> pagetitle = H4('{0} {1}'.format(T('Manage'), tablename))
>> buttongroup = [_btn_index()]
>> table = db[tablename]
>> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>>
>>
>> response.view = 'tooladmin_core.html'
>> return dict(pagetitle=pagetitle, buttongroup=buttongroup, 
>> pagecontent=pagecontent)
>>
>> The search feature on the SQLFORM.grid is throwing this error when 
>> searching the auth_membership table:
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>>
>> Traceback (most recent call last):
>>   File "E:\web2py\gluon\restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py"
><http://127.0.0.1:8000/admin/edit/OfferTool/controllers/tooladmin.py>,
>line 262, in 
>>   File "E:\web2py\gluon\globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py"
><http://127.0.0.1:8000/admin/edit/OfferTool/controllers/tooladmin.py>,
>line 136, in manage_table
>> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>>   File "E:\web2py\gluon\sqlhtml.py", line 2526, in grid
>> subquery = SQLFORM.build_query(sfields, keywords)
>>   File "E:\web2py\gluon\sqlhtml.py", line 1827, in build_query
>> ) for k in key.split()])
>> TypeError: reduce() of empty sequence with no initial value
>>
>>
>>
>>
>
>-- 
>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/UnN6AyOh2Lg/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] SQLFORM.grid search type error reduce()

2017-08-01 Thread Paul Ellis
I am getting this error only when searching the auth_membership table

I have put in a basic 'appadmin' in my webapp. I call it 'tooladmin' to 
differentiate from the built in stuff.

I use this function to edit any database table:
def manage_table():
tablename = request.args(0)
pagetitle = H4('{0} {1}'.format(T('Manage'), tablename))
buttongroup = [_btn_index()]
table = db[tablename]
pagecontent = SQLFORM.grid(table, args=[request.args(0)])


response.view = 'tooladmin_core.html'
return dict(pagetitle=pagetitle, buttongroup=buttongroup, 
pagecontent=pagecontent)

The search feature on the SQLFORM.grid is throwing this error when 
searching the auth_membership table:

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

Traceback (most recent call last):
  File "E:\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
, line 
262, in 
  File "E:\web2py\gluon\globals.py", line 417, in 
self._caller = lambda f: f()
  File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
, line 
136, in manage_table
pagecontent = SQLFORM.grid(table, args=[request.args(0)])
  File "E:\web2py\gluon\sqlhtml.py", line 2526, in grid
subquery = SQLFORM.build_query(sfields, keywords)
  File "E:\web2py\gluon\sqlhtml.py", line 1827, in build_query
) for k in key.split()])
TypeError: reduce() of empty sequence with no initial value



-- 
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: PDF Download File Name

2017-05-29 Thread Paul Ellis
Found a solution.

response.headers['Content-Disposition'] = 'inline;
filename="{0}.pdf"'.format(reseller.businessname)

Using the 'attachment' keyword the file will just download. But with
'inline' it still displays and uses the custom filename if / when
downloaded.

On Mon, May 29, 2017 at 10:41 AM, Paul Ellis  wrote:

> I tried your suggestion like this:
> response.view = offer_number
> response.headers['Content-Type'] = 'application/pdf'
> return pdf.output(dest='S')
>
> but I still get the controller function name as the filename when
> downloading.
>
> On Thu, May 18, 2017 at 10:42 PM, Dave S  wrote:
>
>>
>>
>> On Tuesday, May 16, 2017 at 1:27:06 AM UTC-7, Paul Ellis wrote:
>>>
>>> Hello,
>>>
>>> I use pyfpdf to display some information from my my database. When I
>>> click save the filename is 'pdf_view' which is the name of the controller
>>> function.
>>>
>>> How can I change this? I want the name to also come from the database.
>>>
>>> With the help of others on here. I can make a download link without
>>> viewing the PDF with a custom filename. However, my client would really
>>> prefer to be able to download with a customer filename from the PDF view.
>>>
>>> This output call works fine. But the Autofill name is not taken from the
>>> variable passed to the function.
>>>
>>> return pdf.output(name=bname, dest='S')
>>>
>>>
>> fpdf?  I haven't tried my sample for a while (like not having seen a
>> typo), but what I see is that the browser uses the page name (from the
>> charming "fpdfdemo" I've called the function).
>>
>> I'm specifying response.view = generic.pdf, I don't know if that is
>> relevant to the naming logic.
>>
>> /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/to
>> pic/web2py/OtWmSAU6NCE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Re: PDF Download File Name

2017-05-29 Thread Paul Ellis
I tried your suggestion like this:
response.view = offer_number
response.headers['Content-Type'] = 'application/pdf'
return pdf.output(dest='S')

but I still get the controller function name as the filename when
downloading.

On Thu, May 18, 2017 at 10:42 PM, Dave S  wrote:

>
>
> On Tuesday, May 16, 2017 at 1:27:06 AM UTC-7, Paul Ellis wrote:
>>
>> Hello,
>>
>> I use pyfpdf to display some information from my my database. When I
>> click save the filename is 'pdf_view' which is the name of the controller
>> function.
>>
>> How can I change this? I want the name to also come from the database.
>>
>> With the help of others on here. I can make a download link without
>> viewing the PDF with a custom filename. However, my client would really
>> prefer to be able to download with a customer filename from the PDF view.
>>
>> This output call works fine. But the Autofill name is not taken from the
>> variable passed to the function.
>>
>> return pdf.output(name=bname, dest='S')
>>
>>
> fpdf?  I haven't tried my sample for a while (like not having seen a
> typo), but what I see is that the browser uses the page name (from the
> charming "fpdfdemo" I've called the function).
>
> I'm specifying response.view = generic.pdf, I don't know if that is
> relevant to the naming logic.
>
> /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/OtWmSAU6NCE/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] PDF Download File Name

2017-05-16 Thread Paul Ellis
Hello,

I use pyfpdf to display some information from my my database. When I click 
save the filename is 'pdf_view' which is the name of the controller 
function.

How can I change this? I want the name to also come from the database.

With the help of others on here. I can make a download link without viewing 
the PDF with a custom filename. However, my client would really prefer to 
be able to download with a customer filename from the PDF view.

This output call works fine. But the Autofill name is not taken from the 
variable passed to the function.

return pdf.output(name=bname, dest='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.


Re: [web2py] Re: Python web2py console

2017-03-07 Thread Paul Ellis
Hey Marlysson,

This command doesn't work. But thanks for your time to try to help.

Anthony has told me the correct command is:

web2py.exe -S your_application -M

Cheers

On Mon, Mar 6, 2017 at 3:46 PM, Marlysson Silva 
wrote:

> python web2py.exe -S your_application -M
>
> Em segunda-feira, 6 de março de 2017 11:14:53 UTC-3, Paul Ellis escreveu:
>>
>> Yes. I want an interactive shell with my application loaded.
>>
>> I know I can run a 'Test' page with output to the console, but it would
>> be much easier (and I know possible) if I could use an interactive shell.
>>
>> I have seen Massimo using it in his videos. But I can' t get the command
>> to work.
>>
>> On Mon, Mar 6, 2017 at 2:36 PM, Marlysson Silva 
>> wrote:
>>
>>> Try just double click in web2py.exe , it open a server in a screen.
>>>
>>> Or are you trying accessing models of application via shell?
>>>
>>> Em segunda-feira, 6 de março de 2017 09:14:34 UTC-3, Paul Ellis escreveu:
>>>
>>>> Hello,
>>>>
>>>> I know this question has been asked before, but didn't solve the
>>>> problem for me.
>>>>
>>>> I am using Windows 10 and web2py binary and have replaced web2py.py
>>>> with web2py.exe in the command python web2py.py -s [applicaiton] -m and am
>>>> getting this error:
>>>>
>>>> python web2py.exe -s [application] -m
>>>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1,
>>>> but no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>>>> details
>>>>
>>>> I have also tried:
>>>> python web2py.exe
>>>>
>>>> e:\web2py\py web2py.exe
>>>> this gives a traceback, but the same error:
>>>> Traceback (most recent call last):
>>>>   File "", line 6, in 
>>>>   File "__main__.py", line 126, in 
>>>>   File "__main__py__.py", line 60, in 
>>>>   File "web2py.exe", line 1
>>>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1,
>>>> but no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>>>> details
>>>>
>>>> What am I doing wrong?
>>>>
>>>> Cheers
>>>>
>>> --
>>> 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/to
>>> pic/web2py/T1OH6haDHHM/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/T1OH6haDHHM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Python web2py console

2017-03-07 Thread Paul Ellis
Thank you. That works.

I used the binary in the beginning, simply because I was so new and it
seemed the simplest way forwards.

Maybe it's time to switch to the source version.

On Mon, Mar 6, 2017 at 4:51 PM, Anthony  wrote:

> If using the Windows binary, the .exe file includes the Python
> interpreter, so you don't run it using your system's installed Python.
> Instead, it would be:
>
> web2py.exe -S application -M
>
> Also, note that S and M are capitalized.
>
> Anyway, the point of the binary .exe file is for systems that do not have
> Python installed. If you have Python installed, it would be preferable to
> just use the source version of web2py -- don't bother with the .exe version.
>
> Anthony
>
>
> On Monday, March 6, 2017 at 7:14:34 AM UTC-5, Paul Ellis wrote:
>>
>> Hello,
>>
>> I know this question has been asked before, but didn't solve the problem
>> for me.
>>
>> I am using Windows 10 and web2py binary and have replaced web2py.py with
>> web2py.exe in the command python web2py.py -s [applicaiton] -m and am
>> getting this error:
>>
>> python web2py.exe -s [application] -m
>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but
>> no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>> details
>>
>> I have also tried:
>> python web2py.exe
>>
>> e:\web2py\py web2py.exe
>> this gives a traceback, but the same error:
>> Traceback (most recent call last):
>>   File "", line 6, in 
>>   File "__main__.py", line 126, in 
>>   File "__main__py__.py", line 60, in 
>>   File "web2py.exe", line 1
>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but
>> no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>> details
>>
>> What am I doing wrong?
>>
>> Cheers
>>
> --
> 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/T1OH6haDHHM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Python web2py console

2017-03-06 Thread Paul Ellis
Yes. I want an interactive shell with my application loaded.

I know I can run a 'Test' page with output to the console, but it would be
much easier (and I know possible) if I could use an interactive shell.

I have seen Massimo using it in his videos. But I can' t get the command to
work.

On Mon, Mar 6, 2017 at 2:36 PM, Marlysson Silva 
wrote:

> Try just double click in web2py.exe , it open a server in a screen.
>
> Or are you trying accessing models of application via shell?
>
> Em segunda-feira, 6 de março de 2017 09:14:34 UTC-3, Paul Ellis escreveu:
>
>> Hello,
>>
>> I know this question has been asked before, but didn't solve the problem
>> for me.
>>
>> I am using Windows 10 and web2py binary and have replaced web2py.py with
>> web2py.exe in the command python web2py.py -s [applicaiton] -m and am
>> getting this error:
>>
>> python web2py.exe -s [application] -m
>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but
>> no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>> details
>>
>> I have also tried:
>> python web2py.exe
>>
>> e:\web2py\py web2py.exe
>> this gives a traceback, but the same error:
>> Traceback (most recent call last):
>>   File "", line 6, in 
>>   File "__main__.py", line 126, in 
>>   File "__main__py__.py", line 60, in 
>>   File "web2py.exe", line 1
>> SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but
>> no encoding declared; see http://python.org/dev/peps/pep-0263/ for
>> details
>>
>> What am I doing wrong?
>>
>> Cheers
>>
> --
> 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/T1OH6haDHHM/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] Python web2py console

2017-03-06 Thread Paul Ellis
Hello, 

I know this question has been asked before, but didn't solve the problem 
for me.

I am using Windows 10 and web2py binary and have replaced web2py.py with 
web2py.exe in the command python web2py.py -s [applicaiton] -m and am 
getting this error:

python web2py.exe -s [application] -m
SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but 
no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I have also tried: 
python web2py.exe

e:\web2py\py web2py.exe
this gives a traceback, but the same error:
Traceback (most recent call last):
  File "", line 6, in 
  File "__main__.py", line 126, in 
  File "__main__py__.py", line 60, in 
  File "web2py.exe", line 1
SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but 
no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

What am I doing wrong?

Cheers

-- 
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: Autoincrement which resets each month (not primary id)

2017-03-06 Thread Paul Ellis
Hey Brian,

Doing it on the fly won't work because I want the number to be set at
record creation and be a part of the dataset. Also, this is what I am
already doing.

Using a database trigger is something I don't know anything about. So thank
you for the nudge, I will research this option.

Paul

On Mon, Mar 6, 2017 at 1:03 AM, Brian M  wrote:

> First of all, at the risk of asking a silly question - is there actually a
> reason to store this secondary ID in the database rather than just have it
> calculated on the fly as-needed using a virtual field? Assuming that you've
> got a created_date field already in the table that'll give you the month
> portion and then there's definitely an id field to give you that so just
> let web2py figure it out for you on-the-fly
>
> Field.Virtual('human_id', lambda row: int(row.your_table.created_date.
> strftime('%y%m0')) + row.your_table.id)
>
> The above would cause a record created today (2017-03-05) that had id =
> 123 to return a human_id of 170300123 which is I think what you want. Note
> the extra zeros tacked on to the end of the strftime they are important so
> that when you add the ID you don't accidentally increment your month number
> - be sure to include enough to ensure that you can cover the highest
> realistic record ID (and then add an extra zero :D). Alternatively, you may
> wish to consider changing your human ID format to something like
> yymm-## so that you don't have to worry about inadvertently messing up
> your date related portion and it is perhaps slightly easier for humans to
> understand which is presumably important because I don't get why you'd want
> to include the year and month if it isn't supposed to mean anything to the
> user.
>
> db.your_table.human_id = Field.Virtual('human_id', lambda row:
> '{0}-{1}'.format(row.your_table.created_date.strftime('%y%m') +'-' + row.
> your_table.id), table_name = 'your_table')
>
> If you need to actually store it in the database then you'll have to work
> more.  Sadly, web2py's computed fields won't work because they don't know
> the ID before the insert. That leaves you with doing it DB side. MySQL
> appears to only lets you have one auto-increment per table so unfortunately
> you can't have both your actual primary key ID and a second human readable
> monthly ID (that would intentionally be reset to something like 170300
> this month and 170400 next).  What I'd consider is creating a DB
> trigger that would take care of automatically populating your secondary ID
> for you all within the database so that there's nothing for you to manage.
> So on insert the database could automatically look at the date (or use an
> existing created_date field) and the current auto-increment number and
> combine as needed and store it for you.
>
> ~Brian
>
>
>
> On Sunday, March 5, 2017 at 11:26:51 AM UTC-6, Paul Ellis wrote:
>>
>> I want to have a numbering system which is 2 digit year, 2 digit month
>> and then an autoincrement number which resets each month. 1703#
>>
>> Currently using SQLite with a view to move to MYSQL in future. The MYSQL
>> examples I have found suggest using a composite primary key, which doesn't
>> seem to fit too well with web2py.
>>
>> The reason I am trying for autoincrement is so the database ensures the
>> numbers are unique. I am willing to look at another way if I am sure I
>> won't end up with 2 identical numbers.
>>
>> At the moment I have it working with datetime.date.today().strftime('%y%m')
>> + id. So I am half way there, but can't see how to reset each month. I
>> guess I can check for the highest number in the database programmatically,
>> but I am worried about duplicate numbers with a high number of users. This
>> also seems like if the document with the highest number was deleted (but
>> possibly already printed), then the number will be reused.
>>
>> The program uses the actual primary key for all backend work. This is
>> just an identifier for humans, but the documents produced by the program
>> can't afford to have the same number as another document.
>>
>> Can someone give me a nudge in the right direction, I am a bit stuck?
>>
> --
> 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 u

[web2py] Autoincrement which resets each month (not primary id)

2017-03-05 Thread Paul Ellis
I want to have a numbering system which is 2 digit year, 2 digit month and 
then an autoincrement number which resets each month. 1703#

Currently using SQLite with a view to move to MYSQL in future. The MYSQL 
examples I have found suggest using a composite primary key, which doesn't 
seem to fit too well with web2py.

The reason I am trying for autoincrement is so the database ensures the 
numbers are unique. I am willing to look at another way if I am sure I 
won't end up with 2 identical numbers.

At the moment I have it working with datetime.date.today().strftime('%y%m') 
+ id. So I am half way there, but can't see how to reset each month. I 
guess I can check for the highest number in the database programmatically, 
but I am worried about duplicate numbers with a high number of users. This 
also seems like if the document with the highest number was deleted (but 
possibly already printed), then the number will be reused.

The program uses the actual primary key for all backend work. This is just 
an identifier for humans, but the documents produced by the program can't 
afford to have the same number as another document.

Can someone give me a nudge in the right direction, I am a bit stuck?

-- 
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 open web2py console shell on my windows 8 ??

2017-03-04 Thread Paul Ellis
Hi Anthony,

I am using Windows 10 and have replaced web2py.py with web2py.exe and am 
getting this error:
SyntaxError: Non-ASCII character '\x90' in file web2py.exe on line 1, but 
no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

What am I doing wrong?

Cheers

On Sunday, 25 August 2013 15:38:57 UTC+2, Anthony wrote:
>
> If you are using the source version of web2py, you be need to have Python 
> installed. If using the Windows binary, replace web2py.py with web2py.exe 
> in that command.
>
> Anthony
>

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


[web2py] Re: SQLFORM.grid field.represent not working with joined tables

2017-02-20 Thread Paul Ellis
I still don't know what caused this. There was obviously something missing 
in the grid. I have come back to the problem after working around it with 
js and can't replicate the issue. It is now working.

-- 
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 field.represent not working with joined tables

2017-02-15 Thread Paul Ellis
Here is the traceback:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.

Traceback (most recent call last):
  File "E:\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "E:\web2py\applications\OfferTool\views\offer/test.html", line 79, in 

  File "E:\web2py\gluon\globals.py", line 430, in write
self.body.write(xmlescape(data))
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\html.py", line 963, in xml
(fa, co) = self._xml()
  File "E:\web2py\gluon\html.py", line 955, in _xml
self.components])
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\html.py", line 963, in xml
(fa, co) = self._xml()
  File "E:\web2py\gluon\html.py", line 955, in _xml
self.components])
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\html.py", line 963, in xml
(fa, co) = self._xml()
  File "E:\web2py\gluon\html.py", line 955, in _xml
self.components])
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\html.py", line 963, in xml
(fa, co) = self._xml()
  File "E:\web2py\gluon\html.py", line 955, in _xml
self.components])
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\html.py", line 963, in xml
(fa, co) = self._xml()
  File "E:\web2py\gluon\html.py", line 955, in _xml
self.components])
  File "E:\web2py\gluon\html.py", line 131, in xmlescape
return data.xml()
  File "E:\web2py\gluon\packages\dal\pydal\objects.py", line 2344, in xml
rv = self.db.represent('rows_xml', self)
  File "E:\web2py\gluon\packages\dal\pydal\base.py", line 1076, in represent
return self.representers[name](*args, **kwargs)
  File "E:\web2py\gluon\sqlhtml.py", line 3329, in __init__
r = represent(field, r, record)
  File "E:\web2py\gluon\sqlhtml.py", line 70, in represent
return f(value, record)
  File "E:/web2py/applications/OfferTool/controllers/offer.py" 
, line 331, in 

_id=row.product.id)
  File "E:\web2py\gluon\packages\dal\pydal\objects.py", line 90, in __getattr__
raise AttributeError
AttributeError


And I should point out that if I do something like 'row.id' which should 
cause an Attribute Error I get a much shorter Traceback.

-- 
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 field.represent not working with joined tables

2017-02-14 Thread Paul Ellis
I have have a grid with a left outer join. So the row objects look like 
this:


I am trying to use represent to make some of them editable. For the 
optional checkbox it is like this:
db.product_offer_item.optional.represent = lambda value, row: 
INPUT(_type='checkbox',

_checked=value,

_name='optional',

_id=row.product.id
)
and placed just before the grid is created. Now I am getting an Attribute 
Error from adding the ID to the checkbox. If I just ad the whole row as the 
ID it works and I get an ID which looks like the row object above (that's 
where I copied the details from) but when I try to access the row data to 
put the product.id as the ID it throws an error. I also can't access the 
sub object product or product_offer_item, I get the same error.

With the left outer join, the product.id is present for all rows, the 
product_offer_item details are not.

I haven't had this problem before and can't think of a way to add a row 
unique identifier any other way. 

Why am I getting an Attribute Error when I can clearly see the attributes.


-- 
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 changing the behaviour when there are no records

2017-02-13 Thread Paul Ellis
Oh I didn't know I could do that. That's perfect!

Thanks Edwin.

On Mon, Feb 13, 2017 at 8:59 PM, Edwin Haver  wrote:

> Hi Paul,
>
> You can test if the grid has rows by doing the following
>
> {{if grid.rows:}}
>   {{=grid.rows}}
> {{else:}}
>   No records
> {{pass}}
>
>
> That should do it I think.
>
> Regards, Edwin
>
> On Monday, February 13, 2017 at 7:12:53 PM UTC+4, Paul Ellis wrote:
>>
>> I want to display something else if the query returns empty. Like some
>> instructions and buttons.
>>
>> I can't find anything in the SQLFORM.grid signature, like an on_empty
>> option and haven't found anything in the book or by googling.
>>
>> As the Add button doesn't fit this situation. I am getting a DIV with the
>> text 'No records Found' not an empty grid.
>>
>> How can I do this without checking the DB for rows before calling the
>> grid? This would then be accessing the DB twice when there are rows to be
>> displayed which is most of the time.
>>
> --
> 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/oTMg3gLlb3U/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] SQLFORM.grid changing the behaviour when there are no records

2017-02-13 Thread Paul Ellis
I want to display something else if the query returns empty. Like some 
instructions and buttons. 

I can't find anything in the SQLFORM.grid signature, like an on_empty 
option and haven't found anything in the book or by googling.

As the Add button doesn't fit this situation. I am getting a DIV with the 
text 'No records Found' not an empty grid.

How can I do this without checking the DB for rows before calling the grid? 
This would then be accessing the DB twice when there are rows to be 
displayed which is most of the time.

-- 
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:34645] Re: Does your Response Flash get in the way?

2017-02-13 Thread Paul Ellis
Hi Thadeus,

How did you move the flash messages?

On Thursday, 5 November 2009 17:52:15 UTC+1, Thadeus Burgess wrote:
>
> Instead of putting a timer on response.flash, I moved its location to 
> another location on the site that does conflict with any text.
>
> -Thadeus
>
>
>
>
> On Thu, Nov 5, 2009 at 1:08 AM, Sebastian Brandt  > wrote:
>
>>
>> Thnaks Russel for pointing that out. I think this is very nice.
>> Of course the message will be unread if the user is distracted, but
>> after the message is generated after user input in most cases I guess,
>> that should be no problem in my opinion.
>>
>> Sebastian
>>
>> On 5 Nov., 05:43, mdipierro  wrote:
>> > The problem with that is that if the user is distracted, the message
>> > fades out before he/she can read it.
>> >
>> > On Nov 4, 4:48 pm, Russell  wrote:
>> >
>> > > Hi there,
>> >
>> > > A mild annoyance: Sometimes the response flash covers other text on
>> > > the screen and, when you are doing lots of testing, you are
>> > > continually clicking it to make it go away.
>> >
>> > > My suggestion is to replace web2py_ajax.html line 36:
>> >
>> > > jQuery('.flash').click(function() { jQuery(this).fadeOut('slow');
>> > > return false; });
>> >
>> > > with:
>> >
>> > > jQuery('.flash').hide().fadeIn(2000).animate({opacity: 1.0},
>> > > 2000).animate({ opacity: 'hide' }, 2000);
>> >
>> > > This makes the response.flash fade in and then fade out.  No clicking
>> > > required.
>> >
>> > > Thanks
>> > > Russell
>>
>>
>

-- 
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] Changing the default PDF dowload filename (fpdf)

2017-02-12 Thread Paul Ellis
When want to save a PDF made with FPDF and web2py. The filename is always 
the controller function name (pdf_view) in this case.

I would like to make the filename take a value from the database. Customer 
name or Business name for example. 

I have tried adding a name in the output() but it doesn't help:
response.headers['Content-Type'] = 'application/pdf'
return pdf.output(name=bname, dest='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: Changing Bootstrap Navbar to light background colour

2017-02-07 Thread Paul Ellis
In my version of web2py the layout.html has this:


However, it is definitely black. If I change it to navbar-inverse I get a 
green navbar.

By using the above css. I am able to get a light navbar.

Thanks


On Thursday, 3 December 2015 11:32:48 UTC+1, Leonel Câmara wrote:
>
> I don't mean in the css file, I mean in layout.html where you have
>
> 
>
>
>
> Just remove navbar-inverse.
>

-- 
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: How to add an input field in SQLFORM.grid??

2016-11-28 Thread Paul Ellis
What about if I don't use 'callback' but 'href' so it loads the whole page. 
I still can't get the quantity value to be passed as an arg.

On Saturday, 26 November 2016 14:35:33 UTC+1, Anthony wrote:
>
> On Friday, November 25, 2016 at 11:11:41 PM UTC-5, Paul Ellis wrote:
>>
>> Hi,
>> I am trying to do the same thing as the OP. Add a quantity input field to 
>> a grid and then use Callback to work with the product_id and quantity. I 
>> just don't seem to be able to pass the quantity to the callback function.
>>
>> Using this method I don't get a value from quantity.
>> links=[
>> lambda row: INPUT(_type='number', _value=0, 
>> _name='qty'),
>> lambda row: A(T('Add'),
>>   
>> callback=URL('_add_product',args=[row.id, request.vars.qty]),
>>
>
> Obviously request.vars.qty won't work here, as request.vars is not 
> populated until after the request arrives at the server. Instead, you would 
> have to use Javascript to update the callback URL whenever the value of the 
> input changes.
>
> 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.


Re: [web2py] Re: How to add an input field in SQLFORM.grid??

2016-11-25 Thread Paul Ellis
Hi,
I am trying to do the same thing as the OP. Add a quantity input field to a 
grid and then use Callback to work with the product_id and quantity. I just 
don't seem to be able to pass the quantity to the callback function.

Using this method I don't get a value from quantity.
links=[
lambda row: INPUT(_type='number', _value=0, 
_name='qty'),
lambda row: A(T('Add'),
  
callback=URL('_add_product',args=[row.id, request.vars.qty]),
  _class='button btn btn-default')
]
)

If I use args or vars doesn't matter. The point is I always get 'None' for 
the Quantity field.
I have tried wrapping the grid in a form and the input in a form. I am sure 
I am doing something simple wrong.

Here's the whole function:
@auth.requires_login()
def product_add():
productid = request.args(0)
grid = SQLFORM.grid(db.product.id == productid,
args=[productid],
create=False,
editable=False,
deletable=False,
fields=[db.product.productname,
db.product.purchasecost,
db.product.monthlycost,
db.product.smallimage],
links=[
lambda row: FORM(INPUT(_type='number', 
_value=0, _name='qty')),
lambda row: A(T('Add'),
  callback=URL('_add_product', 
vars=dict(productid=productid, qt=request.vars.qty)),
  _class='button btn btn-default')
]
)

return locals()



On Friday, 13 April 2012 21:26:56 UTC+2, greenpoise wrote:
>
> Richard,
>
> I tried Massimos approach but it created one form button rather than one 
> for each row. For my uses, it wont cut it. I need one text field plus a 
> button on each row. I was able to accomplish this like this
>
> links = [lambda row: INPUT(_name='qty', _value='1'), lambda row: A('+',
> callback=URL('cart_callback',vars=dict(id=row.id,action='add',qt=request.
> vars.qty)))]
>
> Maybe I did not make myself clear but I just want to have a product grid 
> with all the products and the qty. Sort of a storefront, so the input text 
> is not db attached. Click on the button and add it to my cart.. Hmmm but it 
> seems you want to have like a bulk functionality with the grid, right???
>
>
>
>
>
>
> On Thursday, 12 April 2012 14:27:53 UTC-7, Richard wrote:
>>
>> Hello Danel,
>>
>> May I see screenshot of what Massimo propose?
>>
>> I mean I would be really interrested in a bulk entry capability too.
>>
>> If it is already available I would know I was about to make a custom 
>> mechanism to allow user to add many result at the same time that would rely 
>> on Excel and validate_and_insert web2py method...
>>
>> The problem I had was to read directly Excel file, I would need to write 
>> a lot of code with xlrd. If I can avoid that I will be happy :)
>>
>> Thanks.
>>
>> Richard
>>
>> On Thu, Apr 12, 2012 at 5:14 PM, greenpoise > > wrote:
>>
>>> Massimo,
>>>
>>> where do I change the INPUT size (length, width)?
>>>
>>>
>>>
>>> links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)]
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote:

 yes and not and what I said needs clarification.

 grid = SQLFORM.grid(create=False,update=False) is not a form. If 
 create=True or update=True then it contains a form when you are creating 
 or 
 updating a record. you must avoind a form within a form and you can do so 
 in the view:

 {{if grid.create_form or grid.update_form:}}
 {{=grid}} it is a form
 {{else:}}
 {{=grid}} it is not a form but you can embed it in one >>> type='submit'/>
 {{pass}}


 On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote:
>
> A bit confused..I thought SQLFORM.grid was itself a form? Also, can I 
> add more than one link per grid? Reading from the book, it creates a 
> column 
> so technically sounds as if I could???
>
> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote:
>>
>> You can put the grid in a form and you add 
>>
>> SQLFORM.grid(..., link=[lambda row: INTPUT(...)])
>>
>> On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote:
>>>
>>> Is this possible?? I have a products table that shows all the 
>>> products. I also created an add to cart button in it problem is if I 
>>> want 
>>> to add 100 items I would have to press the button 100 times.  Is there 
>>> a 
>>> way to add a quantity text field???
>>>
>>>

[web2py] Experts4Solutions down?

2016-10-11 Thread Paul Flaherty
Hi All,

First post to this list. Thanks to all the developers and contributors for 
the tremendous work!

It appears that Experts4Solutions is down, and an email I sent sometime 
back to cont...@experts4solutions.com went unanswered. Is this still an 
active domain/organization for web2py consulting?

Best regards,
Paul Flaherty

-- 
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: set difference using db

2016-03-10 Thread Paul
works!

Thanks Jim!

On Thursday, March 10, 2016 at 9:55:33 AM UTC-5, Jim S wrote:
>
> Maybe something like this?  (not tested)
>
> already_owns = db(db.owns.person == person_id)._select(db.owns.thing)
>
> things_not_owned = db(~db.thing.id.belongs(already_owns)).select()
>
>
> -Jim
>
> On Thursday, March 10, 2016 at 8:49:32 AM UTC-6, Paul wrote:
>>
>> Does anyone know if there is a way to perform set difference (ie the 
>> elements in set A that are not in set B) using database queries / DAL?
>>
>> for example if you had some tables defined like this:
>>
>> db.define_table('thing',
>>Field('name'))
>>
>> db.define_table('owns',
>>Field('person', 'reference auth_user'),
>>Field('thing', 'reference thing'))
>>
>>
>> and you want to find a list of all the things that person X doesn't yet 
>> own.
>>
>> The "easy" way would be to query for a set of all the "thing"s and then 
>> do a separate query for all the "thing"s owned by person X, create python 
>> set objects and use the set difference operator. 
>>
>>
>> I'm wondering if there is a way to do this as a single db query? 
>>
>> Thanks!
>>
>> Paul
>>
>>

-- 
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] set difference using db

2016-03-10 Thread Paul Green
Does anyone know if there is a way to perform set difference (ie the
elements in set A that are not in set B) using database queries / DAL?

for example if you had some tables defined like this:

db.define_table('thing',
   Field('name'))

db.define_table('owns',
   Field('person', 'reference auth_user'),
   Field('thing', 'reference thing'))


and you want to find a list of all the things that person X doesn't yet own.

The "easy" way would be to query for a set of all the "thing"s and then do
a separate query for all the "thing"s owned by person X, create python set
objects and use the set difference operator.


I'm wondering if there is a way to do this as a single db query?

Thanks!

Paul

-- 
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: Create a service running continuously

2016-03-06 Thread Paul Gerrard
Hi thanks for the suggestions. Sorry for not responding sooner. I figured a
way of working and been working abroad for a few days...) so I haven't
tried your suggestions.

What worked for me was I wrote a service that returned the contents of a
table that define the bot commands and called it using requests in Python.
The response contains the data as json. Then I connect to my Slack room and
listen for commands that invoke my bot. the bot responds according to the
commands received and looked-up responses read from the DB.

I suspect using the DAL directly could have achieved the same goal and also
retain the DB connection to store stuff too if required - but right now I
don't need to do that.

Happy to share my code if you have a similar need to drive a Slack bot.



On 2 March 2016 at 20:42, Ian Ryder  wrote:

> Sounds like you just need some sort of never ending loop (obviously you
> can put checks in the loop for stop requests and whatever other complexity
> you like / need).
>
> You can pass arguments on the python command line. So for example you
> could do something like:
>
> python web2py.py -S your_app -M -A 1 run_my_loop
>
> In the example, 1 is the user record to use and then:
>
> if sys.argv[2] == 'run_my_loop':
> this_user = db_auth.auth_user[sys.argv[1]]
>
>
> if not this_user:
> raise Exception('...')
> auth.login_bare(this_user.email, this_user.password)
> run_my_loop()
>
>
>
> On Monday, 29 February 2016 10:36:23 UTC+1, Paul Gerrard wrote:
>>
>> I have written some Python code to act as a chatbot working with Slack.
>> All looks good so far. I could add it as a service to /etc/init.d etc and
>> make it work at startup. However...
>>
>> I want to enhance the service to access my MySQL database using the
>> Web2py DAL. Now, I created a webservice to do this - but of course when run
>> the Apache server eventually times out and I get a 500 error. Is there a
>> simple way of creating a permanently running service that can access
>> models, the DAL etc?
>>
>> Now, in the web2py directory, I guess I could run:
>>
>> python -M -S myapp/controller/function
>>
>> But I need to add credentials to the command too? How do I do this?
>>
>> Assuming there's a way to provide credentials through the shell, would a
>> permanently running service created this way cause any other issues?
>>
>> thanks, Paul.
>>
> --
> 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/XEbLuixLJUY/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] Create a service running continuously

2016-02-29 Thread Paul Gerrard
I have written some Python code to act as a chatbot working with Slack. All 
looks good so far. I could add it as a service to /etc/init.d etc and make 
it work at startup. However...

I want to enhance the service to access my MySQL database using the Web2py 
DAL. Now, I created a webservice to do this - but of course when run the 
Apache server eventually times out and I get a 500 error. Is there a simple 
way of creating a permanently running service that can access models, the 
DAL etc?

Now, in the web2py directory, I guess I could run:

python -M -S myapp/controller/function

But I need to add credentials to the command too? How do I do this?

Assuming there's a way to provide credentials through the shell, would a 
permanently running service created this way cause any other issues?

thanks, Paul.

-- 
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: Simple left sidebar example

2016-01-05 Thread Paul McDonald


On Tuesday, January 5, 2016 at 5:03:19 PM UTC-5, Paul McDonald wrote:
>
> Can anyone post a simple example of a View with a left sidebar?
> I must be missing something.  It looks so simple in the manual "5.7 Blocks 
> in views".
> Thank you in advance.  Paul
>



Stifan,
Thank you for your help.
The problem seems to be that I used the Wizzard to generate a new 
application, and that Layout.html is different from the Welcome Layout.html.
The Wizzard Layout.html does not handle sidebars  properly.
There seems to be a error in this code:

# using sidebars need to know what sidebar you want to use
mc0 = 'col-md-12'
mc1 = 'col-md-9'
mc2 = 'col-md-6'
left_sidebar_enabled = globals().get('left_sidebar_enabled', False)
right_sidebar_enabled = globals().get('right_sidebar_enabled', False)
middle_column = {0: mc0, 1: mc1, 2: mc2}[
(left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)]
}}
 

-- 
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] Simple left sidebar example

2016-01-05 Thread Paul McDonald
Can anyone post a simple example of a View with a left sidebar?
I must be missing something.  It looks so simple in the manual "5.7 Blocks 
in views".
Thank you in advance.  Paul

-- 
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: Q: Efficiently searching by tag / field widths

2015-05-28 Thread Paul Coy
Thanks for the reply. I can't find anything that looks like your reply so I 
think I'm going to try Example 29 from the Web2py site instead. It looks 
very similar to what I'm trying to accomplish.

On Thursday, May 28, 2015 at 1:16:53 AM UTC-4, Paul Coy wrote:
>
> In the Web2Py Cookbook, Ch3 there is a section called "Efficiently 
> searching by tag" which works quite well, thanks. I've been playing with it 
> and when I enter more than 16 characters to the data.value the data shows 
> up as 15 characters followed by "...". this happens with the results "rows" 
> also. How do I expand the size of the field or fields to show the whole 
> data string". The view seems quite simple but it's just not obvious to me 
> where to adjust field sizes. If someone could point me in the right 
> direction that 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] Q: Efficiently searching by tag / field widths

2015-05-27 Thread Paul Coy
In the Web2Py Cookbook, Ch3 there is a section called "Efficiently 
searching by tag" which works quite well, thanks. I've been playing with it 
and when I enter more than 16 characters to the data.value the data shows 
up as 15 characters followed by "...". this happens with the results "rows" 
also. How do I expand the size of the field or fields to show the whole 
data string". The view seems quite simple but it's just not obvious to me 
where to adjust field sizes. If someone could point me in the right 
direction that 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.


Re: [web2py] Re: Crud is deprecated?

2015-04-12 Thread Paul
There is a bug in crud search which i pointed out in this issue (and 
highlighted a fix for it)

https://github.com/web2py/web2py/issues/844



On Saturday, 11 April 2015 05:19:20 UTC+1, Massimo Di Pierro wrote:
>
> We never officially said it but we have not touched the crud code in more 
> than 2 years. No bugs have reported but we have no intention of adding 
> functionality since better functionality if available in SQLFORM now.
>
> On Friday, 10 April 2015 19:34:04 UTC-5, Anthony wrote:
>>
>>
>> * The buglist isn't going to get shorter [2]
>>>
>>
>> While the primary developers may or may not bother to fix a given bug, I 
>> doubt a pull request with a fix would be rejected.
>>
>> Actually, I'm not sure we can really even say Crud has officially been 
>> deprecated. There is no mention of that in the documentation, and I don't 
>> think I have seen any formal announcement on the list (there have been some 
>> discussions, but no definitive decisions). Of course, the code hasn't been 
>> touched much in the past couple years, but neither has Service, T, or 
>> templates, and we obviously don't consider those to be deprecated. If we 
>> want to officially deprecate Crud, we should make that clear in the 
>> documentation.
>>
>> 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] Am I correct that the | operator has multiple meanings

2015-04-07 Thread Paul McDonald
For queries the | means  or:
>>> rows = db((db.person.name=='Alex') | (db.person.id>3)).select()
 ↖  here it is 
an or

You can sort the records according to multiple fields by concatenating them 
with a "|":
>>> for row in db().select(
db.person.ALL, orderby=db.person.name|db.person.id):
↖   
here it| concatinates multiple fields  

-- 
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 with two python operators

2015-03-28 Thread Paul McDonald
 


 In the web2py Application Development Cookbook:


 
 page 69 the | operator


 alphabetical = User.first_name|User.last_name *← | what is this doing??*


 
 
 page 82 the &= operator


 if not form:

# search flatpage according to the current request

query = db.flatpage.c==request.controller

query &= db.flatpage.f==request.function *← &= what is this doing??*

if request.args:

query &= db.flatpage.args==request.args(0)

else:

query &= (db.flatpage.args==None)|(db.flatpage.args=='')

query &= db.flatpage.lang==lang


 

-- 
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 with two Python operators

2015-03-28 Thread Paul McDonald
In the Web2py Application Development Cookbook:
 
 p82the  &=  operators


 if not form:

# search flatpage according to the current request

query = db.flatpage.c==request.controller

query &= db.flatpage.f==request.function *<-  what is going on 
here?*

if request.args:

query &= db.flatpage.args==request.args(0)

else:

query &= (db.flatpage.args==None)|(db.flatpage.args=='')

query &= db.flatpage.lang==lang


 Alos, p69the   |   bianary or operator

alphabetical = User.first_name|User.last_name   * <--  what is 
going on here?   *
  

  Can anyone explain what these are doing?
Thank you in advance


Paul
  

-- 
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] Automatically displaying email field as mailto anchor tag in views.

2015-01-22 Thread Paul

I am a web2py newbie though I've used Python for years. I need a CRMy kind 
of application so I latched onto this 
https://github.com/mdipierro/web2py-appliances/tree/master/CustomerRelationshipManagement
 
and am trying to tweak it for my specific needs. It would probably be 
better to cut my teeth on something simpler, but oh well, there you have it.

My newbie question: I added an email field to the person table. Every time 
I view this datum I want this field, without exception, to be displayed as 
a mailto anchor tag. Where in the MVC paradigm is the best place to define 
this parameter?

To elaborate a bit in the following view it's the crud.read that 
automatically handles all the data iterations and display, yes? As a 
workaround I know I could go with something like a for or while block and 
walk through the data. I'd rather that the crud.read knows that it needs to 
display the email field as a mailto anchor tag. That way my views will stay 
synced with future data model changes which is one of the benefits of 
web2py.

{{extend 'layout.html'}}
{{=person.name}}
{{=person.role}} at {{=link_company(person.company)}}

{{=button('edit','edit_person',person.id)}}
{{=button('logs','list_logs',person.id)}}
{{=button('docs','list_docs',person.id)}}
{{=button('tasks','list_tasks',person.id)}}

{{=crud.read(db.person,person)}}

{{=tag('person',person.id)}}

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


[web2py] Re: Beginner issues

2014-09-14 Thread Jean-Paul McCoy
I am not an expert but it seems that you need a two stage validation, for 
which I would use AJAX form submission. 

On Thursday, September 11, 2014 5:22:04 AM UTC-7, Pedro Henrique Correa 
Ferreira wrote:
>
> Hey, lads!
>
> How you're doing?
>
> I've got a issue with data validation. I gotta use a validator that 
> depends on a previous field from the same table, for example:
>
> db.define_table( 
>'driver',
>Field('your_age'),
>Field('years_as_driver'), #requires IS_INT_IN_RANGE (0,(your_age-18)
>Field('years_with_current_car'), #requires IS_INT_IN_RANGE (0, 
> (years_as_driver +1)
>
> How is the correct way to do 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] Live preview, with COLT + Sublime Text, server config?

2014-09-04 Thread Jean-Paul McCoy
How can I use CodeOrchestraRPCHttpServer with Web2py? COLT live preview is 
all html and Java so it must be doable. The COLT server opens one port for 
itself then a second for the live coding session. Should I attempt to hack 
the COLT side to proxy through Rocket, or can I just get Web2py to 
recognize COLT?

-- 
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] Is it ok (i.e. safe !?) to extend the crud class

2014-02-18 Thread Paul
Hi,

The html form created by crud.search is great, but for some fields I wanted 
the right hand 'text' input field to be a autocomplete style field so users 
can see all the distinct values for a field that they can then pick.

I've extended crud search in a class, this files is in in the applications 
modules folder,  i had to import from gluon.tools import Crud , from gluon 
import * to get past errors with current.request 

Before I spend more time working on this just wanted to check this is safe 
to do!

Thanks

Paul

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


[web2py] Re: DAL select help

2013-07-23 Thread Paul
try:

Field('name','list:string')

then select:

db.table.name.contains('string')

On Tuesday, 23 July 2013 09:37:00 UTC+8, Trevor Overman wrote:
>
> In my database, I have a list of items stored. What I am trying to do is 
> select a database row when the list in the database contains the item that 
> I am iterating through in the controller. Do anyone know how this could be 
> done ? 
>
> model
>
> db.define_table('table',
>
> Field('field_list','string')
>
> )
>
> controller
>
> for item in items:
>
> #db select here
>
>
> Thanks !
>
> -Trevor
>

-- 

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




[web2py] Re: How to conditionally add a _class="warning" to a using the TR() helper ?

2013-03-31 Thread Paul
Thanks Anthony, just what I needed ! (.add_class method is not in the 
manual)

On Sunday, 31 March 2013 14:21:57 UTC+1, Anthony wrote:
>
> Actually, here's an easier method:
>
> tr = TR(...).add_class('warning' if row.field1 == None else '')
>
> So, no need for the separate "if" statement. The .add_class() method has 
> the extra benefit of working even if there is already an existing class and 
> you want to add an additional one.
>
> Anthony
>
> On Sunday, March 31, 2013 9:16:32 AM UTC-4, Anthony wrote:
>>
>> Depends on what your code looks like, but in general you can add a class 
>> (or other attributes) to an existing helper object as follows:
>>
>> tr = TR(...)
>> if row.field1 == None:
>> tr['_class'] = 'warning'
>>
>> Anthony
>>
>> On Sunday, March 31, 2013 8:50:42 AM UTC-4, Paul wrote:
>>>
>>> Hi, its been a while since I've used web2py, I'm sure this is easy but 
>>> cannot find it in the manual:-
>>>
>>> In a view I'm generating html using the helper TR() while looping over 
>>> rows from a sqlite table, I just want to add a class="warning" to some rows 
>>> based on the value in a database field  (e.g. if row.field1 == None then 
>>> add class="warning" to this TR row, else don't add any css class to this 
>>> row), so I can highlight just some of the rows with missing data.
>>>
>>> Thanks
>>>
>>>  
>>>
>>

-- 

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




[web2py] How to conditionally add a _class="warning" to a using the TR() helper ?

2013-03-31 Thread Paul
Hi, its been a while since I've used web2py, I'm sure this is easy but 
cannot find it in the manual:-

In a view I'm generating html using the helper TR() while looping over rows 
from a sqlite table, I just want to add a class="warning" to some rows 
based on the value in a database field  (e.g. if row.field1 == None then 
add class="warning" to this TR row, else don't add any css class to this 
row), so I can highlight just some of the rows with missing data.

Thanks

 

-- 

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




[web2py] Re: Example JSON Code

2013-02-28 Thread Paul Lozancich
Figured out error.  Co-worker showed me I had the Python file in the wrong 
directory.  I need to study Web2py and get a better undertstanding of it. 
 Thanks for all the help!

On Thursday, February 14, 2013 2:17:21 AM UTC-8, Alan Etkin wrote:
>
> How do you put that before the $.jsonp({ call?
>>
>
> {{=SCRIPT(...)}}
> 
>
> You can also do string interpolation with one SCRIPT call
>
> SCRIPT("""
> ... url: "%(url)s",
> """ % dict(url=URL(...)))
>
>

-- 

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




Re: [web2py] Re: How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Thanks,

This did not only clear up this particular problem for me but seeing the
format in the IS_IN_DB constructor showed me why I was losing the default
table represents when adding constraints elsewhere so that is now sorted
too.

Thanks again.

We expect to exceed ten thousand dockets. What will happen regarding the
dropdown representation for columns referencing the dockets id as the
number grows? Will I need to introduce a custom solution for this?

On 19 February 2013 03:37, Massimo Di Pierro wrote:

> The only problem is that for self referendes you do not get an automatic
> represent and validator (because the field is created before the table
> referenced is created):
>
> You can do it manually:
>
> db.define_table('Docket',
> Field('Docket_No', 'integer',
> required = True),
> Field('Reference_Docket_ID', 'reference Docket',
> required = False),
> Field('Reference_Docket_No', 'integer',
> required = False),
> ...
>
> db.Docket.Reference_Docket_ID.requires=IS_IN_DB(db,'Docket.
> Reference_Docket_ID','%(Docket_No)s'))
> db.Docket.Reference_Docket_ID.represent=lambda value,row: value
>
>
> On Monday, 18 February 2013 02:19:04 UTC-6, Paul Whipp wrote:
>>
>> Here is an example of what I need to do:
>>
>> db.define_table('Docket',
>> Field('Docket_No', 'integer',
>> required = True),
>> Field('Reference_Docket_ID', 'reference Docket',
>> required = False),
>> Field('Reference_Docket_No', 'integer',
>> required = False),
>> ...
>>
>> The docket optionally refers to a preceding docket in the model. It
>> appears that web2py's DAL ignores the required = False specification for
>> this field because when I use the SQLFORM it tells me that 'Reference
>> Docket_ID' is a required field so its impossible to enter any docket
>> records.
>>
>> The client database is postgresSQL
>>
>> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
>> IS_NULL_OR(IS_IN_DB(...)))
>> but then it fails to display the dropdown when the form is presented.
>>
>> With hundreds of tables, I don't want to have to craft the form by hand.
>>
>> I'm also wondering what happens when there are many thousands of dockets
>> - will the dropdown for the Reference_Docket_ID on the form cope
>> effectively?
>>
>> Cheers,
>> Paul
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] Re: How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Yes it can - the table I'm trying to create is perfectly valid and sensible
(and it works fine if implemented directly in postgres or mysql). I'm just
having trouble representing it effectively with the DAL.

On 18 February 2013 18:54, pbreit  wrote:

> Can a reference be optional?
>
>
> On Monday, February 18, 2013 12:19:04 AM UTC-8, Paul Whipp wrote:
>>
>> Here is an example of what I need to do:
>>
>> db.define_table('Docket',
>> Field('Docket_No', 'integer',
>> required = True),
>> Field('Reference_Docket_ID', 'reference Docket',
>> required = False),
>> Field('Reference_Docket_No', 'integer',
>> required = False),
>> ...
>>
>> The docket optionally refers to a preceding docket in the model. It
>> appears that web2py's DAL ignores the required = False specification for
>> this field because when I use the SQLFORM it tells me that 'Reference
>> Docket_ID' is a required field so its impossible to enter any docket
>> records.
>>
>> The client database is postgresSQL
>>
>> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
>> IS_NULL_OR(IS_IN_DB(...)))
>> but then it fails to display the dropdown when the form is presented.
>>
>> With hundreds of tables, I don't want to have to craft the form by hand.
>>
>> I'm also wondering what happens when there are many thousands of dockets
>> - will the dropdown for the Reference_Docket_ID on the form cope
>> effectively?
>>
>> Cheers,
>> Paul
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Here is an example of what I need to do:

db.define_table('Docket',
Field('Docket_No', 'integer',
required = True),
Field('Reference_Docket_ID', 'reference Docket',
required = False),
Field('Reference_Docket_No', 'integer',
required = False),
...

The docket optionally refers to a preceding docket in the model. It appears 
that web2py's DAL ignores the required = False specification for this field 
because when I use the SQLFORM it tells me that 'Reference Docket_ID' is a 
required field so its impossible to enter any docket records.

The client database is postgresSQL

I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
IS_NULL_OR(IS_IN_DB(...))) 
but then it fails to display the dropdown when the form is presented.

With hundreds of tables, I don't want to have to craft the form by hand.

I'm also wondering what happens when there are many thousands of dockets - 
will the dropdown for the Reference_Docket_ID on the form cope effectively?

Cheers,
Paul

-- 

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




Re: [web2py] Re: What is the right way to specialize an application?

2013-01-30 Thread Paul Whipp
For me, magic is anything that supplies context or functionality that is
not visible in the usual python manner. For example where the default.py
controller file looks like normal python and mostly behaves that way but
has a whole lot of magic going on in terms of variables it can access.

On 30 January 2013 16:25, Anthony  wrote:

> And how do you define "magic" in this case?
>
>
> On Wednesday, January 30, 2013 12:38:25 AM UTC-5, Paul Whipp wrote:
>
>> A very fair question.
>>
>> I'd like to define a class that inherits from the controller class set up
>> in the magic stuff. In that class I'd define the replacement edit method.
>> I'd then have some code indicating that the files for the specialised app
>> are to be searched for in the source app folders and indicating that my
>> controller class is to be used in place of the usual magic controller.
>>
>>
>> On 30 January 2013 15:30, Anthony  wrote:
>>
>>> What sort of solution do you envision?
>>>
>>>
>>> On Tuesday, January 29, 2013 11:02:36 PM UTC-5, Paul Whipp wrote:
>>>
>>>> Thanks for that.
>>>>
>>>> If I use a plug in I can replace the default.py controller file in
>>>> admin in its entirety, if my reading of that section is correct, a plugin
>>>> solution still involves a lot of repetition (although at least we're down
>>>> to one file) and a hole in future update behaviour.
>>>>
>>>> On 30 January 2013 13:42, Anthony  wrote:
>>>>
>>>>>  Maybe look into plugins: http://web2py.com/**boo**
>>>>> ks/default/chapter/29/12#**Plugi**ns<http://web2py.com/books/default/chapter/29/12#Plugins>
>>>>>
>>>>>
>>>>> On Tuesday, January 29, 2013 6:39:44 PM UTC-5, Paul Whipp wrote:
>>>>>>
>>>>>> I'm new to web2py but not to Python or web application frameworks.
>>>>>>
>>>>>> I love the dry pythonic nature of web2py. I'm less enamoured by its
>>>>>> use of magic but the convenient REP makes this mostly forgivable. I'm
>>>>>> giving web2py a go on a couple of real projects.
>>>>>>
>>>>>> As I use emacs, it looks like it would be straightforward to modify
>>>>>> the admin app to pass a file to an emacs service (if available) for
>>>>>> editing. Its also easy to copy the admin application, call it myadmin and
>>>>>> make the change there. These are both bad things to do because; in the
>>>>>> first case an upgrade will overwrite my change (yes I use source control
>>>>>> but its still going to be a pain), and in the second case I've copied a
>>>>>> large slice of code and lost the benefit of upgrades in myadmin which 
>>>>>> could
>>>>>> lead to all sorts of problems in the long term.
>>>>>>
>>>>>> What I want to do is specialize the admin app such that I just use my
>>>>>> specialised default controller with its single specialized edit method 
>>>>>> (the
>>>>>> latter specialisation is a little tricky because the method is a bit
>>>>>> monolithic but you can see what I'm aiming at).
>>>>>>
>>>>>> The result would be a specialization of the admin app called myadmin
>>>>>> containing virtually nothing but the specialized default controller and
>>>>>> edit method. I cannot see any obvious way to do this. Am I going to have 
>>>>>> to
>>>>>> make like a PHP programmer and copy the whole application to make one 
>>>>>> small
>>>>>> change or is there some cool way to unravel the magic a bit and point the
>>>>>> myadmin file lookups to admin, except for my controllers/default.py?
>>>>>>
>>>>>> For the time being I'll stick with navigating the file structure and
>>>>>> invoking emacs directly, so my question is more of a "How would I". I've
>>>>>> tried google to no avail and I'll be happy for an RTFM response if you 
>>>>>> can
>>>>>> point me at the FM (or an example) that covers this.
>>>>>>
>>>>>> Cheers,
>>>>>> Paul
>>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are

Re: [web2py] Re: What is the right way to specialize an application?

2013-01-29 Thread Paul Whipp
A very fair question.

I'd like to define a class that inherits from the controller class set up
in the magic stuff. In that class I'd define the replacement edit method.
I'd then have some code indicating that the files for the specialised app
are to be searched for in the source app folders and indicating that my
controller class is to be used in place of the usual magic controller.


On 30 January 2013 15:30, Anthony  wrote:

> What sort of solution do you envision?
>
>
> On Tuesday, January 29, 2013 11:02:36 PM UTC-5, Paul Whipp wrote:
>
>> Thanks for that.
>>
>> If I use a plug in I can replace the default.py controller file in admin
>> in its entirety, if my reading of that section is correct, a plugin
>> solution still involves a lot of repetition (although at least we're down
>> to one file) and a hole in future update behaviour.
>>
>> On 30 January 2013 13:42, Anthony  wrote:
>>
>>> Maybe look into plugins: http://web2py.com/**
>>> books/default/chapter/29/12#**Plugins<http://web2py.com/books/default/chapter/29/12#Plugins>
>>>
>>>
>>> On Tuesday, January 29, 2013 6:39:44 PM UTC-5, Paul Whipp wrote:
>>>>
>>>> I'm new to web2py but not to Python or web application frameworks.
>>>>
>>>> I love the dry pythonic nature of web2py. I'm less enamoured by its use
>>>> of magic but the convenient REP makes this mostly forgivable. I'm giving
>>>> web2py a go on a couple of real projects.
>>>>
>>>> As I use emacs, it looks like it would be straightforward to modify the
>>>> admin app to pass a file to an emacs service (if available) for editing.
>>>> Its also easy to copy the admin application, call it myadmin and make the
>>>> change there. These are both bad things to do because; in the first case an
>>>> upgrade will overwrite my change (yes I use source control but its still
>>>> going to be a pain), and in the second case I've copied a large slice of
>>>> code and lost the benefit of upgrades in myadmin which could lead to all
>>>> sorts of problems in the long term.
>>>>
>>>> What I want to do is specialize the admin app such that I just use my
>>>> specialised default controller with its single specialized edit method (the
>>>> latter specialisation is a little tricky because the method is a bit
>>>> monolithic but you can see what I'm aiming at).
>>>>
>>>> The result would be a specialization of the admin app called myadmin
>>>> containing virtually nothing but the specialized default controller and
>>>> edit method. I cannot see any obvious way to do this. Am I going to have to
>>>> make like a PHP programmer and copy the whole application to make one small
>>>> change or is there some cool way to unravel the magic a bit and point the
>>>> myadmin file lookups to admin, except for my controllers/default.py?
>>>>
>>>> For the time being I'll stick with navigating the file structure and
>>>> invoking emacs directly, so my question is more of a "How would I". I've
>>>> tried google to no avail and I'll be happy for an RTFM response if you can
>>>> point me at the FM (or an example) that covers this.
>>>>
>>>> Cheers,
>>>> Paul
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] Is auth.requires_signature() worth using?

2013-01-29 Thread Paul Whipp
I'm trying to get a quick crud interface up for a large number of tables.
The default controller data method is decorated with
auth.requires_signature() which I don't understand. I could not get past
'not authorized' with it.

I changed it to auth.requires_login() and added a 'create', 'read',
'update', 'select' and 'delete' method for every table I wanted access to.

dbadmin_group_id = db(db.auth_group.role ==
'dbadmin').select().first().idfor table_name in db.tables():
for crud_name in ['create', 'read', 'update', 'delete', 'select']:
db.auth_permission.update_or_insert(group_id = dbadmin_group_id,
name = crud_name,
table_name = table_name)

It now works if I use the auth.requires_login() decorator but it still
fails if I use the auth.requires_signature() decorator.

What do I have to do to get the auth.requires_signature() decorator to work
and should I care?

-- 

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




Re: [web2py] Re: What is the right way to specialize an application?

2013-01-29 Thread Paul Whipp
Thanks for that.

If I use a plug in I can replace the default.py controller file in admin in
its entirety, if my reading of that section is correct, a plugin solution
still involves a lot of repetition (although at least we're down to one
file) and a hole in future update behaviour.

On 30 January 2013 13:42, Anthony  wrote:

> Maybe look into plugins:
> http://web2py.com/books/default/chapter/29/12#Plugins
>
>
> On Tuesday, January 29, 2013 6:39:44 PM UTC-5, Paul Whipp wrote:
>>
>> I'm new to web2py but not to Python or web application frameworks.
>>
>> I love the dry pythonic nature of web2py. I'm less enamoured by its use
>> of magic but the convenient REP makes this mostly forgivable. I'm giving
>> web2py a go on a couple of real projects.
>>
>> As I use emacs, it looks like it would be straightforward to modify the
>> admin app to pass a file to an emacs service (if available) for editing.
>> Its also easy to copy the admin application, call it myadmin and make the
>> change there. These are both bad things to do because; in the first case an
>> upgrade will overwrite my change (yes I use source control but its still
>> going to be a pain), and in the second case I've copied a large slice of
>> code and lost the benefit of upgrades in myadmin which could lead to all
>> sorts of problems in the long term.
>>
>> What I want to do is specialize the admin app such that I just use my
>> specialised default controller with its single specialized edit method (the
>> latter specialisation is a little tricky because the method is a bit
>> monolithic but you can see what I'm aiming at).
>>
>> The result would be a specialization of the admin app called myadmin
>> containing virtually nothing but the specialized default controller and
>> edit method. I cannot see any obvious way to do this. Am I going to have to
>> make like a PHP programmer and copy the whole application to make one small
>> change or is there some cool way to unravel the magic a bit and point the
>> myadmin file lookups to admin, except for my controllers/default.py?
>>
>> For the time being I'll stick with navigating the file structure and
>> invoking emacs directly, so my question is more of a "How would I". I've
>> tried google to no avail and I'll be happy for an RTFM response if you can
>> point me at the FM (or an example) that covers this.
>>
>> Cheers,
>> Paul
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




[web2py] What is the right way to specialize an application?

2013-01-29 Thread Paul Whipp
I'm new to web2py but not to Python or web application frameworks.

I love the dry pythonic nature of web2py. I'm less enamoured by its use of 
magic but the convenient REP makes this mostly forgivable. I'm giving 
web2py a go on a couple of real projects.

As I use emacs, it looks like it would be straightforward to modify the 
admin app to pass a file to an emacs service (if available) for editing. 
Its also easy to copy the admin application, call it myadmin and make the 
change there. These are both bad things to do because; in the first case an 
upgrade will overwrite my change (yes I use source control but its still 
going to be a pain), and in the second case I've copied a large slice of 
code and lost the benefit of upgrades in myadmin which could lead to all 
sorts of problems in the long term.

What I want to do is specialize the admin app such that I just use my 
specialised default controller with its single specialized edit method (the 
latter specialisation is a little tricky because the method is a bit 
monolithic but you can see what I'm aiming at).

The result would be a specialization of the admin app called myadmin 
containing virtually nothing but the specialized default controller and 
edit method. I cannot see any obvious way to do this. Am I going to have to 
make like a PHP programmer and copy the whole application to make one small 
change or is there some cool way to unravel the magic a bit and point the 
myadmin file lookups to admin, except for my controllers/default.py?

For the time being I'll stick with navigating the file structure and 
invoking emacs directly, so my question is more of a "How would I". I've 
tried google to no avail and I'll be happy for an RTFM response if you can 
point me at the FM (or an example) that covers this.

Cheers,
Paul

-- 

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




[web2py] Re: how to install plugin_wiki?

2013-01-29 Thread Paul Whipp
This is an old thread but there is still the same issue with the 
documentation which is very worrying. Is there a documentation update 
somewhere?

The link in the documentation 
(http://127.0.0.1:8000/myapp/plugin_wiki/index) implies that the plug in is 
added to your own app called myapp (contradicting the preceding paragraph) 
but http://127.0.0.1:8000/welcome/plugin_wiki/index does work and you can 
proceed from there (as long as you apply the plugin to the welcome 
scaffolding as suggested).

On Thursday, 21 October 2010 08:28:29 UTC+10, Timmie wrote:
>
> > Make a new app.
> > Open the app in design/admin.
> > Install the plug-in by scrolling down to the bottom of the admin page
> > to where it says install plug-in.
> Could you please add this to the book online?
> It's not descibed there.
>
>

-- 

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




Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-17 Thread Paul Rykiel
mine worked by copying to gluon/contrib/fpdf

and then in code:

from gluon.contrib.fpdf import PDFLabel



On Thu, Jan 17, 2013 at 10:42 AM, António Ramos wrote:

> I still cannot import it in web2py shell by just copying pdflabels.py to
> gluon/contrib/pypdf
>
> can someone post a stupid example app?
>
> Thank you
> António
>
> 2013/1/17 Paul Rykiel 
>
>> I just want to say a big Thank you!
>> this works perfectly!!
>> I am so happy!
>> Best Regards,
>>
>> On Thu, Jan 17, 2013 at 1:49 AM, Mariano Reingart wrote:
>>
>>> Sorry, the correct url for PDFLabels is currently:
>>>
>>> https://code.google.com/p/pyfpdf/source/browse/tools/pdflabels.py
>>>
>>> We did some cleanups and reorganization of the project folders
>>> structure to be more compatible with pep8, distutils, etc.
>>> For the next release, if you can confirm that PDFLabels is working
>>> with the new structure, it could be moved to fpdf folder (currently in
>>> tools) so it would be packaged with web2py.
>>>
>>> BTW, there has been some other enhancements and bugfixes to PyFPDF
>>> thanks to several contributors, if you find an issue, please grab a
>>> latest copy and take a look on the project site:
>>>
>>> https://code.google.com/p/pyfpdf/source/browse/
>>>
>>> (look for the download zip link)
>>>
>>> https://code.google.com/p/pyfpdf/issues/list
>>>
>>> ASAP we close a few more pending tickets, surely a new version of FPDF
>>> will be published.
>>>
>>> Best regards,
>>>
>>> Mariano Reingart
>>> http://www.sistemasagiles.com.ar
>>> http://reingart.blogspot.com
>>>
>>>
>>> On Thu, Jan 17, 2013 at 4:13 AM, José Luis Redrejo 
>>> wrote:
>>> > I've just checked pdflabel is not included in fpdf in web2py. I ignore
>>> > the reason because I uploaded it to pyfpdf 18 months ago. I thought
>>> > web2py automatically included pyfpdf updates. You can download it from
>>> > http://code.google.com/p/pyfpdf/source/browse/pdflabels.py and copy it
>>> > at gluon/contrib/fpdf directory so you can use:
>>> >
>>> > from gluon.contrib.fpdf.pdflabels import PDFLabel
>>> >
>>> > PDFLabel accepts "\n" , if you use cell, it doesn't understand "\n"
>>> >
>>> > Regards.
>>> >
>>> > 2013/1/16 Paul Rykiel :
>>> >> Hi Jose,
>>> >>
>>> >> I tried what you suggested, I was getting errors on the line
>>> >> from glon.contrib.pyfpdf.pdflabels import PDFLabel ... it does not
>>> seem to
>>> >> exist, and cannot find how to load this
>>> >>
>>> >> so, my other option seems to be to get all of the text inside of one
>>> cell,
>>> >> so I used your "more_text" from below, it works ('sort of") ... it
>>> lists all
>>> >> of the text inside the one cell, but
>>> >> the program is ignoring the "\n" page breaks, if I can get those to
>>> work, I
>>> >> am almost done
>>> >>
>>> >> then I have to figure out how to create the pages side by side, but I
>>> want
>>> >> to tackle one thing at a time.
>>> >>
>>> >> I am sure when I get to my next issue of printing the labels where
>>> there are
>>> >> 3 labels across and 10 down, maybe I will have to figure out
>>> >> how to use the PDFLabel, but for right now I just want to get this to
>>> work.
>>> >>
>>> >> thanks for all of your help!!
>>> >> Regards,
>>> >>
>>> >>
>>> >> On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote:
>>> >>>
>>> >>> Some time ago, we include PDFLabel too, so you can simplify your code
>>> >>> if you are using an avery-compatible format ( the sys stuff is only
>>> >>> needed if you're using a non-english language):
>>> >>>
>>> >>> def label_bikes():
>>> >>> from gluon.contrib.pyfpdf.pdflabels import PDFLabel
>>> >>> import sys
>>> >>> reload(sys)
>>> >>> sys.setdefaultencoding( "latin-1" )
>>> >>>
>>> >>> pdf = PDFLabel('Apli-01277')
>>> >>> 

Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-17 Thread Paul Rykiel
I just want to say a big Thank you!
this works perfectly!!
I am so happy!
Best Regards,

On Thu, Jan 17, 2013 at 1:49 AM, Mariano Reingart wrote:

> Sorry, the correct url for PDFLabels is currently:
>
> https://code.google.com/p/pyfpdf/source/browse/tools/pdflabels.py
>
> We did some cleanups and reorganization of the project folders
> structure to be more compatible with pep8, distutils, etc.
> For the next release, if you can confirm that PDFLabels is working
> with the new structure, it could be moved to fpdf folder (currently in
> tools) so it would be packaged with web2py.
>
> BTW, there has been some other enhancements and bugfixes to PyFPDF
> thanks to several contributors, if you find an issue, please grab a
> latest copy and take a look on the project site:
>
> https://code.google.com/p/pyfpdf/source/browse/
>
> (look for the download zip link)
>
> https://code.google.com/p/pyfpdf/issues/list
>
> ASAP we close a few more pending tickets, surely a new version of FPDF
> will be published.
>
> Best regards,
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
>
>
> On Thu, Jan 17, 2013 at 4:13 AM, José Luis Redrejo 
> wrote:
> > I've just checked pdflabel is not included in fpdf in web2py. I ignore
> > the reason because I uploaded it to pyfpdf 18 months ago. I thought
> > web2py automatically included pyfpdf updates. You can download it from
> > http://code.google.com/p/pyfpdf/source/browse/pdflabels.py and copy it
> > at gluon/contrib/fpdf directory so you can use:
> >
> > from gluon.contrib.fpdf.pdflabels import PDFLabel
> >
> > PDFLabel accepts "\n" , if you use cell, it doesn't understand "\n"
> >
> > Regards.
> >
> > 2013/1/16 Paul Rykiel :
> >> Hi Jose,
> >>
> >> I tried what you suggested, I was getting errors on the line
> >> from glon.contrib.pyfpdf.pdflabels import PDFLabel ... it does not seem
> to
> >> exist, and cannot find how to load this
> >>
> >> so, my other option seems to be to get all of the text inside of one
> cell,
> >> so I used your "more_text" from below, it works ('sort of") ... it
> lists all
> >> of the text inside the one cell, but
> >> the program is ignoring the "\n" page breaks, if I can get those to
> work, I
> >> am almost done
> >>
> >> then I have to figure out how to create the pages side by side, but I
> want
> >> to tackle one thing at a time.
> >>
> >> I am sure when I get to my next issue of printing the labels where
> there are
> >> 3 labels across and 10 down, maybe I will have to figure out
> >> how to use the PDFLabel, but for right now I just want to get this to
> work.
> >>
> >> thanks for all of your help!!
> >> Regards,
> >>
> >>
> >> On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote:
> >>>
> >>> Some time ago, we include PDFLabel too, so you can simplify your code
> >>> if you are using an avery-compatible format ( the sys stuff is only
> >>> needed if you're using a non-english language):
> >>>
> >>> def label_bikes():
> >>> from gluon.contrib.pyfpdf.pdflabels import PDFLabel
> >>> import sys
> >>> reload(sys)
> >>> sys.setdefaultencoding( "latin-1" )
> >>>
> >>> pdf = PDFLabel('Apli-01277')
> >>> pdf.add_page()
> >>> rows = db(db.bike.id.belongs(bikeIds)).select()
> >>> # Print labels
> >>> for row in rows:
> >>> idString = row.destination + str(row.id)
> >>> more_text = idString
> >>> more_text += "Make:  " + row.make + "\n" if row.make else ""
> >>> more_text += "Model:  " + row.model + "\n" if row.model else ""
> >>> more_text += "Size:  " + row.size + "\n" if row.size else ""
> >>> pdf.add_label(more_text)
> >>>
> >>> response.headers['Content-Type'] = 'application/pdf'
> >>> response.headers['Content-Disposition']='attachment.filename =
> >>> sample.pdf'
> >>> return pdf.output(dest='S')
> >>>
> >>>
> >>> Regards
> >>> José L.
> >>>
> >>> 2013/1/16 Paul Rykiel :
> >>

Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-17 Thread Paul Rykiel
Thank you so much Jose... you are so helpful.
I am going to try this. this is a requirement to launch this system I wrote 
with another programmer
there is more work to do, but this needs to work.
Thank you again!!
Regards,
On Thursday, January 17, 2013 1:13:21 AM UTC-6, José L. wrote:

> I've just checked pdflabel is not included in fpdf in web2py. I ignore 
> the reason because I uploaded it to pyfpdf 18 months ago. I thought 
> web2py automatically included pyfpdf updates. You can download it from 
> http://code.google.com/p/pyfpdf/source/browse/pdflabels.py and copy it 
> at gluon/contrib/fpdf directory so you can use: 
>
> from gluon.contrib.fpdf.pdflabels import PDFLabel 
>
> PDFLabel accepts "\n" , if you use cell, it doesn't understand "\n" 
>
> Regards. 
>
> 2013/1/16 Paul Rykiel >: 
> > Hi Jose, 
> > 
> > I tried what you suggested, I was getting errors on the line 
> > from glon.contrib.pyfpdf.pdflabels import PDFLabel ... it does not seem 
> to 
> > exist, and cannot find how to load this 
> > 
> > so, my other option seems to be to get all of the text inside of one 
> cell, 
> > so I used your "more_text" from below, it works ('sort of") ... it lists 
> all 
> > of the text inside the one cell, but 
> > the program is ignoring the "\n" page breaks, if I can get those to 
> work, I 
> > am almost done 
> > 
> > then I have to figure out how to create the pages side by side, but I 
> want 
> > to tackle one thing at a time. 
> > 
> > I am sure when I get to my next issue of printing the labels where there 
> are 
> > 3 labels across and 10 down, maybe I will have to figure out 
> > how to use the PDFLabel, but for right now I just want to get this to 
> work. 
> > 
> > thanks for all of your help!! 
> > Regards, 
> > 
> > 
> > On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote: 
> >> 
> >> Some time ago, we include PDFLabel too, so you can simplify your code 
> >> if you are using an avery-compatible format ( the sys stuff is only 
> >> needed if you're using a non-english language): 
> >> 
> >> def label_bikes(): 
> >> from gluon.contrib.pyfpdf.pdflabels import PDFLabel 
> >> import sys 
> >> reload(sys) 
> >> sys.setdefaultencoding( "latin-1" ) 
> >> 
> >> pdf = PDFLabel('Apli-01277') 
> >> pdf.add_page() 
> >> rows = db(db.bike.id.belongs(bikeIds)).select() 
> >> # Print labels 
> >> for row in rows: 
> >> idString = row.destination + str(row.id) 
> >> more_text = idString 
> >> more_text += "Make:  " + row.make + "\n" if row.make else "" 
> >> more_text += "Model:  " + row.model + "\n" if row.model else "" 
> >> more_text += "Size:  " + row.size + "\n" if row.size else "" 
> >> pdf.add_label(more_text) 
> >> 
> >> response.headers['Content-Type'] = 'application/pdf' 
> >> response.headers['Content-Disposition']='attachment.filename = 
> >> sample.pdf' 
> >> return pdf.output(dest='S') 
> >> 
> >> 
> >> Regards 
> >> José L. 
> >> 
> >> 2013/1/16 Paul Rykiel : 
> >> > Hi Mariano, 
> >> > thank you for the response. Let me look into the margin issue, maybe 
> you 
> >> > have given me enough to figure this out. 
> >> > thanks so much for the response. you know, Massimo was my professor 
> last 
> >> > term. 
> >> > 
> >> > On Wednesday, January 16, 2013 12:39:06 AM UTC-6, Mariano Reingart 
> >> > wrote: 
> >> >> 
> >> >> Hello Paul: 
> >> >> 
> >> >> Could you send a sample without actual data? 
> >> >> (without the db query, so it can be reproduced) 
> >> >> 
> >> >> fpdf.cell will jump to the next page if no more room available, 
> maybe 
> >> >> there is a sizing or rounding issue. 
> >> >> Also, you have to take a look at page margins. 
> >> >> 
> >> >> Best regards, 
> >> >> 
> >> >> Mariano Reingart 
> >> >> http://www.sistemasagiles.com.ar 
> >> >> http://reingart.blogspot.com 
> >> >> 
> >> >> 
> >> &

[web2py] Re: why is my "\n" not working

2013-01-16 Thread Paul Rykiel
I am printing the text in a cell in PDF
pdf.cell()
On Wednesday, January 16, 2013 9:57:45 PM UTC-6, Massimo Di Pierro wrote:

> Are you printing it or writing it into HTML? In html \n is not newline.
>
> On Wednesday, 16 January 2013 21:51:56 UTC-6, Paul Rykiel wrote:
>>
>> greetings,
>>  
>> I have a string that I have defined
>>  
>> string = "line 1" + "\n"
>> string += "line 2" + "\n"
>>  
>> shouldn't my string print as follows:
>>  
>> line 1
>> line 2
>>  
>> it does not
>> what do I seem to be doing incorrectly?
>>  
>>  
>>
>

-- 





[web2py] Anyone have experience printing labels Avery 5160

2013-01-16 Thread Paul Rykiel
I need to create a sheet of labels (Avery 5160) 
I am using FPDF cells
any assistance would be greatly appreciated.
 
Regards,

-- 





[web2py] why is my "\n" not working

2013-01-16 Thread Paul Rykiel
greetings,
 
I have a string that I have defined
 
string = "line 1" + "\n"
string += "line 2" + "\n"
 
shouldn't my string print as follows:
 
line 1
line 2
 
it does not
what do I seem to be doing incorrectly?
 
 

-- 





Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-16 Thread Paul Rykiel
Hi Jose,
 
I tried what you suggested, I was getting errors on the line
from glon.contrib.pyfpdf.pdflabels import PDFLabel ... it does not seem to 
exist, and cannot find how to load this
 
so, my other option seems to be to get all of the text inside of one cell, 
so I used your "more_text" from below, it works ('sort of") ... it lists 
all of the text inside the one cell, but
the program is ignoring the "\n" page breaks, if I can get those to work, I 
am almost done
 
then I have to figure out how to create the pages side by side, but I want 
to tackle one thing at a time. 
 
I am sure when I get to my next issue of printing the labels where there 
are 3 labels across and 10 down, maybe I will have to figure out
how to use the PDFLabel, but for right now I just want to get this to work.
 
thanks for all of your help!!
Regards, 
 

On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote:

> Some time ago, we include PDFLabel too, so you can simplify your code 
> if you are using an avery-compatible format ( the sys stuff is only 
> needed if you're using a non-english language): 
>
> def label_bikes(): 
> from gluon.contrib.pyfpdf.pdflabels import PDFLabel 
> import sys 
> reload(sys) 
> sys.setdefaultencoding( "latin-1" ) 
>
> pdf = PDFLabel('Apli-01277') 
> pdf.add_page() 
> rows = db(db.bike.id.belongs(bikeIds)).select() 
> # Print labels 
> for row in rows: 
> idString = row.destination + str(row.id) 
> more_text = idString 
> more_text += "Make:  " + row.make + "\n" if row.make else "" 
> more_text += "Model:  " + row.model + "\n" if row.model else "" 
> more_text += "Size:  " + row.size + "\n" if row.size else "" 
> pdf.add_label(more_text) 
>
> response.headers['Content-Type'] = 'application/pdf' 
> response.headers['Content-Disposition']='attachment.filename = 
> sample.pdf' 
> return pdf.output(dest='S') 
>
>
> Regards 
> José L. 
>
> 2013/1/16 Paul Rykiel >: 
> > Hi Mariano, 
> > thank you for the response. Let me look into the margin issue, maybe you 
> > have given me enough to figure this out. 
> > thanks so much for the response. you know, Massimo was my professor last 
> > term. 
> > 
> > On Wednesday, January 16, 2013 12:39:06 AM UTC-6, Mariano Reingart 
> wrote: 
> >> 
> >> Hello Paul: 
> >> 
> >> Could you send a sample without actual data? 
> >> (without the db query, so it can be reproduced) 
> >> 
> >> fpdf.cell will jump to the next page if no more room available, maybe 
> >> there is a sizing or rounding issue. 
> >> Also, you have to take a look at page margins. 
> >> 
> >> Best regards, 
> >> 
> >> Mariano Reingart 
> >> http://www.sistemasagiles.com.ar 
> >> http://reingart.blogspot.com 
> >> 
> >> 
> >> On Tue, Jan 15, 2013 at 8:02 PM, Paul Rykiel  
> wrote: 
> >> > Greetings this is my code: 
> >> > 
> >> > def triagePrintTags(bikeIds): 
> >> > assert(bikeIds != None) 
> >> > assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple)) 
> >> > pdf = FPDF('P', 'mm', (66.548, 25.4)) 
> >> > # get all the r(ows 
> >> > rows = db(db.bike.id.belongs(bikeIds)).select() 
> >> > for row in rows: 
> >> > pdf.add_page() 
> >> > pdf.set_font('Times', 'B', 8) 
> >> > idString = row.destination + str(row.id) 
> >> > pdf.cell(0, 2, idString, 0, 1) 
> >> > if row.make != None: 
> >> > pdf.cell(0, 2, "Make:  " + row.make,0,1) 
> >> > if row.model != None: 
> >> > pdf.cell(0, 2, "Model:  " + row.model,0,1) 
> >> > if row.size != 0: 
> >> > sz = "Size:  " + str(row.size) 
> >> > pdf.cell(0, 2, sz,0,1) 
> >> > if row.color != None: 
> >> > pdf.cell(0, 2, "Color:  " + row.color,0,1) 
> >> > # TODO this should be a true temp file, stored in /tmp with 
> random 
> >> > unique filename. 
> >> > fileName = request.folder + '/static/temp.pdf' 
> >> > pdf.output(name=fileName) 
> >> > response.headers['Content-Disposition']='attachment.filename = 
> >> > sample.pdf' 
> >> > response.headers['Content-Type']='application/pdf' 
> >> > return response.stream(open(fileName, 'rb'), chunk_size=4096) 
> >> > 
> >> > the problem with the above code is: 
> >> > 
> >> > my dimentions of my page are supposed to simulate a label (no 
> problem) 
> >> > my text should all be on the same label, but when the next cell 
> prints, 
> >> > it 
> >> > jumps to the 
> >> > next label. What am I doing incorrectly here? 
> >> > 
> >> > Or maybe is it is just wrong print with pdf.cell, maybe there is a 
> >> > better 
> >> > way. 
> >> > Please help if you can? 
> >> > 
> >> > Thank you in advance. 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-16 Thread Paul Rykiel
thanks Jose, I am going to try this out, it would be so great if this 
worked!
I know I am close to my answer, this is more or less a configuration issue 
at this point.
thanks for all of your help!!
Regards, 
Paul 

On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote:

> Some time ago, we include PDFLabel too, so you can simplify your code 
> if you are using an avery-compatible format ( the sys stuff is only 
> needed if you're using a non-english language): 
>
> def label_bikes(): 
> from gluon.contrib.pyfpdf.pdflabels import PDFLabel 
> import sys 
> reload(sys) 
> sys.setdefaultencoding( "latin-1" ) 
>
> pdf = PDFLabel('Apli-01277') 
> pdf.add_page() 
> rows = db(db.bike.id.belongs(bikeIds)).select() 
> # Print labels 
> for row in rows: 
> idString = row.destination + str(row.id) 
> more_text = idString 
> more_text += "Make:  " + row.make + "\n" if row.make else "" 
> more_text += "Model:  " + row.model + "\n" if row.model else "" 
> more_text += "Size:  " + row.size + "\n" if row.size else "" 
> pdf.add_label(more_text) 
>
> response.headers['Content-Type'] = 'application/pdf' 
> response.headers['Content-Disposition']='attachment.filename = 
> sample.pdf' 
> return pdf.output(dest='S') 
>
>
> Regards 
> José L. 
>
> 2013/1/16 Paul Rykiel >: 
> > Hi Mariano, 
> > thank you for the response. Let me look into the margin issue, maybe you 
> > have given me enough to figure this out. 
> > thanks so much for the response. you know, Massimo was my professor last 
> > term. 
> > 
> > On Wednesday, January 16, 2013 12:39:06 AM UTC-6, Mariano Reingart 
> wrote: 
> >> 
> >> Hello Paul: 
> >> 
> >> Could you send a sample without actual data? 
> >> (without the db query, so it can be reproduced) 
> >> 
> >> fpdf.cell will jump to the next page if no more room available, maybe 
> >> there is a sizing or rounding issue. 
> >> Also, you have to take a look at page margins. 
> >> 
> >> Best regards, 
> >> 
> >> Mariano Reingart 
> >> http://www.sistemasagiles.com.ar 
> >> http://reingart.blogspot.com 
> >> 
> >> 
> >> On Tue, Jan 15, 2013 at 8:02 PM, Paul Rykiel  
> wrote: 
> >> > Greetings this is my code: 
> >> > 
> >> > def triagePrintTags(bikeIds): 
> >> > assert(bikeIds != None) 
> >> > assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple)) 
> >> > pdf = FPDF('P', 'mm', (66.548, 25.4)) 
> >> > # get all the r(ows 
> >> > rows = db(db.bike.id.belongs(bikeIds)).select() 
> >> > for row in rows: 
> >> > pdf.add_page() 
> >> > pdf.set_font('Times', 'B', 8) 
> >> > idString = row.destination + str(row.id) 
> >> > pdf.cell(0, 2, idString, 0, 1) 
> >> > if row.make != None: 
> >> > pdf.cell(0, 2, "Make:  " + row.make,0,1) 
> >> > if row.model != None: 
> >> > pdf.cell(0, 2, "Model:  " + row.model,0,1) 
> >> > if row.size != 0: 
> >> > sz = "Size:  " + str(row.size) 
> >> > pdf.cell(0, 2, sz,0,1) 
> >> > if row.color != None: 
> >> > pdf.cell(0, 2, "Color:  " + row.color,0,1) 
> >> > # TODO this should be a true temp file, stored in /tmp with 
> random 
> >> > unique filename. 
> >> > fileName = request.folder + '/static/temp.pdf' 
> >> > pdf.output(name=fileName) 
> >> > response.headers['Content-Disposition']='attachment.filename = 
> >> > sample.pdf' 
> >> > response.headers['Content-Type']='application/pdf' 
> >> > return response.stream(open(fileName, 'rb'), chunk_size=4096) 
> >> > 
> >> > the problem with the above code is: 
> >> > 
> >> > my dimentions of my page are supposed to simulate a label (no 
> problem) 
> >> > my text should all be on the same label, but when the next cell 
> prints, 
> >> > it 
> >> > jumps to the 
> >> > next label. What am I doing incorrectly here? 
> >> > 
> >> > Or maybe is it is just wrong print with pdf.cell, maybe there is a 
> >> > better 
> >> > way. 
> >> > Please help if you can? 
> >> > 
> >> > Thank you in advance. 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-16 Thread Paul Rykiel
Hi Mariano,
thank you for the response. Let me look into the margin issue, maybe you 
have given me enough to figure this out.
thanks so much for the response. you know, Massimo was my professor last 
term. 

On Wednesday, January 16, 2013 12:39:06 AM UTC-6, Mariano Reingart wrote:

> Hello Paul: 
>
> Could you send a sample without actual data? 
> (without the db query, so it can be reproduced) 
>
> fpdf.cell will jump to the next page if no more room available, maybe 
> there is a sizing or rounding issue. 
> Also, you have to take a look at page margins. 
>
> Best regards, 
>
> Mariano Reingart 
> http://www.sistemasagiles.com.ar 
> http://reingart.blogspot.com 
>
>
> On Tue, Jan 15, 2013 at 8:02 PM, Paul Rykiel > 
> wrote: 
> > Greetings this is my code: 
> > 
> > def triagePrintTags(bikeIds): 
> > assert(bikeIds != None) 
> > assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple)) 
> > pdf = FPDF('P', 'mm', (66.548, 25.4)) 
> > # get all the r(ows 
> > rows = db(db.bike.id.belongs(bikeIds)).select() 
> > for row in rows: 
> > pdf.add_page() 
> > pdf.set_font('Times', 'B', 8) 
> > idString = row.destination + str(row.id) 
> > pdf.cell(0, 2, idString, 0, 1) 
> > if row.make != None: 
> > pdf.cell(0, 2, "Make:  " + row.make,0,1) 
> > if row.model != None: 
> > pdf.cell(0, 2, "Model:  " + row.model,0,1) 
> > if row.size != 0: 
> > sz = "Size:  " + str(row.size) 
> > pdf.cell(0, 2, sz,0,1) 
> > if row.color != None: 
> > pdf.cell(0, 2, "Color:  " + row.color,0,1) 
> > # TODO this should be a true temp file, stored in /tmp with random 
> > unique filename. 
> > fileName = request.folder + '/static/temp.pdf' 
> > pdf.output(name=fileName) 
> > response.headers['Content-Disposition']='attachment.filename = 
> > sample.pdf' 
> > response.headers['Content-Type']='application/pdf' 
> > return response.stream(open(fileName, 'rb'), chunk_size=4096) 
> > 
> > the problem with the above code is: 
> > 
> > my dimentions of my page are supposed to simulate a label (no problem) 
> > my text should all be on the same label, but when the next cell prints, 
> it 
> > jumps to the 
> > next label. What am I doing incorrectly here? 
> > 
> > Or maybe is it is just wrong print with pdf.cell, maybe there is a 
> better 
> > way. 
> > Please help if you can? 
> > 
> > Thank you in advance. 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] Having some strange occurence with label printing and FPDF

2013-01-15 Thread Paul Rykiel
Greetings this is my code:
 
def triagePrintTags(bikeIds):
assert(bikeIds != None)
assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple))
pdf = FPDF('P', 'mm', (66.548, 25.4))
# get all the r(ows 
rows = db(db.bike.id.belongs(bikeIds)).select()
for row in rows:
pdf.add_page()
pdf.set_font('Times', 'B', 8)
idString = row.destination + str(row.id)
pdf.cell(0, 2, idString, 0, 1)
if row.make != None:
pdf.cell(0, 2, "Make:  " + row.make,0,1)
if row.model != None:
pdf.cell(0, 2, "Model:  " + row.model,0,1)
if row.size != 0:
sz = "Size:  " + str(row.size)
pdf.cell(0, 2, sz,0,1)
if row.color != None:
pdf.cell(0, 2, "Color:  " + row.color,0,1)
# TODO this should be a true temp file, stored in /tmp with random 
unique filename.
fileName = request.folder + '/static/temp.pdf'
pdf.output(name=fileName)
response.headers['Content-Disposition']='attachment.filename = 
sample.pdf'
response.headers['Content-Type']='application/pdf'
return response.stream(open(fileName, 'rb'), chunk_size=4096)
 
the problem with the above code is:
 
my dimentions of my page are supposed to simulate a label (no problem)
my text should all be on the same label, but when the next cell prints, it 
jumps to the 
next label. What am I doing incorrectly here?
 
Or maybe is it is just wrong print with pdf.cell, maybe there is a better 
way.
Please help if you can?
 
Thank you in advance.
 
 
 
 

-- 





  1   2   3   >