[web2py] Returning a controller function with an integer causes Thread issues

2015-11-04 Thread Calvin
Hi

I was working on the a controller function where the end result was the row 
id following a 

def insert_record()
  id= db[f].insert(**data) operaton
  return id

As it turns out, this works without a hitch on my mac running python 2.7.10 
and Web2py Version 2.9.12-beta+timestamp.2015.01.12.21.00.43, while on a 
Centos 7 machine with python 2.7.5 and the head web2py Version 
2.12.3-stable+timestamp.2015.08.18.19.14.07, I could not for the longest 
time get the AJAX POST call to return the id of the inserted row from the 
Centos machine while it worked perfectly fine from my mac.

After much frustration, I am happy to share that I have resolved this by 
casting the return id into a string:

def insert_record()
  id= db[f].insert(**data) operaton
  return str(id)


Sharing this if it helps save some one else some time!

C

-- 
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] IOError(11, 'Resource temporarily unavailable')

2015-10-01 Thread Calvin
Hi

We have been experiencing the above error message particularly for calls 
which require more complex queries. The set up is as follows:

nginx, uwsgi, postgresql-9.1, web2py Version 
2.11.2-stable+timestamp.2015.05.30.11.29.46

We have seen this error occur at different controllers/function.

Any suggestions on how to debug/troubleshoot this would be most appreciated!

Calvin

-- 
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: IOError(11, 'Resource temporarily unavailable')

2015-10-01 Thread Calvin
I have an error handler within web2py that provides the error trace. 

One hypothesis offered was that nginx is closing the socket as uwsgi is 
taking too long to serve data. I've increased the keepalive_timeout 
parameter from 60 to 600 but this does not help. Where else could the 
problem be?

On Friday, 2 October 2015 03:27:33 UTC+8, Niphlod wrote:
>
> where does this error pop up ?
>
>
>

-- 
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: Prince - Print Python Html to PDF

2015-04-21 Thread Calvin
Or why not http://html2pdfrocket.com instead? It's free.

On Tuesday, 21 April 2015 03:52:10 UTC+8, Ovidio Marinho wrote:


 Has anyone tried to use it with web2py?

 http://www.princexml.com/doc/9.0/python/



[image: http://itjp.net.br] http://itjp.net.br
  http://itjp.net.b http://itjp.net.brr
   *Ovidio Marinho Falcao Neto*
  ovid...@gmail.com javascript:
 Brasil
  
  

-- 
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] wiki_editor group added to impersonated account

2015-02-23 Thread Calvin
Hi

When I access the wiki function with an impersonated account, the 
impersonated account automatically gets added to the wiki_editor group at 
least for the duration of the account being impersonated. Is this the 
desired behaviour?

Thanks
Calvin

-- 
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] db.Table no longer available in recent modularised DAL update

2014-10-07 Thread Calvin
Hi

With the current version of Web2py (Version 
2.10.0-beta+timestamp.2014.09.24.13.35.58), the following code 

standard_fields = db.Table(db, 'standard_fields',
Field('created_on', 'datetime', default=request.now))



results in the following error being thrown:

*** AttributeError: 'DAL' object has no attribute 'Table'


This used to work before (Version 
2.9.6-stable+timestamp.2014.09.02.10.10.07)


Would this functionality be removed moving forward or is this an unintended 
omission?


Thanks

Calvin


-- 
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: putting in a custom render function with T.M()

2014-08-26 Thread Calvin
Thanks for clarifying, Massimo. MARKMIN will have to do for now.

On Monday, 25 August 2014 23:18:43 UTC+8, Massimo Di Pierro wrote:

 At this time T.M does not support extra. You can do:

 MARKMIN(hello ``you``:custom, extra=dict(custom=lambda x: SPAN(x, 
 _style=font-size:0.8em)))

 Do you need to internationalize this? 

 On Friday, 22 August 2014 10:33:28 UTC-5, Calvin wrote:

 Hi Massimo

 Here's an example:

 T.M(hello ``you``:custom, extra=dict(custom=lambda x: SPAN(x, _style=
 font-size:0.8em)))

 which throws

 *** TypeError: M() got an unexpected keyword argument 'extra'

 Calvin



-- 
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: putting in a custom render function with T.M()

2014-08-22 Thread Calvin
Hi Massimo

Here's an example:

T.M(hello ``you``:custom, extra=dict(custom=lambda x: SPAN(x, _style=
font-size:0.8em)))

which throws

*** TypeError: M() got an unexpected keyword argument 'extra'

Calvin

-- 
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] putting in a custom render function with T.M()

2014-08-20 Thread Calvin
Hi

I am wondering if it is possible to customise the render function within a 
``code`` segment with T.M(). I have tried adding the extra keyword as 
documented in the Markmin documentation but this is generating out a 
keyword not recognised error.

Thanks in advance!
Calvin

-- 
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] March 4 Lab 8

2014-03-04 Thread Calvin Morrison
I am so glad I am not taking intro to programming ever again. I hate string
manipulation!

Massimo - you might want to resend this to your actual students

Calvin


On 4 March 2014 14:20, Massimo Di Pierro massimo.dipie...@gmail.com wrote:

 During lab today you will begin writing the solutions for these problems:


1.

Write a version of a palindrome recogniser that accepts a file name
from the user, reads each line, and prints the line to the screen if it is
a palindrome.
2.

According to Wikipedia, a *semordnilap* is a word or phrase that
spells a *different* word or phrase backwards. (Semordnilap is
itself palindromes spelled backwards.) Write a semordnilap recogniser
that accepts a file name (pointing to a list of words) from the user and
finds and prints all pairs of words that are semordnilaps to the screen.
For example, if stressed and desserts is part of the word list, the the
output should include the pair stressed desserts. Note, by the way, that
each pair by itself forms a palindrome!
3.

Write a *procedure* char_freq_table() that, when run in a terminal,
accepts a file name from the user, builds a frequency listing of the
characters contained in the file, and prints a sorted and nicely formatted
character frequency table to the screen.

 You start today and continue at home. They will count as problems a8p1,
 a8p2, a8p3 of lab 8. They will be graded next week. Next week you will also
 work on problems a8p4, a8p5, a8p6.


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


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


Re: [web2py] trying to help young son learn Python, and...

2014-03-04 Thread Calvin Morrison
Hi,

http://web2py.com/books/default/chapter/29/13/deployment-recipes

this page offers different deployment  recipes for hosting like
PythonAnywhere. If your host (i am unfamiliar with go-daddy) provides you
root/shell access to a linux box, you shouldn't have any trouble. I am
Running my web2py instance from a VPS service.


On 4 March 2014 13:58, ezraho...@gmail.com wrote:

 1. does anyone know if web2py can be installed on a common web host like
 verio or go daddy hosting, and if so, if there is a how to anywhere to do
 it
 2. does, or will, web2py support python 3.x any time soon?

 thanks much!

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


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


Re: [web2py] Best practices for using mercurial within web2py

2014-02-21 Thread Calvin Morrison
 Also, relatedly, I was trying to restart apache from within a web2py app.
 That was giving me errors, so I'm doing something else.  Is there a way to
 do this?

you can do it from the shell. Look up your relevant distro information
on init scripts.

usually it's something like

sudo service apache2 restart

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


Re: [web2py] Using Homemade task queues

2014-01-30 Thread Calvin Morrison
Look at the scheduler documentation. I have mine called this way from
my db.py. This calls a few different tasks, adding file size and also
calling a task called unzip / untar which are functions i have written
to handle zipping and unzipping. Hopefully this explains it somewhat


def upload_post_hook(row_id):

row = db(db.uploads.id == row_id).select('up_file', 'username',
'filename')[0]

add_size(row_id)

if row.filename.endswith('.zip'):
scheduler.queue_task(unzip,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))
if any(row.filename.endswith(ext) for ext in ['.tar', 'tgz',
'.tar.gz', '.tar.bz', '.tar.xz', '.tar.bz2']):
  scheduler.queue_task(untar,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))

return None


db.uploads._after_insert.append(lambda id, i: upload_post_hook(i))

On 30 January 2014 16:31, desta demes...@gmail.com wrote:
 Hello everyone,

 A user uploads a file through a form and I want to process it using an
 external python script. I read from the manual about the Homemade task
 queues (http://web2py.com/books/default/chapter/29/04#Homemade-task-queues).
 I understand how it works.

 What I am missing is how to actually run the following command from my
 controller

 python web2py.py -S app -M -R applications/app/private/myscript.py -A a b c


 I would appreciate any help!

 Thanks for reading

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

-- 
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] Selects as_trees

2014-01-28 Thread Calvin
Hi

I am looking for a way to expand all referenced fields and have read about 
the as_trees() method for selecting rows. I do not quite understand the 
parent field requirement, but say we have the following 
tables/relationships, was looking for a nested dict output which could be 
JSONified as follows:

db.define_table('customers',
  Field('name'),
  Field('email'),
  Field('address')
)


db.define_table('products',
  Field('name'),
  Field('description')
)


db.define_table('orders',
  Field('customer', db.customers),
  Field('order_date', 'date'),
  Field('discount', 'double')
)

db.define_table('orders_line',
  Field('order', db.orders),

  Field('product', db.products),
  Field('price', 'double'),
  Field('qty', 'double')
)


db(db.orders_line.order==123).select().as_trees()


would give


[{'order':{'id':123, 'customer':{'id':1, 'name':'Bob', 'email':
'b...@demo.com', 'address':None}, 'order_date':'2014/01/29', 'discount': 0}, 
'product':{'id':1, 'name':'desk', 'description':'Wood finish, 4-legs'}, 
'price':100.0, 'qty': 1.0}]

I get the following error: *** AttributeError: AttributeError('Row' object 
has no attribute 'id',)

Any suggestions?


-- 
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: caching TAG()

2014-01-28 Thread Calvin
Thanks Anthony. It still appears to be returning the string result rather 
than the HTML object - even for the first time the function is called 
(uncached). I have cleared the cache (using redis cache). 

On Monday, 27 January 2014 23:38:30 UTC+8, Anthony wrote:

 Don't use XML() in your SMALL definition. Instead, create the entire HTML 
 helper object, call the .xml() method, store the resulting string in the 
 cache, and then after retrieving from cache, use XML() to display the 
 string in a view. For example:

 myoutput = XML(cache.disk('Hello', lambda: CAT(P('Hello'), TAG.small(
 'World')).xml(),
   time_expire=100))

 {{=myoutput}}



 On Monday, January 27, 2014 10:06:59 AM UTC-5, Calvin wrote:

 Thanks Leonel-I tried this without any success. It still rendering 
 incorrectly but this time consistently before and after caching.

 On Tuesday, 21 January 2014 03:34:39 UTC+8, Leonel Câmara wrote:

 You can use {{=XML(output, sanitize=False)}} to get the correct rendering



-- 
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: caching TAG()

2014-01-28 Thread Calvin
Yes-you are right. I had meant XML object, but the issue still persists. 
Even with the XML() function wrapping the cache output, the output rendered 
on the browser is a string with the tags printed. In this case, this always 
appears while previously, it would only occur after the cache has been 
filled. Perplexed!

On Wednesday, 29 January 2014 14:12:05 UTC+8, Anthony wrote:

 On Wednesday, January 29, 2014 12:19:54 AM UTC-5, Calvin wrote:

 Thanks Anthony. It still appears to be returning the string result rather 
 than the HTML object - even for the first time the function is called 
 (uncached). I have cleared the cache (using redis cache).


 Not sure what you mean. The value stored in the cache is always a string 
 (even when there's nothing yet in the cache, the value created to be stored 
 in the cache must be a string). When the value is created or retrieved from 
 the cache, it is then wrapped in XML(), so the myoutput variable is an XML 
 object. At no point do you have a standard HTML helper.

 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/groups/opt_out.


[web2py] Re: caching TAG()

2014-01-27 Thread Calvin
Thanks Leonel-I tried this without any success. It still rendering 
incorrectly but this time consistently before and after caching.

On Tuesday, 21 January 2014 03:34:39 UTC+8, Leonel Câmara wrote:

 You can use {{=XML(output, sanitize=False)}} to get the correct rendering


-- 
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] Slow response

2014-01-27 Thread Calvin Morrison

Hi guys,

I have a fairly typical web2py application I am trying to deploy with a 
standard CentOS 6 configuration using Apache and MySQL.


What seems to be bugging me right now is that the responses are very 
slow, around .7 seconds to load the home page. I have a feeling this is 
because of my apache WSGI setup.


It seems that web2py doesn't stay running as a process on the server,
so i guess each time it has to reimport and load everything up, seems 
quite slow.


 Before when running using the Rocket sever for development the site 
was snappy, now it's slow.


Any tips/tricks to keep web2p in the background for wsgi so that it's 
not so slow?


Calvin

--
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] CentOS install notes

2014-01-27 Thread Calvin Morrison
I've been having trouble with centOS getting a 503 Service unavailable 
using Apache's httpd. If anyone else is seeing this same problem, I 
found that this solved my problem:


adding this to my main httpd.conf:

WSGISocketPrefix /var/run/wsgi

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


Re: [web2py] Printing statements from Python

2014-01-26 Thread Calvin Morrison
A ghetto way: just open a file and use regular write commands
On Jan 26, 2014 1:30 PM, horridohobbyist horrido.hobb...@gmail.com
wrote:

 I'm looking for a simple way to print out statements in Python. I
 understand the 'print' function outputs to the console on the server side,
 but once web2py is deployed through Apache, I don't there's a console
 anymore.

 I tried looking at Python logging. The simplest case from the Python
 documentation suggests the following *should* work:

 import logging
 logging.basicConfig(filename=URL('static','debug.log'),level=logging.DEBUG)

 logging.debug('this is a test')


 But when I examine debug.log, it's empty. (Without the filename
 configuration, I have NO IDEA where the logging outputs to.)

 Is there no way to obtain a simple outputting mechanism in web2py?

 Thanks.

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


-- 
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] caching TAG()

2014-01-15 Thread Calvin
Hi

I'm getting the following error(s) when caching a TAG() element:

 File /path/to/projects/web2py/gluon/globals.py, line 372, in lambda
self._caller = lambda f: f()
  File /path/to/projects/web2py/gluon/tools.py, line 3239, in f
return action(*a, **b)
  File /path/to/projects/web2py/gluon/cache.py, line 405, in __call__
self.time_expire)
  File /path/to/projects/web2py/gluon/cache.py, line 364, in __call__
storage[key] = (now, value)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py,
 line 132, in __setitem__
p.dump(value)
  File /path/to/projects/web2py/gluon/html.py, line 1200, in TAG_pickler
marshal_dump = cPickle.dumps(d)

...

File /path/to/projects/web2py/gluon/html.py, line 1200, in TAG_pickler
marshal_dump = cPickle.dumps(d)
RuntimeError: maximum recursion depth exceeded


Code along the following should recreate it:

SMALL = lambda x, **kwargs: TAG.small(x, **kwargs)
cache.disk('Hello', lambda: CAT(P('Hello'), SMALL('World')), time_expire=100
)


Any ideas?


Calvin


-- 
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: caching TAG()

2014-01-15 Thread Calvin
Thanks Leonel! That works. 

I ended up doing it as follows:

SMALL = lambda x, **kwargs: XML(TAG.small(x, **kwargs).xml())
cache.disk('Hello', lambda: CAT(P('Hello'), SMALL('World')), time_expire=100
)

However, with such an approach, the retrieved cache value is a string 
rather than an XML object which means that I get the following output

Hello
smallWorld/small

as the rendered output rather than

Hello
World

Any further thoughts?

On Wednesday, 15 January 2014 23:43:56 UTC+8, Leonel Câmara wrote:

 Just save the generated xml instead


 cache.disk('Hello', lambda: CAT(P('Hello'), SMALL('World')).xml(),time_expire
 =100)


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


Re: [web2py] Re: Writing Web2Py specification and finding free lance Web2Py coders

2014-01-13 Thread Calvin Morrison
elance.com?

On 11 January 2014 23:04, Simon Ashley gregs...@gregsier.com.au wrote:
 Often thought that it would be good to push this to another level. We have
 projects from time to time that would be good to outsource, if people were
 interested. Something like a project post board, with bidders, assignment,
 monitoring and completion.

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

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-09 Thread Calvin Morrison
Brando,

Thanks for working this out!

it would be good to make a web2py slice or add it to the documentation/ examples

Calvin

On 8 January 2014 14:35, Brando bhe...@trustcc.com wrote:
 This works, added the requires statement for form validation:

 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 print f.filename
 up_file = db.uploads.up_file.store(f, f.filename)
 i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
 filename=f.filename, up_date= datetime.datetime.now())
 db.commit()
 return form submitted #redirect(URL('data', 'index'))
 return dict(form=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/groups/opt_out.

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
I  just wrote my own way to do it yesterday which worked great. I would
love it to go upstream.

It's just a standard file upload with the multiple attribute.

here's the entire thing: it spits out a form.

my db looks like this:

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: None if x == None else
x[:45]),
Field('up_file', 'upload', uploadseparate=True,
requires=IS_NOT_EMPTY()),
Field('up_date', 'datetime'),
Field('up_size', 'integer', represent= lambda x, row:
quikr_utils.sizeof_fmt(x) ),
Field('notes', 'text'))


my contorller

def submit():
  import datetime

  form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
_multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
BR(),INPUT(_type='submit'))

  if form.accepts(request.vars, formname=form):

if hasattr(request.vars, 'up_files'):
  if len(request.vars.up_files)  0:

files = request.vars['up_files']
if not isinstance(files, list):
  files = [files]

for f in files:
  print f.filename
  up_file = db.uploads.up_file.store(f, f.filename)
  i = db.uploads.insert(notes=request.vars.notes,
up_file=up_file,filename=f.filename, username = auth.user.email, up_date=
datetime.datetime.now())
  db.commit()

redirect(URL('data', 'index'))
  else:
form.errors.up_files = No files selected

  return dict(form=form)


On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





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


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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
:-) I was having a hell of a time trying to get all the AJAX examples to
work and well, none of it f***ing would. Yesterday I brewed an extra strong
pot of coffee and cranked this out.

Some of the code i would like review on, I am not sure how to properly
check for if there was an uploaded file or not, i have that weird is in
then len()  0 but i don't think it's the best.

Whoever is a maintainer/developer of web2py - could we integrate this
somehow?

Calvin


On 8 January 2014 10:40, Brando bhe...@trustcc.com wrote:

 Calvin, you are awesome.  I will try this on my end and report back.





 On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True,
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row:
 quikr_utils.sizeof_fmt(x) ),
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file,filename=f.filename, username = auth.user.email,
 up_date= datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to 
 implement multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





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

 For more options, visit https://groups.google.com/groups/opt_out.


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


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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
instead of inserting it, you could write the file stream out to whereever
you want.

It's really just a python cgi module object. so you can use all
corresponding documentation to help

look at this SO answer

https://stackoverflow.com/questions/15947988/in-my-python-cgi-script-how-do-i-save-to-disk-a-file-uploaded-via-post-request


On 8 January 2014 10:44, Brando bhe...@trustcc.com wrote:

 Also, should it be possible to adapt this so that I could use
 SQLFORM.factory instead of FORM?  I notice this uploads the files to the
 db.  What would need to change so that I'm just pulling it to the local
 disk?







 On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True,
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row:
 quikr_utils.sizeof_fmt(x) ),
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file,filename=f.filename, username = auth.user.email,
 up_date= datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to 
 implement multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





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

 For more options, visit https://groups.google.com/groups/opt_out.


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


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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
Yes I am getting that same problem here.

Like I said, I don't really know how to properly test if the variable has
been set.

Any input from more wise web2pyers would be great

Calvin


On 8 January 2014 14:03, Brando bhe...@trustcc.com wrote:

 Calvin, I'm getting this error when I select only 1 file to upload:



 Traceback (most recent call last):
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/gluon/restricted.py, line 217,
 in restricted
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
 , line 158, in module
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in
 lambda
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
 , line 116, in submit
  File cgi.pyc, line 591, in __len__
  File cgi.pyc, line 574, in keys
 TypeError: not indexable

 Which is coming from the highlighted line:
 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', 
 _type='file',_multiple
 =''), INPUT(_type='submit'))


   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
 filename=f.filename, username = auth.user.email, up_date= datetime.
 datetime.now())
   db.commit()


 return form submitted #redirect(URL('data', 'index'))

   else:
 form.errors.up_files = No files selected

   return dict(form=form)





 Did you see that during your testing? Any thoughts on 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/groups/opt_out.


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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
that'd be a Jquery thing.

jQuery(input#fileid).change(function () {
alert(jQuery(this).val())
});



On 8 January 2014 14:36, Brando bhe...@trustcc.com wrote:

 Question, how could I make it so I don't have to click the submit button.
  How could i make it to where they choose the files and it auto submits it?



 On Wednesday, January 8, 2014 11:35:44 AM UTC-8, Brando wrote:

 This works, added the requires statement for form validation:

 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 print f.filename
 up_file = db.uploads.up_file.store(f, f.filename)
 i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
 db.commit()
 return form submitted #redirect(URL('data', 'index'))
 return dict(form=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/groups/opt_out.


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


Re: [web2py] Re: custom widgets

2014-01-07 Thread Calvin Morrison
great thanks!

On 7 January 2014 15:18, Anthony abasta...@gmail.com wrote:
 1. Where should I put my custom widget logic?

 Right now i have it grossely stored in my db.py


 You can always put it in a module file and import it.


 2. Can i pass more information to my widget other than field, value from
 my
 db.table.colum.widget = mywidgetfunc


 If you have:

 def mywidget(field, value, arg1, arg2):

 you can do:

 db.table.column.widget = lambda f, v: mywidget(f, v, value1, value2)

 or:

 import functools
 db.table.column.widget = functools.partial(mywidget, arg1=value1,
 arg2=value2)

 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/groups/opt_out.

-- 
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] Happy New Year everybody!

2014-01-04 Thread Calvin
Happy New year Massimo and all the contributors who have made web2py so awesome!

-- 
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] require based on another field.

2014-01-02 Thread Calvin Morrison
Hi!

I have a field called Job Type, and another field database that
depends on the type. If the user selects Train for Job Type, they
don't need to enter a database (a integer id), but i don't know how to
make validators do this for me.

Right now I have this:

db.jobs.db.requires =
IS_NULL_OR(IS_IN_DB(db((db.quikr_database.username == auth.user.email)
| (db.quikr_database.share_with_others == True)),
db.quikr_database.id, '%(name)s'))

Either it can be null (in the case of Train) or otherwise it needs to
be in the list of shared quikr_databases.

Any ideas?

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


Re: [web2py] Re: save upload filename in database

2013-12-31 Thread Calvin Morrison
Here is my solution!


  if hasattr(request.vars['up_file'],filename):
form.vars.filename = request.vars['up_file'].filename

  if form.process().accepted:
redirect(URL('data', 'index'))
  elif form.errors:
response.flash = form has errors

On 28 December 2013 17:08, Calvin Morrison mutanttur...@gmail.com wrote:
 More specifically this only happens if I put in the if up_name != None check
 to set the filename in the database, otherwise it works well


 On Friday, December 27, 2013 11:48:09 PM UTC-5, Massimo Di Pierro wrote:

 Let's isolate the problem.

 Are you saying that even if you have this:

 Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
 IS_UPLOAD_FILENAME(extension=ext_regex)]),

 You can submit a form that does not upload a file into up_file?

 On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:

 I'm following the documentation trying to figure out how to correctly
 save a filename to my uploads database.

 Basically i have the same code as the website shows in it's examples


 def submit():


  import datetime


  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


  form.vars.up_date = datetime.datetime.now()
  form.vars.username = auth.user.email


  if request.vars.up_file != None:
  form.vars.filename = request.vars.up_file.filename


  if form.process().accepted:
  redirect(URL('data', 'index'))
  elif form.errors:
  response.flash = form has errors


 But my form doesn't appear to be validating correctly. It allows me to
 hit submit even if a file is not supplied. This leads to a error being
 logged, so I want to avoid things getting submitted.  My only thought is
 that it could be my requires not working correctly

 ext_regex = '|'.join(quikr_utils.all_ext)

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True,
 requires=[IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row:
 quikr_utils.sizeof_fmt(x) ),
 Field('notes', 'text'))

  print quikr_utils.all_ext
 ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

 Any ideas?
 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/groups/opt_out.

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


Re: [web2py] Re: save upload filename in database

2013-12-28 Thread Calvin Morrison
Yes that's exactly the problem!

Which in turn causes the other problems I think
On Dec 27, 2013 11:48 PM, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

 Let's isolate the problem.

 Are you saying that even if you have this:

 Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
  IS_UPLOAD_FILENAME(extension=ext_regex)]),

 You can submit a form that does not upload a file into up_file?

 On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:

 I'm following the documentation trying to figure out how to correctly
 save a filename to my uploads database.

 Basically i have the same code as the website shows in it's examples


 def submit():


  import datetime


  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


  form.vars.up_date = datetime.datetime.now()
  form.vars.username = auth.user.email


  if request.vars.up_file != None:
  form.vars.filename = request.vars.up_file.filename


  if form.process().accepted:
  redirect(URL('data', 'index'))
  elif form.errors:
  response.flash = form has errors


 But my form doesn't appear to be validating correctly. It allows me to
 hit submit even if a file is not supplied. This leads to a error being
 logged, so I want to avoid things getting submitted.  My only thought is
 that it could be my requires not working correctly

 ext_regex = '|'.join(quikr_utils.all_ext)

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None elsex
 [:45]),
 Field('up_file', 'upload', uploadseparate=True, requires=[
 IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
 sizeof_fmt(x) ),
 Field('notes', 'text'))

  print quikr_utils.all_ext
 ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

 Any ideas?
 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/groups/opt_out.


-- 
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: save upload filename in database

2013-12-28 Thread Calvin Morrison
More specifically this only happens if I put in the if up_name != None 
check to set the filename in the database, otherwise it works well

On Friday, December 27, 2013 11:48:09 PM UTC-5, Massimo Di Pierro wrote:

 Let's isolate the problem.

 Are you saying that even if you have this:

 Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
  IS_UPLOAD_FILENAME(extension=ext_regex)]),

 You can submit a form that does not upload a file into up_file?

 On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:

 I'm following the documentation trying to figure out how to correctly 
 save a filename to my uploads database.

 Basically i have the same code as the website shows in it's examples


 def submit():


  import datetime


  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


  form.vars.up_date = datetime.datetime.now()
  form.vars.username = auth.user.email


  if request.vars.up_file != None:
  form.vars.filename = request.vars.up_file.filename


  if form.process().accepted:
  redirect(URL('data', 'index'))
  elif form.errors:
  response.flash = form has errors


 But my form doesn't appear to be validating correctly. It allows me to 
 hit submit even if a file is not supplied. This leads to a error being 
 logged, so I want to avoid things getting submitted.  My only thought is 
 that it could be my requires not working correctly

 ext_regex = '|'.join(quikr_utils.all_ext)

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None elsex
 [:45]),
 Field('up_file', 'upload', uploadseparate=True, requires=[
 IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
 Field('up_date', 'datetime'), 
 Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
 sizeof_fmt(x) ), 
 Field('notes', 'text'))

  print quikr_utils.all_ext
 ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

 Any ideas?
 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/groups/opt_out.


[web2py] save upload filename in database

2013-12-27 Thread Calvin Morrison
I'm following the documentation trying to figure out how to correctly save 
a filename to my uploads database.

Basically i have the same code as the website shows in it's examples


def submit():


 import datetime


 form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


 form.vars.up_date = datetime.datetime.now()
 form.vars.username = auth.user.email


 if request.vars.up_file != None:
 form.vars.filename = request.vars.up_file.filename


 if form.process().accepted:
 redirect(URL('data', 'index'))
 elif form.errors:
 response.flash = form has errors


But my form doesn't appear to be validating correctly. It allows me to hit 
submit even if a file is not supplied. This leads to a error being logged, 
so I want to avoid things getting submitted.  My only thought is that it 
could be my requires not working correctly

ext_regex = '|'.join(quikr_utils.all_ext)

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: None if x == None else x
[:45]),
Field('up_file', 'upload', uploadseparate=True, requires=[IS_NOT_EMPTY
(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
Field('up_date', 'datetime'), 
Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
sizeof_fmt(x) ), 
Field('notes', 'text'))

 print quikr_utils.all_ext
['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

Any ideas?
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/groups/opt_out.


[web2py] Re: how to hide the [wiki] menu option in auth.wiki

2013-11-26 Thread Calvin
I'm using web2py  2.7.4-stable+timestamp.2013.11.25.15.21.21 but it doesn't 
appear that the patch for this is in yet.

However, instead of doing the removal of the Wiki link with jQuery on the 
client, which is susceptible to being hacked by a savvy user, the following 
may be more secure:


To the layout.html or equivalent, 

add the following line 
{{if auth.user and (not auth.has_membership('wiki_editor', auth.user.id) 
andresponse
.menu[-1][0].m=='[Wiki]'): response.menu.pop()}}



before

{{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',
mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}}





On Thursday, 25 October 2012 16:44:08 UTC+8, Andrew W wrote:

 the [wiki] menu option is good for the person maintaining the website, but 
 shouldn't be seen by others (at least those not logged in) .
 How do I hide it for unauthorised users ?

 Any update on when the book will contain auth.wiki information ?  I can 
 see plugin_wiki still there.

 Thanks

 Andrew W


-- 
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: Adding custom operators to DAL

2013-06-27 Thread Calvin
Thanks for the clarification but in any case, I thought it was Google 
acting up! 

-- 

--- 
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] generic WHERE clause in DAL

2013-06-26 Thread Calvin
I would like to suggest a generic query which could allow queries within 
the DAL framework for functions supported by the database but not web2py's 
DAL by feeding in the raw query as would be expected in SQL native to a 
particular database. While DAL hides alot of subtle differences in 
different database engines, most projects would be using a particular 
instance and hence, I think the code would be very straightforward and 
along the lines of:

In dal.py

def raw_where(self, value, op):
  db = self.db
  returnQuery(db, op, self,value)   

and so in a controller somewhere...

def OPERATOR(self, first, second):
  return '(%s  %s)' % (self.expand(first), self.expand(second)) 

db(db.table.field.raw_where(parameter, OPERATOR)).select()


would be possible.

-- 

--- 
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: Adding custom operators to DAL

2013-06-26 Thread Calvin
Hi Massimo

I am not familiar with the method you suggested but when I tried it, I got 
the following error:

print db(Expression(db,business_view.loc  
ST_MakeEnvelope(42.179139323652443, 141.20906066894531, 42.307520083522473, 
143.34776306152344))).select().as_list()
NameError: global name 'Expression' is not defined


In any case, in the non-working example that I tried, I was trying to use the 
bounding box operator in postgis, which is not currently available in the 
DAL... With the approach I suggested, I managed to get it to work without 
issues.



On Wednesday, 26 June 2013 15:09:25 UTC+8, Massimo Di Pierro wrote:

 Can you show an example of how you plan to use something like this. I 
 believe there is already a method 

 db(Expression(db, ... raw query ...)).select()

 perhaps I do not understand.

 On Tuesday, 25 June 2013 22:36:45 UTC-5, Calvin wrote:

 I think it would be nice to specify custom operators that can be used 
 with the DAL as I believe this would allow for operators that are currently 
 yet to be supported with a built-in DAL operator...

 From dal.py, I am thinking this should be relatively easy to implement, 
 and code would be along the lines of:

 update to dal.py

 def raw_where(self, value, op):
   db = self.db
   return Query(db, op, self, value)


 which enables the following in a project

 def OPERATOR(self, first, second):
   return '(%s  %s)' % (self.expand(first), self.expand(second)) //'this 
 return expression should be customised...


 rows = db(db.table.field.raw_where(parameter, OPERATOR)).select()



-- 

--- 
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: Adding custom operators to DAL

2013-06-26 Thread Calvin
Not sure why it says my previous reply has been deleted but here it is 
again:

Hi Massimo


I am not familiar with the method you suggested but when I tried it, I got 
the following error:


print db(Expression(db,business_view.loc  
ST_MakeEnvelope(42.179139323652443, 141.20906066894531, 42.307520083522473, 
143.34776306152344))).select().as_list()

NameError: global name 'Expression' is not defined


In any case, in the non-working example that I tried, I was trying to use 
the bounding box operator in postgis, which is not currently available in 
the DAL... With the approach I suggested, I managed to get it to work 
without 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: Adding custom operators to DAL

2013-06-26 Thread Calvin
Thanks Anthony and Massimo. It all works now!

On Thursday, 27 June 2013 00:42:26 UTC+8, Anthony wrote:

 from gluon.dal import Expression

 Anthony

 On Wednesday, June 26, 2013 11:53:34 AM UTC-4, Calvin wrote:

 Not sure why it says my previous reply has been deleted but here it is 
 again:

 Hi Massimo


 I am not familiar with the method you suggested but when I tried it, I 
 got the following error:


 print db(Expression(db,business_view.loc  
 ST_MakeEnvelope(42.179139323652443, 141.20906066894531, 42.307520083522473, 
 143.34776306152344))).select().as_list()

 NameError: global name 'Expression' is not defined


 In any case, in the non-working example that I tried, I was trying to use 
 the bounding box operator in postgis, which is not currently available in 
 the DAL... With the approach I suggested, I managed to get it to work 
 without 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] Adding custom operators to DAL

2013-06-25 Thread Calvin
I think it would be nice to specify custom operators that can be used with 
the DAL as I believe this would allow for operators that are currently yet 
to be supported with a built-in DAL operator...

From dal.py, I am thinking this should be relatively easy to implement, and 
code would be along the lines of:

update to dal.py

def raw_where(self, value, op):
  db = self.db
  return Query(db, op, self, value)


which enables the following in a project

def OPERATOR(self, first, second):
  return '(%s  %s)' % (self.expand(first), self.expand(second)) //'this 
return expression should be customised...


rows = db(db.table.field.raw_where(parameter, OPERATOR)).select()

-- 

--- 
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: Preventing repeated submissions, or rate limiting submissions

2013-05-29 Thread Calvin
Just wondering if a cache decorator would work here?

-- 

--- 
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: Preventing repeated submissions, or rate limiting submissions

2013-05-29 Thread Calvin
Just wondering if a cache decorator would work here?

-- 

--- 
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: Preventing repeated submissions, or rate limiting submissions

2013-05-29 Thread Calvin
Just wondering if a cache decorator would work here?

-- 

--- 
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: hiding a column in smartgrid

2013-05-27 Thread Calvin
before the call to SQLFORM.smartgrid, add

db.tablename.linkfield.readable=False

On Monday, 27 May 2013 23:57:31 UTC+8, Ricardo Cárdenas wrote:

 Hi,

 My model contains a URL field, and I'm displaying the model in a 
 SQLFORM.smartgrid. I don't want to show the whole URL, but I do want the 
 user to be able to visit the URL directly from the grid. So I use the 
 'links' parameter to SQLFORM.smartgrid. It works very nicely:

 links=[dict(header=Link, body=lambda row: A(Go, 
 _href=row.linkfield,_target
 =_blank))]


 But it doesn't work if I remove 'linkfield' from the 'fields' parameter to 
 SQLFORM.smartgrid. That's because, according to the 
 documentationhttp://web2py.com/books/default/chapter/29/07#SQLFORM.grid-and-SQLFORM.smartgrid
 :

 *'fields' is a list of fields to be fetched from the database. It is also 
 used to determine which fields to be shown in the grid view.*


 In my use case, I want the field to be fetched, but not shown. Is there a 
 smart (pun intended :) way to do this?

 best regards -Ricardo

 ps. I'd prefer not to mess around with jquery, and anyway it seems the 
 th does not have a CSS class or id that would allow me to hide an 
 undesired column.


-- 

--- 
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] edit static content from web interface nginx

2013-05-19 Thread Calvin
Check the file permissions for the static folder to see if it's own by uwsgi 
(if you're using that... or whichever wsgi)?

-- 

--- 
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] edit static content from web interface nginx

2013-05-19 Thread Calvin
Check the file permissions for the static folder to see if it's own by uwsgi 
(if you're using that... or whichever wsgi)?

-- 

--- 
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 store data records for recurrent jQuery call

2013-05-19 Thread Calvin
I've not verified the code but something along the lines of:

script
   var rec = 
JSON.parse('{{=json.dumps(db(db.xyz.id0).select().as_list())}}');
/script

You could then write some javascript to populate block 2 using the rec 
object created...

On Sunday, 19 May 2013 11:32:40 UTC+8, Lio wrote:

 Hello there,

 I have two DIV blocks on my page, one is a list of matched data records 
 list (only a few fields each row) using olli, the other is detail 
 record info when a record in above list is clicked. I want to use jQuery to 
 update the content in the Block 2 whenever a record is clicked, without 
 refreshing the whole page. 

 Block 1
 
 1. Record #1|
 2. Record #2|
 ...   
 |
 

 Block 2
 
 field 1:   
|
 field 2:   
|
 . 
  |
 

 Here is the question:
 A query was executed to create the list of records, and all records are 
 already returned to View, How can I store all matched data records and pass 
 the clicked one to jQuery functions? Otherwise I have to pass the record id 
 to controller via ajax and execute another query and return it back to 
 Block 2 every time a record row is clicked. This seems to be very 
 inefficient. 

 Any suggestion is appreciated.

 Lio



-- 

--- 
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] sending an image file to client without a temp file

2013-05-15 Thread Calvin
I was searching for the above functionality and found a solution using 
Flask and StringIO as below (short code snippet attached for convenience). 
Is there a way to do the same with web2py?



http://flask.pocoo.org/snippets/32/

#!/usr/bin/env python
# Thanks to Dan Jacob for a part of the code !
from flask import Flask, send_fileimport StringIO
app = Flask(__name__)
@app.route('/')def index():
strIO = StringIO.StringIO()
strIO.write('Hello from Dan Jacob and Stephane Wirtel !')
strIO.seek(0)
return send_file(strIO,
 attachment_filename=testing.txt,
 as_attachment=True)
app.run(debug=True)

-- 

--- 
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: sending an image file to client without a temp file

2013-05-15 Thread Calvin
Thanks Anthony.

-- 

--- 
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: IS_IN_DB orderby natural sort?

2013-05-13 Thread Calvin
How about doing your own widget:

import re
def natural_key(string_):
  return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]

items = db(db.item_type.id  0).select()
sorted_items= items.sort(key=natural_key(items.name))

db.item.item_type.widget = lambda f, v: SELECT([OPTION(i.name, _value=i.id) 
for i in sorted_items], _name=f.name, _id=%s_%s % (f._tablename, f.name), 
_value=v, value=v)

On Saturday, 11 May 2013 04:11:41 UTC, rppowell wrote:

 I have pre-populated a table of types by name:
   db.item_type.insert(name='Type1'...)
   db.item_type.insert(name='Type2'...)
   db.item_type.insert(name='Type3'...)
   ...
   db.item_type.insert(name='Type10'...)
   db.item_type.insert(name='Type11'...)
   ...

 I want to use the table as selection in another table, (using 
 requires=IS_IN_DB(db, db.item_type, '%(name)s'):
   db.define_table('item',
 Field('item_type', db.item_type),
   )
   db.item.item_type.requires = IS_IN_DB(db, db.item_type, '%(name)s')

 When I use a form to add a new record, the items are displayed out of 
 order in the dropdown:
   Type1
   Type10
   Type11
   ...
   Type2

 How do I specify using natural sorting, for example, using the following 
 python:

 import re
 def natural_key(string_):
   return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', 
 string_)]

 items = [
   'Item99', 'Item1', 'Item10', 'Item20', 'Item2', 'Item3', 'Item30'
 ]
 items.sort(key=natural_key)
 print ' '.join(items)



 How do I do this with the db in web2py?  Do a query, sort the list, and 
 use it as a IS_IN_SET()?

 -rppowell


-- 

--- 
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] distinct keyword for SQLFORM.grid

2013-04-10 Thread Calvin
Hi

I have been struggling with how one could get just distinct records to show 
with SQLFORM.grid if the query passed to it involved more than one table? 
Doing an inner join tends to generate a lot of non-unique rows and hence it 
would be important to just filter out the unique ones. With select, there 
is support for the distinct keyword but this is not the case with 
SQLFORM.grid. 

Using the groupby keyword is one approach but this can get somewhat tedious 
having to specify the fields to group by in advance and hence, I would like 
to understand if the omission of support for distinct in SQLFORM.grid is by 
design?

Many thanks
Calvin

-- 

--- 
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: Override _autocomplete function

2013-03-11 Thread Calvin
If of interest to anyone, eventually, I made my own autocomplete based on 
Bootstrap Typeahead:

def bs_typeahead(f, v, **kwargs):
options = {'_data-provide':'textahead'}
options.update(kwargs)
return CAT(
INPUT(_type=text, _class=string, _id=%s_%s_ac % (f._tablename,f
.name), **options), 
INPUT(_type=hidden, _id=%s_%s % (f._tablename, f.name), _name=f.
name, _value=v, requires=f.requires),
SCRIPT($($('#%(table)s_%(field)s_ac').typeahead({minLength: 3, 
source:function(query,process){console.log(query); return 
$.get('%(url)s.json', {'_ac_%(table)s_%(field)s': query}, 
function(data){return process(data.options)})}, 
highlighter:function(item){return 
item.split('_')[1]},updater:function(item){ var p=item.split('_'); 
$('#%(table)s_%(field)s').val(p[0]); return p[1]}})) % {'url':URL(), 
'table':f._tablename, 'field':f.name})
)

and with the appropriate handler for request.vars['ac_%s_%s' 
%(f._tablename, f.name)]

-- 

--- 
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] Override _autocomplete function

2013-03-08 Thread Calvin
I have been using the autocomplete widget which makes is really convenient. 
However, there are times where I would like to customise what is shown in 
the SELECT say with a custom expression rather than being limited to each 
OPTION being the value of the field in the row.

It appears that the autocomplete widget does not accept a lambda in place 
of a field. However, I guess one approach would be to define a virtual 
field which could then be listed on the option. However, in my usage 
scenario, I am looking for a way to display full addresses in the SELECT 
when the user starts to enter a fragment of the postcode. Given that 
postcodes are expected at the end of the address rather than at the start, 
the autocomplete will not match that. Also, I am not sure if it would be a 
good idea to do this with a virtual field over a large addresses dataset. 

So, as an alternative, I have been toying with a workaround in which I try 
to override the autocomplete AJAX call. Say given a function/url /address, 
I have the following in my controller:


def address():
   if request.vars._autocomplete_address_postcode: return SELECT([OPTION(%s 
%s % (r.addr, r.postcode) for r in db(db.address.postcode.like('%s%%' %request
.vars._autocomplete_address_postcode)).select()])

This however does not appear to run and I still get the default 
autocomplete behaviour.

Any ideas?

-- 

--- 
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: Rows object not returning reference fields

2013-02-27 Thread Calvin
Oops--for some reason (very likely me mucking things up) this was an issue 
but has now magically resolved itself! Not quite sure why!

On Wednesday, 27 February 2013 20:30:21 UTC+8, Anthony wrote:

 Can you show some code and explain what you are expecting and what you are 
 seeing instead?

 On Wednesday, February 27, 2013 1:59:38 AM UTC-5, Calvin wrote:

 I am encountering a strange observation in that when accessing the Rows 
 object for a given table, the object returns all the fields except for 
 those that are of the reference type. I am using the HEAD version... Is 
 this a bug?



-- 

--- 
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] Rows object not returning reference fields

2013-02-26 Thread Calvin
I am encountering a strange observation in that when accessing the Rows 
object for a given table, the object returns all the fields except for 
those that are of the reference type. I am using the HEAD version... Is 
this a bug?

-- 

--- 
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] How to restrict choices in an OPTIONS widget based on values in that row or the default value

2013-01-03 Thread Calvin
Thanks Vinicius. I adopted your suggestion, although I really like the idea 
of defining all the widgets at the model level and this approach does not 
conform to it.

If say the constraint on continent was made on another table and selected 
prior to this form, i.e. we know what it is before the countries form is 
shown, I am wondering if there is a way to add a filter to the options 
widget?


On Wednesday, 2 January 2013 20:13:46 UTC+8, viniciusban wrote:

 Ajax will help you. 

 You need to load countries HTML OPTION's when continent changes. 



 On Wed, Jan 2, 2013 at 3:26 AM, Calvin calvi...@gmail.com javascript: 
 wrote: 
  Say I have a look-up tables as follows: 
  
  db.define_table('continent', 
 Field('name') 
  ) 
  
  
  db.define_table('country', 
 Field('name'), 
 Field('in_continent', db.continent, requi) 
  ) 
  
  Now, if I then have a table as defined: 
  
  
  
  I would then like to have an SQLFORM in which field country presents a 
 list 
  in an options dropdown box with only countries based on what continent 
 is 
  selected in the record but I am not able to figure out the correct 
 syntax. 
  
  
  db.define_table('where_is_carmen', 
Field('continent', db.continent, default= 1, requires = IS_IN_DB(db, 
  'continent.id', '%(name)s'), represent = lambda value, row: 
  db.continent[value].name), 
Field('country', db.country, requires = lambda id: 
  
 IS_EMPTY_OR(IS_IN_DB(db(db.country.continent==(db.where_is_carmen[id].continent
  

  if id else db.where_is_carmen.continent.default)), 'country.id', 
  '%(name)s'))) 
  ) 
  
  
  I would then like to have an SQLFORM in which field country presents a 
 list 
  in an options dropdown box with only countries based on what continent 
 is 
  selected in the record but I am not able to figure out the correct 
 syntax. 
  
  Any light shed on how this could be done would be much appreciated. 
  
  -- 
  
  
  


-- 





[web2py] Re: SQLFORM widget support for wider range of input types

2013-01-01 Thread Calvin
Sorry, the earlier patch contained some typos. Here is the corrected 
version.

On Monday, 31 December 2012 05:18:12 UTC+8, Massimo Di Pierro wrote:

 Seems like a good idea. What do other think? If the difference is only in 
 the type, could we simply override the value of type using a class variable 
 and use the widget method of the base class?

 Massimo

 On Sunday, 30 December 2012 12:01:06 UTC-6, Calvin wrote:

 Hi Massimo

 Here is a patch which updates the date, time and datetime widget. If this 
 approach is acceptable, I am happy to provide a patch for the other types 
 as well.

 Calvin

 On Sunday, 30 December 2012 00:50:59 UTC+8, Massimo Di Pierro wrote:

 I think this would be a good idea but somebody should be in charge of 
 this. Perhaps we can take this approach for web3py where widgets will have 
 a simpler internal design. It will be possible to use web3py widgets in 
 web2py.

 Anybody wants to be in charge of this? I can explain more so we can 
 discuss options.

 Massimo




-- 



From 4a4806d78aa18ea109b8c14e425d12cc3ed49071 Mon Sep 17 00:00:00 2001
From: Calvin Sim cal...@3vialy.com
Date: Mon, 31 Dec 2012 01:56:23 +0800
Subject: [PATCH 1/5] updated date, time, datetime widget's type attribute to
 enable more specific inputs with compatible browsers.

---
 gluon/sqlhtml.py |   42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index a5827e9..7f4423b 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -160,16 +160,56 @@ class DecimalWidget(StringWidget):
 class TimeWidget(StringWidget):
 _class = 'time'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT time tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='time', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DateWidget(StringWidget):
 _class = 'date'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT date tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='date', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DatetimeWidget(StringWidget):
 _class = 'datetime'
 
 
-class TextWidget(FormWidget):
+clamethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT datetime tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='datetime', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
+
+ TextWidget(FormWidget):
 _class = 'text'
 
 @classmethod
-- 
1.7.10.2 (Apple Git-33)


From 52c1ba67e33ebdef20268c2e31141cc70185ac3f Mon Sep 17 00:00:00 2001
From: mdipierro massimo.dipie...@gmail.com
Date: Sun, 30 Dec 2012 15:16:39 -0600
Subject: [PATCH 2/5] added
 setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh,
 thanks Richard

---
 VERSION|2 +-
 ...ntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh |  464 
 2 files changed, 465 insertions(+), 1 deletion(-)
 create mode 100644 scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh

diff --git a/VERSION b/VERSION
index 25bf7f5..c532e5e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-Version 2.4.1-alpha.2+timestamp.2012.12.28.16.18.51
+Version 2.4.1-alpha.2+timestamp.2012.12.30.15.15.53
diff --git a/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh b/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh
new file mode 100644
index 000..84a0b0f
--- /dev/null
+++ b/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh
@@ -0,0 +1,464 @@
+#!/bin/bash
+
+# --
+# Description : Installation and basic configuration of web2py, uWSGI, Redmine,
+#   Unicorn, Nginx and PostgreSQL.
+#   Usage : Copy the script in /home/username and run it as root, you may 
+#   need to allow exectuion (chmod +x). Ex.: 
+#   sudo ./setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh
+#File : setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh
+#  Author : Richard V?zina
+#   Email : ml.richard.vez...@gmail.com
+#   Copyright : Richard V?zina
+#Date : ven 28 d?c 2012 13:27:11 EST
+# Disclaimers : This script is provided as is, without warranty of any kind.
+# Licence : CC BY-NC 2.5 CA
+# --
+
+echo 'setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh'
+echo 'Requires Ubuntu = 12.04 (May works with 12.10

[web2py] How to restrict choices in an OPTIONS widget based on values in that row or the default value

2013-01-01 Thread Calvin
Say I have a look-up tables as follows:

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


db.define_table('country',
   Field('name'),
   Field('in_continent', db.continent, requi)
)

Now, if I then have a table as defined:



I would then like to have an SQLFORM in which field country presents a list 
in an options dropdown box with only countries based on what continent is 
selected in the record but I am not able to figure out the correct syntax.


db.define_table('where_is_carmen',
  Field('continent', db.continent, default= 1, requires = IS_IN_DB(db, 
'continent.id', '%(name)s'), represent = lambda value, row: db.continent[
value].name),
  Field('country', db.country, requires = lambda id: IS_EMPTY_OR(IS_IN_DB(db
(db.country.continent==(db.where_is_carmen[id].continent if id else db.
where_is_carmen.continent.default)), 'country.id', '%(name)s')))
)


I would then like to have an SQLFORM in which field country presents a list 
in an options dropdown box with only countries based on what continent is 
selected in the record but I am not able to figure out the correct syntax.

Any light shed on how this could be done would be much appreciated.

-- 





[web2py] Re: SQLFORM widget support for wider range of input types

2012-12-30 Thread Calvin
Hi Massimo

Here is a patch which updates the date, time and datetime widget. If this 
approach is acceptable, I am happy to provide a patch for the other types 
as well.

Calvin

On Sunday, 30 December 2012 00:50:59 UTC+8, Massimo Di Pierro wrote:

 I think this would be a good idea but somebody should be in charge of 
 this. Perhaps we can take this approach for web3py where widgets will have 
 a simpler internal design. It will be possible to use web3py widgets in 
 web2py.

 Anybody wants to be in charge of this? I can explain more so we can 
 discuss options.

 Massimo




-- 



From 4a4806d78aa18ea109b8c14e425d12cc3ed49071 Mon Sep 17 00:00:00 2001
From: Calvin Sim cal...@3vialy.com
Date: Mon, 31 Dec 2012 01:56:23 +0800
Subject: [PATCH] updated date, time, datetime widget's type attribute to
 enable more specific inputs with compatible browsers.

---
 gluon/sqlhtml.py |   42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index a5827e9..7f4423b 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -160,16 +160,56 @@ class DecimalWidget(StringWidget):
 class TimeWidget(StringWidget):
 _class = 'time'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT time tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='time', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DateWidget(StringWidget):
 _class = 'date'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT date tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='date', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DatetimeWidget(StringWidget):
 _class = 'datetime'
 
 
-class TextWidget(FormWidget):
+clamethod
+def widget(cls, field, value, **attributes):
+
+generates an INPUT datetime tag.
+
+see also: :meth:`FormWidget.widget`
+
+
+default = dict(_type='datetime', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
+
+ TextWidget(FormWidget):
 _class = 'text'
 
 @classmethod
-- 
1.7.10.2 (Apple Git-33)



[web2py] SQLFORM widget support for wider range of input types

2012-12-29 Thread Calvin
WHATWG (*Web Hypertext Application Technology Working 
Grouphttp://www.whatwg.org/
) list a wide range of input types in *

http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute

Could we update SQLFORM.widgets so that a whole range is implemented as 
currently only a subset of types are available? I believe this would allow 
developers to provide a better user experience for their applications. It 
may also be useful to enable a number of specific features such as 
pattern=[0-9] in iOS devices to enable different keyboards.

I had a look at sqlhtml.py and believe this to be straightforward to do.

-- 





[web2py] How to get T() to work within a module?

2012-11-27 Thread Calvin
I would like to get the translation function T() working within a module in 
web2py but I am not sure how one would go abouts importing the necessary 
modules to do that. Could someone enlighten me on this? 

Many thanks in advance!
Calvin

-- 





Re: [web2py] How do you I use geo-spatial types in Web2py DAL?

2012-10-01 Thread Calvin
Thanks for your suggestion Manuele. I have installed GDAL and also tried 
point 1, but then I get stuck as web2py throws the following error:

Traceback (most recent call last):
  File /var/www/web2py/gluon/restricted.py, line 209, in restricted
exec ccode in environment
  File /usr/share/web2py/applications/hello_world/models/db.py 
https://3vialy.com/admin/default/edit/3v2/models/db.py, line 132, in module
migrate=True
  File /var/www/web2py/gluon/dal.py, line 7033, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File /var/www/web2py/gluon/dal.py, line 7064, in lazy_define_table
polymodel=polymodel)
  File /var/www/web2py/gluon/dal.py, line 784, in create_table
srid = self.srid
AttributeError: 'MySQLAdapter' object has no attribute 'srid'


when I set migrate=True. Apparently, the fieldtype starting with 'geo' is 
causing an issue. Any further clues?

many thanks
Calvin


   - 
   

On Thursday, 27 September 2012 18:14:49 UTC+8, Manuele wrote:

 Il 27/09/2012 05:02, Calvin ha scritto: 
  Hi 
  
  I am a big fan of Web2py and would like to use the DAL for capturing 
  location specific information. I use MySQL as a back-end and would 
  like to understand how I could define a table with MySQL's Spatial 
  Extension data types into the DAL and hopefully be able to access this 
  with SQLFORM. For instance, how could I get the DAL  to define a field 
  as a WKT point? 

 as long as I have tested you can: 

 1) define your table with geometry: 

 db.define_table('mytab' 
  Field('geometry_name'), 
  Field('the_geom', 'geometry()') 
 ) 

 2) than you can insert geometries in this way: 

 info = dict( 
  geometry_name = 'test', 
  the_geom = 'POINT(0 0)' 
 ) 

 db.mytab.insert(**info) 

 I suggest you to manage your geometries using the power of python-gdal 
 useful for wkt/b conversion and not only 

 hope it could help 

 Cheers 

  Manuele 



  Many thanks 
  Calvin 
  -- 
  
  
  



-- 





[web2py] How do you I use geo-spatial types in Web2py DAL?

2012-09-26 Thread Calvin
Hi

I am a big fan of Web2py and would like to use the DAL for capturing 
location specific information. I use MySQL as a back-end and would like to 
understand how I could define a table with MySQL's Spatial Extension data 
types into the DAL and hopefully be able to access this with SQLFORM. For 
instance, how could I get the DAL  to define a field as a WKT point?

Many thanks
Calvin

-- 





[web2py] SQLTABLE param headers=None bug - Web2py 1.99.2 (2011-09-26 06:55:33) stable

2011-10-26 Thread Calvin
Hi

I think I found a bug with the headers with the above version, which
when headers=None generates a unsubscriptable error at line 2061:

if isinstance(headers[colname],dict):

This error can be fixed by the following changes added to line 1966 of
sqlhtml.py:


if not headers is None:
for c in columns:#new implement dict
if isinstance(headers.get(c, c), dict):
coldict = headers.get(c, c)
attrcol = dict()
if coldict['width']!=:
attrcol.update(_width=coldict['width'])
if coldict['class']!=:
attrcol.update(_class=coldict['class'])
row.append(TH(coldict['label'],**attrcol))
elif orderby:
row.append(TH(A(headers.get(c, c),
_href=th_link+'?orderby=' + c)))
else:
row.append(TH(headers.get(c, c)))

if extracolumns:#new implement dict
for c in extracolumns:
attrcol = dict()
if c['width']!=:
attrcol.update(_width=c['width'])
if c['class']!=:
attrcol.update(_class=c['class'])
row.append(TH(c['label'],**attrcol))

components.append(THEAD(TR(*row)))
+else:
+  headers={}

Cheers
Calvin