[web2py] Re: Need a little help with DAL

2012-07-17 Thread pbreit
Looks like it is comparing them as strings. As others noted, need to see 
code.

-- 





Re: [web2py] Re: How to build a modular menu

2012-07-17 Thread Johann Spies
Thanks Jaap and Cliff.
It was helpful.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Need a little help with DAL

2012-07-17 Thread Aurelijus Useckas
Yes, it really acts like str. I'm using the nightly build 1.99.7 dev. Could 
it be because of dev?

here's all of the db definition:

db.define_table('company',
Field('title', label='Pavadinimas', unique=True),
Field('CEO', label='Generalinis dir.'),
Field('code', 'integer', label='Įmonės kodas',unique=True, 
default=None),
Field('revenue', 'integer', label='Metinė apyvarta'),
Field('workers', 'integer', label='Darbuotojų skaičius'),
# Field('logo', 'upload', label='Įmonės logo'),
Field('produce_tag', db.tag, 'list:string', label='Produkcija', 
default=None),
Field('produce', label='Produkcija (smulkiau)'),
Field('Email', default=None, notnull=False),
Field('Tel'),
Field('Fax'),
Field('www'),
Field('City', db.city, 'list:reference city', label='Miestas'),
Field('address', label='Adresas'),
Field('extra_contacts', 'boolean', label='Pridėti kontakt. duomenų'),
Field('extra_contacts_2', 'boolean', label='Pridėti kontakt. duomenų'),
Field('name_1', label='Vardas'),
Field('pareigos_1', label='Pareigos'),
Field('tel_1', label='Papildomas tel.'),
Field('email_1', label='Papildomas el. paštas'),
Field('name_2', label='Vardas'),
Field('pareigos_2', label='Pareigos'),
Field('tel_2', label='Papildomas tel.'),
Field('email_2', label='Papildomas el. paštas'),
Field('Association',  db.asoc, label='Priklauso asociacijai'),
Field('other', 'text', label='Papildoma info'),
Field('submited_at', 'datetime', default=request.now, writable=False, 
readable=False),
Field('submited_by', db.auth_user, default=auth.user_id, 
writable=False, readable=False),
Field('updated_at', 'datetime', update=request.now, writable=False, 
readable=False),
Field('updated_by', db.auth_user, update=auth.user_id, writable=False, 
readable=False),
Field('exports_wants_to', 'list:reference countries', label='Domina 
šalys'),
  #  Field('exports_or_not', 'boolean', label = 'Ar eksportuoja?'),
Field('exports_to', 'list:reference countries', label='Eksportuoja į', 
required=False),
  #  Field('imports_or_not', 'boolean', label = 'Ar Importuoja?'),
Field('imports_from', 'list:reference countries', label='Importuoja 
iš', required=False),
format = '%(title)s')

in order to test the selection, I use web2py DB environment. Query: 
db.company.workers40
acts like comparing strings.. wonder why :/




On Tuesday, July 17, 2012 9:37:20 AM UTC+3, pbreit wrote:

 Looks like it is comparing them as strings. As others noted, need to see 
 code.

-- 





[web2py] Re: Need a little help with DAL

2012-07-17 Thread Anthony
Are you using SQLite? Did you initially forget to define workers as an 
integer field, enter some data, and then convert it to an integer field? 
What happens if you start with a fresh db?

Anthony

On Tuesday, July 17, 2012 3:55:35 AM UTC-4, Aurelijus Useckas wrote:

 Yes, it really acts like str. I'm using the nightly build 1.99.7 dev. 
 Could it be because of dev?

 here's all of the db definition:

 db.define_table('company',
 Field('title', label='Pavadinimas', unique=True),
 Field('CEO', label='Generalinis dir.'),
 Field('code', 'integer', label='Įmonės kodas',unique=True, 
 default=None),
 Field('revenue', 'integer', label='Metinė apyvarta'),
 Field('workers', 'integer', label='Darbuotojų skaičius'),
 # Field('logo', 'upload', label='Įmonės logo'),
 Field('produce_tag', db.tag, 'list:string', label='Produkcija', 
 default=None),
 Field('produce', label='Produkcija (smulkiau)'),
 Field('Email', default=None, notnull=False),
 Field('Tel'),
 Field('Fax'),
 Field('www'),
 Field('City', db.city, 'list:reference city', label='Miestas'),
 Field('address', label='Adresas'),
 Field('extra_contacts', 'boolean', label='Pridėti kontakt. duomenų'),
 Field('extra_contacts_2', 'boolean', label='Pridėti kontakt. duomenų'),
 Field('name_1', label='Vardas'),
 Field('pareigos_1', label='Pareigos'),
 Field('tel_1', label='Papildomas tel.'),
 Field('email_1', label='Papildomas el. paštas'),
 Field('name_2', label='Vardas'),
 Field('pareigos_2', label='Pareigos'),
 Field('tel_2', label='Papildomas tel.'),
 Field('email_2', label='Papildomas el. paštas'),
 Field('Association',  db.asoc, label='Priklauso asociacijai'),
 Field('other', 'text', label='Papildoma info'),
 Field('submited_at', 'datetime', default=request.now, writable=False, 
 readable=False),
 Field('submited_by', db.auth_user, default=auth.user_id, 
 writable=False, readable=False),
 Field('updated_at', 'datetime', update=request.now, writable=False, 
 readable=False),
 Field('updated_by', db.auth_user, update=auth.user_id, writable=False, 
 readable=False),
 Field('exports_wants_to', 'list:reference countries', label='Domina 
 šalys'),
   #  Field('exports_or_not', 'boolean', label = 'Ar eksportuoja?'),
 Field('exports_to', 'list:reference countries', label='Eksportuoja į', 
 required=False),
   #  Field('imports_or_not', 'boolean', label = 'Ar Importuoja?'),
 Field('imports_from', 'list:reference countries', label='Importuoja 
 iš', required=False),
 format = '%(title)s')

 in order to test the selection, I use web2py DB environment. Query: 
 db.company.workers40
 acts like comparing strings.. wonder why :/




 On Tuesday, July 17, 2012 9:37:20 AM UTC+3, pbreit wrote:

 Looks like it is comparing them as strings. As others noted, need to see 
 code.



-- 





[web2py] CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread murtaza52
Hi,

We are creating our frontend using angular.js and the API layer is in 
web2py. The web2py documentation says - 

web2py prevents CSRF as well as accidental double submission of forms by 
 assigning a one-time random token to each form. 


So how will that work in the instance of a pure JS frontend ? Will I need 
to implement something on the client side to enable it ?

The initial request will go to the web2py app, which will send back the 
index.html, which will contain the js script as an include. This will load 
the js interface during the initial request. After this all calls will be 
ajax calls to the server, to return back JSON.

Also I will be using the web2py authentication/authorization for securing 
the API. So would I be breaking any web2py compatibly in this regard or 
with any other security concerns ?

Thanks,
Murtaza 

-- 





[web2py] Re: A Web2py CMS like Joomla ?

2012-07-17 Thread Gour
On Wed, 13 Jun 2012 02:23:35 -0700 (PDT)
Andrew awillima...@gmail.com wrote:

 I have started doing some trials with both instantpress and movuca,
 and I would have to say that it is not a question of which is better,
 each has a different focus and I've enjoyed using both (I'm still
 learning and still have heaps of questions though). 

I've decided to use (wx)python instead of D for our multi-platform
project, so being already in Python-world it really makes sense to
forget about PHP and use Python framework.

Here we prefer full-stack one and between Django an Web2py, the latter
wins in all the aspects except the number of ready apps...and here we
think about blog/CMS ones.

In Django there is Django-CMS, FeinCMS, Mezzanine...(there are
more, but just picked 1st three from the below mentioned URL)... having
blog engines and/or ecommerce packages nicely integrating with them.

There is another aspect of the game: Django-CMS has (according to
http://www.djangopackages.com/grids/g/cms/) 1654 repo watchers and 525
repo forks, FeinCMS (384/110) and Mezzanine (662/176).

All of them are actively developed, there are submitted tickets which
are commented by the devs and we can say there are communities
developed around the projects.

Otoh, situation with the two web2py CMS-es (there is also w2cms but not
with much activity) is the following:

1) InstantPress: 18 followers, 0 forks, last commit 5 months ago, 5
(new) issues and not a *single* comment from the developer

2) Movuca CMS: 80 watchers, 14 forks, active development,  9 issues and
*every* issue is commented by the main developer.

I cannot judge the quality of the code itself, but it is pretty obvious
which project build community around it.

It's clear that web2py is simply too young and/or small to compare in
numbers of apps within the Django community, but I'm sure  it would be
possible to focus on one CMS platform which is (more) focused on
end-users (as it was already expressed in this thread) and make it
actively developed, maintained  sufficient flexible in order that all
sites developed by it would not look as WP with Kubrick theme.

Is there any interest for it?

Personally, InstantPress looks more appealing to me as 'general'
CMS/blog app in comparison with Movuca which seems to be more focused
towards social networking, but I simply do not feel confident to invest
time in learning the former.

It could be that there is simply no interest within web2py community
to build such thing, but the list referenced in wikipedia article
( http://en.wikipedia.org/wiki/Web2py):

quote
Applications built on Web2py

Movuca CMS and Social Network Engine.
Instant Press Blog platform.
Ourway Social networking site.
NoobMusic A rock music website.
LinkFindr Network diagnostic tool.
StarMaker Develops karaoke-style social music apps.

/quote

is, imho, too short for such fine quality web framework.


Sincerely,
Gour


-- 
As the ignorant perform their duties with attachment to results, 
the learned may similarly act, but without attachment, for the 
sake of leading people on the right path.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Amit Kumar
I understand the proposed procedure is as follows:

1. change db table field to writable
2. make the form as needed
3. change back db table field to not writable

Suppose there are two concurrent users now, A and B, and they execute the
above procedure.
The concurrent scheduling is done by the server; one possible sequence is:

A 1, B 1, B 2, B 3, problem occurs A 2, A 3.

At the point of problem occurs, the db field is not writable and so the
form will not be correct.

On Tue, Jul 17, 2012 at 12:46 PM, Anthony abasta...@gmail.com wrote:

 Can you elaborate?


 On Tuesday, July 17, 2012 12:24:37 AM UTC-4, amit wrote:

 Old thread, but this would trigger a race condition in case of multiple
 concurrent users.

 On Friday, June 17, 2011 5:12:27 AM UTC+8, JayShaffstall wrote:

 I'd been thinking I needed to do that between form creation and the
 accepts call, but you're right, it works even after that point.  I
 make the call to auth.register, and then modify the readonly
 attribute, and it works fine.

 Thanks!
 Jay

  --





-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Anthony


 I understand the proposed procedure is as follows:

 1. change db table field to writable
 2. make the form as needed
 3. change back db table field to not writable


First, I don't think this is the proposal. The proposal was to manipulate 
the form object itself after the form is created, but before it is 
serialized in the view (i.e., set the HTML readonly attribute of the 
input widget).

Second, even something like the above wouldn't be a problem for concurrent 
users, as the above would all happen within a single request and therefore 
only apply to that one request. Setting a field to writable in one request 
does not affect it another request.

Anthony

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread amit


On Tuesday, July 17, 2012 5:29:51 PM UTC+8, Anthony wrote:

 I understand the proposed procedure is as follows:

 1. change db table field to writable
 2. make the form as needed
 3. change back db table field to not writable


 First, I don't think this is the proposal. The proposal was to manipulate 
 the form object itself after the form is created, but before it is 
 serialized in the view (i.e., set the HTML readonly attribute of the 
 input widget).


Yes, this will work fine. 

Sorry, I was referring to 

db.table.field.writable = False # change the field to writable false
 

 Second, even something like the above wouldn't be a problem for concurrent 
 users, as the above would all happen within a single request and therefore 
 only apply to that one request. Setting a field to writable in one request 
 does not affect it another request.


I am not sure if I understand this for db.table.field.writable. The change 
is occurring within the shared DAL object. Is it not? 

Best Regards
-Amit
 

-- 





[web2py] Change in behaviour of cache

2012-07-17 Thread marius.v.niekerk
I have some code that works as follows

@cache('key', 60, cache_model=cache.ram)
@cache('key', 60, cache_model=cache.disk)
def f()
   do stuff
  return dict()

I do the dual cache thing since the ram cache is not shared between 
processes that get spawned by Apache.

The recent changes to gluon/cache.py involving 

particularly 

File C:\src\web2py\gluon\cache.py, line 477, in tmp
action.__name___ = func.__name__
AttributeError: 'CacheAction' object has no attribute '__name__'

causes this to fail since the first @cache is a cache of a CacheAction 
which by this stage does not yet have a __name__

I've added a __name__ = 'dummy' to the CacheAction __init__ but that feels 
like a bad solution.

So
Suggestions?

regards
Marius

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Anthony


 Sorry, I was referring to 

 db.table.field.writable = False # change the field to writable false
  

 Second, even something like the above wouldn't be a problem for 
 concurrent users, as the above would all happen within a single request and 
 therefore only apply to that one request. Setting a field to writable in 
 one request does not affect it another request.


 I am not sure if I understand this for db.table.field.writable. The change 
 is occurring within the shared DAL object. Is it not?


No, the DAL object is not shared. Each request happens in a new thread, and 
all the objects generated in the app code are specific to that request and 
thread. The database itself is shared and accessible from multiple 
requests, but the web2py objects defined in the app code are not. If the 
writable attribute of a field is set in one request, that does not affect 
its status in another request.

Anthony 

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Amit Kumar
On Tue, Jul 17, 2012 at 6:15 PM, Anthony abasta...@gmail.com wrote:

 Sorry, I was referring to

 db.table.field.writable = False # change the field to writable false


 Second, even something like the above wouldn't be a problem for
 concurrent users, as the above would all happen within a single request and
 therefore only apply to that one request. Setting a field to writable in
 one request does not affect it another request.


 I am not sure if I understand this for db.table.field.writable. The
 change is occurring within the shared DAL object. Is it not?


 No, the DAL object is not shared. Each request happens in a new thread,
 and all the objects generated in the app code are specific to that request
 and thread. The database itself is shared and accessible from multiple
 requests, but the web2py objects defined in the app code are not. If the
 writable attribute of a field is set in one request, that does not affect
 its status in another request.


Got it! Thanks for clarifying.




-- 





[web2py] Re: Need a little help with DAL

2012-07-17 Thread Aurelijus Useckas
I've tried to erase all fields, but still with no success :( yep, SQLite

On Tuesday, July 17, 2012 11:15:02 AM UTC+3, Anthony wrote:

 Are you using SQLite? Did you initially forget to define workers as an 
 integer field, enter some data, and then convert it to an integer field? 
 What happens if you start with a fresh db?

 Anthony

 On Tuesday, July 17, 2012 3:55:35 AM UTC-4, Aurelijus Useckas wrote:

 Yes, it really acts like str. I'm using the nightly build 1.99.7 dev. 
 Could it be because of dev?

 here's all of the db definition:

 db.define_table('company',
 Field('title', label='Pavadinimas', unique=True),
 Field('CEO', label='Generalinis dir.'),
 Field('code', 'integer', label='Įmonės kodas',unique=True, 
 default=None),
 Field('revenue', 'integer', label='Metinė apyvarta'),
 Field('workers', 'integer', label='Darbuotojų skaičius'),
 # Field('logo', 'upload', label='Įmonės logo'),
 Field('produce_tag', db.tag, 'list:string', label='Produkcija', 
 default=None),
 Field('produce', label='Produkcija (smulkiau)'),
 Field('Email', default=None, notnull=False),
 Field('Tel'),
 Field('Fax'),
 Field('www'),
 Field('City', db.city, 'list:reference city', label='Miestas'),
 Field('address', label='Adresas'),
 Field('extra_contacts', 'boolean', label='Pridėti kontakt. duomenų'),
 Field('extra_contacts_2', 'boolean', label='Pridėti kontakt. 
 duomenų'),
 Field('name_1', label='Vardas'),
 Field('pareigos_1', label='Pareigos'),
 Field('tel_1', label='Papildomas tel.'),
 Field('email_1', label='Papildomas el. paštas'),
 Field('name_2', label='Vardas'),
 Field('pareigos_2', label='Pareigos'),
 Field('tel_2', label='Papildomas tel.'),
 Field('email_2', label='Papildomas el. paštas'),
 Field('Association',  db.asoc, label='Priklauso asociacijai'),
 Field('other', 'text', label='Papildoma info'),
 Field('submited_at', 'datetime', default=request.now, writable=False, 
 readable=False),
 Field('submited_by', db.auth_user, default=auth.user_id, 
 writable=False, readable=False),
 Field('updated_at', 'datetime', update=request.now, writable=False, 
 readable=False),
 Field('updated_by', db.auth_user, update=auth.user_id, 
 writable=False, readable=False),
 Field('exports_wants_to', 'list:reference countries', label='Domina 
 šalys'),
   #  Field('exports_or_not', 'boolean', label = 'Ar eksportuoja?'),
 Field('exports_to', 'list:reference countries', label='Eksportuoja 
 į', required=False),
   #  Field('imports_or_not', 'boolean', label = 'Ar Importuoja?'),
 Field('imports_from', 'list:reference countries', label='Importuoja 
 iš', required=False),
 format = '%(title)s')

 in order to test the selection, I use web2py DB environment. Query: 
 db.company.workers40
 acts like comparing strings.. wonder why :/




 On Tuesday, July 17, 2012 9:37:20 AM UTC+3, pbreit wrote:

 Looks like it is comparing them as strings. As others noted, need to see 
 code.



-- 





[web2py] Re: Need a little help with DAL

2012-07-17 Thread Anthony
Note, SQLite cannot drop fields -- see 
http://web2py.com/books/default/chapter/29/6#Fixing-broken-migrations. How 
about if you create a fresh database (i.e., delete everything from the 
databases folder and start from scratch)?

On Tuesday, July 17, 2012 6:27:52 AM UTC-4, Aurelijus Useckas wrote:

 I've tried to erase all fields, but still with no success :( yep, SQLite

 On Tuesday, July 17, 2012 11:15:02 AM UTC+3, Anthony wrote:

 Are you using SQLite? Did you initially forget to define workers as an 
 integer field, enter some data, and then convert it to an integer field? 
 What happens if you start with a fresh db?

 Anthony

 On Tuesday, July 17, 2012 3:55:35 AM UTC-4, Aurelijus Useckas wrote:

 Yes, it really acts like str. I'm using the nightly build 1.99.7 dev. 
 Could it be because of dev?

 here's all of the db definition:

 db.define_table('company',
 Field('title', label='Pavadinimas', unique=True),
 Field('CEO', label='Generalinis dir.'),
 Field('code', 'integer', label='Įmonės kodas',unique=True, 
 default=None),
 Field('revenue', 'integer', label='Metinė apyvarta'),
 Field('workers', 'integer', label='Darbuotojų skaičius'),
 # Field('logo', 'upload', label='Įmonės logo'),
 Field('produce_tag', db.tag, 'list:string', label='Produkcija', 
 default=None),
 Field('produce', label='Produkcija (smulkiau)'),
 Field('Email', default=None, notnull=False),
 Field('Tel'),
 Field('Fax'),
 Field('www'),
 Field('City', db.city, 'list:reference city', label='Miestas'),
 Field('address', label='Adresas'),
 Field('extra_contacts', 'boolean', label='Pridėti kontakt. duomenų'),
 Field('extra_contacts_2', 'boolean', label='Pridėti kontakt. 
 duomenų'),
 Field('name_1', label='Vardas'),
 Field('pareigos_1', label='Pareigos'),
 Field('tel_1', label='Papildomas tel.'),
 Field('email_1', label='Papildomas el. paštas'),
 Field('name_2', label='Vardas'),
 Field('pareigos_2', label='Pareigos'),
 Field('tel_2', label='Papildomas tel.'),
 Field('email_2', label='Papildomas el. paštas'),
 Field('Association',  db.asoc, label='Priklauso asociacijai'),
 Field('other', 'text', label='Papildoma info'),
 Field('submited_at', 'datetime', default=request.now, 
 writable=False, readable=False),
 Field('submited_by', db.auth_user, default=auth.user_id, 
 writable=False, readable=False),
 Field('updated_at', 'datetime', update=request.now, writable=False, 
 readable=False),
 Field('updated_by', db.auth_user, update=auth.user_id, 
 writable=False, readable=False),
 Field('exports_wants_to', 'list:reference countries', label='Domina 
 šalys'),
   #  Field('exports_or_not', 'boolean', label = 'Ar eksportuoja?'),
 Field('exports_to', 'list:reference countries', label='Eksportuoja 
 į', required=False),
   #  Field('imports_or_not', 'boolean', label = 'Ar Importuoja?'),
 Field('imports_from', 'list:reference countries', label='Importuoja 
 iš', required=False),
 format = '%(title)s')

 in order to test the selection, I use web2py DB environment. Query: 
 db.company.workers40
 acts like comparing strings.. wonder why :/




 On Tuesday, July 17, 2012 9:37:20 AM UTC+3, pbreit wrote:

 Looks like it is comparing them as strings. As others noted, need to 
 see code.



-- 





[web2py] Re: IntegrityError: column email is not unique

2012-07-17 Thread Remco K
Hi Massimo,

Thanks for your (quick) answer! I've created an issue for this: 
http://code.google.com/p/web2py/issues/detail?id=900

I'll try to implement the modern approach and the 'requires work-around'

Remco

On Tuesday, July 17, 2012 4:03:20 AM UTC+2, Massimo Di Pierro wrote:

 For the time being... remove unique=True and use 
 requires=(IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email'))

 On Monday, July 16, 2012 9:01:54 PM UTC-5, Massimo Di Pierro wrote:

 This is a bug. The archive function creates a an auxiliary table to store 
 copies of the current record. 
 It reproduces the same table structure as your table including 
 (incorrectly) the unique attribute. 
 This fails when you insert ore than one revision.

 Please open a ticket on google code. This is also an issue with the more 
 modern approach 

 auth.enable_record_versioning(db)


 On Monday, July 16, 2012 4:54:54 PM UTC-5, Remco K wrote:

 Hi everyone,

 I got stuck in creating an update form for an auth_user.

 In the auth_user table i made an extra field:

 Field('email', length=128, default='', unique=True, notnull=True),

 Now everytime i try to update the user information (the last name) i get 
 the error:

 IntegrityError: column email is not unique

 I try to combine updating the user information with creating an archive 
 entry for the previous entry:

 _id = db.auth_user(request.args(0)) or redirect(URL('index'))
 form = SQLFORM(db.auth_user, _id)
 if form.process(onsuccess=auth.archive).accepted:

 This method works for an other table which doesnt have an Field with 
 Unique=True but not for this table with this Unique=True value.

 Someone who can help me out a bit?

 Thanks in advance!
 Remco



-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread wdtatenh
When I go through the exercise of re-tooling this site I will catalog what 
I did wrong and what I had to do get it right based on the input provided 
and perhaps it  will be some benefit to others who won't make the same 
mistakes I made.  :)

-- 





Re: [web2py] web2py DAL connection failing in Apache?

2012-07-17 Thread Osman Masood
Thanks for the response! Actually, the problem was fixed by updating 
mod_wsgi from 2.8 to 3.3 (the latest version). I'm using Ubuntu, BTW.

Thanks

On Sunday, July 8, 2012 4:55:51 PM UTC-7, Ovidio Marinho wrote:

 have you ever tried 

 #sudo /etc/init.d/apache2 stop
 #sudo /etc/init.d/apache2 start

 if this does not work, use this:


 http://www.web2pyslices.com/slice/show/1356/setup-web2pyapachesslmod-wsgipostgresql-in-few-seconds
  

   


Ovidio Marinho Falcao Neto
 Web Developer
  ovidio...@gmail.com 
   ovidiomari...@itjp.net.br
  ITJP - itjp.net.br
83   8826 9088 - Oi
83   9334 0266 - Claro
 Brasil
   



 2012/7/8 Osman Masood oamas...@gmail.com


 Hi,
 I'm running web2py from an Apache server (in production), and it 
 occasionally shuts down, i.e. fails to connect to the DAL until Apache is 
 reset with 'sudo service apache2 restart'. The version of web2py is: 
  Version 2.0.0 (2012-05-16 18:23:15) dev
 Running on Apache/2.2.14 (Ubuntu)


 Here's the traceback:

 TRACEBACK

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 27.
 28.
 29.

 Traceback (most recent call last):


   File /home/www-data/web2py/gluon/main.py, line 538, in wsgibase


 session._try_store_on_disk(request, response)


   File /home/www-data/web2py/gluon/globals.py, line 649, in 
 _try_store_on_disk


 cPickle.dump(dict(self), response.session_file)


   File /home/V_ENVS/Web2py/lib/python2.6/copy_reg.py, line 74, in 
 _reduce_ex


 getstate = self.__getstate__
   File /home/www-data/web2py/gluon/dal.py, line 6918, in __getattr__


 self.__allocate()
   File /home/www-data/web2py/gluon/dal.py, line 6911, in __allocate


 self._record = self._table[int(self)]


   File /home/www-data/web2py/gluon/dal.py, line 7186, in __getitem__


 return self._db(self._id == key).select(limitby=(0,1)).first()


   File /home/www-data/web2py/gluon/dal.py, line 8189, in select


 return adapter.select(self.query,fields,attributes)


   File /home/www-data/web2py/gluon/dal.py, line 1410, in select


 rows = response(sql)
   File /home/www-data/web2py/gluon/dal.py, line 1400, in response


 self.execute(sql)
   File /home/www-data/web2py/gluon/dal.py, line 1489, in execute


 return self.log_execute(*a, **b)


   File /home/www-data/web2py/gluon/dal.py, line 1483, in log_execute


 ret = self.cursor.execute(*a, **b)


   File /home/www-data/web2py/gluon/contrib/pymysql/cursors.py, line 108, 
 in execute


 self.errorhandler(self, exc, value)


   File /home/www-data/web2py/gluon/contrib/pymysql/connections.py, line 
 184, in defaulterrorhandler


 raise errorclass, errorvalue
 InterfaceError: (0, '')


 Any idea about what's going on? Thanks for all the help guys! 




-- 





Re: [web2py] Re: [web2py-dev] Asyncronous Application Sync

2012-07-17 Thread José Luis Redrejo Rodríguez
I had to to do something similar a couple of years ago (between
several waste water plants and the control center) and ended using a
similar approach to what nick name said:
- In the control center I used mysql
- In the waste water plants I used a sqlite database per day
(initializating the database every day at 00:00 and backing up the
previous file in another directory)
- Every record in the plants had a datetime stamp
- The plants just send the sqlite files gzipped (and splitted in small
bits because my connection was really bad) and the control center just
received the bits, joined them, unziped the sqlite files and import
their data into mysql using the plant-datetime as key to avoid
duplicated items.


Regards.
José L.


2012/7/13 nick name i.like.privacy@gmail.com:
 On Wednesday, July 11, 2012 6:26:00 PM UTC-4, Massimo Di Pierro wrote:

 I am planning to improve this functionality but it would help to know if
 it works for you as it is and what problems you encounter with it.


 I originally used the export-to-csv, but a few months ago, I switched to
 just shipping the sqlite files (actually the whole databases directory
 with .table files); That handles everything like types, blobs, fractional
 seconds in the database, etc, without any conversion. It is also faster when
 processing the files at the other end - especially if you have indices and
 have a non-trivial import requirement. It should be opened with
 auto_import=True on the receiving end, of course.

 (you'd still need an export to a new .sqlite database, or use sqlite's
 backup command, to make sure you get the database in a consistent state --
 unless you know that the database is in a fully committed state when you
 send it).

 If the connection is not reliable, the classic solution is a queuing system
 like MSMQ / MQSeries / RabbitMQ (which is often non-trivial to manage), but
 you could just export (csv, .sqlite, whatever) to a dropbox-or-similar
 synced directory (e.g. sparkleshare lets you own the repository and not rely
 on dropbox.com servers), and import it on the server side when the file has
 changed. much, much simpler and works just as well for one way communication
 that does not require the lowest possible latency.

-- 





[web2py] Adding cancel button - form submission

2012-07-17 Thread Mathias
Hello,

I have added a CANCEL button to my SQLFORM.

Form submission prevents the correct working of it.

I have tried to avoid form submission with this code :


def new_guest_contact():
   form = SQLFORM.factory(...)   
   
  
 
form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax(%s,[],:eval);return
 
false' %URL(r=request,f='new_contact')))
   
   if form.process().accepted:
...
redirect(URL(r=request,f='new_contact_part')) 
   elif form.errors:
   response.flash = 'form has errors'
   else:
   response.flash = 'Create new guest'
   
   return dict(form=form)  


If I click the cancel button now, nothing happens anymore.


Any help is welcome.

Thanks


Mathias

-- 





[web2py] Re: TAKE 2: Web2py + (jython / modjy) + Tomcat 6

2012-07-17 Thread Duncan
I know this thread is a little old, but I really agree getting web2py going 
on a servlet container would be awesome.

I followed Andrew's excellent example from the previous post, BUT i worked 
around the root url redirect issue by simply renaming the web2py folder to 
'ROOT' (which, by convention, Tomcat will then serve from '/')

Like this:
Tomcat_HOME 
   |__webapps 
|__ROOT 
| 
|__WEB-INF  

Anyway, I think I got closer than Andrew's attempt because (yay?) I got a 
real web2py ticket error. The contents of the web2pyticket was:

(dp1
S'code'
p2
S''
p3
sS'output'
p4
S''
p5
sS'snapshot'
p6
(dp7
sS'layer'
p8
S'Framework'
p9
sS'traceback'
p10
S'Traceback (most recent call last):\n  File 
C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\main.py,
 
line 475, in wsgibase\nsession.connect(request, response)\n  File 
C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\main.py,
 
line 475, in wsgibase\nsession.connect(request, response)\n  File 
C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\globals.py,
 
line 507, in connect\nresponse.cookies[response.session_id_name] = 
response.session_id\n  File C:\\jython2.5.2\\Lib\\Cookie.py, line 579, in 
__setitem__\nself.__set(key, rval, cval)\n  File 
C:\\jython2.5.2\\Lib\\Cookie.py, line 572, in _BaseCookie__set\n   
 M.set(key, real_value, coded_value)\n  File 
C:\\jython2.5.2\\Lib\\Cookie.py, line 450, in set\nif  != 
translate(key, idmap, LegalChars):\n  File 
C:\\jython2.5.2\\Lib\\string.py, line 491, in translate\nreturn 
s.translate(table, deletions)\nTypeError: translate() takes 2 arguments (2 
given)\n'
p11
s.

Looks like there is something wrong with the cookie setting? Any other 
ideas out there?

Thanks for any tips. 

Once again -- it feels like we are getting closer (albeit slowly) to having 
a working modjy/Tomcat deploy-ready web2py.war -- that would be sooo 
awesome!


-- 





Re: [web2py] Adding cancel button - form submission

2012-07-17 Thread Richard Vézina
Maybe this could be enough??

{{=A(T('cancel'),_href=javascript:void(history.go(-1)))}}

It will bring you back to the precedent page, in my use case, I direct the
user on a crud.read page where the user can edit the record (crud.update).
Then if don't want make change anymore there is a cancel hyperlink that
bring back the user on the crud.read page.

Richard

On Tue, Jul 17, 2012 at 8:13 AM, Mathias mathias.v.da...@gmail.com wrote:

 Hello,

 I have added a CANCEL button to my SQLFORM.

 Form submission prevents the correct working of it.

 I have tried to avoid form submission with this code :


 def new_guest_contact():
form = SQLFORM.factory(...)


  
 form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax(%s,[],:eval);return
 false' %URL(r=request,f='new_contact')))

if form.process().accepted:
 ...
 redirect(URL(r=request,f='new_contact_part'))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'Create new guest'

return dict(form=form)


 If I click the cancel button now, nothing happens anymore.


 Any help is welcome.

 Thanks


 Mathias

  --





-- 





Re: [web2py] Re: [web2py-dev] Asyncronous Application Sync

2012-07-17 Thread Bruno Rocha
I would set a Dropbox shared folder on both machines (there is a server
dropbox.py for linux)

So create a script which copies the .sqlite in to Dropbox folder.

On city machine a scheduled task read records on sqlite and import new
records directly to mysql.

You are going to need a 'signal' field on every record. I am using 'N' for
new, 'U' for updated, 'D' to deactivate.

In this scenario it is not a good idea to delete any data, so use the
is_active bool to change the status for deactivated.

In the other side you can have the city machine exporting on to the  sqlite
database the records that should go to the forest.

Also, you need to set a sqlite-status table, or file to be readed on both
sides before any transaction occurs. (to avoid race condition)

The better solution would be a mysql master-slave structure. But if yoi
have connection issues you can go with a home made queue.

http://zerp.ly/rochacbruno
Em 17/07/2012 08:49, José Luis Redrejo Rodríguez jredr...@debian.org
escreveu:

 I had to to do something similar a couple of years ago (between
 several waste water plants and the control center) and ended using a
 similar approach to what nick name said:
 - In the control center I used mysql
 - In the waste water plants I used a sqlite database per day
 (initializating the database every day at 00:00 and backing up the
 previous file in another directory)
 - Every record in the plants had a datetime stamp
 - The plants just send the sqlite files gzipped (and splitted in small
 bits because my connection was really bad) and the control center just
 received the bits, joined them, unziped the sqlite files and import
 their data into mysql using the plant-datetime as key to avoid
 duplicated items.


 Regards.
 José L.


 2012/7/13 nick name i.like.privacy@gmail.com:
  On Wednesday, July 11, 2012 6:26:00 PM UTC-4, Massimo Di Pierro wrote:
 
  I am planning to improve this functionality but it would help to know if
  it works for you as it is and what problems you encounter with it.
 
 
  I originally used the export-to-csv, but a few months ago, I switched
 to
  just shipping the sqlite files (actually the whole databases directory
  with .table files); That handles everything like types, blobs, fractional
  seconds in the database, etc, without any conversion. It is also faster
 when
  processing the files at the other end - especially if you have indices
 and
  have a non-trivial import requirement. It should be opened with
  auto_import=True on the receiving end, of course.
 
  (you'd still need an export to a new .sqlite database, or use sqlite's
  backup command, to make sure you get the database in a consistent state
 --
  unless you know that the database is in a fully committed state when you
  send it).
 
  If the connection is not reliable, the classic solution is a queuing
 system
  like MSMQ / MQSeries / RabbitMQ (which is often non-trivial to manage),
 but
  you could just export (csv, .sqlite, whatever) to a dropbox-or-similar
  synced directory (e.g. sparkleshare lets you own the repository and not
 rely
  on dropbox.com servers), and import it on the server side when the file
 has
  changed. much, much simpler and works just as well for one way
 communication
  that does not require the lowest possible latency.

 --





-- 





Re: [web2py] Adding cancel button - form submission

2012-07-17 Thread Mathias Van Daele
Thanks for your solution Richard !

I am still looking for a solution with a button component...

Mathias

2012/7/17 Richard Vézina ml.richard.vez...@gmail.com:
 Maybe this could be enough??

 {{=A(T('cancel'),_href=javascript:void(history.go(-1)))}}

 It will bring you back to the precedent page, in my use case, I direct the
 user on a crud.read page where the user can edit the record (crud.update).
 Then if don't want make change anymore there is a cancel hyperlink that
 bring back the user on the crud.read page.

 Richard


 On Tue, Jul 17, 2012 at 8:13 AM, Mathias mathias.v.da...@gmail.com wrote:

 Hello,

 I have added a CANCEL button to my SQLFORM.

 Form submission prevents the correct working of it.

 I have tried to avoid form submission with this code :


 def new_guest_contact():
form = SQLFORM.factory(...)


 form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax(%s,[],:eval);return
 false' %URL(r=request,f='new_contact')))

if form.process().accepted:
 ...
 redirect(URL(r=request,f='new_contact_part'))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'Create new guest'

return dict(form=form)


 If I click the cancel button now, nothing happens anymore.


 Any help is welcome.

 Thanks


 Mathias

 --





 --




-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Bruce Wade
Yeah that is what I was just sharing. My site was slow I have over 200
models now.

My setup is:
models/controller/action/db.py - In here it includes a function
define_tables(db, tables = [], migrate=False, fake_migrate=False)

The define_tables is a function that I put somewhere else out side of
models and it is if statements checking:
First if the table in tables already exists in db.tables if so skip the
table generation. Other wise checks if I have a definitions for that table
if I do define it.

This has helped increase the speed of the site a lot. I am still doing some
other major optimizations like just hitting the front page of the site does
53 requests to the server I want to drop that at least in half.

On Tue, Jul 17, 2012 at 4:33 AM, wdtatenh wdt...@comcast.net wrote:

 When I go through the exercise of re-tooling this site I will catalog what
 I did wrong and what I had to do get it right based on the input provided
 and perhaps it  will be some benefit to others who won't make the same
 mistakes I made.  :)

  --







-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread lyn2py
Hello guys, still need help with this... thanks.

On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to find an 
 answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?



-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread rdodev
The fact that you don't have sudo installed tells me you might have chosen 
the wrong instance type. I'd say stop that instance (unless you have 
critical data or code on that box) and start a new micro 64-bit micro 
instance with 64-bit Ubuntu. Once you are in the instance via ssh, run: 
sudo script_name_here.sh it should prompt you for your password, and then 
proceed to install.



On Tuesday, July 17, 2012 10:07:23 AM UTC-4, lyn2py wrote:

 Hello guys, still need help with this... thanks.

 On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to find an 
 answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?



-- 





[web2py] Re: How to manage redundant files for application version control

2012-07-17 Thread Yarin
Here's a slice with .gitignore files for app-level and site-level repos:
http://www.web2pyslices.com/slice/show/1532/gitignore

On Friday, April 27, 2012 2:08:18 PM UTC-4, mrtn wrote:


 Hi,

 I'm using Git (Github) to manage my app development in Web2py. I noticed 
 that each time when I make a commit lots of runtime generated files such as 
 error tickets, logs, db files, etc are picked up by Git, which probably 
 shouldn't be checked in as part of the codebase. These files exist at both 
 /web2py and /web2py/applications/myapp level, and make extra work of of 
 picking them out when committing.

 I wonder how other Web2py developers manage their code (especially using 
 Git), and how you guys deal with such unnecessary files. Thanks. 


-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread lyn2py
rdodev, 

sudo is installed. I know that because 
sudo apt-get update
works.

The instance is, in fact, a micro, 64-bit Ubuntu!

I ran both 
sudo setup-web2py-ubuntu.sh

and
sudo ./setup-web2py-ubuntu.sh


The error that came up is:
sudo: setup-web2py-ubuntu.sh: command not found

no password prompt. If it comes up, what should be the password?

Sorry if this sounds easy peasy to you, I only know minimum commands and 
understand a little. Just following whatever instructions are given.

Pls help. If it is of any consequence, the image used is Ubuntu 12.x


On Tuesday, July 17, 2012 10:15:45 PM UTC+8, rdodev wrote:

 The fact that you don't have sudo installed tells me you might have chosen 
 the wrong instance type. I'd say stop that instance (unless you have 
 critical data or code on that box) and start a new micro 64-bit micro 
 instance with 64-bit Ubuntu. Once you are in the instance via ssh, run: 
 sudo script_name_here.sh it should prompt you for your password, and then 
 proceed to install.



 On Tuesday, July 17, 2012 10:07:23 AM UTC-4, lyn2py wrote:

 Hello guys, still need help with this... thanks.

 On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to find 
 an answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?



-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread rdodev
First, let's check the file is in the same directory you are currently at: 
type 'ls -al' (w/o quotes) see if the script is in the list.
Second, type 'sudo chmod +x scrip_name.sh' (again, no quotes)
Third, try 'sudo ./script_name.sh' 


On Tuesday, July 17, 2012 10:43:32 AM UTC-4, lyn2py wrote:

 rdodev, 

 sudo is installed. I know that because 
 sudo apt-get update
 works.

 The instance is, in fact, a micro, 64-bit Ubuntu!

 I ran both 
 sudo setup-web2py-ubuntu.sh

 and
 sudo ./setup-web2py-ubuntu.sh


 The error that came up is:
 sudo: setup-web2py-ubuntu.sh: command not found

 no password prompt. If it comes up, what should be the password?

 Sorry if this sounds easy peasy to you, I only know minimum commands and 
 understand a little. Just following whatever instructions are given.

 Pls help. If it is of any consequence, the image used is Ubuntu 12.x


 On Tuesday, July 17, 2012 10:15:45 PM UTC+8, rdodev wrote:

 The fact that you don't have sudo installed tells me you might have 
 chosen the wrong instance type. I'd say stop that instance (unless you have 
 critical data or code on that box) and start a new micro 64-bit micro 
 instance with 64-bit Ubuntu. Once you are in the instance via ssh, run: 
 sudo script_name_here.sh it should prompt you for your password, and then 
 proceed to install.



 On Tuesday, July 17, 2012 10:07:23 AM UTC-4, lyn2py wrote:

 Hello guys, still need help with this... thanks.

 On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to find 
 an answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), are 
 you root?



-- 





Re: [web2py] Re: web2py on EC2

2012-07-17 Thread Jonathan Lundell
On 17 Jul 2012, at 7:43 AM, lyn2py wrote:
 rdodev, 
 
 sudo is installed. I know that because
 sudo apt-get update
 works.
 
 The instance is, in fact, a micro, 64-bit Ubuntu!
 
 I ran both 
 sudo setup-web2py-ubuntu.sh
 
 and
 sudo ./setup-web2py-ubuntu.sh
 
 
 The error that came up is:
 sudo: setup-web2py-ubuntu.sh: command not found
 
 no password prompt. If it comes up, what should be the password?

The system's root password.

Please try pwd; ls -l setup-web2py-ubuntu.sh (you're in the web2py scripts 
directory, right?).

 
 Sorry if this sounds easy peasy to you, I only know minimum commands and 
 understand a little. Just following whatever instructions are given.
 
 Pls help. If it is of any consequence, the image used is Ubuntu 12.x
 


-- 





Re: [web2py] Adding cancel button - form submission

2012-07-17 Thread Mathias Van Daele
I found a good solution for me :

form[0][-1][1].append(TAG.INPUT(_value='Cancel',_type=button,_onclick=window.location='%s';%URL(r=request,f='new_contact')))

Mathias


2012/7/17 Mathias Van Daele mathias.v.da...@gmail.com:
 Thanks for your solution Richard !

 I am still looking for a solution with a button component...

 Mathias

 2012/7/17 Richard Vézina ml.richard.vez...@gmail.com:
 Maybe this could be enough??

 {{=A(T('cancel'),_href=javascript:void(history.go(-1)))}}

 It will bring you back to the precedent page, in my use case, I direct the
 user on a crud.read page where the user can edit the record (crud.update).
 Then if don't want make change anymore there is a cancel hyperlink that
 bring back the user on the crud.read page.

 Richard


 On Tue, Jul 17, 2012 at 8:13 AM, Mathias mathias.v.da...@gmail.com wrote:

 Hello,

 I have added a CANCEL button to my SQLFORM.

 Form submission prevents the correct working of it.

 I have tried to avoid form submission with this code :


 def new_guest_contact():
form = SQLFORM.factory(...)


 form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax(%s,[],:eval);return
 false' %URL(r=request,f='new_contact')))

if form.process().accepted:
 ...
 redirect(URL(r=request,f='new_contact_part'))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'Create new guest'

return dict(form=form)


 If I click the cancel button now, nothing happens anymore.


 Any help is welcome.

 Thanks


 Mathias

 --





 --




-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread lyn2py
Thank you it works!

The different thing I did was 
sudo chmod +x setup-web2py-ubuntu.sh

instead of
chmod +x setup-web2py-ubuntu.sh

(which were the instructions at 
http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2 )

Although, when I did 
ls -al

both directories looked the same to me (the permissions on setup-web2py-
ubuntu.sh file appear to be the same to me)


On Tuesday, July 17, 2012 10:47:49 PM UTC+8, rdodev wrote:

 First, let's check the file is in the same directory you are currently at: 
 type 'ls -al' (w/o quotes) see if the script is in the list.
 Second, type 'sudo chmod +x scrip_name.sh' (again, no quotes)
 Third, try 'sudo ./script_name.sh' 


 On Tuesday, July 17, 2012 10:43:32 AM UTC-4, lyn2py wrote:

 rdodev, 

 sudo is installed. I know that because 
 sudo apt-get update
 works.

 The instance is, in fact, a micro, 64-bit Ubuntu!

 I ran both 
 sudo setup-web2py-ubuntu.sh

 and
 sudo ./setup-web2py-ubuntu.sh


 The error that came up is:
 sudo: setup-web2py-ubuntu.sh: command not found

 no password prompt. If it comes up, what should be the password?

 Sorry if this sounds easy peasy to you, I only know minimum commands and 
 understand a little. Just following whatever instructions are given.

 Pls help. If it is of any consequence, the image used is Ubuntu 12.x


 On Tuesday, July 17, 2012 10:15:45 PM UTC+8, rdodev wrote:

 The fact that you don't have sudo installed tells me you might have 
 chosen the wrong instance type. I'd say stop that instance (unless you have 
 critical data or code on that box) and start a new micro 64-bit micro 
 instance with 64-bit Ubuntu. Once you are in the instance via ssh, run: 
 sudo script_name_here.sh it should prompt you for your password, and then 
 proceed to install.



 On Tuesday, July 17, 2012 10:07:23 AM UTC-4, lyn2py wrote:

 Hello guys, still need help with this... thanks.

 On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to find 
 an answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?



-- 





[web2py] Re: How to start a thread upon starting of webserver?

2012-07-17 Thread Massimo Di Pierro
Do you use rocket (the built-in web server) or apache?

On Monday, 16 July 2012 23:42:49 UTC-5, Amit wrote:

 Hi,
 I have one timer thread which has to start once when web sever starts very 
 first time and stop when web server stops, means it should be running 
 continuously irrespective of how many users interacting with the 
 application so there is only one instance of this thread running though out 
 life of the application , it is common for all users who are accessing the 
 application.

 How to achieve it in web2py?



-- 





[web2py] Re: web2py on EC2

2012-07-17 Thread rdodev
Cool. Glad to help.

On Tuesday, July 17, 2012 11:10:43 AM UTC-4, lyn2py wrote:

 Thank you it works!

 The different thing I did was 
 sudo chmod +x setup-web2py-ubuntu.sh

 instead of
 chmod +x setup-web2py-ubuntu.sh

 (which were the instructions at 
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2 )

 Although, when I did 
 ls -al

 both directories looked the same to me (the permissions on setup-web2py-
 ubuntu.sh file appear to be the same to me)


 On Tuesday, July 17, 2012 10:47:49 PM UTC+8, rdodev wrote:

 First, let's check the file is in the same directory you are currently 
 at: type 'ls -al' (w/o quotes) see if the script is in the list.
 Second, type 'sudo chmod +x scrip_name.sh' (again, no quotes)
 Third, try 'sudo ./script_name.sh' 


 On Tuesday, July 17, 2012 10:43:32 AM UTC-4, lyn2py wrote:

 rdodev, 

 sudo is installed. I know that because 
 sudo apt-get update
 works.

 The instance is, in fact, a micro, 64-bit Ubuntu!

 I ran both 
 sudo setup-web2py-ubuntu.sh

 and
 sudo ./setup-web2py-ubuntu.sh


 The error that came up is:
 sudo: setup-web2py-ubuntu.sh: command not found

 no password prompt. If it comes up, what should be the password?

 Sorry if this sounds easy peasy to you, I only know minimum commands and 
 understand a little. Just following whatever instructions are given.

 Pls help. If it is of any consequence, the image used is Ubuntu 12.x


 On Tuesday, July 17, 2012 10:15:45 PM UTC+8, rdodev wrote:

 The fact that you don't have sudo installed tells me you might have 
 chosen the wrong instance type. I'd say stop that instance (unless you 
 have 
 critical data or code on that box) and start a new micro 64-bit micro 
 instance with 64-bit Ubuntu. Once you are in the instance via ssh, run: 
 sudo script_name_here.sh it should prompt you for your password, and then 
 proceed to install.



 On Tuesday, July 17, 2012 10:07:23 AM UTC-4, lyn2py wrote:

 Hello guys, still need help with this... thanks.

 On Tuesday, July 17, 2012 8:25:03 AM UTC+8, lyn2py wrote:

 I tried and it said, command not found. I did:
 sudo ./setup-web2py-ubuntu.sh

 Or how should the command be?

 Thanks for the help!


 On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:

 Run with 'sudo' in front.

 On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:

 Hi,

 I have browsed a few older threads on this but didn't manage to 
 find an answer. Hope I can get help here.

 I started an instance with Ubuntu image, per the instructions here:
 http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

 And got stuck at this command:
 ./setup-web2py-ubuntu.sh

 because Permission Denied... what should I do?

 Here is a snippet of the output:

 installing useful packages

 ==

 E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)

 E: Unable to lock directory /var/lib/apt/lists/

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?

 E: Could not open lock file /var/lib/dpkg/lock - open (13: 
 Permission denied)

 E: Unable to lock the administration directory (/var/lib/dpkg/), 
 are you root?



-- 





Re: [web2py] Re: How to build a modular menu

2012-07-17 Thread Cliff Kachinske
You are welcome.

On Tuesday, July 17, 2012 2:48:35 AM UTC-4, Johann Spies wrote:

 Thanks Jaap and Cliff.  
 It was helpful.

 Regards
 Johann
 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 





[web2py] Re: pg8000 '%' not supported in quoted string

2012-07-17 Thread Massimo Di Pierro
Can you please run a test for me?

In dal.py there are these lines:

def adapt(self,obj):
return psycopg2_adapt(obj).getquoted()

can you plase replace them with

def adapt(self,obj):
if self.driver == self.drivers.get('pg8000'):
obj = str(obj).replace('%','%%')
return psycopg2_adapt(obj).getquoted()

Does this fix the problem? This is a pg8000 bug anyway. Even if the 
workaround fixes it, it will cause problems once the bug in the driver is 
fixed.



On Tuesday, 17 July 2012 00:34:03 UTC-5, KMax wrote:

 db.py:
 db = 
 DAL('postgres:pg8000://username:u$erpas$@localhost/userdb',pool_size=10,
  check_reserved=['postgres', 'mssql', 'mysql'])
 db.define_table('mytable',Field('myfield','string'))


 default.py:
 def index():
 return dict(form=crud.create(db.mytable))


 Posting % into form gives an error.

 error attached


On Tuesday, 17 July 2012 00:34:03 UTC-5, KMax wrote:

 db.py:
 db = 
 DAL('postgres:pg8000://username:u$erpas$@localhost/userdb',pool_size=10,
  check_reserved=['postgres', 'mssql', 'mysql'])
 db.define_table('mytable',Field('myfield','string'))


 default.py:
 def index():
 return dict(form=crud.create(db.mytable))


 Posting % into form gives an error.

 error attached


-- 





[web2py] Re: KeyError on pyfpdf

2012-07-17 Thread Cliff Kachinske
Is this report to be printed?  If so, just generate a pdf.

On Saturday, July 14, 2012 4:06:33 PM UTC-4, thinkwell wrote:

 Hello everyone,

 I'm experimenting with pyfpdf with HTML formatting, but it's not going so 
 well. Is a bit buggy. For example, this code generates a KeyError: 'width'.

 {from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
 from gluon.html import *

 header = HEAD('html2pdf', _align='center')

 pets = TABLE(_border=1, _width=100%)
 pets.append(TR(TH('Dogs'),TH(Cats),TH('Snakes')))
 pets.append(TR('Collies','Tabby','Python'))
 pets.append(TR('Akitas', 'Persian', 'Garter'))

  
 class MyFPDF(FPDF, HTMLMixin):
 pass

 html2 = pets.xml()

 print html2

 pdf=MyFPDF()
 #First page
 pdf.add_page()
 pdf.write_html(html2)
 pdf.output('html2.pdf','F')}

 I
 {/usr/lib/python2.7/HTMLParser.pyc in goahead(self, end)
 156 if startswith('', i):
 157 if starttagopen.match(rawdata, i): #  + letter
 -- 158 k = self.parse_starttag(i)
 159 elif startswith(/, i):
 160 k = self.parse_endtag(i)

 /usr/lib/python2.7/HTMLParser.pyc in parse_starttag(self, i)
 322 self.handle_startendtag(tag, attrs)
 323 else:
 -- 324 self.handle_starttag(tag, attrs)
 325 if tag in self.CDATA_CONTENT_ELEMENTS:
 326 self.set_cdata_mode(tag)

 /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.pyc in 
 handle_starttag(self, tag, attrs)
 245 self.td = dict([(k.lower(), v) for k,v in 
 attrs.items()])
 246 self.th = True
 -- 247 if self.td.has_key('width'):
 248 self.table_col_width.append(self.td['width'])
 249 if tag=='thead':

 KeyError: 'width'
 }

 I tried changing line 247 to -
 {if self.td.has_key('width'):}

 But the KeyError is still getting raised. :-(

 Is  generating reports from HTML not recommended? In addition to this 
 KeyError, I've frequently gotten list out of range exceptions raised as 
 well, on what seem like the most vanilla of experiments.




-- 





[web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread Massimo Di Pierro
CRSF only works if you use SQLFORM. Do you? Then it depends on how to use 
it. The workflow is the following

1) visit the page
{{=SQLFORM().process()}} generate the html for and injects some hidden 
fields in it
2) you submit the form
{{=SQLFORM().process()}} check the hidden fields and accepts of rejects 
the submission

If you use SQLFORM (even if via ajax) you must make both calls, retrieve 
and display the hidden fields.


On Tuesday, 17 July 2012 03:21:59 UTC-5, murtaza52 wrote:

 Hi,

 We are creating our frontend using angular.js and the API layer is in 
 web2py. The web2py documentation says - 

 web2py prevents CSRF as well as accidental double submission of forms by 
 assigning a one-time random token to each form. 


 So how will that work in the instance of a pure JS frontend ? Will I need 
 to implement something on the client side to enable it ?

 The initial request will go to the web2py app, which will send back the 
 index.html, which will contain the js script as an include. This will load 
 the js interface during the initial request. After this all calls will be 
 ajax calls to the server, to return back JSON.

 Also I will be using the web2py authentication/authorization for securing 
 the API. So would I be breaking any web2py compatibly in this regard or 
 with any other security concerns ?

 Thanks,
 Murtaza 



-- 





[web2py] Re: Change in behaviour of cache

2012-07-17 Thread Massimo Di Pierro
Sorry. Should not be fixed in trunk. Thanks for reporting this problem.

On Tuesday, 17 July 2012 05:14:48 UTC-5, marius.v.niekerk wrote:

 I have some code that works as follows

 @cache('key', 60, cache_model=cache.ram)
 @cache('key', 60, cache_model=cache.disk)
 def f()
    do stuff
   return dict()

 I do the dual cache thing since the ram cache is not shared between 
 processes that get spawned by Apache.

 The recent changes to gluon/cache.py involving 

 particularly 

 File C:\src\web2py\gluon\cache.py, line 477, in tmp
 action.__name___ = func.__name__
 AttributeError: 'CacheAction' object has no attribute '__name__'

 causes this to fail since the first @cache is a cache of a CacheAction 
 which by this stage does not yet have a __name__

 I've added a __name__ = 'dummy' to the CacheAction __init__ but that feels 
 like a bad solution.

 So
 Suggestions?

 regards
 Marius


-- 





[web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Massimo Di Pierro
Doesn't 

db.table.field.writable = False
db.table.field.default = 'whatever'

do what you want?

On Thursday, 16 June 2011 13:05:34 UTC-5, JayShaffstall wrote:

 I have a situation where I need to adjust an SQLFORM field to be
 non-editable.  I can do that with .writable = False, but that seems to
 also prevents database I/O for that field.  What I'm trying to do is
 set a default that cannot be changed.

 Is there a way to set an SQLFORM field so that it appears as a label
 on the form itself, but is still writable for the database?

 For reference, I'm doing this with a field in the form returned by
 auth.register, so I cannot insert code between the form creation and
 the accepts call.  I believe I'm restricted to working with the model
 before calling auth.register, or by using custom forms.

 Jay



-- 





Re: [web2py] Re: response.js on regular requests.

2012-07-17 Thread Richard Vézina
Hello Anthony in order to do what you propose here, I mean passing
javascript code from the controller to the view by mean of return
dict(var=js), I think the only way I have to execute the passed js code is
to use eval in the view like this :

script type=text/javascript
eval({{=var}});
/script

Now, my concern is, is that secure to use javascript eval(); in this way
and is what you have in mind when you make this proposition?

Thanks

Richard

On Sun, Jun 5, 2011 at 7:43 PM, Anthony abasta...@gmail.com wrote:

 Can't you just include the relevant JS directly in the view template for
 the page, or maybe include the JS string in the dict returned by the
 controller, and insert it as a variable in the view?

 On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote:

 How do I inject javascript in my controller from a regular web request?

 I read the docs it syas response.js is executed only in a component;

 so I have a form and I would like to add JS validators.

 so I try adding to the response.js = '$(myfield).validate(**digits);'


 Of course this only works in component mode as I tried it;

 But now I have a single form page and I want this same javascript to
 work;

 How do I do that?

 Thanks.




-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread vinicius...@gmail.com

Maybe Massimo's ideia can work for you.

But don't be afraid to count on custom forms. They give us much more power.



On 07/17/2012 12:37 PM, Massimo Di Pierro wrote:

Doesn't

db.table.field.writable = False
db.table.field.default = 'whatever'

do what you want?

On Thursday, 16 June 2011 13:05:34 UTC-5, JayShaffstall wrote:

I have a situation where I need to adjust an SQLFORM field to be
non-editable.  I can do that with .writable = False, but that seems to
also prevents database I/O for that field.  What I'm trying to do is
set a default that cannot be changed.

Is there a way to set an SQLFORM field so that it appears as a label
on the form itself, but is still writable for the database?

For reference, I'm doing this with a field in the form returned by
auth.register, so I cannot insert code between the form creation and
the accepts call.  I believe I'm restricted to working with the model
before calling auth.register, or by using custom forms.

Jay

--





--





[web2py] Re: Scheduler: help us test it while learning

2012-07-17 Thread Niphlod
instructions: download the archive from 
https://github.com/niphlod/w2p_scheduler_tests/zipball/master. the zip 
contains a folder (now it is named niphlod-w2p_scheduler_tests-903ee75). 
Decompress that folder under applications and rename it to 
w2p_scheduler_tests.

That should be enough

On Monday, July 16, 2012 11:35:36 PM UTC+2, Pystar wrote:

 I downloaded the app, tried to upload and install it but it always gives 
 an error message failed to install app. I also renamed it but no changes

 On Sunday, July 15, 2012 9:02:01 PM UTC+1, Niphlod wrote:

 Maybe if you tell what issues you have we'll be able to help you .



 On Sunday, July 15, 2012 9:58:55 PM UTC+2, Pystar wrote:

 I am having issues installing the app in the web2py 2.0.0 dev version

 On Thursday, July 12, 2012 9:36:38 PM UTC+1, Niphlod wrote:

 Hello everybody, in the last month several changes were commited to the 
 scheduler, in order to improve it.
 Table schemas were changed, to add some features that were missed by 
 some users.
 On the verge of releasing web2py v.2.0.0, and seeing that the scheduler 
 potential is often missed by regular web2py users, I created a test app 
 with two main objectives: documenting the new scheduler and test the 
 features.

 App is available on github (
 https://github.com/niphlod/w2p_scheduler_tests). All you need is 
 download the trunk version of web2py, download the app and play with it.

 Current features:
 - one-time-only tasks
 - recurring tasks
 - possibility to schedule functions at a given time
 - possibility to schedule recurring tasks with a stop_time
 - can operate distributed among machines, given a database reachable 
 for all workers
 - group_names to divide tasks among different workers
 - group_names can also influence the percentage of assigned tasks to 
 similar workers
 - simple integration using modules for embedded tasks (i.e. you can 
 use functions defined in modules directly in your app or have them 
 processed in background)
 - configurable heartbeat to reduce latency: with sane defaults and not 
 t many tasks queued normally a queued task doesn't exceed 5 seconds 
 execution times
 - option to start it, process all available tasks and then die 
 automatically
 - integrated tracebacks
 - monitorable as state is saved on the db
 - integrated app environment if started as web2py.py -K
 - stop processes immediately (set them to KILL)
 - stop processes gracefully (set them to TERMINATE)
 - disable processes (set them to DISABLED)
 - functions that doesn't return results do not generate a scheduler_run 
 entry
 - added a discard_results parameter that doesn't store results no 
 matter what
 - added a uuid record to tasks to simplify checkings of unique tasks
 - task_name is not required anymore
 - you can skip passing the function to the scheduler istantiation: 
 functions can be dinamically retrieved in the app's environment

 So, your mission is:
 - test the scheduler with the app and familiarize with it
 Secondary mission is:
 - report any bug you find here or on github (
 https://github.com/niphlod/w2p_scheduler_tests/issues)
 - propose new examples to be embedded in the app, or correct the 
 current docs (English is not my mother tongue) 

 Once approved, docs will be probably embedded in the book (
 http://web2py.com/book)

 Feel free to propose features you'd like to see in the scheduler, I 
 have some time to spend implementing it.





-- 





[web2py] Web2py on EC2: site does not appear

2012-07-17 Thread lyn2py
Another issue O.O
 
Now that the whole script has installed, and I followed through with the 
rest of the commands

sudo -u www-data bash
cd /home/www-data/web2py
python -c from gluon.main import save_password; save_password('hello',443)

Accessed via the public DNS, but the site does not appear.

What did I do wrong?

-- 





[web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread pbreit
I don't think there are any SQLFORMs. It's all custom Ajax calls. I'm guessing 
your JavaScript library (angular, in this case) needs to take care of it?

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread pbreit
I'd be surprised if model processing is your biggest problem. Have you reviewed 
all your queries for optimization opportunities? Cache, cache and more cache? 
Indexes?

-- 





Re: [web2py] customizing email for registration verification

2012-07-17 Thread Bruno Rocha
You need to use the url like this

img src='+URL('static', 'images', args='poweredby.png', host=True,
 scheme=True)+'/


-- 





[web2py] Re: Jeditable and SQLTables

2012-07-17 Thread Brent Zeiben

Going back to your first example code you gave above,

Javascript in the view nothing really changed I just don't have the 
indicator gif
script
  jQuery(document).ready(function(){
   
   jQuery('.EDit').editable({{=URL('update')}},{
  style: 'display:inline',
  indicator: Saving...,
  tooltip : Click to edit...,
  style : inherit
  });
  });
  
 /script


the update() function in the controller:

def update():
  if request.post_vars:
  idloc = request.post_vars.id
  id,column = idloc.split('.')
  value = request.post_vars.value
  db(db.WSProb.id == id).update(**{column:value})
  return value


It seems jeditable submits its values through request.post_vars instead of 
using request.args 
I also modified the update clause so it would work with passing a column 
name in as text.
I am using the source 1.7.1 version of jeditable from the 
sitehttp://www.appelsiini.net/projects/jeditable. 
 

With minimal testing this seemed to allow you to update the numbers and 
display the updated value.

HTH,
Brent

On Monday, 16 July 2012 20:11:39 UTC-6, Simon Ashley wrote:

 Thanks Brent,

 Sorry for the delay - first chance to delve into this again. Still no 
 luck. Have tried various combinations but unable to get jeditable fire in 
 this setup. 
 Do you have a quick example that works (just a cut and paste one would do)?

 TIA.



-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Bruce Wade
LOL well the before and after performance improvements from moving the
models has proven it to be a major problem. So yes models are definitely a
problem primarily because they are redefined every call and with a high
traffic site that means a lot of redefinitions.

On Tue, Jul 17, 2012 at 9:12 AM, pbreit pbreitenb...@gmail.com wrote:

 I'd be surprised if model processing is your biggest problem. Have you
 reviewed all your queries for optimization opportunities? Cache, cache and
 more cache? Indexes?

 --






-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Bruce Wade
Just think about it loading a page that queries from one table, and models
that define 200 tables. For that single query 200 tables must be define
with the default web2py setup. This isn't rocket science to know it will be
wasting a lot of resources and slow down performance every extra function
call will cause performance problems on a high traffic website. Lets not
forget with every model definition it will use more memory.

Another performance problem is translations for sites with a lot of
translations strings as the entire dictionary must be loaded into memory.
This part I am still thinking whether having a different file per action
would be worth it to improve speed.

On Tue, Jul 17, 2012 at 9:40 AM, Bruce Wade bruce.w...@gmail.com wrote:

 LOL well the before and after performance improvements from moving the
 models has proven it to be a major problem. So yes models are definitely a
 problem primarily because they are redefined every call and with a high
 traffic site that means a lot of redefinitions.

 On Tue, Jul 17, 2012 at 9:12 AM, pbreit pbreitenb...@gmail.com wrote:

 I'd be surprised if model processing is your biggest problem. Have you
 reviewed all your queries for optimization opportunities? Cache, cache and
 more cache? Indexes?

 --






 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.fittraineronline.com - Fitness Personal Trainers Online
 http://www.warplydesigned.com




-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





Re: [web2py] Re: response.js on regular requests.

2012-07-17 Thread Richard Vézina
I had to use XML() to avoid $quot; in the view, like this :

# In controller
conditional_field_trigger_selected_event_js
= '$(select[name=FIELDOFINTERESS]).change(function() {var val =
$(this).children(:selected).attr(value);$(this).trigger($(this).attr(id)
+ __selected, [val]);});'

...

return dict(..., conditional_field_trigger_selected_event_js
= conditional_field_trigger_selected_event_js)

# In view
{{if request.args(0)=='SOMETHING':}}
script type=text/javascript
var conditional_field_trigger_selected_event_js =
{{=XML(conditional_field_trigger_selected_event_js)}}
eval(conditional_field_trigger_selected_event_js);
/script
{{pass}}

But, still curious to know if there is security issue with javascript
eval(); the way I use it.

The purpose of this is to use lazy_option_widget plugin (
http://dev.s-cubism.com/plugin_lazy_options_widget) without having to use
suggest widget that is a dependency of lazy_option_widget... Since
lazy_option_widget only need selected event to be trigger on by suggest
widget, giving it trigger event from a default web2py dropbox allow to
eliminate the dependency.

In the future I would implement a custom dropbox widget that support
trigger selected event. Thought it could be nice to have a option in the
default web2py dropbox widget to activate and deactivate as needed selected
trigger event, but don't know if it a good idea.

Thanks to answer.

Richard



On Tue, Jul 17, 2012 at 11:38 AM, Richard Vézina 
ml.richard.vez...@gmail.com wrote:

 Hello Anthony in order to do what you propose here, I mean passing
 javascript code from the controller to the view by mean of return
 dict(var=js), I think the only way I have to execute the passed js code is
 to use eval in the view like this :

 script type=text/javascript
 eval({{=var}});
 /script

 Now, my concern is, is that secure to use javascript eval(); in this way
 and is what you have in mind when you make this proposition?

 Thanks

 Richard

 On Sun, Jun 5, 2011 at 7:43 PM, Anthony abasta...@gmail.com wrote:

 Can't you just include the relevant JS directly in the view template for
 the page, or maybe include the JS string in the dict returned by the
 controller, and insert it as a variable in the view?

 On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote:

 How do I inject javascript in my controller from a regular web request?

 I read the docs it syas response.js is executed only in a component;

 so I have a form and I would like to add JS validators.

 so I try adding to the response.js = '$(myfield).validate(**digits);'


 Of course this only works in component mode as I tried it;

 But now I have a single form page and I want this same javascript to
 work;

 How do I do that?

 Thanks.





-- 





[web2py] Re: Auth.register() questions

2012-07-17 Thread howesc
to add to massimo's response, i have added some HTML5'ness to my 
registration widget:

reg_form = auth.register()
reg_form.custom.widget.email['_required'] = True
reg_form.custom.widget.stage_name['_required'] = True
reg_form.custom.widget.stage_name['_pattern'] = '[\w-]{3,20}'
reg_form.custom.widget.stage_name['_title'] = 'Choose a stagename 
of 3-20 characters'
reg_form.custom.widget.password['_required'] = True
reg_form.custom.widget.password_two['_required'] = True

good luck!

cfh

On Monday, July 16, 2012 1:50:45 PM UTC-7, Massimo Di Pierro wrote:

 The register function, as all the functions in auch which return a form, 
 call process internally. Therefore if you fo

 form = auth.register()
 form.process()

 you would be calling process twice with undesired consequences. Moreover 
 if the process() called inside it successful and the form was accepted you 
 may have a redirect (raise HTTP) and therefore the function never returns.

 I think this is what you want:

 def register():
 def onvalidation(form):
 if form.errors: # form has errors
 session.flash = 'Registration form processed, please check 
 your email'
 def onaccept(form): # form accepted
 response.flash = 'Registration form contains error(s)'
 auth.settings.register_onvalidation.append(onvalidation)
 auth.settings.register_onaccept.append(onaccept)
 form = auth.register()
 if not form.vars: # form not sumitted
 response.flash = 'Please fill in the registration form'
 return dict(form=form)

 Anyway if all you want is set errors, you should use auth.messages.*

 2.
 open a web2py shell with

 python web2py.py -S welcome -M -N

 then experiment yourself

form = auth.register()
print form
form['_class'] = 'test'
print form
form.element('input[name=myfield]')['_class'] = 'test' # jquery syntax
print form

 On Monday, 16 July 2012 13:30:06 UTC-5, cyan wrote:


 I have a couple of questions about the provided Auth.register() function 
 (I suppose they also apply to other Auth functions in general):

 1. In a controller, if I do:

 def register():
 return dict(form=auth.register())

 with the following settings in a model:

 auth.settings.registration_requires_verification = True
 auth.settings.register_next = URL (...)

 Everything works as expected, i.e. the verification email is sent after 
 the registration form is processed, and the user gets re-directed to a 
 different page. However, as soon as I do sth like:

 def register():
 form = auth.register()

 if form.process().accepted:
 session.flash = 'Registration form processed, please check your 
 email'
 elif form.errors:
 response.flash = 'Registration form contains error(s)'
 else:
 response.flash = 'Please fill in the registration form'

 return dict(form=form)

 *Both verification email and re-direction stop working even though the 
 form processed successfully* (a record is inserted, the form clears 
 itself, and a flash message 'Success!' appears). I wonder what causes this 
 breakdown? I am using the trunk version of web2py.


 2. How much customization can we do with the form returned by 
 auth.register()? I know we can add add fields to it (a few different ways), 
 but there are many other things one may want to adjust. For example, I am 
 able to do sth like:

 form.element(_type='submit')['_class'] = '...'

 to change the class of its elements. How do we change the class for the 
 whole form? How do we change the label for each field? How do we adjust the 
 position of each field? How do we position the whole form on the page? etc.

 Thanks in advance! 





-- 





[web2py] Re: TAKE 2: Web2py + (jython / modjy) + Tomcat 6

2012-07-17 Thread Massimo Di Pierro
This is a jython bug. Does this error make sense to you?

translate() takes 2 arguments (2 given)



On Tuesday, 17 July 2012 07:50:14 UTC-5, Duncan wrote:

 I know this thread is a little old, but I really agree getting web2py 
 going on a servlet container would be awesome.

 I followed Andrew's excellent example from the previous post, BUT i worked 
 around the root url redirect issue by simply renaming the web2py folder to 
 'ROOT' (which, by convention, Tomcat will then serve from '/')

 Like this:
 Tomcat_HOME 
|__webapps 
 |__ROOT 
 | 
 |__WEB-INF  

 Anyway, I think I got closer than Andrew's attempt because (yay?) I got a 
 real web2py ticket error. The contents of the web2pyticket was:

 (dp1
 S'code'
 p2
 S''
 p3
 sS'output'
 p4
 S''
 p5
 sS'snapshot'
 p6
 (dp7
 sS'layer'
 p8
 S'Framework'
 p9
 sS'traceback'
 p10
 S'Traceback (most recent call last):\n  File 
 C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\main.py,
  
 line 475, in wsgibase\nsession.connect(request, response)\n  File 
 C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\main.py,
  
 line 475, in wsgibase\nsession.connect(request, response)\n  File 
 C:\\Users\\duncanjm\\Documents\\various\\tomcat\\tomcat7\\webapps\\ROOT\\WEB-INF\\lib-python\\gluon\\globals.py,
  
 line 507, in connect\nresponse.cookies[response.session_id_name] = 
 response.session_id\n  File C:\\jython2.5.2\\Lib\\Cookie.py, line 579, in 
 __setitem__\nself.__set(key, rval, cval)\n  File 
 C:\\jython2.5.2\\Lib\\Cookie.py, line 572, in _BaseCookie__set\n   
  M.set(key, real_value, coded_value)\n  File 
 C:\\jython2.5.2\\Lib\\Cookie.py, line 450, in set\nif  != 
 translate(key, idmap, LegalChars):\n  File 
 C:\\jython2.5.2\\Lib\\string.py, line 491, in translate\nreturn 
 s.translate(table, deletions)\nTypeError: translate() takes 2 arguments (2 
 given)\n'
 p11
 s.

 Looks like there is something wrong with the cookie setting? Any other 
 ideas out there?

 Thanks for any tips. 

 Once again -- it feels like we are getting closer (albeit slowly) to 
 having a working modjy/Tomcat deploy-ready web2py.war -- that would be sooo 
 awesome!




-- 





Re: [web2py] Adding cancel button - form submission

2012-07-17 Thread Massimo Di Pierro
In trunk:

form.add_button(Cancel,URL(r=request,f='new_contact'))

On Tuesday, 17 July 2012 10:00:59 UTC-5, Mathias wrote:

 I found a good solution for me : 

 form[0][-1][1].append(TAG.INPUT(_value='Cancel',_type=button,_onclick=window.location='%s';%URL(r=request,f='new_contact')))
  


 Mathias 


 2012/7/17 Mathias Van Daele mathias.v.da...@gmail.com: 
  Thanks for your solution Richard ! 
  
  I am still looking for a solution with a button component... 
  
  Mathias 
  
  2012/7/17 Richard Vézina ml.richard.vez...@gmail.com: 
  Maybe this could be enough?? 
  
  {{=A(T('cancel'),_href=javascript:void(history.go(-1)))}} 
  
  It will bring you back to the precedent page, in my use case, I direct 
 the 
  user on a crud.read page where the user can edit the record 
 (crud.update). 
  Then if don't want make change anymore there is a cancel hyperlink 
 that 
  bring back the user on the crud.read page. 
  
  Richard 
  
  
  On Tue, Jul 17, 2012 at 8:13 AM, Mathias mathias.v.da...@gmail.com 
 wrote: 
  
  Hello, 
  
  I have added a CANCEL button to my SQLFORM. 
  
  Form submission prevents the correct working of it. 
  
  I have tried to avoid form submission with this code : 
  
  
  def new_guest_contact(): 
 form = SQLFORM.factory(...) 
  
  
  
 form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax(%s,[],:eval);return
  

  false' %URL(r=request,f='new_contact'))) 
  
 if form.process().accepted: 
  ... 
  redirect(URL(r=request,f='new_contact_part')) 
 elif form.errors: 
 response.flash = 'form has errors' 
 else: 
 response.flash = 'Create new guest' 
  
 return dict(form=form) 
  
  
  If I click the cancel button now, nothing happens anymore. 
  
  
  Any help is welcome. 
  
  Thanks 
  
  
  Mathias 
  
  -- 
  
  
  
  
  
  -- 
  
  
  


-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Massimo Di Pierro
I remind the readers we have conditional models:

models/db.py (runs for every action)
models/default/db.py runs (runs only for actions in controllers/default.py)
models/default/index/db.py runs (runs only for action index() in 
controllers/default.py)

This speeds things a lot.


On Tuesday, 17 July 2012 11:40:07 UTC-5, Bruce Wade wrote:

 LOL well the before and after performance improvements from moving the 
 models has proven it to be a major problem. So yes models are definitely a 
 problem primarily because they are redefined every call and with a high 
 traffic site that means a lot of redefinitions. 

 On Tue, Jul 17, 2012 at 9:12 AM, pbreit pbreitenb...@gmail.com wrote:

 I'd be surprised if model processing is your biggest problem. Have you 
 reviewed all your queries for optimization opportunities? Cache, cache and 
 more cache? Indexes?

 --






 -- 
 -- 
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.fittraineronline.com - Fitness Personal Trainers Online
 http://www.warplydesigned.com



-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Bruno Rocha
The conditional models are good, but the problem is the fact that they are
not reusable, when you need the same table on multiple controllers, or you
have to define it globally, or you have to repeat the definition on every
sub model.

I think having a module with functions or classes to define the tables are
better, and qhen you have this, you dont need to use submodels, because you
can run each desired function/class direclty on the controller.

On Tue, Jul 17, 2012 at 2:46 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I remind the readers we have conditional models:

 models/db.py (runs for every action)
 models/default/db.py runs (runs only for actions in controllers/default.py)
 models/default/index/db.py runs (runs only for action index() in
 controllers/default.py)

 This speeds things a lot.


-- 





Re: [web2py] Re: response.js on regular requests.

2012-07-17 Thread Richard Vézina
Sorry for the noise, I struggled with quot; for long time and didn't
realise that I wasn't need eval() anymore...

I don't need js var and eva(); at all as long as I have XML()

# In view
{{if request.args(0)=='SOMETHING':}}
script type=text/javascript
{{=XML(conditional_field_trigger_selected_event_js)}}
/script
{{pass}}

Richard

On Tue, Jul 17, 2012 at 12:52 PM, Richard Vézina 
ml.richard.vez...@gmail.com wrote:

 I had to use XML() to avoid $quot; in the view, like this :

 # In controller
 conditional_field_trigger_selected_event_js
 = '$(select[name=FIELDOFINTERESS]).change(function() {var val =
 $(this).children(:selected).attr(value);$(this).trigger($(this).attr(id)
 + __selected, [val]);});'

 ...

 return dict(..., conditional_field_trigger_selected_event_js
 = conditional_field_trigger_selected_event_js)

 # In view
 {{if request.args(0)=='SOMETHING':}}
 script type=text/javascript
 var conditional_field_trigger_selected_event_js =
 {{=XML(conditional_field_trigger_selected_event_js)}}
 eval(conditional_field_trigger_selected_event_js);
 /script
 {{pass}}

 But, still curious to know if there is security issue with javascript
 eval(); the way I use it.

 The purpose of this is to use lazy_option_widget plugin (
 http://dev.s-cubism.com/plugin_lazy_options_widget) without having to use
 suggest widget that is a dependency of lazy_option_widget... Since
 lazy_option_widget only need selected event to be trigger on by suggest
 widget, giving it trigger event from a default web2py dropbox allow to
 eliminate the dependency.

 In the future I would implement a custom dropbox widget that support
 trigger selected event. Thought it could be nice to have a option in the
 default web2py dropbox widget to activate and deactivate as needed selected
 trigger event, but don't know if it a good idea.

 Thanks to answer.

 Richard



 On Tue, Jul 17, 2012 at 11:38 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Hello Anthony in order to do what you propose here, I mean passing
 javascript code from the controller to the view by mean of return
 dict(var=js), I think the only way I have to execute the passed js code is
 to use eval in the view like this :

 script type=text/javascript
 eval({{=var}});
 /script

 Now, my concern is, is that secure to use javascript eval(); in this way
 and is what you have in mind when you make this proposition?

 Thanks

 Richard

 On Sun, Jun 5, 2011 at 7:43 PM, Anthony abasta...@gmail.com wrote:

 Can't you just include the relevant JS directly in the view template for
 the page, or maybe include the JS string in the dict returned by the
 controller, and insert it as a variable in the view?

 On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote:

 How do I inject javascript in my controller from a regular web request?

 I read the docs it syas response.js is executed only in a component;

 so I have a form and I would like to add JS validators.

 so I try adding to the response.js = '$(myfield).validate(**digits);'


 Of course this only works in component mode as I tried it;

 But now I have a single form page and I want this same javascript to
 work;

 How do I do that?

 Thanks.






-- 





[web2py] Re: Web2py on EC2: site does not appear

2012-07-17 Thread rdodev
Was it a 404, timeout error or what?

On Tuesday, July 17, 2012 11:49:14 AM UTC-4, lyn2py wrote:

 Another issue O.O
  
 Now that the whole script has installed, and I followed through with the 
 rest of the commands

 sudo -u www-data bash
 cd /home/www-data/web2py
 python -c from gluon.main import save_password; 
 save_password('hello',443)

 Accessed via the public DNS, but the site does not appear.

 What did I do wrong?


-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Massimo Di Pierro
There is an old proposal from Mariano to address that we should revisit 
that. Yet I find that if a model is needed by multiple controllers, it can 
be defined at top-level. It is in general a good design to group actions in 
controllers depending on which models they need.


On Tuesday, 17 July 2012 12:51:36 UTC-5, rochacbruno wrote:

 The conditional models are good, but the problem is the fact that they are 
 not reusable, when you need the same table on multiple controllers, or you 
 have to define it globally, or you have to repeat the definition on every 
 sub model.

 I think having a module with functions or classes to define the tables are 
 better, and qhen you have this, you dont need to use submodels, because you 
 can run each desired function/class direclty on the controller.

 On Tue, Jul 17, 2012 at 2:46 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 I remind the readers we have conditional models:

 models/db.py (runs for every action)
 models/default/db.py runs (runs only for actions in 
 controllers/default.py)
 models/default/index/db.py runs (runs only for action index() in 
 controllers/default.py)

 This speeds things a lot.




-- 





Re: [web2py] KeyError on pyfpdf

2012-07-17 Thread Mariano Reingart
On Mon, Jul 16, 2012 at 5:08 PM, thinkwell thinkwelldesi...@gmail.com wrote:
 Well, me again. I decided that I wanted to use points as measurements
 instead of percentages, so now it barfs with an AttributeError.



 from gluon.contrib.pyfpdf import FPDF, HTMLMixin
 from gluon.html import *


 pets = TABLE(_width=720pt)
 pets.append(TR(TH('Dogs', _width=72pt,
 _align=left),TH(Cats,_width=72pt,
 _align=left),TH('Snakes',_width=72pt, _align=left)))
 pets.append(TR('Collies','Tabby','Python', _width=60pt))

 pets.append(TR('Akitas', 'Persian', 'Garter'))
 pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes'))


 class MyFPDF(FPDF, HTMLMixin):
 pass

 pdf=MyFPDF()
 #First page
 pdf.add_page()
 pdf.write_html(pets.xml())

 pdf.output('html2.pdf','F')


 This is clearly unremarkable HTML, but no, I get tracebacks like so:

 Traceback (most recent call last):
   File pyfpdf_test.py, line 73, in module
 pdf.write_html(pets.xml())
   File /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py, line
 388, in write_html
 h2p.feed(text)
   File /usr/lib/python2.7/HTMLParser.py, line 114, in feed
 self.goahead(0)
   File /usr/lib/python2.7/HTMLParser.py, line 158, in goahead
 k = self.parse_starttag(i)
   File /usr/lib/python2.7/HTMLParser.py, line 324, in parse_starttag
 self.handle_starttag(tag, attrs)
   File /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py, line
 241, in handle_starttag
 self.pdf.set_x(self.table_offset)
 AttributeError: HTML2FPDF instance has no attribute 'table_offset'

Sorry, only percentage is supported.
Pt and Em and any other unit is not supported.
I'll try to add better error messages and documentation, sorry for the issue.

 I find this remarkable; this ordinary HTML; web2py encourages the use of
 HTML helpers. web2py is easy to use, requires few dependencies, etc. etc.
 But what a fight to create a simple table-based PDF! :-( And I'm still
 experimenting in the layout stage. My final report will be much larger and
 include nested tables (that are already rendering fine in HTML, but not in
 pyfpdf / html2pdf).

Sorry, but definitively your report is out of scope of html2pdf /
pyfpdf right now.
Please remember, the current implementation is a basic HTML parser to
do *basic* reports.
Nested tables are not supported and I don't think they will in the near future.
If I could get some funding maybe I could spend more time enhancing this.

 Should I bite the bullet and install Reportlab? It'll be harder to get
 started, more complicated to install  maintain (this will have to go on
 multiple machines). The idea of a simple web2py project was very attractive
 for these reasons.

AFAIK Reportlab doesn't even have a html2pdf conversor.
If you switch to reportlab, you will have to code your report using PlatyPlus.
You should consider they commercial licence that includes paid support
for this kind of issues.

As you said, the html2pdf recipe is a simple web2py project
Maybe you have to go with third-party tools like Pisa (xhtml2pdf) or
use built-in pdf conversion of chrome-browser, or pdf printers.

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

-- 





Re: [web2py] Re: pg8000 '%' not supported in quoted string

2012-07-17 Thread Mariano Reingart
I'll take a look.
Maybe it is related to paramstyle o similar setting.

Can you fill a bug issue, just in case I forget about this..

https://code.google.com/p/pg8000/issues/entry

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Tue, Jul 17, 2012 at 12:22 PM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 Can you please run a test for me?

 In dal.py there are these lines:

 def adapt(self,obj):
 return psycopg2_adapt(obj).getquoted()

 can you plase replace them with

 def adapt(self,obj):
 if self.driver == self.drivers.get('pg8000'):
 obj = str(obj).replace('%','%%')
 return psycopg2_adapt(obj).getquoted()

 Does this fix the problem? This is a pg8000 bug anyway. Even if the
 workaround fixes it, it will cause problems once the bug in the driver is
 fixed.



 On Tuesday, 17 July 2012 00:34:03 UTC-5, KMax wrote:

 db.py:
 db =
 DAL('postgres:pg8000://username:u$erpas$@localhost/userdb',pool_size=10,
  check_reserved=['postgres', 'mssql', 'mysql'])
 db.define_table('mytable',Field('myfield','string'))


 default.py:
 def index():
 return dict(form=crud.create(db.mytable))


 Posting % into form gives an error.

 error attached


 On Tuesday, 17 July 2012 00:34:03 UTC-5, KMax wrote:

 db.py:
 db =
 DAL('postgres:pg8000://username:u$erpas$@localhost/userdb',pool_size=10,
  check_reserved=['postgres', 'mssql', 'mysql'])
 db.define_table('mytable',Field('myfield','string'))


 default.py:
 def index():
 return dict(form=crud.create(db.mytable))


 Posting % into form gives an error.

 error attached

 --




-- 





[web2py] Re: Web2py expert needed for start-up

2012-07-17 Thread howesc
to help with your search consider posting here 
http://experts4solutions.com/ if you haven't already.

On Monday, July 16, 2012 4:23:41 PM UTC-7, Pepe C wrote:

 Hi, 

 We have a set of applications on web2py and we are looking for an expert 
 that can help us to operate and develop them.  This is a long-term role 
 taking ~10 hours a week, although we do have a bunch of additional work to 
 get done in the next few weeks. 

 Responsibilities include:

- Development of new web services 
- Web2py administration and deployment 
- Polishing and addressing bugs in the existing code

 Experience with Jquery mobile plugin or mobile layouts would be a big plus.

 In your replies please tell us about your portfolio, your availability for 
 the next two months and your hourly rate.

 Thanks!


-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Bruce Wade
Massimo my suggest was conditionals, Bruno the way I handle mine there is
no repeating of model definitions.

db_tables.py
# define all tables in a function this file should be out side of the
models directory
def define_tables(db, tables=[], migrate=False, fake_migrate=True)

models/global.py - Use define_tables() to define all tables required by
all controllers
models/controler/global.py - Use define_tables() to add more tables used
only by this controller but all actions in this controller
models/controler/action/db.py - Use define_tables() for tables that have
not been defined yet but are required for this action.

This situation works pretty good without having all the import's inside
controllers :D

On Tue, Jul 17, 2012 at 11:29 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 There is an old proposal from Mariano to address that we should revisit
 that. Yet I find that if a model is needed by multiple controllers, it can
 be defined at top-level. It is in general a good design to group actions in
 controllers depending on which models they need.


 On Tuesday, 17 July 2012 12:51:36 UTC-5, rochacbruno wrote:

 The conditional models are good, but the problem is the fact that they
 are not reusable, when you need the same table on multiple controllers, or
 you have to define it globally, or you have to repeat the definition on
 every sub model.

 I think having a module with functions or classes to define the tables
 are better, and qhen you have this, you dont need to use submodels, because
 you can run each desired function/class direclty on the controller.

 On Tue, Jul 17, 2012 at 2:46 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 I remind the readers we have conditional models:

 models/db.py (runs for every action)
 models/default/db.py runs (runs only for actions in
 controllers/default.py)
 models/default/index/db.py runs (runs only for action index() in
 controllers/default.py)

 This speeds things a lot.


  --







-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





[web2py] Re: Hiding columns in SQLFORM.grid

2012-07-17 Thread Ashraf Mansour

Hi,

 How can i hide columns in the create form generated by sqlform.grid ? 

Thanks

Ashraf

-- 





Re: [web2py] Re: Hiding columns in SQLFORM.grid

2012-07-17 Thread Bruno Rocha
if request.function == 'new':
db.mytable.myfield.readable = False
db.mytable.myfield2.readable = False
db.mytable.myfield3.readable = False

On Tue, Jul 17, 2012 at 5:16 PM, Ashraf Mansour ad...@aqar-riyadh.comwrote:


 Hi,

 How can i hide columns in the create form generated by sqlform.grid ?

 Thanks

 Ashraf

 --





-- 





[web2py] Re: hi

2012-07-17 Thread Derek
Excellent reply. Yes, learning web2py will help you learn the concepts of 
MVC, SQL, OWASP, Javascript, HTML, JSON, CSS, Python. It's really nice to 
put those on your resumee.

On Sunday, July 15, 2012 2:45:19 AM UTC-7, mart wrote:

 in my experience brand names do not sell as much as bare bone 
 concepts... Sure mentioning Django vs web2py can open/close doors (even 
 raise an eyebrow or 2)... But IMHO doors open more when stating the basics: 
 SQL, MVC, complexe data types, security, apps for the web, etc... Besides, 
 employers don't necessarily know specifics (well not all the time). I 
 remember an employer mentioning Django, then I asked why?. As expected, 
 there was no real answer. When I mentioned that there are other frameworks 
 (yes, specifically web2py), with a couple of examples (most found online 
 written folks from this group), i got the look of interest... The point is, 
 its too hard to keep up, and there are plenty of smart people out there who 
 already know the brand names... going out to look for jobs is easier with 
 pockets full of those bare bone basics than it is with brand name framework 
  up-to-the-minute corporate pets... So, I would say 'absolutely' go with 
 web2py! learn the basics, evolve, then move on (but always come back ;) ) 
 and apply those basics to other brand name frameworks. And, as mentioned 
 above, showcase what you can do!

 Mart :) 

 On Thursday, July 12, 2012 2:52:26 AM UTC-7, ahmad wrote:

 please anyone can tell me about the web2py  and it's community and if i 
 learn it can i find a job easily 



-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-17 Thread Derek
raw maple syrup, well, it flows out of the tree easily enough, and buckets 
of it seem almost like water, it's not very viscous. Only when you heat it 
and cook it for a while does it become the thick maple syrup you see on 
your kitchen table. 

On Monday, July 16, 2012 5:14:22 PM UTC-7, wdtatenh wrote:

 Thanks very much for this information.  I need to examine it more closely 
 but it looks darn good. I'm hoping with this change and re-organizing my 
 controllers, then my site will speed up significantly.  At present, it is 
 slower than raw maple syrup and I can't afford to stay with web2py if I 
 can't redesign my site so the speed increases significantly.  

 On Monday, July 16, 2012 5:20:42 PM UTC-4, rochacbruno wrote:

 You can also download a modelless app here: 
 https://github.com/rochacbruno/web2py_model_less_app/downloads

 I am using this approach for all my apps ( But I know we have things to 
 improve)




-- 





[web2py] Re: Web2py on EC2: site does not appear

2012-07-17 Thread lyn2py
Connection Timeout error. 

On Wednesday, July 18, 2012 1:59:15 AM UTC+8, rdodev wrote:

 Was it a 404, timeout error or what?

 On Tuesday, July 17, 2012 11:49:14 AM UTC-4, lyn2py wrote:

 Another issue O.O
  
 Now that the whole script has installed, and I followed through with the 
 rest of the commands

 sudo -u www-data bash
 cd /home/www-data/web2py
 python -c from gluon.main import save_password; 
 save_password('hello',443)

 Accessed via the public DNS, but the site does not appear.

 What did I do wrong?



-- 





Re: [web2py] Re: Hiding columns in SQLFORM.grid

2012-07-17 Thread Ashraf Mansour
 
I added the statements

if request.function == 'new':
db.mytable.myfield.readable = False
db.mytable.myfield2.readable = False
db.mytable.myfield3.readable = False

before constructing the grid, but the fields are still in the add (create) 
form of the grid.

I am definging default values for these fields, is this the problem?




-- 





[web2py] Import CSV in appadmin to update database

2012-07-17 Thread Mark Li
Is there a way I can add an import excel (saved as csv) option in the 
appadmin that can update multiple data tables (one of them an 
intermediate/relational table)? 

for example the excel file (saved as csv):

*ID   |  title  |category|*
1 | one   |   cat1, cat2   |
2 | two|   cat2, cat3  |
3 | three |cat2   |

Uploading this would update table1 with the ID and title, and also update 
the intermediate/relational table with the relation between the title and 
category (as described here 
http://web2py.com/books/default/chapter/29/6#Many-to-many)

I'm relatively new to web2py and could not find anything in the book, while 
other questions relating to importing CSV files already had a strong 
understanding of what to do. I'd appreciate any info that could set me on 
the right path, thanks!

-- 





[web2py] Accessing non-returned items in Views

2012-07-17 Thread adohertyd
In my function page2(): I return a dictionary to be accessed by the page2 
HTML view. In the page2 function I have some other dictionaries. What I 
want to do to be able to use the non-returned dictionaries in the HTML code 
to show some items. This is a sample of what I want: Hope it's clear

def page2():


Dict1 = {key1:{keyA:value, keyB:value, keyC:value}
Dict2 = {key2:{keyD:value, keyE:value, keyF:value}

OtherDict = {key:value, key:value...}

return dict(ReturnedDict = OtherDict)


page2.html:


ul
{{for x in ReturnedDict:}}
{{if x in Dict1:}}
li{{=Dict1[x]['keyA']}}{{=Dict1[x]['keyB']/li
{{elif x in Dict2:}}
li{{=Dict2[x]['keyD']}}{{=Dict2[x]['keyE']/li
{{pass}}
/ul


-- 





[web2py] Re: Accessing non-returned items in Views

2012-07-17 Thread Massimo Di Pierro
replace

return dict(ReturnedDict = OtherDict) 

with

return locals()

On Tuesday, 17 July 2012 16:40:00 UTC-5, adohertyd wrote:

 In my function page2(): I return a dictionary to be accessed by the page2 
 HTML view. In the page2 function I have some other dictionaries. What I 
 want to do to be able to use the non-returned dictionaries in the HTML code 
 to show some items. This is a sample of what I want: Hope it's clear

 def page2():


 Dict1 = {key1:{keyA:value, keyB:value, keyC:value}
 Dict2 = {key2:{keyD:value, keyE:value, keyF:value}

 OtherDict = {key:value, key:value...}

 return dict(ReturnedDict = OtherDict)


 page2.html:


 ul
 {{for x in ReturnedDict:}}
 {{if x in Dict1:}}
 li{{=Dict1[x]['keyA']}}{{=Dict1[x]['keyB']/li
 {{elif x in Dict2:}}
 li{{=Dict2[x]['keyD']}}{{=Dict2[x]['keyE']/li
 {{pass}}
 /ul




-- 





Re: [web2py] Accessing non-returned items in Views

2012-07-17 Thread Lucas R. Martins

Just curious:

There is a special reason to not simply return the needed dicts?

Em Ter 17 Jul 2012 18:40:00 BRT, adohertyd escreveu:

In my function page2(): I return a dictionary to be accessed by the
page2 HTML view. In the page2 function I have some other dictionaries.
What I want to do to be able to use the non-returned dictionaries in
the HTML code to show some items. This is a sample of what I want:
Hope it's clear

||
defpage2():


Dict1={key1:{keyA:value,keyB:value,keyC:value}
Dict2={key2:{keyD:value,keyE:value,keyF:value}

OtherDict={key:value,key:value...}

returndict(ReturnedDict=OtherDict)


||
page2.html:


ul
{{forx inReturnedDict:}}
{{ifx inDict1:}}
li{{=Dict1[x]['keyA']}}{{=Dict1[x]['keyB']/li
{{elifx inDict2:}}
li{{=Dict2[x]['keyD']}}{{=Dict2[x]['keyE']/li
{{pass}}
/ul


--






--





Re: [web2py] Accessing non-returned items in Views

2012-07-17 Thread adohertyd
I need all of them!

On Tuesday, 17 July 2012 22:47:02 UTC+1, Lucas R. Martins wrote:

 Just curious: 

 There is a special reason to not simply return the needed dicts? 

 Em Ter 17 Jul 2012 18:40:00 BRT, adohertyd escreveu: 
  In my function page2(): I return a dictionary to be accessed by the 
  page2 HTML view. In the page2 function I have some other dictionaries. 
  What I want to do to be able to use the non-returned dictionaries in 
  the HTML code to show some items. This is a sample of what I want: 
  Hope it's clear 
  
  || 
  defpage2(): 
  
  
  Dict1={key1:{keyA:value,keyB:value,keyC:value} 
  Dict2={key2:{keyD:value,keyE:value,keyF:value} 
  
  OtherDict={key:value,key:value...} 
  
  returndict(ReturnedDict=OtherDict) 
  
  
  || 
  page2.html: 
  
  
  ul 
  {{forx inReturnedDict:}} 
  {{ifx inDict1:}} 
  li{{=Dict1[x]['keyA']}}{{=Dict1[x]['keyB']/li 
  {{elifx inDict2:}} 
  li{{=Dict2[x]['keyD']}}{{=Dict2[x]['keyE']/li 
  {{pass}} 
  /ul 
  
  
  -- 
  
  
  




-- 





[web2py] Re: Accessing non-returned items in Views

2012-07-17 Thread adohertyd
Simple as that :) thanks Massimo Web2py is fantastic 

On Tuesday, 17 July 2012 22:45:48 UTC+1, Massimo Di Pierro wrote:

 replace

 return dict(ReturnedDict = OtherDict) 

 with

 return locals()

 On Tuesday, 17 July 2012 16:40:00 UTC-5, adohertyd wrote:

 In my function page2(): I return a dictionary to be accessed by the page2 
 HTML view. In the page2 function I have some other dictionaries. What I 
 want to do to be able to use the non-returned dictionaries in the HTML code 
 to show some items. This is a sample of what I want: Hope it's clear

 def page2():


 Dict1 = {key1:{keyA:value, keyB:value, keyC:value}
 Dict2 = {key2:{keyD:value, keyE:value, keyF:value}

 OtherDict = {key:value, key:value...}

 return dict(ReturnedDict = OtherDict)


 page2.html:


 ul
 {{for x in ReturnedDict:}}
 {{if x in Dict1:}}
 li{{=Dict1[x]['keyA']}}{{=Dict1[x]['keyB']/li
 {{elif x in Dict2:}}
 li{{=Dict2[x]['keyD']}}{{=Dict2[x]['keyE']/li
 {{pass}}
 /ul




-- 





[web2py] Import CSV in appadmin to update database

2012-07-17 Thread Mark Li
I would like to know how I would add an import csv (from excel) option to 
appadmin that would update multiple database tables (one of them a 
relational/intermediate table).

For example, the CSV file would look like this (in excel)

ID |  posttitle |category  |
1   |  title1 | cat1, cat2|
2   |  title2 | cat2, cat3|
3   |  title3 | cat1, cat3|

Uploading this would update table 1 with the ID and posttitle, and also the 
intermediate/relational table with the relationship between posttitle and 
category (as described here: 
http://web2py.com/books/default/chapter/29/6#Many-to-many).

I'm new to web2py and couldn't find anything in the book, also the 
questions previously asked already had a good grasp of what to do add a CSV 
upload feature. I'd appreciate any help as I'm not really sure where to 
start with this, thanks!

-- 





[web2py] Re: Jeditable and SQLTables

2012-07-17 Thread Simon Ashley
Thanks Brent,

Appreciate that, but the main issue is that the controller does not called 
from jQuery. i.e. from this line

jQuery('.EDit').editable({{=URL('update')}},{ 

There no post vars.
(have also used a brute force updates to confirm that it doesn't fire)

If we can only find out why.
(thinking is a fundamental concept that I'm missing)

Will give that another go today, but would be grateful for any hints.





On Wednesday, 18 July 2012 02:25:43 UTC+10, Brent Zeiben wrote:


 Going back to your first example code you gave above,

 Javascript in the view nothing really changed I just don't have the 
 indicator gif
 script
   jQuery(document).ready(function(){

jQuery('.EDit').editable({{=URL('update')}},{
   style: 'display:inline',
   indicator: Saving...,
   tooltip : Click to edit...,
   style : inherit
   });
   });
   
  /script


 the update() function in the controller:

 def update():
   if request.post_vars:
   idloc = request.post_vars.id
   id,column = idloc.split('.')
   value = request.post_vars.value
   db(db.WSProb.id == id).update(**{column:value})
   return value


 It seems jeditable submits its values through request.post_vars instead of 
 using request.args 
 I also modified the update clause so it would work with passing a column 
 name in as text.
 I am using the source 1.7.1 version of jeditable from the 
 sitehttp://www.appelsiini.net/projects/jeditable. 
  

 With minimal testing this seemed to allow you to update the numbers and 
 display the updated value.

 HTH,
 Brent

 On Monday, 16 July 2012 20:11:39 UTC-6, Simon Ashley wrote:

 Thanks Brent,

 Sorry for the delay - first chance to delve into this again. Still no 
 luck. Have tried various combinations but unable to get jeditable fire in 
 this setup. 
 Do you have a quick example that works (just a cut and paste one would 
 do)?

 TIA.



-- 





[web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread Anthony


 I don't think there are any SQLFORMs. It's all custom Ajax calls. I'm 
 guessing your JavaScript library (angular, in this case) needs to take care 
 of it?


Presumably you could still use SQLFORM to generate the _formkey value, send 
it to the client, and have the client send it back with the form 
submission. This doesn't require using web2py's default form serialization 
in the view. It's probably only worth doing it this way if you are using 
SQLFORM on the server side for processing.

Anthony 

-- 





[web2py] Re: Foreign Key fields as null?

2012-07-17 Thread Anthony
You should probably make it a reference field. By default, if you don't 
specify any requires, you'll automatically get an IS_IN_DB validator as 
well as a represent attribute that displays whatever is specifying by the 
format attribute of the referenced table. However, if you specify your 
own validator(s), then you don't get any default represent -- so just add 
your own explicit represent:

db.define_table('dog',
Field http://127.0.0.1:8000/examples/global/vars/Field('name'), 
Field http://127.0.0.1:8000/examples/global/vars/Field('owner', db.
person, 
requires=IS_EMPTY_ORhttp://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR
(IS_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_IN_DB(db, 
'person.id', '%(name)')),
  represent=lambda id, row: db.person(id).name),
format = '%(name)s')

Anthony

On Tuesday, July 17, 2012 10:26:52 AM UTC-4, joe wrote:

 Is there any way to make a field in a form referencing a foreign key null, 
 while storing a foreign key as a foreign key, but making dropdowns 
 corrospond to the format.  Here is my example:

 Model:

 db = DAL 
 http://127.0.0.1:8000/examples/global/vars/DAL('sqlite://storage.sqlite')

 db.define_table('person',
 Field http://127.0.0.1:8000/examples/global/vars/Field('name'),
 Field http://127.0.0.1:8000/examples/global/vars/Field('email'),
 format = '%(name)s')
 
 db.define_table('dog',
 Field http://127.0.0.1:8000/examples/global/vars/Field('name'), 
 Field http://127.0.0.1:8000/examples/global/vars/Field('owner', 
 requires = IS_EMPTY_OR 
 http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IN_DB 
 http://127.0.0.1:8000/examples/global/vars/IS_IN_DB(db,db.person))), #I 
 have also tried default=None, and required = False, no difference
 format = '%(name)s')


 Controller:

 *from gluon.tools import Crud
 crud = Crud(db)

 def index():
 form = SQLFORM(db.person)
 if form.process().accepted:
 response.flash = 'success'
 return dict(form=form)
 
 def add_dog():
 form = SQLFORM(db.dog)
 if form.process().accepted:
 response.flash = 'success'
 return dict(form=form)

 def view():
 grid = SQLFORM.smartgrid(db.dog)
 grid2 = crud.select(db.person)
 return dict(grid=grid, grid2=grid2)
 *

 *
 *

 When I have the above code, a foreign key will be stored in the database, but 
 all views of that key will be rendered as the numerical value of the foreign 
 key, and not the name.  In the table definition, if I just have *db.person* 
 instead of requires = *IS_EMPTY_OR*(*IS_IN_DB*(db,db.person)), It requires 
 the field.  


 Are there any workarounds?

 -Joe Peacock



-- 





[web2py] Re: TAKE 2: Web2py + (jython / modjy) + Tomcat 6

2012-07-17 Thread Duncan
Thanks, Massimo,

I'm happy to say that I now have a *working*** web2py install in Tomcat*! 

The 'translate' issue was a bit of a cryptic one, but thanks to a previous 
post by Sergio, I realised that the issue was in a redundant cookie check 
in the Jython Cookie.py file. I just comment out the if block and it now 
works. 

The examples app runs and displays the web2py Web Framework menu page. 
Woot! :)

 For clarity: I commented out lines 450/451 in the Jython Cookie.py file:

#if  != translate(key, idmap, LegalChars):
#raise CookieError(Illegal key value: %s % key)

*So the remaining bits of work I need to do is check up on the details of 
making a JDBC connection to sqlite instead of driver-based. At that point I 
figure the 'welcome' app will then work, too. Currently it can't use/find 
the driver missing from CPython -- Jython.

Finally, I'll need to sort out some unavailable Unicode methods from the 
Jython side.

I'm hoping to document it all, and possibly even create a deploy-ready 
web2py.war file.

More news as it comes to hand.


On Wednesday, 18 July 2012 03:40:09 UTC+10, Massimo Di Pierro wrote:

 This is a jython bug. Does this error make sense to you?

 translate() takes 2 arguments (2 given)




-- 





[web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread Massimo Di Pierro
It is possible. Yet there is some overhead because SQLFROM is built on top 
of helpers. It will create a representation of the form even if it unused. 
It may work to create a SQLFORM light that only does what you need. It can 
be done in a few lines of code. Let me think about it

On Tuesday, 17 July 2012 18:12:48 UTC-5, Anthony wrote:

 I don't think there are any SQLFORMs. It's all custom Ajax calls. I'm 
 guessing your JavaScript library (angular, in this case) needs to take care 
 of it?


 Presumably you could still use SQLFORM to generate the _formkey value, 
 send it to the client, and have the client send it back with the form 
 submission. This doesn't require using web2py's default form serialization 
 in the view. It's probably only worth doing it this way if you are using 
 SQLFORM on the server side for processing.

 Anthony 


-- 





[web2py] Re: TAKE 2: Web2py + (jython / modjy) + Tomcat 6

2012-07-17 Thread Massimo Di Pierro
I would be very much interested in a web2py war file! We can distribute it 
directly from the web2py.com

On Tuesday, 17 July 2012 19:03:40 UTC-5, Duncan wrote:

 Thanks, Massimo,

 I'm happy to say that I now have a *working*** web2py install in Tomcat*! 

 The 'translate' issue was a bit of a cryptic one, but thanks to a previous 
 post by Sergio, I realised that the issue was in a redundant cookie check 
 in the Jython Cookie.py file. I just comment out the if block and it now 
 works. 

 The examples app runs and displays the web2py Web Framework menu page. 
 Woot! :)

  For clarity: I commented out lines 450/451 in the Jython Cookie.py file:

 #if  != translate(key, idmap, LegalChars):
 #raise CookieError(Illegal key value: %s % key)

 *So the remaining bits of work I need to do is check up on the details of 
 making a JDBC connection to sqlite instead of driver-based. At that point I 
 figure the 'welcome' app will then work, too. Currently it can't use/find 
 the driver missing from CPython -- Jython.

 Finally, I'll need to sort out some unavailable Unicode methods from the 
 Jython side.

 I'm hoping to document it all, and possibly even create a deploy-ready 
 web2py.war file.

 More news as it comes to hand.


 On Wednesday, 18 July 2012 03:40:09 UTC+10, Massimo Di Pierro wrote:

 This is a jython bug. Does this error make sense to you?

 translate() takes 2 arguments (2 given)




-- 





[web2py] Re: Web2py on EC2: site does not appear

2012-07-17 Thread lyn2py
Ok it works now!

Thanks rdodev!

On Wednesday, July 18, 2012 4:55:38 AM UTC+8, lyn2py wrote:

 Connection Timeout error. 

 On Wednesday, July 18, 2012 1:59:15 AM UTC+8, rdodev wrote:

 Was it a 404, timeout error or what?

 On Tuesday, July 17, 2012 11:49:14 AM UTC-4, lyn2py wrote:

 Another issue O.O
  
 Now that the whole script has installed, and I followed through with the 
 rest of the commands

 sudo -u www-data bash
 cd /home/www-data/web2py
 python -c from gluon.main import save_password; 
 save_password('hello',443)

 Accessed via the public DNS, but the site does not appear.

 What did I do wrong?



-- 





[web2py] Re: Import CSV in appadmin to update database

2012-07-17 Thread Mark Li
I am also unable to import a CSV file using the list:reference format 
(exporting then importing with no changes still doesn't work). I get the 
error message :

Unable to parse CSV file

'nonetype'object has no attribute '__getitem__'






On Tuesday, July 17, 2012 2:44:58 PM UTC-7, Mark Li wrote:

 I would like to know how I would add an import csv (from excel) option to 
 appadmin that would update multiple database tables (one of them a 
 relational/intermediate table).

 For example, the CSV file would look like this (in excel)

 ID |  posttitle |category  |
 1   |  title1 | cat1, cat2|
 2   |  title2 | cat2, cat3|
 3   |  title3 | cat1, cat3|

 Uploading this would update table 1 with the ID and posttitle, and also 
 the intermediate/relational table with the relationship between posttitle 
 and category (as described here: 
 http://web2py.com/books/default/chapter/29/6#Many-to-many).

 I'm new to web2py and couldn't find anything in the book, also the 
 questions previously asked already had a good grasp of what to do add a CSV 
 upload feature. I'd appreciate any help as I'm not really sure where to 
 start with this, thanks!


-- 





[web2py] x509 authentication

2012-07-17 Thread tiadobatima
Hi guys,

After reading the docs, searching through old posts, and scouring the net, 
I'm hoping someone can enlighten me regarding x509 auth:

1- How to retrieve the subject contained in the x509 certificate (serialNumber, 
commonName, etc). Any example code?
2- Does the current implementation of x509 auth require any of the 
auth_ tables in the database for anything?

Thanks!


-- 





Re: [web2py] Re: How to start a thread upon starting of webserver?

2012-07-17 Thread Amit
for development purpose I am using Rocket but  will deploy the application
to ubuntu machine where web server will be apache, so please provide me
solution for both.

On Tue, Jul 17, 2012 at 8:41 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Do you use rocket (the built-in web server) or apache?


 On Monday, 16 July 2012 23:42:49 UTC-5, Amit wrote:

 Hi,
 I have one timer thread which has to start once when web sever starts
 very first time and stop when web server stops, means it should be running
 continuously irrespective of how many users interacting with the
 application so there is only one instance of this thread running though out
 life of the application , it is common for all users who are accessing the
 application.

 How to achieve it in web2py?

  --





-- 





Re: [web2py] Web2py expert needed for start-up

2012-07-17 Thread Jason Brower
I may be able to a lot some hours from my teams if you would like the 
work. It all depends on how much you want to pay for the developer.  
Ours are some of the best in Finland and we are experienced in working 
with many kinds of platforms including web2py.

If you want to discuss more I am available on skype or through this email.
Best regards,
Jason Brower

On 07/17/2012 02:23 AM, Pepe C wrote:

Hi,

We have a set of applications on web2py and we are looking for an 
expert that can help us to operate and develop them.  This is a 
long-term role taking ~10 hours a week, although we do have a bunch of 
additional work to get done in the next few weeks.


Responsibilities include:

  * Development of new web services
  * Web2py administration and deployment
  * Polishing and addressing bugs in the existing code

Experience with Jquery mobile plugin or mobile layouts would be a big 
plus.


In your replies please tell us about your portfolio, your availability 
for the next two months and your hourly rate.


Thanks!
--






--





Re: [web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread Murtaza Husain
Yes it will be only ajax calls and I will not be using SQLFORM.

I am presuming this is the mechanism you use for preventing CSRF attacks -

1) Generate a unique value for every form that is sent to clientside.
2) Assign this value to _formkey, and also store it in the session.
3) When the user submits the form back compare the value in the _formkey
and the session.
4) If the value matches then its a valid request, otherwise its an attack.

If you are using the above mechanism -

1) How do you know which formkey to compare to which key in the session. As
you have generated multiple form keys and stored them in session, one for
each form.

I was thinking of this scheme for CSRF protection -

1) Generate a CSRF protection token and set it on client side during the
first request.
2) On every subsequent ajax call the client will grab the token and post it
with the data. (client side double submit)
3) The server will compare the returned cookie value with the POST request,
to verify if it is a valid request.

Thanks,
Murtaza

On Wed, Jul 18, 2012 at 6:03 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 It is possible. Yet there is some overhead because SQLFROM is built on top
 of helpers. It will create a representation of the form even if it unused.
 It may work to create a SQLFORM light that only does what you need. It can
 be done in a few lines of code. Let me think about it


 On Tuesday, 17 July 2012 18:12:48 UTC-5, Anthony wrote:

 I don't think there are any SQLFORMs. It's all custom Ajax calls. I'm
 guessing your JavaScript library (angular, in this case) needs to take care
 of it?


 Presumably you could still use SQLFORM to generate the _formkey value,
 send it to the client, and have the client send it back with the form
 submission. This doesn't require using web2py's default form serialization
 in the view. It's probably only worth doing it this way if you are using
 SQLFORM on the server side for processing.

 Anthony

  --





-- 





[web2py] Re: User Login/Logout authentication event

2012-07-17 Thread amit
For logout, I could not find logout_onaccept.
There is though: auth.settings.logout_onlogout
I am using v 1.99.7.

-- 





Re: [web2py] Re: CSRF consideration for running web2py with pure JS interface

2012-07-17 Thread Anthony


 I am presuming this is the mechanism you use for preventing CSRF attacks - 
  
 1) Generate a unique value for every form that is sent to clientside.
 2) Assign this value to _formkey, and also store it in the session.


Yes, but _formkey is stored along with the _formname, so it is associated 
with a particular form (which answers your question below).
 

 3) When the user submits the form back compare the value in the _formkey 
 and the session.
 4) If the value matches then its a valid request, otherwise its an attack.

 If you are using the above mechanism - 

 1) How do you know which formkey to compare to which key in the session. 
 As you have generated multiple form keys and stored them in session, one 
 for each form.


As noted above, a _formkey goes with a particular _formname. That means if 
multiple forms with the same name have been loaded in the browser (e.g., in 
separate tabs, or even on the same page), only the last form generated will 
work (because its _formkey will have overwritten the _formkey of any 
previously generated form with the same name). We've discussed allowing 
multiple formkeys for the same formname, so if a user opens a second tab 
and then goes back to the first tab to submit a form, the submission will 
work rather than failing.

Note, the _formkey mechanism is intended to prevent double form submission 
in addition to CSRF (though you can protect against double submission on 
the client via JS as well).
 

 I was thinking of this scheme for CSRF protection - 

 1) Generate a CSRF protection token and set it on client side during the 
 first request. 
 2) On every subsequent ajax call the client will grab the token and post 
 it with the data. (client side double submit)
 3) The server will compare the returned cookie value with the POST 
 request, to verify if it is a valid request.


Sounds reasonable.

Anthony

-- 





[web2py] Re: Scheduler: help us test it while learning

2012-07-17 Thread Andrew
Great Job with packaging up the app and the documentation/instructions.  
Very impressive.
I'll now start testing / familiarising myself with the scheduler 




--