Re: [web2py] Re: Webfaction: Memory usage way over your limit ; again.

2011-11-27 Thread Roberto De Ioris

 and also uwsgi --version doesn't give the version but tells that there
 is an error


This could only be generated by a wrong compiled-binary (maybe a make
without a make clean after some config changes).

--version triggers only a fprintf() on a fixed binary blob, so if it fails
something really bad is in place :)

-- 
Roberto De Ioris
http://unbit.it


[web2py] How to check a value in a dictionary entry in template?

2011-11-27 Thread Constantine Vasil
I am passing a dictionary to template. Each dictionary value is 
True or False and I want to check it value in the template.

{{=default_fields['job_title']}} renders to True

but this construct is returning SyntaxError: invalid syntax:

{{ if {{=default_fields['job_title']}}: }}

{{ pass }}

How to check a value in a dictionary entry in template?


[web2py] Re: How to check a value in a dictionary entry in template?

2011-11-27 Thread apple
{{=myvariable}} outputs myvariable to the page. You just need to refer
to the variable. Here is an example:

{{if default_fields['job_title']:}}
divthe job title is /div{{=default_fields['job_title']}}
{{pass}}

The first one checks the value. The second outputs to the page.

On Nov 27, 9:22 am, Constantine Vasil thst...@gmail.com wrote:
 I am passing a dictionary to template. Each dictionary value is
 True or False and I want to check it value in the template.

 {{=default_fields['job_title']}} renders to True

 but this construct is returning SyntaxError: invalid syntax:

 {{ if {{=default_fields['job_title']}}: }}

 {{ pass }}

 How to check a value in a dictionary entry in template?


Re: [web2py] Re: Webfaction: Memory usage way over your limit ; again.

2011-11-27 Thread Vasile Ermicioi
but the binary works as it executes web2py and website works but doesn't
allow me to login (without showing errors)
and my flex app shows the error that I wrote before,
and --version shows this error

./uwsgi --version
uWSGI 1.0-dev
*** glibc detected *** ./uwsgi: free(): invalid pointer: 0x099204e8 ***
=== Backtrace: =
/lib/libc.so.6[0x9d66c5]
/lib/libc.so.6(cfree+0x59)[0x9d6b09]
/lib/libselinux.so.1[0xb8107e]
/lib/libselinux.so.1[0xb75632]
/lib/libselinux.so.1[0xb8253c]
/lib/ld-linux.so.2[0x95c996]
/lib/libc.so.6(exit+0xe9)[0x998ec9]
./uwsgi(manage_opt+0x10b8)[0x8073908]
./uwsgi(main+0x7ff)[0x80764af]
/lib/libc.so.6(__libc_start_main+0xdc)[0x982e9c]
./uwsgi[0x8053431]
=== Memory map: 
0011-0012f000 r-xp  68:05 14746876   /lib/libpcre.so.0.0.1
0012f000-0013 rw-p 0001e000 68:05 14746876   /lib/libpcre.so.0.0.1
0013-00134000 r-xp  68:05 14745630   /lib/libuuid.so.1.2
00134000-00135000 rw-p 3000 68:05 14745630   /lib/libuuid.so.1.2
00135000-0027e000 r-xp  68:05 182846037
 /home/fermer/lib/libpython2.7.so.1.0
0027e000-002ac000 rw-p 00149000 68:05 182846037
 /home/fermer/lib/libpython2.7.so.1.0
002ac000-002b6000 rw-p 002ac000 00:00 0
002b6000-002ce000 r-xp  68:05 131618952  /usr/lib/libsasl2.so.2.0.22
002ce000-002cf000 rw-p 00017000 68:05 131618952  /usr/lib/libsasl2.so.2.0.22
002cf000-00363000 r-xp  68:05 131618556  /usr/lib/libkrb5.so.3.3
00363000-00366000 rw-p 00093000 68:05 131618556  /usr/lib/libkrb5.so.3.3
00366000-00371000 r-xp  68:05 14746848
/lib/libgcc_s-4.1.2-20080825.so.1
00371000-00372000 rw-p a000 68:05 14746848
/lib/libgcc_s-4.1.2-20080825.so.1
00387000-00388000 r-xp 00387000 00:00 0  [vdso]
0040b000-00438000 r-xp  68:05 131618949
 /usr/lib/libgssapi_krb5.so.2.2
00438000-00439000 rw-p 0002d000 68:05 131618949
 /usr/lib/libgssapi_krb5.so.2.2
004bd000-005e9000 r-xp  68:05 131614729  /usr/lib/libxml2.so.2.6.26
005e9000-005ee000 rw-p 0012c000 68:05 131614729  /usr/lib/libxml2.so.2.6.26
005ee000-005ef000 rw-p 005ee000 00:00 0
005f1000-00635000 r-xp  68:05 14746857   /lib/libssl.so.0.9.8e
00635000-00639000 rw-p 00043000 68:05 14746857   /lib/libssl.so.0.9.8e
00639000-00763000 r-xp  68:05 14746856   /lib/libcrypto.so.0.9.8e
00763000-00776000 rw-p 00129000 68:05 14746856   /lib/libcrypto.so.0.9.8e
00776000-0077a000 rw-p 00776000 00:00 0
0094e000-00969000 r-xp  68:05 14746845   /lib/ld-2.5.so
00969000-0096a000 r--p 0001a000 68:05 14746845   /lib/ld-2.5.so
0096a000-0096b000 rw-p 0001b000 68:05 14746845   /lib/ld-2.5.so
0096d000-00ac r-xp  68:05 14746846   /lib/libc-2.5.so
00ac-00ac2000 r--p 00153000 68:05 14746846   /lib/libc-2.5.so
00ac2000-00ac3000 rw-p 00155000 68:05 14746846   /lib/libc-2.5.so
00ac3000-00ac6000 rw-p 00ac3000 00:00 0
00ac8000-00aef000 r-xp  68:05 14746847   /lib/libm-2.5.so
00aef000-00af r--p 00026000 68:05 14746847   /lib/libm-2.5.so
00af-00af1000 rw-p 00027000 68:05 14746847   /lib/libm-2.5.so
00af3000-00af6000 r-xp  68:05 14746849   /lib/libdl-2.5.so
00af6000-00af7000 r--p 2000 68:05 14746849   /lib/libdl-2.5.so
00af7000-00af8000 rw-p 3000 68:05 14746849   /lib/libdl-2.5.so
00afa000-00b0f000 r-xp  68:05 14746859   /lib/libpthread-2.5.so
00b0f000-00b1 r--p 00015000 68:05 14746859   /lib/libpthread-2.5.so
00b1-00b11000 rw-p 00016000 68:05 14746859   /lib/libpthread-2.5.so
00b11000-00b13000 rw-p 00b11000 00:00 0
00b15000-00b27000 r-xp  68:05 14746855   /lib/libz.so.1.2.3
00b27000-00b28000 rw-p 00011000 68:05 14746855   /lib/libz.so.1.2.3
00b2a000-00b65000 r-xp  68:05 14746852   /lib/libsepol.so.1
00b65000-00b66000 rw-p 0003b000 68:05 14746852   /lib/libsepol.so.1
00b66000-00b7 rw-p 00b66000 00:00 0
00b72000-00b88000 r-xp  68:05 14746853   /lib/libselinux.so.1
00b88000-00b8a000 rw-p 00015000 68:05 14746853   /lib/libselinux.so.1
00b97000-00ba r-xp  68:05 14746858   /lib/libcrypt-2.5.so
00ba-00ba1000 r--p 8000 68:05 14746858   /lib/libcrypt-2.5.so
00ba1000-00ba2000 rw-p 9000 68:05 14746858   /lib/libcrypt-2.5.so
00ba2000-00bc9000 rw-p 00ba2000 00:00 0
00bcb000-00bcd000 r-xp  68:05 14746865   /lib/libutil-2.5.so
00bcd000-00bce000 r--p 1000 68:05 14746865   /lib/libutil-2.5.so
00bce000-00bcf000 rw-p 2000 68:05 14746865   /lib/libutil-2.5.so
00c1c000-00c29000 r-xp  68:05 131618951
 /usr/lib/liblber-2.3.so.0.2.31
00c29000-00c2a000 rw-p c000 68:05 131618951
 /usr/lib/liblber-2.3.so.0.2.31
00c63000-00c9c000 r-xp  68:05 131615394
 /usr/lib/libldap-2.3.so.0.2.31
00c9c000-00c9d000 rw-p 00039000 68:05 131615394
 /usr/lib/libldap-2.3.so.0.2.31
00d8b000-00d8d000 r-xp  68:05 14746850   /lib/libkeyutils-1.2.so
00d8d000-00d8e000 rw-p 1000 68:05 14746850   /lib/libkeyutils-1.2.so
00d9-00da r-xp  68:05 14746851   /lib/libresolv-2.5.so
00da-00da1000 r--p f000 68:05 14746851   

[web2py] Adding custom fields or virtual fields to rows object

2011-11-27 Thread villas
I know we had this discussion about a year ago and Bruno et al wrote their 
own code and proposed patches to try and get around this limitation,  which 
also limits the usefulness of SQLTABLE.

I just wondered if we had any new methods or techniques to add columns  etc 
to the rows object.

Thanks,
David


[web2py] Re: Adding custom fields or virtual fields to rows object

2011-11-27 Thread Anthony
Virtual fields can already be added to Rows 
objects: http://web2py.com/book/default/chapter/06#Virtual-Fields.

Also, SQLTABLE takes an 'extracolumns' argument, like this:

extracolums = [{'label':A('Extra',_href='#'),
'class': '', #class name of the header
'width':'', #width in pixels or %
'content':lambda row, rc: 
A('Edit',_href='edit/%s'%row.id),
'selected': False #agregate class selected to this 
column
}]

And SQLFORM.grid takes a 'links' argument, which can be used to add extra 
columns.

Anthony

On Sunday, November 27, 2011 7:30:15 AM UTC-5, villas wrote:

 I know we had this discussion about a year ago and Bruno et al wrote their 
 own code and proposed patches to try and get around this limitation,  which 
 also limits the usefulness of SQLTABLE.

 I just wondered if we had any new methods or techniques to add columns 
  etc to the rows object.

 Thanks,
 David



[web2py] PostgreSQL names case sensitivity

2011-11-27 Thread Alan Etkin
Hi, I am trying to use PostgreSQL DAL interface with my project, but
i'm having trouble with table references and insert/update/delete
commands.

The system info:
OS: GNU/Linux, web2py 1.99.2, PostgreSQL 8.4

I have tried the workaround posted by pbreit for a very similar
problem:
http://groups.google.com/group/web2py/browse_thread/thread/b9eb96cbb5dbbc3f/7590e311d57260d9

The tables are created first without references and after that the
rest of the fields are added, so define_tables is called twice for
each table. As of this point all tables are created without errors.
Then I try to upload legacy records from a customized csv file. When
running the insert commands web2py raises this exception: (insert
commands include the id field number as argument)

Traceback (most recent call last):
  File /home/alan/gestionlibre_gui-hg/controllers/appadmin.py, line
172, in create
config.session.record_id =
config.session.db_table.insert(**config.session.form.vars)
  File /home/alan/web2py/gluon/dal.py, line 4976, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File /home/alan/web2py/gluon/dal.py, line 890, in insert
id = self.lastrowid(table)
  File /home/alan/web2py/gluon/dal.py, line 1830, in lastrowid
self.execute(select currval('%s') % table._sequence_name)
  File /home/alan/web2py/gluon/dal.py, line 1309, in execute
return self.log_execute(*a, **b)
  File /home/alan/web2py/gluon/dal.py, line 1304, in log_execute
ret = self.cursor.execute(*a,**b)
psycopg2.ProgrammingError: relation debugging_id_seq does not exist
LÍNEA 1: select currval('debugging_id_Seq')
^

Where debugging is a table defined in the model and debugging_id is
the id field

Maybe there is some conflict with auto generated web2py sql and the db
engine

I think that this has something to do with this thread on PostgeSQL
and quotes:
http://groups.google.com/group/web2py/browse_thread/thread/e894189f9b532b75/5d248791cd55c4d1

Thank you


[web2py] Problem understanding imports

2011-11-27 Thread david.waldrop
I am trying to use the suggest widget plugin, but am getting an error on 
the import.  

from plugin_suggest_widget import suggest_widget
db.auth_user.org_ref.widget = suggest_widget(db.org.name, 
limitby=(0,10), min_length=1)

and get the error:

Traceback (most recent call last):
  File gluon/restricted.py, line 194, in restricted
  File C:/Users/david/My 
Projects/Miscelaneous/MeetingMonkey/web2py/applications/COPSIS/controllers/plugin_suggest_widget.py
 
http://127.0.0.1:8000/admin/default/edit/COPSIS/controllers/plugin_suggest_widget.py,
 line 2, in module
  File gluon/custom_import.py, line 294, in __call__
  File gluon/custom_import.py, line 78, in __call__
ImportError: No module named plugin_suggest_widget


I installed the plug in via the admin interface.  This is the only plugin I am 
using in the test app.

The plugin name is 

plugin_suggest_widget

it has no models

one controller which i think is for testing named plugin_suggest_widget.py

no views

1 folder of static files name plugin_suggest_widget/

   suggest.css

   suggest.js

1 module named plugin_suggest_widget.py  



[web2py] I cant start the web2py shell

2011-11-27 Thread chawk
I have tried to start the shell through windows dos prompt by typing:

 python web2py.py -s test -m

and i get this: python cant open file web2py.py no such file or
directory

not sure why i cannot get this working.







[web2py] Re: How to check a value in a dictionary entry in template?

2011-11-27 Thread Constantine Vasil
Thank you!

Re: [web2py] I cant start the web2py shell

2011-11-27 Thread Javier Quarite



 and i get this: python cant open file web2py.py no such file or
 directory

 It seems that you're not inside web2py directory


Re: [web2py] I cant start the web2py shell

2011-11-27 Thread Kenneth Lundström

Are you in the folder wher you have installed web2py?


Kenneth


I have tried to start the shell through windows dos prompt by typing:

  python web2py.py -s test -m

and i get this: python cant open file web2py.py no such file or
directory

not sure why i cannot get this working.









Re: [web2py] Problem understanding imports

2011-11-27 Thread Bruno Rocha
probably there is an error in the plugin module.

the error can be in syntax or importing something inside the module.

check if the plugin is not trying to import another module.

I often have problems like that when there is some errors ij module.

http://zerp.ly/rochacbruno
Em 27/11/2011 12:47, david.waldrop david.wald...@gmail.com escreveu:

 I am trying to use the suggest widget plugin, but am getting an error on
 the import.

 from plugin_suggest_widget import suggest_widget
 db.auth_user.org_ref.widget = suggest_widget(db.org.name,
 limitby=(0,10), min_length=1)

 and get the error:

 Traceback (most recent call last):
   File gluon/restricted.py, line 194, in restricted
   File C:/Users/david/My 
 Projects/Miscelaneous/MeetingMonkey/web2py/applications/COPSIS/controllers/plugin_suggest_widget.py
  
 http://127.0.0.1:8000/admin/default/edit/COPSIS/controllers/plugin_suggest_widget.py,
  line 2, in module
   File gluon/custom_import.py, line 294, in __call__
   File gluon/custom_import.py, line 78, in __call__
 ImportError: No module named plugin_suggest_widget


 I installed the plug in via the admin interface.  This is the only plugin I 
 am using in the test app.

 The plugin name is

 plugin_suggest_widget

 it has no models

 one controller which i think is for testing named plugin_suggest_widget.py

 no views

 1 folder of static files name plugin_suggest_widget/

suggest.css

suggest.js

 1 module named plugin_suggest_widget.py




[web2py] Re: cross-platform apps

2011-11-27 Thread VP
Thanks Anthony.

Is Skeletion configured by default when a new application is created
or it's just in this welcome app?

Thanks,
VP


On Nov 26, 10:35 pm, Anthony abasta...@gmail.com wrote:
 On the server side, request.user_agent() returns info about the user agent,
 and request.user_agent().is_mobile indicates whether it's a mobile device.
 You can also decorate a function with @mobilize, and when it's a mobile
 client, it will automatically change the view from func.html to
 func.mobile.html, so you can have a separate mobile view (which can extend
 an alternative layout). I suppose you could also specify a variable in the
 {{extend ...}} to extend different layouts for mobile and non-mobile
 requests, but in that case, you won't be able to byetcode compile the views
 (because the view being extended must be known at compile time).

 You can also do things on the client side with CSS media queries and JS.
 For example, the new 'welcome' app (in trunk -- demo 
 here:http://tests.web2py.com/welcome/) uses Skeleton
 (http://www.getskeleton.com). If you make your browser window skinny,
 you'll see how the layout changes (dynamically) to accommodate the narrow
 screen.

 Anthony







 On Saturday, November 26, 2011 9:10:50 PM UTC-5, VP wrote:

  Hi,
  I know web2py has a seemingly very useful plugin for jquery mobile.  I
  am wondering what everyone does for apps that are supposed to be
  tailored for both PCs and mobile devices.  At the simplest level,
  let's say there are two layouts that need to be switched depending on
  which platforms.  How do we do this efficiently in web2py?

  Further, in addition to layouts, different controllers might be needed
  for different platforms too.  How do we do this efficiently?

  Thanks.
  VP


[web2py] some ideas on built-in emphasis on client-side processing for web2py

2011-11-27 Thread VP
Hi massimo and everyone,

Hope everyone is doing fine.

With support for Pyjamas, Massimo must have thought of this, but for
some reason I feel something ain't right with the Pyjamas' approach.

I have just realised that there has been massive amount of effort
dedicated to client-side processing in the javascript community.
Things like knockout.js, spine.js, backbone.js, and alot more.

Being able to move processing from server to client will greatly
affect scalability.  One thing we can start with is template
processing.  You can translate python codes directly to javascript and
embed it on the client side for processing or you can use javascript
template engines like handlebar.js, jade.js instead of web2py template
engine.

More generally, if there is a mechanism to delegate a piece of Python
code in web2py (via decoration or inheritance), that would be very
nice.  I would imagine one can use Pyjamas' pyjs.js to translate the
Python code to javascript or to use something like Skulpt (which will
be slow) to interpret Python code directly on the browsers.

VP


[web2py] Translation error in SQLFORM.grid

2011-11-27 Thread José L .
When using SQLFORM.grid, the message:
'%(nrows)s records found'
is never translated and it fills the language/lang.py file with 
untranslated strings whenever the number of rows change.

Changing in gluon/sqlhtml.py, in the grid static method, the line:

message = error or T('%(nrows)s records found' % dict(nrows=nrows))


by:

message = error or T('%s records found', nrows)


The problem is fixed.

I've filled bug #539 to follow this issue.

Regards.
José L.


[web2py] Re: cross-platform apps

2011-11-27 Thread Anthony
The 'welcome' app is the foundation for any new app created via 'admin', so 
yes, you'll get the Skeleton scaffold for any new app. Note, this is 
currently only in trunk -- I believe Massimo is planning the next release 
very soon.

Anthony

On Sunday, November 27, 2011 11:45:47 AM UTC-5, VP wrote:

 Thanks Anthony.

 Is Skeletion configured by default when a new application is created
 or it's just in this welcome app?

 Thanks,
 VP


 On Nov 26, 10:35 pm, Anthony abas...@gmail.com wrote:
  On the server side, request.user_agent() returns info about the user 
 agent,
  and request.user_agent().is_mobile indicates whether it's a mobile 
 device.
  You can also decorate a function with @mobilize, and when it's a mobile
  client, it will automatically change the view from func.html to
  func.mobile.html, so you can have a separate mobile view (which can 
 extend
  an alternative layout). I suppose you could also specify a variable in 
 the
  {{extend ...}} to extend different layouts for mobile and non-mobile
  requests, but in that case, you won't be able to byetcode compile the 
 views
  (because the view being extended must be known at compile time).
 
  You can also do things on the client side with CSS media queries and JS.
  For example, the new 'welcome' app (in trunk -- demo here:
 http://tests.web2py.com/welcome/) uses Skeleton
  (http://www.getskeleton.com). If you make your browser window skinny,
  you'll see how the layout changes (dynamically) to accommodate the narrow
  screen.
 
  Anthony
 
 
 
 
 
 
 
  On Saturday, November 26, 2011 9:10:50 PM UTC-5, VP wrote:
 
   Hi,
   I know web2py has a seemingly very useful plugin for jquery mobile.  I
   am wondering what everyone does for apps that are supposed to be
   tailored for both PCs and mobile devices.  At the simplest level,
   let's say there are two layouts that need to be switched depending on
   which platforms.  How do we do this efficiently in web2py?
 
   Further, in addition to layouts, different controllers might be needed
   for different platforms too.  How do we do this efficiently?
 
   Thanks.
   VP



[web2py] how to change form.custom.submit background?

2011-11-27 Thread Constantine Vasil
I am following the example to make my own custom form
design:
http://www.web2py.com/book/default/chapter/


{{=form.custom.begin}}
Image name: div{{=form.custom.widget.name}}/div
Image file: div{{=form.custom.widget.file}}/div
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}


Generated HTML is:

 Click here to submit: input type=submit value=Submit /

I want to add my own tag data-theme=e so the final HTML

to be:

Click here to submit: input data-theme=e type=submit value=Submit /

Or simply to change the background color to make the Submit button

better visible.


How to do that?








[web2py] Re: how to change form.custom.submit background?

2011-11-27 Thread Anthony
In the controller or view, you should be able to do:

form.custom.submit['_data-theme'] = 'e'

or

form.custom.submit.update(**{'_data-theme': 'e'})

form.custom.submit is just an INPUT helper, so you can add additional 
attributes to it like any html helper object.

Anthony


[web2py] Re: I cant start the web2py shell

2011-11-27 Thread chawk
I must be missing something, i have always run web2py by downloading
and extracting to a directory.  i then double click the web2py.exe and
it starts the server, but i cannot ever get the shell to work, so that
i can practice with the DAL.   is there more to installing it then
this?


[web2py] Re: how to change form.custom.submit background?

2011-11-27 Thread Constantine Vasil
Thank you, this was so simple!

[web2py] Re: Adding custom fields or virtual fields to rows object

2011-11-27 Thread villas
Hi Anthony,

Thanks for that,  I couldn't remember about the 'extracolumns' and I don't 
think they were in the book yet (unless just recently).

With regards the virtual fields,  I was still struggling with including the 
virtualfields when limiting columns. 

This works fine:
rows = db(db.table.id0).select()
for row in rows: print row.myvirtualfield

But this does not:
rows = db(db.table.id0).select(db.table.id, db.table.myvirtualfield)
  keyerror: db.table.myvirtualfield

It doesn't matter on a table with few fields,  but when the rows are very 
wide,  it hurts.  I made this point recently with regards to SQLFORM.grid, 
 so I guess I ought to be patient until it becomes a priority.  Thanks for 
you help

Regards, David



[web2py] how to update auth_user first_name last_name programmatically?

2011-11-27 Thread Constantine Vasil
I want to change auth_user first_name and last name
progrmmaically having the user id:

I tried this:
db.auth_user[id] = dict(first_name=first_name)
db.auth_user[id] = dict(last_name=last_name)

but when reaching this statement in my db.py file I don't see 
auth updated:

db = DAL('google:datastore')
auth = Auth(db, hmac_key=Auth.get_or_create_key()) 

How is the right way to do that?




Re: [web2py] Re: I cant start the web2py shell

2011-11-27 Thread ~redShadow~
On Sun, 2011-11-27 at 12:13 -0800, chawk wrote: 
 I must be missing something, i have always run web2py by downloading
 and extracting to a directory.  i then double click the web2py.exe and
 it starts the server, but i cannot ever get the shell to work, so that
 i can practice with the DAL.   is there more to installing it then
 this?

Looks like you are not running command from web2py directory.
You have to cd into it before running that command.
That's not so easy on windows due to path names containing spaces broken
tabbing in DOS. My suggestion to do it quickly is: place web2py
directory directly inside C:\, then type

cd C:\web2py
python web2py.py -s test -m


-- 
Samuele ~redShadow~ Santi

 redshadow[at]hackzine.org - redshadowhack[at]gmail.com

  Blog: http://hackzine.org

  GPG Key signature:
   050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933

/me recommends:
Squadra Informatica - http://www.squadrainformatica.com

 - Proud ThinkPad T-Series owner
 - Registered Linux-User: #440008
  * GENTOO User since 1199142000 (2008-01-01)
  * former DEBIAN SID user

  Software is like sex: it's better when it's free!
  -- Linus Torvalds



signature.asc
Description: This is a digitally signed message part


[web2py] Re: how to update auth_user first_name last_name programmatically?

2011-11-27 Thread Massimo Di Pierro
Any of these will work:

db.auth_user[id] = dict(first_name=first_name)
db.auth_user[id].update_record(first_name=first_name)
db(db.auth_user.id==id).update(first_name=first_name)

the problem is (I believe) that auth caches the current logged in user
in session.auth.user==auth.user so you also need:

auth.user.first_name=first_name




On Nov 27, 3:35 pm, Constantine Vasil thst...@gmail.com wrote:
 I want to change auth_user first_name and last name
 progrmmaically having the user id:

 I tried this:
         db.auth_user[id] = dict(first_name=first_name)
         db.auth_user[id] = dict(last_name=last_name)

 but when reaching this statement in my db.py file I don't see
 auth updated:

     db = DAL('google:datastore')
     auth = Auth(db, hmac_key=Auth.get_or_create_key())

 How is the right way to do that?


[web2py] simpatiCA -- A simple PKI for x509 in web2py

2011-11-27 Thread Michele Comitini
Hi list,

I have released a small PKI implementation for those who need to start
with web2py + SSL/TLS + x509.
At the moment the documentation is 0, but it is quite simple so anyone
that has some knowlege of PKI can try to use it.
Please note that today it is still very basic and too young to be the
foundation of an enterprise grade PKI.
It has an rpc endpoit so that it can be easily plugged in a
registration flow thanks to web2py jsonrpc support.
And yes it can be used to generate both server certs and client certs.
The code is under released under GPLv3 license and is available only
through git.  Find it at:

http://simpatica.googlecode.com


mic


[web2py] Re: I cant start the web2py shell

2011-11-27 Thread chawk
I don't understand, i am using windows 7, python 2.7, python is added
to my enviroment variables, I even downloaded another copy of web2py,
extracted it to the c directory, i cd into web2py directory, i ran the
exact thing shown and i get the error:

   python: cant open file 'web2py.py' : [Errno 2] No such file or
directory

i downloaded the web2py stable version dedicated for everybody.


Re: [web2py] Re: I cant start the web2py shell

2011-11-27 Thread Javier Quarite
On Sun, Nov 27, 2011 at 5:23 PM, chawk chrshawke...@gmail.com wrote:

 I don't understand, i am using windows 7, python 2.7, python is added
 to my enviroment variables, I even downloaded another copy of web2py,
 extracted it to the c directory, i cd into web2py directory, i ran the
 exact thing shown and i get the error:

   python: cant open file 'web2py.py' : [Errno 2] No such file or
 directory

 i downloaded the web2py stable version dedicated for everybody.


You got to be inside your directory...

maybe youre command looks like this

c:/users/name/python web2py.py

but it should be

c:/users/name/web2py/python web2py.py

PD: It depends a lot of the location of your web2py folder, its just a
quick example


[web2py] Re: I cant start the web2py shell

2011-11-27 Thread Anthony
Don't download the Windows version -- it has it's own Python 2.5 
interpreter. Instead, download the source version -- that will run with 
your own Python 2.7 installation.

Anthony

On Sunday, November 27, 2011 5:23:47 PM UTC-5, chawk wrote:

 I don't understand, i am using windows 7, python 2.7, python is added
 to my enviroment variables, I even downloaded another copy of web2py,
 extracted it to the c directory, i cd into web2py directory, i ran the
 exact thing shown and i get the error:

python: cant open file 'web2py.py' : [Errno 2] No such file or
 directory

 i downloaded the web2py stable version dedicated for everybody.



[web2py] Re: I cant start the web2py shell

2011-11-27 Thread chawk
Thanks Anthony!

that was the problem, i was not aware that python 2.5 comes with the
standard web2py version.

i downloaded the source and the problem is solved.




[web2py] Re: how to update auth_user first_name last_name programmatically?

2011-11-27 Thread Constantine Vasil
Hi Massimo,

It worked, the cache was the issue. Also is it possible to 
update both first and last name in batch? This is a general question
how can the database fields can be updated in one operation?

Thank you, the framework is excellent!


[web2py] on micro frameworks

2011-11-27 Thread Massimo Di Pierro
http://rawsyntax.com/blog/the-problem-with-micro-frameworks/


[web2py] Re: simpatiCA -- A simple PKI for x509 in web2py

2011-11-27 Thread Massimo Di Pierro
:-)

On Nov 27, 4:18 pm, Michele Comitini michele.comit...@gmail.com
wrote:
 Hi list,

 I have released a small PKI implementation for those who need to start
 with web2py + SSL/TLS + x509.
 At the moment the documentation is 0, but it is quite simple so anyone
 that has some knowlege of PKI can try to use it.
 Please note that today it is still very basic and too young to be the
 foundation of an enterprise grade PKI.
 It has an rpc endpoit so that it can be easily plugged in a
 registration flow thanks to web2py jsonrpc support.
 And yes it can be used to generate both server certs and client certs.
 The code is under released under GPLv3 license and is available only
 through git.  Find it at:

 http://simpatica.googlecode.com

 mic


[web2py] Re: how to update auth_user first_name last_name programmatically?

2011-11-27 Thread Massimo Di Pierro
Any of these will do:

db.auth_user[id] =
dict(first_name=first_name,last_name=last_name) db.auth_user[id].update_record(first_name=first_name,last_name=last_name) db(db.auth_user.id==id).update(first_name=first_name,last_name=last_name)
On Nov 27, 5:51 pm, Constantine Vasil thst...@gmail.com wrote:
 Hi Massimo,

 It worked, the cache was the issue. Also is it possible to
 update both first and last name in batch? This is a general question
 how can the database fields can be updated in one operation?

 Thank you, the framework is excellent!


[web2py] Decimal vs float

2011-11-27 Thread pbreit
I have some price fields specified as type 'decimal'. But am finding that I 
have to cast to 'float' do do any math (or the other to decimal.Decimal I 
guess).

This seems cumbersome. Is 'decimal' the best field type for storing 
financial amounts that will be involved in math calculations?


[web2py] Re: Decimal vs float

2011-11-27 Thread Massimo Di Pierro
You should not need any casting to do math computations. Can you
provide an example of what you do, perhaps something does not behave
as intended.

On Nov 27, 7:33 pm, pbreit pbreitenb...@gmail.com wrote:
 I have some price fields specified as type 'decimal'. But am finding that I
 have to cast to 'float' do do any math (or the other to decimal.Decimal I
 guess).

 This seems cumbersome. Is 'decimal' the best field type for storing
 financial amounts that will be involved in math calculations?


[web2py] SQLFORM.factory and custom HTML form radio boxes

2011-11-27 Thread Constantine Vasil
I am using SQLFORM.factory to set several fields and a custom form
setting a radio boxes like this:

input type=radio name=primary-email-choice id=id_email_home_ch 
value=Home checked=yes/

I want the code 
if form.process(formname='myinfo').accepted:

to be able to check if id_email_home_ch is checked or not, but this
id does not appear in form.vars

How to do that?




[web2py] Error in custom_import and Pyforum

2011-11-27 Thread mikech
Hi:  I downloaded Pyforums in order to study some code in what looks like a 
very well done application.  When I try to look at the default index view I 
get the following error:

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

Traceback (most recent call last):
  File gluon/restricted.py, line 194, in restricted
  File C:\web2py\applications\pyforum\controllers/default.py, line 6, in 
module
  File gluon/custom_import.py, line 294, in __call__
  File gluon/custom_import.py, line 78, in __call__
ImportError: No module named json


Running Version 1.99.2 (2011-09-26 06:55:33) stable



[web2py] How to preselect radio check box with checked=yes using SQLFORM.factory?

2011-11-27 Thread Constantine Vasil
in SQLFORM.factory I have defined a radio check box.

Field('primary_email_choice_new', widget=SQLFORM.widgets.radio.widget, 
requires=IS_IN_SET({'Work' : 'Work', 'Home' : 'Home'})),   
 

It shows on the form but I need to set it checked=yes one of the values.

The generated HTML is:
divtable class=string id=no_table_primary_email_choice_new 
name=primary_email_choice_newtrtd
input id=primary_email_choice_newHome name=primary_email_choice_new 
type=radio value=Home /

label for=primary_email_choice_newHomeHome/label/td/trtrtd
input id=primary_email_choice_newWork name=primary_email_choice_new 
type=radio value=Work /label 
for=primary_email_choice_newWorkWork/label/td/tr/table/div

If I know how to make one of the values checked it would be:
The generated HTML is:
divtable class=string id=no_table_primary_email_choice_new 
name=primary_email_choice_newtrtd
input id=primary_email_choice_newHome name=primary_email_choice_new 
type=radio value=Home checked=yes/

label for=primary_email_choice_newHomeHome/label/td/trtrtd
input id=primary_email_choice_newWork name=primary_email_choice_new 
type=radio value=Work /label 
for=primary_email_choice_newWorkWork/label/td/tr/table/div


How to do that?




[web2py] Re: Adding custom fields or virtual fields to rows object

2011-11-27 Thread Anthony
Good point. Maybe submit an issue on Google 
Code: http://code.google.com/p/web2py/issues/list

On Sunday, November 27, 2011 3:58:37 PM UTC-5, villas wrote:

 Hi Anthony,

 Thanks for that,  I couldn't remember about the 'extracolumns' and I don't 
 think they were in the book yet (unless just recently).

 With regards the virtual fields,  I was still struggling with including 
 the virtualfields when limiting columns. 

 This works fine:
 rows = db(db.table.id0).select()
 for row in rows: print row.myvirtualfield

 But this does not:
 rows = db(db.table.id0).select(db.table.id, db.table.myvirtualfield)
   keyerror: db.table.myvirtualfield

 It doesn't matter on a table with few fields,  but when the rows are very 
 wide,  it hurts.  I made this point recently with regards to SQLFORM.grid, 
  so I guess I ought to be patient until it becomes a priority.  Thanks for 
 you help

 Regards, David



[web2py] Re: How to preselect radio check box with checked=yes using SQLFORM.factory?

2011-11-27 Thread Anthony
Try:

Field('primary_email_choice_new', widget=SQLFORM.widgets.radio.widget,
requires=IS_IN_SET({'Work' : 'Work', 'Home' : 'Home'}), default='Home')

Also, I think it's checked=checked, not checked=yes.

Anthony

On Sunday, November 27, 2011 9:59:30 PM UTC-5, Constantine Vasil wrote:

 in SQLFORM.factory I have defined a radio check box.

 Field('primary_email_choice_new', widget=SQLFORM.widgets.radio.widget, 
 requires=IS_IN_SET({'Work' : 'Work', 'Home' : 'Home'})),   
  

 It shows on the form but I need to set it checked=yes one of the values.

 The generated HTML is:
 divtable class=string id=no_table_primary_email_choice_new 
 name=primary_email_choice_newtrtd
 input id=primary_email_choice_newHome name=primary_email_choice_new 
 type=radio value=Home /

 label for=primary_email_choice_newHomeHome/label/td/trtrtd
 input id=primary_email_choice_newWork name=primary_email_choice_new 
 type=radio value=Work /label 
 for=primary_email_choice_newWorkWork/label/td/tr/table/div

 If I know how to make one of the values checked it would be:
 The generated HTML is:
 divtable class=string id=no_table_primary_email_choice_new 
 name=primary_email_choice_newtrtd
 input id=primary_email_choice_newHome name=primary_email_choice_new 
 type=radio value=Home checked=yes/

 label for=primary_email_choice_newHomeHome/label/td/trtrtd
 input id=primary_email_choice_newWork name=primary_email_choice_new 
 type=radio value=Work /label 
 for=primary_email_choice_newWorkWork/label/td/tr/table/div


 How to do that?




[web2py] Re: SQLFORM.factory and custom HTML form radio boxes

2011-11-27 Thread Anthony
form.vars will include the input field name, not id. Radio buttons will 
have the same name, and that name should be in form.vars, with the value of 
the particular radio button selected. Note, you may need to change the name 
to 'primary_email_choice' so it can be used as a Python identifier.

Anthony

On Sunday, November 27, 2011 9:04:26 PM UTC-5, Constantine Vasil wrote:

 I am using SQLFORM.factory to set several fields and a custom form
 setting a radio boxes like this:

 input type=radio name=primary-email-choice id=id_email_home_ch 
 value=Home checked=yes/

 I want the code 
 if form.process(formname='myinfo').accepted:

 to be able to check if id_email_home_ch is checked or not, but this
 id does not appear in form.vars

 How to do that?




[web2py] Re: on micro frameworks

2011-11-27 Thread Anthony
Similar points 
here: 
http://www.reddit.com/r/Python/comments/f8so6/best_framework_for_gae/c1ebgn0



[web2py] Re: How to preselect radio check box with checked=yes using SQLFORM.factory?

2011-11-27 Thread Constantine Vasil
HI Anthony,

Thank you! 

This is useful information not available in the book.

Now I would define the default in the form definition:
form = SQLFORM.factory

How to change it programmatically to other checked 
value before the form is submitted? 

This can be needed for a reason as I do - because I 
don't store the default value in a database but calculate 
it on another values?







[web2py] Re: SQLFORM.factory and custom HTML form radio boxes

2011-11-27 Thread Constantine Vasil
Basically I reverse engineered the HTML generated from web2py and
came with the following solution:
In SQLFORM.factory I have this definition:
Field('*primary_email_choice*', widget=SQLFORM.widgets.radio.widget, 
requires=IS_IN_SET({'Work' : 'Work', '*Home*' : 'Home'})),

So in the HTML id=*primary_email_choiceHome*  is a combination of 
*primary_email_choice* and one of the values in the set: *Home.*
So I manually composed to HTML to have more control. I have the 
value in primary_email which determines if the radio check box is checked 
or not dynamically when the HTML is rendered. It is much more cleared that 
way and I have a full control on the design:

{{ if fields['primary_email'] == Home: }} 
   
input type=radio 
name=primary_email_choice id=*primary_email_choiceHome* value=Home 
checked=yes/
{{ else: }}
input type=radio 
name=primary_email_choice id=primary_email_choiceHome value=Home /
{{ pass }}
label for=primary_email_choiceHome{{ if 
fields['primary_email'] == Home: }}Primary Email: Home{{ else: }}Choose 
Email Home as Primary Email{{ pass }}/label

Radio check-boxes are under-described in the book and I believe this 
solution will help others to do the same.





[web2py] Quick Question about Wiki Tutorial: .default attribute for db foreign-key field

2011-11-27 Thread Aaron Levin
Hi,

For the Wiki Tutorial, In the show(): controller in default.py there
is the following statement:

db.comment.page_id.default = this_page.id

I can't quite figure out what it means. Are we setting the default
value of the page_id field for the comment table to be 'this_page.id?
However, in this case, this_page is being fetched from the database,
so potentially this default value could change everytime the show()
controller is called. This defeats the point of defining a default
value.

Additionally, I'm not really sure how this is used in the code?

I'm really enjoying learning this framework, thank you.

Best,

Aaron Levin


[web2py] Re: Adding custom fields or virtual fields to rows object

2011-11-27 Thread Massimo Di Pierro
 This works fine:

 rows = db(db.table.id0).select()
 for row in rows: print row.myvirtualfield

that is because the row.myvirtualfield is computed AFTER the sql
select

 But this does not:
 rows = db(db.table.id0).select(db.table.id, db.table.myvirtualfield)

because there is no such a thing as a myvirtualfield as far as the
database is concerned. The virtualfield is computed after the select.
It cannot be something you want to select from the db.


[web2py] Book typo

2011-11-27 Thread Johann Spies
In http://www.web2py.com/book/default/chapter/06?search=form.process

ret = db(query).vaidate_and_update(field='value')


should probably be

ret = db(query).validate_and_update(field='value')


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


Re: [web2py] PostgreSQL names case sensitivity

2011-11-27 Thread Johann Spies
On 27 November 2011 16:28, Alan Etkin spame...@gmail.com wrote:

 psycopg2.ProgrammingError: relation debugging_id_seq does not exist


Maybe a typo somewhere where debugging_id_seq should be debugging.id_seq?

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


Re: [web2py] Quick Question about Wiki Tutorial: .default attribute for db foreign-key field

2011-11-27 Thread Bruno Rocha
The complete commented code is:

def show():
 shows a wiki page
   *  # request.args(0) should receive an ID for the page you want to
 'whow'
 # you query the database to fetch the page row*
 this_page = db.page(request.args(0)) or redirect(URL('index'))
* # for this action '/show/' we want every comment to have page_id
 reference field defaults to the current page*
 db.comment.page_id.default = this_page.id
 *# we create a form for the comments only if user is logged in, else
 the form is None*
 form = crud.create(db.comment) if auth.user else None
* # here we are fetching the existing comments for this page*
 pagecomments = db(db.comment.page_id==this_page.id).select()
* # now we return some objects to be rendered in the view*
 return dict(page=this_page, comments=pagecomments, form=form)


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] could use some help ... mobile admin

2011-11-27 Thread Massimo Di Pierro
I could use some help. In trunk there is code for mobile admin.

That means that if you visit admin from a mobile device it will use
jquery.mobile. This is a work in progress and only some pages have
been implemented but you can help. It is easy.

In applications/admin/controllers/default.py there is this magic code:

is_mobile=request.user_agent().is_mobile
if is_mobile:
response.view =
response.view.replace('default/','default.mobile/')

so if you use a mobile is_mobile==True and is will pick up views from
views/default.mobile instead of views/default.

I copied all views from views/default into views/default.mobile and I
have fixed only index.html, site.html, edit.html about.html. The
other *.html files need work, this is where you can help

- replace {{extend 'layout.html'}} with {{extend 'default.mobile/
layout.html}}.
- remove any extra text that does not belong to a mobile
- replace ul with ul  data-role=listview
- replace all external links (i.e. not internal to admin) from a...
to a rel=external...

design.html is going to need some extra work.

If you can help send me the modified files.

Also let me know if you have comments or suggestions.

Massimo


[web2py] Re: PostgreSQL names case sensitivity

2011-11-27 Thread Massimo Di Pierro
In gluon/dal.py there is the following code:

def sequence_name(self,table):
return '%s_id_Seq' % table

is generates the default name of a sequence. if you have a sequence
already and it has another name use

db.define_table(...,sequence_name = '...')

On Nov 28, 12:16 am, Johann Spies johann.sp...@gmail.com wrote:
 On 27 November 2011 16:28, Alan Etkin spame...@gmail.com wrote:

  psycopg2.ProgrammingError: relation debugging_id_seq does not exist

 Maybe a typo somewhere where debugging_id_seq should be debugging.id_seq?

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


[web2py] Problems with forms and firefox

2011-11-27 Thread Bruno Rocha
Hi,

I am trying to solve a problem (all day long and I cannot find the source
of this)

I have a comment form in a page, also I have another page with edit form,
and one with create form.

Every form works ok with Google Chrome, I also tested in Midori and
Safari(running on wine) and it works ok.

But, I tested two versions of firefox on windows and linux and any form is
accepted with firefox. The form is submitted, but the form.vars is always
blank, so it not reach the accepted state.

The form is simple:

 *form = SQLFORM(db.comments, formstyle='divs')
 **if form.process().accepted:
 **   # I DO some stuff here, but only reachs here in chrome, not in
 firefox*


I already tested another methods as accepts(), validate() and using
onsuccess and onvalidation but nothing works.

If somebody knows what can be the source of this here are the test pages:

http://labs.blouweb.com/movuca/article/show/1/solving-web2py-forms-problems-with-firefox
 OR http://labs.blouweb.com/movuca/article/show/2/vegetarian-cheese

In any article (of any article_type) you have a comment box, login with*
t...@test.com* and *1234*.

Try to post a *comment* with Chrome, then try with firefox.

Also (still logged in)

http://labs.blouweb.com/movuca/article/new/Article OR
http://labs.blouweb.com/movuca/article/new/CookRecipe

The create and the respective edit forms (click edit in the article view)

These forms only accepted with another browser but not with firefox *5* to *
8*.

Does anybody knows any issue with this browser?

Thank you.


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] could use some help ... mobile admin

2011-11-27 Thread Angelo Compagnucci
Great!

I'll work on it a soon as possible!

Are you using the Auto-initialization of form elements ?

Thanks!

2011/11/28 Massimo Di Pierro massimo.dipie...@gmail.com:
 I could use some help. In trunk there is code for mobile admin.

 That means that if you visit admin from a mobile device it will use
 jquery.mobile. This is a work in progress and only some pages have
 been implemented but you can help. It is easy.

 In applications/admin/controllers/default.py there is this magic code:

    is_mobile=request.user_agent().is_mobile
    if is_mobile:
        response.view =
 response.view.replace('default/','default.mobile/')

 so if you use a mobile is_mobile==True and is will pick up views from
 views/default.mobile instead of views/default.

 I copied all views from views/default into views/default.mobile and I
 have fixed only index.html, site.html, edit.html about.html. The
 other *.html files need work, this is where you can help

 - replace {{extend 'layout.html'}} with {{extend 'default.mobile/
 layout.html}}.
 - remove any extra text that does not belong to a mobile
 - replace ul with ul  data-role=listview
 - replace all external links (i.e. not internal to admin) from a...
 to a rel=external...

 design.html is going to need some extra work.

 If you can help send me the modified files.

 Also let me know if you have comments or suggestions.

 Massimo




-- 
Profile: http://www.gild.com/compagnucciangelo
Register on Gild: http://www.gild.com/referral/compagnucciangelo