[web2py] Re: top of the day: cross component interaction

2011-02-16 Thread cjrh
On Feb 17, 1:44 am, villas  wrote:
> This is indeed a good post. Do you think it should be a slice or
> perhaps included in the book?
>
> If the latter, do you think it might go best in the Ajax Recipes
> chapter,  or where?
> -D

I think the book is a better location.  I know it makes the hardcopy
very large and more expensive to print, but for the sake of
completeness, important information like this *should* be in the most
frequently-accessed documentation.


[web2py] Re: cron doesn't work

2011-02-16 Thread LightOfMooN
How to check, is the cron working?
If i start web2py with command line:
python web2py.py, Cron runs my function once, and after minute prints
error: cannot allocate memory

On 16 фев, 20:19, LightOfMooN  wrote:
> Hello
> I have web2py installed with setup-web2py-ubuntu.sh
> It runs with Apache mod_wsgi.
>
> Crontab of myapp is:
> */1  *  *  *  *  root  *cron/test
>
> And function:
> def test():
>     shop = db(db.shops.id==8).select().first()
>     new = shop.daystodelete + 1
>     shop.update_record(daystodelete=new)
>     db.commit()
>     return 'done'
> test()
>
> manually function works fine. But not with cron. Seems it's not
> working.
> Any ideas? Thx


Re: [web2py] Re: tip of the day. The power of routes

2011-02-16 Thread Johann Spies
On 16 February 2011 17:35, Bruno Rocha  wrote:

> Thats my working solution
>
> http://snipt.net/rochacbruno/routespy/
>
> http://snipt.net/rochacbruno/routesconf/
>
>
>
Thanks. It is about the same as mine.  I was just wondering whether my
jqgrid-problem (another thread) on my production server was related to the
problem you  reported.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: new URL router use cases

2011-02-16 Thread cjrh
On Feb 17, 8:02 am, Jonathan Lundell  wrote:
> On Feb 16, 2011, at 9:49 PM, cjrh wrote:
>
> > On Feb 16, 11:38 pm, Jonathan Lundell  wrote:
> >> [I'm reposting this message from a while back, because the new release 
> >> 1.92.1 contains it for the first time. It describes some simple use cases 
> >> for the new URL router. Note that there are still some things that you'll 
> >> need the existing regex-based router for, but for most cases the new one 
> >> should work and be easier to configure.]
>
> > May I add this text to the book, now that the router is in the latest
> > stable release version?    I don't want to step on your toes, if you
> > were planning to do this yourself soon anyway, then that's fine too.
>
> Please do. Take a look at router.example.py as well; there's at least one new 
> feature there (path_prefix). I can review the material any time you're ready.

Ok, I'll give it a shot.  I read through (skimmed, tbh)
router.example.py last night, it's quite comprehensive.  For the book,
I would prefer to put a whole bunch of examples of typical use cases
in addition to the formal feature spec since many people, me included,
grok examples much faster than specs.


[web2py] Re: error occurs when use executesql

2011-02-16 Thread hywang
I think it is pymysql's problem because it dosen't escape query
correctly, so, an syntax error is throwed.
MySQLdb can escape query well, as a result , when I update web2py to
new version, this error occurs.

On 2月15日, 下午6时09分, Johann Spies  wrote:
> On 15 February 2011 08:49, hywang  wrote:
>
> > Please help to run it :-)
>
> > # File Name: default.py
>
> > def index():
> >db.define_table("pymysql",Field("content","text"),migrate=True)
> >content = """'http://img1.t.sinajs.cn/t3/style/css/common/
> > layer.css'"""
> >#content = """this sentence is no problem at all"""
> >db.executesql("INSERT INTO pymysql (content)VALUES(%s)",content)
> >return dict()
>
> >  content = """'http://img1.t.sinajs.cn/t3/style/css/common/
>
>...: layer.css'"""
>
> In [2]: content
> Out[2]: "'http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css'"
>
> In [3]: query = "INSERT INTO pymysql (content)VALUES(%s)",content
>
> In [4]: query
> Out[4]:
> ('INSERT INTO pymysql (content)VALUES(%s)',
>  "'http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css'")
>
> In [5]: query = "INSERT INTO pymysql (content)VALUES(%s)" % content
>
> In [6]: query
> Out[6]: "INSERT INTO pymysql 
> (content)VALUES('http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css')"
>
> You syntax is incorrect  as showed in [3].  The correct query[6] is
> generated by the syntax in [5].
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
> 2 Pet. 1:2b,3a


Re: [web2py] Re: new URL router use cases

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 9:49 PM, cjrh wrote:
> 
> On Feb 16, 11:38 pm, Jonathan Lundell  wrote:
>> [I'm reposting this message from a while back, because the new release 
>> 1.92.1 contains it for the first time. It describes some simple use cases 
>> for the new URL router. Note that there are still some things that you'll 
>> need the existing regex-based router for, but for most cases the new one 
>> should work and be easier to configure.]
> 
> May I add this text to the book, now that the router is in the latest
> stable release version?I don't want to step on your toes, if you
> were planning to do this yourself soon anyway, then that's fine too.

Please do. Take a look at router.example.py as well; there's at least one new 
feature there (path_prefix). I can review the material any time you're ready.




[web2py] Re: new URL router use cases

2011-02-16 Thread cjrh
On Feb 16, 11:38 pm, Jonathan Lundell  wrote:
> [I'm reposting this message from a while back, because the new release 1.92.1 
> contains it for the first time. It describes some simple use cases for the 
> new URL router. Note that there are still some things that you'll need the 
> existing regex-based router for, but for most cases the new one should work 
> and be easier to configure.]

May I add this text to the book, now that the router is in the latest
stable release version?I don't want to step on your toes, if you
were planning to do this yourself soon anyway, then that's fine too.

regards
cjrh



[web2py] Mobile device detection script

2011-02-16 Thread Chris
Hello,

I recently tried using 
http://www.web2py.com/examples/static/mobile_device_detect.py
for mobile device detection, but it turns out that it actually picks
up the Googlebot as a mobile device! The cached version on Google
validates this, and I tried User Agent Switcher as well. I'll try and
look at it again tomorrow; suggestions?


[web2py] Re: CRUD form customization - possible??

2011-02-16 Thread Massimo Di Pierro
Yes.

crud.settings.formstyle='divs'.

Now you can position the divs any way you like with css.

On Feb 16, 5:38 pm, greenpoise  wrote:
> Where is the limit? could I align the textboxes horizontally??
>
> The code above worked did the reisizing!
>
> On Feb 16, 3:02 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > On Feb 16, 7:09 am, Massimo Di Pierro 
> > wrote:
>
> > > given...
> > > from=crud.create()
>
> > > you can do
>
> > > form e in form.elements('input[type=text]'): e['size']=50;
>
> > this is in controller (before {{=form}}.
>
> > > or in JS
>
> > > jQuery('input[type=text]').css('width':'50px'):
>
> > This after unless wrapper in $(document).ready({}); in which case
> > before, possibly in header.
>
> > > or better in CSS
>
> > input[type=text] {width: 50px;}
>
> > This can go on header or in the CSS file (without the 

Re: [web2py] Re: GSoC

2011-02-16 Thread Thadeus Burgess
statistics engine = statlib
--
Thadeus




On Wed, Feb 16, 2011 at 9:22 PM, Jason Brower  wrote:

>  Local editor integration and permenent admin settings for that and other
> features.
>
> - Original message -
> > We need proposals. What do we want to be done?
> >
> > On Feb 16, 2:57 pm, Tim Michelsen  wrote:
> > > Hello,
> > > is web2py considering to mentor for this year?
> > >
> > > http://code.google.com/intl/de-DE/soc/
> > >
> > > Regards,
> > > Timmie
>
>


[web2py] Re: database access

2011-02-16 Thread stargate
It's just a database admin tool for mysql.  I just want to be able to
access the mysql lite database that comes with web2py using mysqlfront

On Feb 16, 10:22 pm, Richard Vézina 
wrote:
> I think you should provide information about mysqlfront and how you think it
> could work with Web2py.
>
> Personnaly I am not aware of anything about mysqlfront...
>
> Richard
>
>
>
> On Wed, Feb 16, 2011 at 9:40 PM, stargate  wrote:
> > Is it possible to do this
>
> > On Feb 16, 9:51 am, stargate  wrote:
> > > When running web2py how do i access the mysql database using a
> > > applicaiton like
>
> > >http://www.mysqlfront.de/wp/download/
>
> > > Also when creating a new application using the application wizard it
> > > has no indication to specify a user login for the database.  Where can
> > > i change this.


Re: [web2py] Re: GSoC

2011-02-16 Thread Jason Brower
Local editor integration and permenent admin settings for that and other 
features.

- Original message -
> We need proposals. What do we want to be done?
> 
> On Feb 16, 2:57 pm, Tim Michelsen  wrote:
> > Hello,
> > is web2py considering to mentor for this year?
> > 
> > http://code.google.com/intl/de-DE/soc/
> > 
> > Regards,
> > Timmie



Re: [web2py] Re: GSoC

2011-02-16 Thread Jason Brower
Some ideas:
Mangodb support
Improved wizard tool
Improved plugin_wiki
statistics engine

- Original message -
> We need proposals. What do we want to be done?
> 
> On Feb 16, 2:57 pm, Tim Michelsen  wrote:
> > Hello,
> > is web2py considering to mentor for this year?
> > 
> > http://code.google.com/intl/de-DE/soc/
> > 
> > Regards,
> > Timmie



Re: [web2py] Re: database access

2011-02-16 Thread Richard Vézina
I think you should provide information about mysqlfront and how you think it
could work with Web2py.

Personnaly I am not aware of anything about mysqlfront...

Richard

On Wed, Feb 16, 2011 at 9:40 PM, stargate  wrote:

> Is it possible to do this
>
>
> On Feb 16, 9:51 am, stargate  wrote:
> > When running web2py how do i access the mysql database using a
> > applicaiton like
> >
> > http://www.mysqlfront.de/wp/download/
> >
> > Also when creating a new application using the application wizard it
> > has no indication to specify a user login for the database.  Where can
> > i change this.
>


[web2py] Re: database access

2011-02-16 Thread stargate
Is it possible to do this


On Feb 16, 9:51 am, stargate  wrote:
> When running web2py how do i access the mysql database using a
> applicaiton like
>
> http://www.mysqlfront.de/wp/download/
>
> Also when creating a new application using the application wizard it
> has no indication to specify a user login for the database.  Where can
> i change this.


Re: [web2py] How to use routes

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 5:04 PM, Jonathan Lundell wrote:
> 
> On Feb 16, 2011, at 4:29 PM, Andrew Evans wrote:
>> Hi ty for your help my routes in is just standard with example routes file
>> 
>> 
>> routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'),
>> (r'.*:/robots.txt', r'/examples/static/robots.txt'),
>> ((r'.*http://otherdomain.com.* (?P.*)', 
>> r'/app/ctr\g')))
> 
> 
> You'll need to pick default application. If it's dojo, something like this. 
> This is *not* tested. It assumes that you're supporting accesses to dojo, 
> musico and admin, and that your favicon and robots files are in dojo's static 
> folder, as shown.

It occurred to me later that web2py is interpreting index.php as an app or 
controller (basically a syntax error) and that this is happening before an app 
is determined. So a */* entry for error handling is important.

> 
> routes_in = (
> ('/favicon.ico', '/dojo/static/img/favicon.ico'),
> ('/robots.txt', '/dojo/static/robots.txt'),
> ('/?', '/dojo/default/index'),
> ('/(?P(admin|dojo|musico))','/\g'),
> ('/(?P(admin|dojo|musico))/$anything','/\g/$anything'),
> ('/$anything','/dojo/$anything'),
> )
> 
> routes_out = (
> ('/(?P(admin|musico))/$anything','/\g/$anything'),
> ('/dojo/default/index/','/'),
> ('/dojo/$c/index/','/$c'),
> ('/dojo/$anything','/$anything'),
> )
> 
> A simpler version with no shortening of URLs:
> 
> routes_in = (
> ('/favicon.ico', '/dojo/static/img/favicon.ico'),
> ('/robots.txt', '/dojo/static/robots.txt'),
> )
> 




[web2py] Re: Amazon EC2, How does it... um... how does it work?

2011-02-16 Thread Plumo
Try using memcache to cache your queries.

I host my static content on GAE for free.


> If you are in the USA (and possibly elsewhere) you can try out Amazon's 
smallest instance for free for 1 year.

Yes this deal is available outside the US.


[web2py] Re: SQLFORM hide some fields

2011-02-16 Thread Ed Greenberg
These look like exactly what I'm looking for. I'll try 'em out.
Thanks.


Re: [web2py] GAE or EC2?

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 4:40 PM, howesc wrote:
> for me it's all about the cost (both time cost and money cost), and there is 
> no comparison (if you can work with the GAE bigtable).
> 
> 1. web2py does a good job of working with BigTable, so once you get out of 
> the habit of joins, many apps will just work without much change in your 
> coding.
> 2. ec2 really is just like a private server, you still have to install the 
> server, configure it, create the machine image, deploy, monitor, update etc 
> (time expensive)
> 3. GAE just runs.  upload your app with a simple script (or press a button if 
> you use the mac GAE launcher) and it just runs.  no server to setup, monitor 
> or deploy
> 4. GAE truely auto-scales.  as more requests are made it just services them 
> (until you reach your self-imposed budget limits)
> 5. AWS EC2 needs to be monitored for traffic and it is up to you setup and 
> turn on additional servers (time and maybe money expensive)
> 6. AWS is paid by machine minute, GAE is paid by CPU cycles used.  so 
> always-on for AWS is at least $14 a month with a micro instance, GAE can 
> serve 1000's of pages a day for free.
> 7. GAE background tasks is much harder than just writing scripts and cron.  
> so if you need  background services EC2 might be better.
> 
> if you are curious, the iphone app starmaker (http://starmakerapp.com/) talks 
> to a web2py GAE backend, but uses EC2 for some heavy audio processing (the 
> website will migrate to web2py soon), and http://www.elizabethscanvas.org/ is 
> complete web2py on GAE.

(nice work)

I want to emphasize #2 above (while agreeing with all the rest). Keeping up to 
date is a must these days, for security reasons, and it's a royal pain.

[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread DJ
 I am seeing some issues with admin and CRUD after upgrade - happens only 
for one table.

Updating a table through the admin interface does not work - no values are 
sent to database; but I get a 'Done' message. Likewise for the CRUD action 
in a controller. Database update works when executed in raw sql (MySQL).

Minor issue - when crud/db admin interface checks for incomplete forms, it 
checks all radio buttons by default. Deleted a few records by mistake as I 
did not see the delete option checked.

-Sebastian


Re: [web2py] How to use routes

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 4:29 PM, Andrew Evans wrote:
> Hi ty for your help my routes in is just standard with example routes file
> 
> 
> routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'),
>  (r'.*:/robots.txt', r'/examples/static/robots.txt'),
>  ((r'.*http://otherdomain.com.* (?P.*)', 
> r'/app/ctr\g')))


You'll need to pick default application. If it's dojo, something like this. 
This is *not* tested. It assumes that you're supporting accesses to dojo, 
musico and admin, and that your favicon and robots files are in dojo's static 
folder, as shown.

routes_in = (
('/favicon.ico', '/dojo/static/img/favicon.ico'),
('/robots.txt', '/dojo/static/robots.txt'),
('/?', '/dojo/default/index'),
('/(?P(admin|dojo|musico))','/\g'),
('/(?P(admin|dojo|musico))/$anything','/\g/$anything'),
('/$anything','/dojo/$anything'),
)

routes_out = (
('/(?P(admin|musico))/$anything','/\g/$anything'),
('/dojo/default/index/','/'),
('/dojo/$c/index/','/$c'),
('/dojo/$anything','/$anything'),
)

A simpler version with no shortening of URLs:

routes_in = (
('/favicon.ico', '/dojo/static/img/favicon.ico'),
('/robots.txt', '/dojo/static/robots.txt'),
)



[web2py] Re: SQLFORM hide some fields

2011-02-16 Thread villas
Just specify it explicitly in the function, something like this...
e.g.

def index():
t=db.tablename
rec = t(request.args(0))
t.fieldname.readable = t.fieldname.writable = False
form=SQLFORM(t,rec)
if form.accepts(request.vars, session):
response.flash = 'record accepted'

-D

On Feb 16, 11:57 pm, Ed Greenberg  wrote:
> I'd like to suppress some fields in a SQLFORM.
>
> Imagine that a user is filling out a form to create or edit a record,
> and his user_id is a column in the record. We need to populate the
> user_id, but he should never see it.
>
> If I declare the field as writable=False,readable=False then nobody
> with more privilege could ever use a SQLFORM (or crud.create,
> crud.update, etc) to access the field.  I need it suppressed just in
> certain instances.
>
> Also, if the SQLFORM accepts, web2py needs to know what to put in that
> field.
>
> Should I retire SQLFORM and use a FORM, or is there some magic I can
> use to accomplish this.
>
> I want to say I appreciate all this help. Thanks, Massimo and all.
>
> Ed Greenbeg


[web2py] Re: SQLFORM hide some fields

2011-02-16 Thread DenesL
Hi Ed,

you can set the readable and writable flags of the field on the fly in
the action, just before you call SQLFORM:

def action():
  db.table.field.writable = False
  form=SQLFORM(...)
  ...

On Feb 16, 6:57 pm, Ed Greenberg  wrote:
> I'd like to suppress some fields in a SQLFORM.
>
> Imagine that a user is filling out a form to create or edit a record,
> and his user_id is a column in the record. We need to populate the
> user_id, but he should never see it.
>
> If I declare the field as writable=False,readable=False then nobody
> with more privilege could ever use a SQLFORM (or crud.create,
> crud.update, etc) to access the field.  I need it suppressed just in
> certain instances.
>
> Also, if the SQLFORM accepts, web2py needs to know what to put in that
> field.
>
> Should I retire SQLFORM and use a FORM, or is there some magic I can
> use to accomplish this.
>
> I want to say I appreciate all this help. Thanks, Massimo and all.
>
> Ed Greenbeg


Re: [web2py] GAE or EC2?

2011-02-16 Thread howesc
for me it's all about the cost (both time cost and money cost), and there is 
no comparison (if you can work with the GAE bigtable).

1. web2py does a good job of working with BigTable, so once you get out of 
the habit of joins, many apps will just work without much change in your 
coding.
2. ec2 really is just like a private server, you still have to install the 
server, configure it, create the machine image, deploy, monitor, update etc 
(time expensive)
3. GAE just runs.  upload your app with a simple script (or press a button 
if you use the mac GAE launcher) and it just runs.  no server to setup, 
monitor or deploy
4. GAE truely auto-scales.  as more requests are made it just services them 
(until you reach your self-imposed budget limits)
5. AWS EC2 needs to be monitored for traffic and it is up to you setup and 
turn on additional servers (time and maybe money expensive)
6. AWS is paid by machine minute, GAE is paid by CPU cycles used.  so 
always-on for AWS is at least $14 a month with a micro instance, GAE can 
serve 1000's of pages a day for free.
7. GAE background tasks is much harder than just writing scripts and cron.  
so if you need  background services EC2 might be better.

if you are curious, the iphone app starmaker (http://starmakerapp.com/) 
talks to a web2py GAE backend, but uses EC2 for some heavy audio processing 
(the website will migrate to web2py soon), and 
http://www.elizabethscanvas.org/ is complete web2py on GAE.

that's my 3 cents.

christian


Re: [web2py] How to use routes

2011-02-16 Thread Andrew Evans
Hi ty for your help my routes in is just standard with example routes file


routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'),
 (r'.*:/robots.txt', r'/examples/static/robots.txt'),
 ((r'.*http://otherdomain.com.* (?P.*)',
r'/app/ctr\g')))


any suggestions


*cheers


Re: [web2py] How to use routes

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 4:13 PM, Andrew Evans wrote:
>  Sorry I mean this
> 
> routes_onerror = [('dojo/*', '/dojo/error/index'),
>   ('musico/*', '/musico/error/index'),]
> 
> returns a invalid request when going www.namiyama.com/index.php

I think the problem is that when the above URL is received, there's no 
associated application. You'll need to route /index.php to either dojo or 
musico, or include a */* entry in onerror.

What's your routes_in?

> 
> *cheers
> 
> 
> 
> On Wed, Feb 16, 2011 at 4:07 PM, Andrew Evans  wrote:
> hello it has stopped working for some reason
> 
> and I have no idea what is wrong :-?
> 
> routes_onerror = [('dojo/*','/dojo/error/index'),
>   ('musico/*, /musico/error/index'),]
> 
> 
> 
> def index():
> if request.vars.code == '400':
> redirect(URL('default', 'index'))
> elif request.vars.code == '404':
> redirect(URL('default', 'index'))  
> else:
> redirect(URL('default', 'index'))
> 
> 
> but when I use
> 
> routes_onerror = [('*/*','/dojo/error/index')]
> 
> it works fine *confused
> 
> Any ideas *cheers
> 
> 
> 
> 
> 
> On Tue, Feb 15, 2011 at 9:56 PM, Andrew Evans  wrote:
> Ok ty I got it haha
> 
> now I feel like a novice :-P
> 
> I had an extra period in the routes.py filename so it was routes..py
> 
> 
> any ty for the advice *cheers
> 
> 
> Andrew
> 
> 




[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread VP
I understand what you mean. But maybe I didn't write it clearly.  Let
me describe it again.

Prior to upgrading to 1.92.1, I have apps A, B and C.

After upgrading to 1.92.1 and set MULTI_USER_MODE to True, I have to
register to log into admin control panel.   Then, I register to create
the first user (through the web interface, of course).

This first user, is presumably admin.   I also registered a second
user (non admin).

+ First user can log into admin/site.  Good.
+ First user can not edit apps A, B, C.   Not good.
+ Second user can not log in.  Message is approval pending.  Okay.
You seem to suggest that go to appadmin (of admin?) to approve
registration (by removing the registration key of that particular
user).Problem is I don't know where appadmin of admin is.  I don't
see it on the admin app.   I know other apps have their own appadmins,
but from what i know, admin does not have appadmin.




Maybe I completely misunderstood the meaning/semantics of
MULTIPLE_USER_MODE.   Basically, what I presume to have is:

+ One admin, who can see all apps.
+ Multiple users (of admin app) that can create and edit apps that
only belong to them.  (Of course, I fully understand that this is just
an organizational layer of admin, not real permission).


===

I guess what i need is some documentation of how to use this feature.

Thanks.



On Feb 16, 5:09 pm, Massimo Di Pierro 
wrote:
> On Feb 16, 4:31 pm, VP  wrote:
>
> > Specifically, after setting MULTI_USER_MODE to True in 0.py.  It's not
> > clear what should be done next.   Here are some problems:
>
> > + After creating  the first account (is this supposed to be the
> > "admin" account?), the first account user does not have permission to
> > edit existing apps.
>
> This is though for a teacher/student situation. Each student can see
> only his own apps (via appadmin but mind there is no real security in
> place here!). The admin can see them all.
>
> > + The second account can not log in, pending registration approval.
> > How can I approve registrations?
>
> use admin/appadmin and remove the content of the registration_key
> field for the users you want to approve.
>
>
>
> > On Feb 16, 4:17 pm, VP  wrote:
>
> > > >> admin has MULTI_USER_MODE (admin/models/0.py)
>
> > > Can you show how to use this?   It's not clear how to invoke this
> > > feature and use it from the admin panel.
>
> > > Thanks.
>
> > > On Feb 16, 8:52 am, Massimo Di Pierro 
> > > wrote:
>
> > > > changelog:
>
> > > > much improved routing (thanks Jonathan)
> > > > Expression.__mod__ (thanks Denes)
> > > > admin has MULTI_USER_MODE (admin/models/0.py)
> > > > support for count(distinct=...)
> > > > has_permissions(...,group_id)
> > > > IS_MATCH(...,strict=True)
> > > > URL(...,scheme=,host=,port=), thanks Jonathan
> > > > admin in Afrikaans, thanks Caleb
> > > > auth.signature (experimental)
> > > > many bug fixes
>
> > > > please test it and report any issue.
>
> > > > Massimo
>
>


Re: [web2py] How to use routes

2011-02-16 Thread Andrew Evans
 Sorry I mean this

routes_onerror = [('dojo/*', '/dojo/error/index'),
  ('musico/*', '/musico/error/index'),]

returns a invalid request when going www.namiyama.com/index.php

*cheers



On Wed, Feb 16, 2011 at 4:07 PM, Andrew Evans  wrote:

> hello it has stopped working for some reason
>
> and I have no idea what is wrong :-?
>
> routes_onerror = [('dojo/*','/dojo/error/index'),
>   ('musico/*, /musico/error/index'),]
>
>
>
> def index():
> if request.vars.code == '400':
> redirect(URL('default', 'index'))
> elif request.vars.code == '404':
> redirect(URL('default', 'index'))
> else:
> redirect(URL('default', 'index'))
>
>
> but when I use
>
> routes_onerror = [('*/*','/dojo/error/index')]
>
> it works fine *confused
>
> Any ideas *cheers
>
>
>
>
>
> On Tue, Feb 15, 2011 at 9:56 PM, Andrew Evans  wrote:
>
>> Ok ty I got it haha
>>
>> now I feel like a novice :-P
>>
>> I had an extra period in the routes.py filename so it was routes..py
>>
>>
>> any ty for the advice *cheers
>>
>>
>> Andrew
>>
>
>


Re: [web2py] How to use routes

2011-02-16 Thread Andrew Evans
hello it has stopped working for some reason

and I have no idea what is wrong :-?

routes_onerror = [('dojo/*','/dojo/error/index'),
  ('musico/*, /musico/error/index'),]


def index():
if request.vars.code == '400':
redirect(URL('default', 'index'))
elif request.vars.code == '404':
redirect(URL('default', 'index'))
else:
redirect(URL('default', 'index'))


but when I use

routes_onerror = [('*/*','/dojo/error/index')]

it works fine *confused

Any ideas *cheers




On Tue, Feb 15, 2011 at 9:56 PM, Andrew Evans  wrote:

> Ok ty I got it haha
>
> now I feel like a novice :-P
>
> I had an extra period in the routes.py filename so it was routes..py
>
>
> any ty for the advice *cheers
>
>
> Andrew
>


[web2py] SQLFORM hide some fields

2011-02-16 Thread Ed Greenberg
I'd like to suppress some fields in a SQLFORM.

Imagine that a user is filling out a form to create or edit a record,
and his user_id is a column in the record. We need to populate the
user_id, but he should never see it.

If I declare the field as writable=False,readable=False then nobody
with more privilege could ever use a SQLFORM (or crud.create,
crud.update, etc) to access the field.  I need it suppressed just in
certain instances.

Also, if the SQLFORM accepts, web2py needs to know what to put in that
field.

Should I retire SQLFORM and use a FORM, or is there some magic I can
use to accomplish this.

I want to say I appreciate all this help. Thanks, Massimo and all.

Ed Greenbeg


[web2py] Re: top of the day: cross component interaction

2011-02-16 Thread villas
This is indeed a good post. Do you think it should be a slice or
perhaps included in the book?

If the latter, do you think it might go best in the Ajax Recipes
chapter,  or where?
-D


[web2py] Re: CRUD form customization - possible??

2011-02-16 Thread greenpoise

Where is the limit? could I align the textboxes horizontally??

The code above worked did the reisizing!











On Feb 16, 3:02 pm, Massimo Di Pierro 
wrote:
> On Feb 16, 7:09 am, Massimo Di Pierro 
> wrote:
>
> > given...
> > from=crud.create()
>
> > you can do
>
> > form e in form.elements('input[type=text]'): e['size']=50;
>
> this is in controller (before {{=form}}.
>
> > or in JS
>
> > jQuery('input[type=text]').css('width':'50px'):
>
> This after unless wrapper in $(document).ready({}); in which case
> before, possibly in header.
>
>
>
> > or better in CSS
>
> input[type=text] {width: 50px;}
>
> This can go on header or in the CSS file (without the 

Re: [web2py] Re: Apache, Wsgi problem

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 3:07 PM, Massimo Di Pierro wrote:
> 
> Looks like Jonathan may be the winner here. I think VP raised the
> issue so he should decide whether the issue is solved.
> Is anybody else having problems after upgrade to the latest psycopg2?
> 
> If this problem was dear to you any symbolic contribution towards the
> prize will be appreciated.

It need only be symbolic; I think that this falls into the "known bug" 
category. I found it by Googling.

To be more certain, it'd be good if someone could revert psycogpg2 (with no 
other changes) and reproduce the problem.

> 
> Massimo
> 
> 
> 
> On Feb 10, 8:19 am, Massimo Di Pierro 
> wrote:
>> I offer $300 to whoever can identify within 3 weeks and without
>> ambiguity the cause of this problem. The bounty applies even if the
>> problem turns out to be not in web2py but in one of the Python
>> modules, in Apache or in the mod_wsgi implementation. It does not
>> apply if the problem is due to known bug that has already been fixed
>> by the responsible party (for example if you are using an old un-
>> patched python version like 2.5.0 or an old mod_wsgi version).
>> 
>> On Feb 10, 12:38 am, VP  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Alright people short answer:  I think I figured this out (at least
>>> with my configuration)
>> 
>>> After testing various configurations, here's the result with: ab -kc
>>> 100 -t 20https://domain.com/imageblog/default/index/ (same
>>> imageblog app, 100 connections, 20 seconds stress test).
>> 
>>> Two things you will notice with this result.
>> 
>>> 1.  ZERO failed request.   No more wsgi premature script error
>>> 2.  Complete requests is 1234, 61 requests/second on average.
>>> Compare to prior configuration:  588 total requests, 29 requests/
>>> sec on average.  Not to mention 15 failed requests due to wsgi
>>> premature script errors!!!
>> 
>>> This is insane!!!
>> 
>>> So how did I configure this?   here it is:
>> 
>>>   WSGIDaemonProcess web2py user=username group=username \
>>>display-name=%{GROUP} processes=5 threads=1
>> 
>>> The important option being 5 processes, 1 thread.
>> 
>>> With this configuration, my real app also did not get wsgi premature
>>> script errors anymore.  And guess what... the requests/sec
>>> triples
>> 
>>> I am still curious about this.  While my real app can possibly be not
>>> thread-safe, but the imageblog app should be thread safe (the index
>>> was simply a listing of images, i.e. read only).  Why would there be a
>>> problem with more than 1 thread?
>> 
>>> 
>> 
>>> Document Path:  /imageblog/default/index
>>> Document Length:13083 bytes
>> 
>>> Concurrency Level:  100
>>> Time taken for tests:   20.008 seconds
>>> Complete requests:  1234
>>> Failed requests:0
>>> Write errors:   0
>>> Keep-Alive requests:1234
>>> Total transferred:  16827432 bytes
>>> HTML transferred:   16171262 bytes
>>> Requests per second:61.68 [#/sec] (mean)
>>> Time per request:   1621.377 [ms] (mean)
>>> Time per request:   16.214 [ms] (mean, across all concurrent
>>> requests)
>>> Transfer rate:  821.33 [Kbytes/sec] received
>> 
>>> Connection Times (ms)
>>>   min  mean[+/-sd] median   max
>>> Connect:01   9.4  0  73
>>> Processing:82  481 890.53175475
>>> Waiting:   76  443 878.72745393
>>> Total: 82  483 894.73175503
>> 
>>> Percentage of the requests served within a certain time (ms)
>>>   50%317
>>>   66%342
>>>   75%360
>>>   80%372
>>>   90%416
>>>   95%489
>>>   98%   5351
>>>   99%   5397
>>>  100%   5503 (longest request)
>>> 




[web2py] top of the day: cross component interaction

2011-02-16 Thread Massimo Di Pierro
This was buried in the answer to another post but I think it will be
useful to some of you.

Components allow to insert a
{{=LOAD('controller','function',ajax=True)}} in a web2py view and the
actions /app/controller/function will manage its own content. It can
also communicate with other components and trigger events. For example
(complete program):

# models/db.py
db=DAL()
db.define_table('post',Field('body',notnull=True))
from gluon.tools import *
crud=Crud(globals(),db)

# controllers/default.py
def reload_posts(form):
response.js="web2py_ajax_page('get','%s',null,'posts')" %
URL('posts')
def index(): return dict()
def post(): return crud.create(db.post,onaccept=reload_posts)
def posts(): return SQLTABLE(db(db.post).select())

# views/index.html
{{extend 'layout.html'}}
{{=LOAD('default','post',ajax=True)}}
{{=LOAD('default','posts',ajax=True,target='posts')}}

post and posts are components embedded in the index page. submitting
an invalid post does not reload the page, only the component with its
errors and flash message. Submitting a valid post form, results in a
call (serverside) to reload_posts with sends a JS commend to the
client which forces an ajax reload of the list of previous posts.


[web2py] Re: form.accepts() with reference to other table

2011-02-16 Thread villas
Hi Oskari

1. Your custom auth_user table should be declared before the line:
auth.define_tables()

2. As 'accounts' table is referenced in your auth_user table, this
should be declared prior to auth_user.

I think you should be able to figure out anything else from the error
tickets.  See how it goes!

Regards,
D


On Feb 16, 9:26 pm, Oskari  wrote:
> Here's my code:
>
> db.py:
> db.define_table(
>     "accounts",
>     Field("name","string",length=128,default=''),
>     Field("email","string",length=128,default=''),
>     Field('username', length=128,default='',unique=True),
>     Field('password', 'password', length=512, readable=False,
> label='Password')
>     )
>
> db.accounts.name.requires = IS_NOT_EMPTY()
> db.accounts.password.requires = CRYPT(key=auth.settings.hmac_key)
>
> db.define_table(
>     "mytextbase",
>     Field("mytext","string",length=512,default=''),
>     Field("accountid",db.accounts)
>     )
>
> db.mytextbase.accountid.requires = IS_IN_DB(db,"accounts.id")
>
> #Custom user-table to set accountid
> db.define_table(
>     auth.settings.table_user_name,
>     Field('first_name', length=128, default=''),
>     Field('last_name', length=128, default=''),
>     Field('email', length=128, default='', unique=True),
>     Field('username', length=128,default='',unique=True),
>     Field('password', 'password', length=512, readable=False,
> label='Password'),
>     Field('registration_key', length=512,
>           writable=False, readable=False, default=''),
>     Field('reset_password_key', length=512,
>           writable=False, readable=False, default=''),
>     Field('registration_id', length=512,
>           writable=False, readable=False, default=''),
>     Field('accountid', db.accounts)
>     )
>
> custom_auth_table = db[auth.settings.table_user_name]
> custom_auth_table.first_name.requires =
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> custom_auth_table.last_name.requires =
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> custom_auth_table.password.requires = [CRYPT()]
> custom_auth_table.email.requires = [
>   IS_EMAIL(error_message=auth.messages.invalid_email),
>   IS_NOT_IN_DB(db, custom_auth_table.email)]
>
> and my control.py:
> def add():
>     form=SQLFORM(db.mytextbase)
>     request.vars.accountid = session.auth.user.accountid
>     if form.accepts(request.vars,session):
>         response.flash = "Added successfully! :)"
>     elif form.errors:
>         response.flash = "Something went wrong! :("
>     else:
>         response.flash = "Fill the form!"
>     return dict(form=form)
>
> With these my form only complains that accountid is:nt found in the
> database
>
> On Feb 16, 10:19 pm, villas  wrote:
>
> > It should be easy. Post your relevant model and controller code.
>
> > BTW it probably doesn't make any difference...  but maybe you might
> > consider using the notation account_id instead of accountID.  I read
> > somewhere that some databases have case sensitive fields and that
> > web2py makes some assumptions about this.  Just better to work all in
> > lowercase and avoid hitting that possible complication in the
> > future. :)
>
> > Regards,  D
>
> > On Feb 16, 6:47 pm, Oskari  wrote:
>
> > > I'm still struggling with the IS_IN_DB-validator. This problem occurs
> > > when trying to implement reference id for example via a controller
> > > line:
> > > request.vars.reftableid = 2
>
> > > The form just informs it isn't in the database. Why is that?
>
> > > On Feb 13, 3:14 pm, Oskari  wrote:
>
> > > > Uncommenting that did the trick. Perhaps there was something wrong
> > > > with that =)
>
> > > > Anyways, thanks!
>
> > > > On Feb 13, 3:17 am, villas  wrote:
>
> > > > > Try commenting out the line 'custom_auth_table.accountID.requires...'
> > > > > If that doesn't give you any progress, post all your auth model. I'm
> > > > > sure someone should be able to spot something  obvious -- these bugs
> > > > > can be right under our noses sometimes :)
> > > > > -D
>
> > > > > On Feb 12, 11:03 pm, Oskari  wrote:
>
> > > > > > Thank you for your answer villas!
>
> > > > > > I don't think that is the problem. I am able to make inserts through
> > > > > > the appadmin-site, but somehow it fails with form.accepts().
> > > > > > I also tried what you suggested, but could not quite get it working.
>
> > > > > > On Feb 12, 8:45 pm, villas  wrote:
>
> > > > > > > Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right?
>
> > > > > > > Maybe if you tried something like this, e.g.
> > > > > > > custom_auth_table.accountID.requires = 
> > > > > > > IS_IN_DB(db,db.accounts.id,'%
> > > > > > > (name)s')
>
> > > > > > > On Feb 12, 1:28 pm, Oskari  wrote:
>
> > > > > > > > Hi!
>
> > > > > > > > I'm having trouble making an insert with form.accepts()
>
> > > > > > > > Currently I have a custom auth_user that has one extra field:
> > > > > > > > Field('accountID', db.accounts) with
> > > > > > > > custom_auth_table.accountID.requires = 
> > > > > > > > IS_IN_DB(db,db.ac

[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread Massimo Di Pierro


On Feb 16, 4:31 pm, VP  wrote:
> Specifically, after setting MULTI_USER_MODE to True in 0.py.  It's not
> clear what should be done next.   Here are some problems:
>
> + After creating  the first account (is this supposed to be the
> "admin" account?), the first account user does not have permission to
> edit existing apps.

This is though for a teacher/student situation. Each student can see
only his own apps (via appadmin but mind there is no real security in
place here!). The admin can see them all.

> + The second account can not log in, pending registration approval.
> How can I approve registrations?

use admin/appadmin and remove the content of the registration_key
field for the users you want to approve.

>
> On Feb 16, 4:17 pm, VP  wrote:
>
>
>
>
>
>
>
> > >> admin has MULTI_USER_MODE (admin/models/0.py)
>
> > Can you show how to use this?   It's not clear how to invoke this
> > feature and use it from the admin panel.
>
> > Thanks.
>
> > On Feb 16, 8:52 am, Massimo Di Pierro 
> > wrote:
>
> > > changelog:
>
> > > much improved routing (thanks Jonathan)
> > > Expression.__mod__ (thanks Denes)
> > > admin has MULTI_USER_MODE (admin/models/0.py)
> > > support for count(distinct=...)
> > > has_permissions(...,group_id)
> > > IS_MATCH(...,strict=True)
> > > URL(...,scheme=,host=,port=), thanks Jonathan
> > > admin in Afrikaans, thanks Caleb
> > > auth.signature (experimental)
> > > many bug fixes
>
> > > please test it and report any issue.
>
> > > Massimo


[web2py] Re: Apache, Wsgi problem

2011-02-16 Thread Massimo Di Pierro
Looks like Jonathan may be the winner here. I think VP raised the
issue so he should decide whether the issue is solved.
Is anybody else having problems after upgrade to the latest psycopg2?

If this problem was dear to you any symbolic contribution towards the
prize will be appreciated.

Massimo



On Feb 10, 8:19 am, Massimo Di Pierro 
wrote:
> I offer $300 to whoever can identify within 3 weeks and without
> ambiguity the cause of this problem. The bounty applies even if the
> problem turns out to be not in web2py but in one of the Python
> modules, in Apache or in the mod_wsgi implementation. It does not
> apply if the problem is due to known bug that has already been fixed
> by the responsible party (for example if you are using an old un-
> patched python version like 2.5.0 or an old mod_wsgi version).
>
> On Feb 10, 12:38 am, VP  wrote:
>
>
>
>
>
>
>
> > Alright people short answer:  I think I figured this out (at least
> > with my configuration)
>
> > After testing various configurations, here's the result with: ab -kc
> > 100 -t 20https://domain.com/imageblog/default/index/ (same
> > imageblog app, 100 connections, 20 seconds stress test).
>
> > Two things you will notice with this result.
>
> > 1.  ZERO failed request.   No more wsgi premature script error
> > 2.  Complete requests is 1234, 61 requests/second on average.
> >     Compare to prior configuration:  588 total requests, 29 requests/
> > sec on average.  Not to mention 15 failed requests due to wsgi
> > premature script errors!!!
>
> > This is insane!!!
>
> > So how did I configure this?   here it is:
>
> >   WSGIDaemonProcess web2py user=username group=username \
> >                            display-name=%{GROUP} processes=5 threads=1
>
> > The important option being 5 processes, 1 thread.
>
> > With this configuration, my real app also did not get wsgi premature
> > script errors anymore.  And guess what... the requests/sec
> > triples
>
> > I am still curious about this.  While my real app can possibly be not
> > thread-safe, but the imageblog app should be thread safe (the index
> > was simply a listing of images, i.e. read only).  Why would there be a
> > problem with more than 1 thread?
>
> > 
>
> > Document Path:          /imageblog/default/index
> > Document Length:        13083 bytes
>
> > Concurrency Level:      100
> > Time taken for tests:   20.008 seconds
> > Complete requests:      1234
> > Failed requests:        0
> > Write errors:           0
> > Keep-Alive requests:    1234
> > Total transferred:      16827432 bytes
> > HTML transferred:       16171262 bytes
> > Requests per second:    61.68 [#/sec] (mean)
> > Time per request:       1621.377 [ms] (mean)
> > Time per request:       16.214 [ms] (mean, across all concurrent
> > requests)
> > Transfer rate:          821.33 [Kbytes/sec] received
>
> > Connection Times (ms)
> >               min  mean[+/-sd] median   max
> > Connect:        0    1   9.4      0      73
> > Processing:    82  481 890.5    317    5475
> > Waiting:       76  443 878.7    274    5393
> > Total:         82  483 894.7    317    5503
>
> > Percentage of the requests served within a certain time (ms)
> >   50%    317
> >   66%    342
> >   75%    360
> >   80%    372
> >   90%    416
> >   95%    489
> >   98%   5351
> >   99%   5397
> >  100%   5503 (longest request)
> > 


[web2py] Re: GSoC

2011-02-16 Thread Massimo Di Pierro
We need proposals. What do we want to be done?

On Feb 16, 2:57 pm, Tim Michelsen  wrote:
> Hello,
> is web2py considering to mentor for this year?
>
> http://code.google.com/intl/de-DE/soc/
>
> Regards,
> Timmie


[web2py] Re: CRUD form customization - possible??

2011-02-16 Thread Massimo Di Pierro


On Feb 16, 7:09 am, Massimo Di Pierro 
wrote:
> given...
> from=crud.create()
>
> you can do
>
> form e in form.elements('input[type=text]'): e['size']=50;

this is in controller (before {{=form}}.


> or in JS
>
> jQuery('input[type=text]').css('width':'50px'):

This after unless wrapper in $(document).ready({}); in which case
before, possibly in header.


>
> or better in CSS
>

input[type=text] {width: 50px;}

This can go on header or in the CSS file (without the 

[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread VP
Specifically, after setting MULTI_USER_MODE to True in 0.py.  It's not
clear what should be done next.   Here are some problems:

+ After creating  the first account (is this supposed to be the
"admin" account?), the first account user does not have permission to
edit existing apps.

+ The second account can not log in, pending registration approval.
How can I approve registrations?




On Feb 16, 4:17 pm, VP  wrote:
> >> admin has MULTI_USER_MODE (admin/models/0.py)
>
> Can you show how to use this?   It's not clear how to invoke this
> feature and use it from the admin panel.
>
> Thanks.
>
> On Feb 16, 8:52 am, Massimo Di Pierro 
> wrote:
>
> > changelog:
>
> > much improved routing (thanks Jonathan)
> > Expression.__mod__ (thanks Denes)
> > admin has MULTI_USER_MODE (admin/models/0.py)
> > support for count(distinct=...)
> > has_permissions(...,group_id)
> > IS_MATCH(...,strict=True)
> > URL(...,scheme=,host=,port=), thanks Jonathan
> > admin in Afrikaans, thanks Caleb
> > auth.signature (experimental)
> > many bug fixes
>
> > please test it and report any issue.
>
> > Massimo
>
>


[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread VP
>> admin has MULTI_USER_MODE (admin/models/0.py)

Can you show how to use this?   It's not clear how to invoke this
feature and use it from the admin panel.

Thanks.


On Feb 16, 8:52 am, Massimo Di Pierro 
wrote:
> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo


[web2py] Re: Apache, Wsgi problem

2011-02-16 Thread Ahmed Bani
Problem solved:
# Download : hg clone https://web2py.googlecode.com/hg/ web2py# Follow the 
instructions: 

Title : Using psycopg2 with virtualenv on UbuntuLink: 
http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/

Check your syntax :
# *db* = *DAL*('*postgres*://myself:mypass@127.0.0.1:5432/mydatabase')

Enjoy it!

Now, do we have to migrate web2py database and reimport it again? : 
Short tutorial to migrate web2py database - model and 
data



[web2py] new URL router use cases

2011-02-16 Thread Jonathan Lundell
[I'm reposting this message from a while back, because the new release 1.92.1 
contains it for the first time. It describes some simple use cases for the new 
URL router. Note that there are still some things that you'll need the existing 
regex-based router for, but for most cases the new one should work and be 
easier to configure.]


Suppose you've written an app, named it 'myapp', and want to make it the 
default, with its name always removed. Your default controller is still 
'default', and you want to remove its name from user-visible URLs as well. 
Here's what you put in routes.py:

routers = dict(
  BASE  = dict( default_application='myapp' ),
)

That's it. And it's smart enough to know how to do the right thing with URLs 
like:

http://domain.com/myapp/default/myapp
or  http://domain.com/myapp/myapp/index

...where normal shortening would be ambiguous.


If you have two applications, myapp and myapp2, you'll get the same effect, and 
additionally myapp2's default controller will be stripped from the URL whenever 
it's safe (which is mostly all the time).



Another case. Suppose you want to support URL-based languages, where your URLs 
look like this:

http://myapp/en/some/path

or (rewritten)

http://en/some/path

Here's how:

routers = dict(
  BASE  = dict( default_application='myapp' ),
  myapp = dict( languages=['en', 'it', 'jp'], default_language='en' ),
)

Now an incoming URL like this:

http:/domain.com/it/some/path

will be routed to /myapp/some/path, and request.uri_language will be set to 
'it', so you can force the translation. You can also have language-specific 
static files.

http://domain.com/it/static/filename

will be mapped to:

applications/myapp/static/it/filename

...if that file exists. If it doesn't, then URLs like:

http://domain.com/it/static/base.css

...will still map to:

applications/myapp/static/base.css

(because there is no static/it/base.css)

So you can now have language-specific static files, including images, if you 
need to.


Domain mapping is supported as well.

routers = dict(
  BASE  = dict(
  domains = {
  'domain1.com' : 'app1',
  'domain2.com' : 'app2',
  }
  ),
)

does what you'd expect.

routers = dict(
  BASE  = dict(
  domains = {
  'domain.com:80'  : 'app/insecure',
  'domain.com:443' : 'app/secure',
  }
  ),
)

...maps http://domain.com accesses to app's controller named 'insecure', while 
https accesses go to the 'secure' controller. Or you can map different ports to 
different apps, in the obvious way.


There's more, but mostly everything happens automatically, and there's no need 
to dig into the details of configuration unless there's some non-standard thing 
you need. There's a bit more documentation in router.example.py.

Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Martín Mulone
great! +1

2011/2/16 Jonathan Lundell 

> On Feb 16, 2011, at 1:25 PM, Alexandre Andrade wrote:
> > Where is docs about new routing?
>
> Try router.example.py for now.
>
>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/
Paraná, Entre Ríos, Argentina (CP 3100).

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 1:25 PM, Alexandre Andrade wrote:
> Where is docs about new routing?

Try router.example.py for now.



[web2py] Re: form.accepts() with reference to other table

2011-02-16 Thread Oskari
Here's my code:

db.py:
db.define_table(
"accounts",
Field("name","string",length=128,default=''),
Field("email","string",length=128,default=''),
Field('username', length=128,default='',unique=True),
Field('password', 'password', length=512, readable=False,
label='Password')
)

db.accounts.name.requires = IS_NOT_EMPTY()
db.accounts.password.requires = CRYPT(key=auth.settings.hmac_key)

db.define_table(
"mytextbase",
Field("mytext","string",length=512,default=''),
Field("accountid",db.accounts)
)

db.mytextbase.accountid.requires = IS_IN_DB(db,"accounts.id")

#Custom user-table to set accountid
db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('email', length=128, default='', unique=True),
Field('username', length=128,default='',unique=True),
Field('password', 'password', length=512, readable=False,
label='Password'),
Field('registration_key', length=512,
  writable=False, readable=False, default=''),
Field('reset_password_key', length=512,
  writable=False, readable=False, default=''),
Field('registration_id', length=512,
  writable=False, readable=False, default=''),
Field('accountid', db.accounts)
)

custom_auth_table = db[auth.settings.table_user_name]
custom_auth_table.first_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.last_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [CRYPT()]
custom_auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, custom_auth_table.email)]


and my control.py:
def add():
form=SQLFORM(db.mytextbase)
request.vars.accountid = session.auth.user.accountid
if form.accepts(request.vars,session):
response.flash = "Added successfully! :)"
elif form.errors:
response.flash = "Something went wrong! :("
else:
response.flash = "Fill the form!"
return dict(form=form)

With these my form only complains that accountid is:nt found in the
database


On Feb 16, 10:19 pm, villas  wrote:
> It should be easy. Post your relevant model and controller code.
>
> BTW it probably doesn't make any difference...  but maybe you might
> consider using the notation account_id instead of accountID.  I read
> somewhere that some databases have case sensitive fields and that
> web2py makes some assumptions about this.  Just better to work all in
> lowercase and avoid hitting that possible complication in the
> future. :)
>
> Regards,  D
>
> On Feb 16, 6:47 pm, Oskari  wrote:
>
>
>
>
>
>
>
> > I'm still struggling with the IS_IN_DB-validator. This problem occurs
> > when trying to implement reference id for example via a controller
> > line:
> > request.vars.reftableid = 2
>
> > The form just informs it isn't in the database. Why is that?
>
> > On Feb 13, 3:14 pm, Oskari  wrote:
>
> > > Uncommenting that did the trick. Perhaps there was something wrong
> > > with that =)
>
> > > Anyways, thanks!
>
> > > On Feb 13, 3:17 am, villas  wrote:
>
> > > > Try commenting out the line 'custom_auth_table.accountID.requires...'
> > > > If that doesn't give you any progress, post all your auth model. I'm
> > > > sure someone should be able to spot something  obvious -- these bugs
> > > > can be right under our noses sometimes :)
> > > > -D
>
> > > > On Feb 12, 11:03 pm, Oskari  wrote:
>
> > > > > Thank you for your answer villas!
>
> > > > > I don't think that is the problem. I am able to make inserts through
> > > > > the appadmin-site, but somehow it fails with form.accepts().
> > > > > I also tried what you suggested, but could not quite get it working.
>
> > > > > On Feb 12, 8:45 pm, villas  wrote:
>
> > > > > > Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right?
>
> > > > > > Maybe if you tried something like this, e.g.
> > > > > > custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'%
> > > > > > (name)s')
>
> > > > > > On Feb 12, 1:28 pm, Oskari  wrote:
>
> > > > > > > Hi!
>
> > > > > > > I'm having trouble making an insert with form.accepts()
>
> > > > > > > Currently I have a custom auth_user that has one extra field:
> > > > > > > Field('accountID', db.accounts) with
> > > > > > > custom_auth_table.accountID.requires = 
> > > > > > > IS_IN_DB(db,db.accounts.id,id)
>
> > > > > > > While trying to modify variables it fails with "not found in db"
>
> > > > > > > def func():
> > > > > > >     form=SQLFORM(db.auth_user)
> > > > > > >     request.vars.accountID = 1
> > > > > > >     if form.accepts(request.vars,session):
> > > > > > >         response.flash = "Succesfully created user"
> > > > > > >     return dict(form=form)
>
> > > > > > > Why does not form.accepts() recognize and accept my accountID?


Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Alexandre Andrade
Where is docs about new routing?

2011/2/16 Massimo Di Pierro 

> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo




-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos


[web2py] Re: Spam control? and word filtering?

2011-02-16 Thread Michael McGinnis
For spam control, the best is Akismet, but Spam Assassin is also an
industry standard, I believe.

Other English word filtering resources:
http://urbanoalvarez.es/blog/2008/04/04/bad-words-list/
http://www.bannedwordlist.com/

And from http://www.noswearing.com/about.php:
"The API is currently open on a limited person basis. It currently
supports 4 operations: List dirty words, Censor dirty words, Replace
dirty words, and Define Dirty words. If you're interested in testing
it for us, please send an email to ryan at noslang.com."

Michael McGinnis

On Feb 16, 9:18 am, Jonathan Lundell  wrote:
> On Feb 16, 2011, at 5:10 AM, Massimo Di Pierro wrote:
>
>
>
> > I am not an expert on bad words in english, I could do a better job in
> > Italian. ;-)
>
> No doubt...
>
> It's a tough problem, regardless, and it's awfully easy to get false 
> positives. Better not misspell shiitake mushrooms.
>
>
>
>
>
>
>
>
>
> > On Feb 15, 11:20 pm, Jonathan Lundell  wrote:
> >> On Feb 15, 2011, at 11:21 AM, Massimo Di Pierro wrote:
>
> >>> import base64, re
> >>> BADWORDS=re.compile(base64.b64decode("""KGFob2xlfGFudXN8YXNoMGxlfGFzaDBsZXN
> >>>  8YXNob2xlc3xhc3N8YXNzfGFzc2ZhY2V8YXNzaDBs
>
> >> There are some very peculiar choices (and omissions) in that list.
>
> >> rautenberg? job?
>
> >> honkey, but not honky (or its orginal, bohunk).
>
> >> Aside from the word choice, if you're going to use it, change match to 
> >> search, bracket the pattern with \b's, and make it case-insensitive.


[web2py] GSoC

2011-02-16 Thread Tim Michelsen
Hello,
is web2py considering to mentor for this year?

http://code.google.com/intl/de-DE/soc/

Regards,
Timmie



Re: [web2py] Re: Deleting a registered user

2011-02-16 Thread Michele Comitini
Tnx Massimo for your reply.  I will make an action for that purpose.

I assumed that among Auth actions there would be something like
"unregister" which is a functionality
that any service with subscription should have. I understand that
allowing the user delete all his records is not
safe and could even be illegal, but I suspect that also it is illegal
to keep them without user consent.

Too much legalese I quit

mic

2011/2/16 Massimo Di Pierro :
> It would be a security hazard to allow a user to delete himself and
> all records referencing to the user.
> Moreover it can be clicked accidentally.
>
> I think is is better if you create your own action for that. Anyway,
> instead of
>
> auth.profile()
>
> you can do
>
> crud.update(db.auth_user,auth.user.id)
>
>
> On Feb 16, 10:55 am, Michele Comitini 
> wrote:
>> Hi all!
>>
>> I do not see a way to show the delete checkbox on the Auth.profile()
>> SQLFORM without modifying tools.py.
>> Am I missing something?
>>
>> tnx
>>
>> mic


[web2py] Re: form.accepts() with reference to other table

2011-02-16 Thread villas
It should be easy. Post your relevant model and controller code.

BTW it probably doesn't make any difference...  but maybe you might
consider using the notation account_id instead of accountID.  I read
somewhere that some databases have case sensitive fields and that
web2py makes some assumptions about this.  Just better to work all in
lowercase and avoid hitting that possible complication in the
future. :)

Regards,  D

On Feb 16, 6:47 pm, Oskari  wrote:
> I'm still struggling with the IS_IN_DB-validator. This problem occurs
> when trying to implement reference id for example via a controller
> line:
> request.vars.reftableid = 2
>
> The form just informs it isn't in the database. Why is that?
>
> On Feb 13, 3:14 pm, Oskari  wrote:
>
> > Uncommenting that did the trick. Perhaps there was something wrong
> > with that =)
>
> > Anyways, thanks!
>
> > On Feb 13, 3:17 am, villas  wrote:
>
> > > Try commenting out the line 'custom_auth_table.accountID.requires...'
> > > If that doesn't give you any progress, post all your auth model. I'm
> > > sure someone should be able to spot something  obvious -- these bugs
> > > can be right under our noses sometimes :)
> > > -D
>
> > > On Feb 12, 11:03 pm, Oskari  wrote:
>
> > > > Thank you for your answer villas!
>
> > > > I don't think that is the problem. I am able to make inserts through
> > > > the appadmin-site, but somehow it fails with form.accepts().
> > > > I also tried what you suggested, but could not quite get it working.
>
> > > > On Feb 12, 8:45 pm, villas  wrote:
>
> > > > > Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right?
>
> > > > > Maybe if you tried something like this, e.g.
> > > > > custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'%
> > > > > (name)s')
>
> > > > > On Feb 12, 1:28 pm, Oskari  wrote:
>
> > > > > > Hi!
>
> > > > > > I'm having trouble making an insert with form.accepts()
>
> > > > > > Currently I have a custom auth_user that has one extra field:
> > > > > > Field('accountID', db.accounts) with
> > > > > > custom_auth_table.accountID.requires = 
> > > > > > IS_IN_DB(db,db.accounts.id,id)
>
> > > > > > While trying to modify variables it fails with "not found in db"
>
> > > > > > def func():
> > > > > >     form=SQLFORM(db.auth_user)
> > > > > >     request.vars.accountID = 1
> > > > > >     if form.accepts(request.vars,session):
> > > > > >         response.flash = "Succesfully created user"
> > > > > >     return dict(form=form)
>
> > > > > > Why does not form.accepts() recognize and accept my accountID?
>
>


[web2py] Re: CRUD form customization - possible??

2011-02-16 Thread greenpoise
Is this before I call {{=form}}




On Feb 16, 5:09 am, Massimo Di Pierro 
wrote:
> given...
> from=crud.create()
>
> you can do
>
> form e in form.elements('input[type=text]'): e['size']=50;
>
> or in JS
>
> jQuery('input[type=text]').css('width':'50px'):
>
> or better in CSS
>
> input[type=text] {width: 50px;}
>
> On Feb 15, 10:59 pm, greenpoise  wrote:
>
>
>
> > Sorry for a possible double post but honestly, I could not find my
> > previous post. I had asked if it was possible to customize CRUD forms?
> > such as the length of the text boxes? if so, how?  I love the
> > simplicity of CRUD and would prefer it over manually creating forms
>
> > THanks


Re: [web2py] password issues on server move

2011-02-16 Thread Richard Vézina
The problem is it only when you try to access the appadmin on prod server?

If so, it could come from parameters_443.py file in the web2py folder. It
contain the hash of you admin password.

Richard

On Wed, Feb 16, 2011 at 2:15 PM, Matt  wrote:

> I have recently moved my web2py installation to a new server.  The
> database (postgresql) was copied using an sql dump.  After this the
> user passwords appear to have stopped working.  If I do a password
> reset, and use the same password it works again.  The hash of the
> password is the same before and after the reset.  Any ideas what is
> going on?
>
> Thanks


[web2py] password issues on server move

2011-02-16 Thread Matt
I have recently moved my web2py installation to a new server.  The
database (postgresql) was copied using an sql dump.  After this the
user passwords appear to have stopped working.  If I do a password
reset, and use the same password it works again.  The hash of the
password is the same before and after the reset.  Any ideas what is
going on?

Thanks


[web2py] Re: form.accepts() with reference to other table

2011-02-16 Thread Oskari
I'm still struggling with the IS_IN_DB-validator. This problem occurs
when trying to implement reference id for example via a controller
line:
request.vars.reftableid = 2

The form just informs it isn't in the database. Why is that?

On Feb 13, 3:14 pm, Oskari  wrote:
> Uncommenting that did the trick. Perhaps there was something wrong
> with that =)
>
> Anyways, thanks!
>
> On Feb 13, 3:17 am, villas  wrote:
>
>
>
>
>
>
>
> > Try commenting out the line 'custom_auth_table.accountID.requires...'
> > If that doesn't give you any progress, post all your auth model. I'm
> > sure someone should be able to spot something  obvious -- these bugs
> > can be right under our noses sometimes :)
> > -D
>
> > On Feb 12, 11:03 pm, Oskari  wrote:
>
> > > Thank you for your answer villas!
>
> > > I don't think that is the problem. I am able to make inserts through
> > > the appadmin-site, but somehow it fails with form.accepts().
> > > I also tried what you suggested, but could not quite get it working.
>
> > > On Feb 12, 8:45 pm, villas  wrote:
>
> > > > Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right?
>
> > > > Maybe if you tried something like this, e.g.
> > > > custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,'%
> > > > (name)s')
>
> > > > On Feb 12, 1:28 pm, Oskari  wrote:
>
> > > > > Hi!
>
> > > > > I'm having trouble making an insert with form.accepts()
>
> > > > > Currently I have a custom auth_user that has one extra field:
> > > > > Field('accountID', db.accounts) with
> > > > > custom_auth_table.accountID.requires = IS_IN_DB(db,db.accounts.id,id)
>
> > > > > While trying to modify variables it fails with "not found in db"
>
> > > > > def func():
> > > > >     form=SQLFORM(db.auth_user)
> > > > >     request.vars.accountID = 1
> > > > >     if form.accepts(request.vars,session):
> > > > >         response.flash = "Succesfully created user"
> > > > >     return dict(form=form)
>
> > > > > Why does not form.accepts() recognize and accept my accountID?


Re: [web2py] Re: id pb

2011-02-16 Thread Richard Vézina
Ok, forget about it Massimo. I found why I get duplicated field name error.

Multiples tables in one form works, but I have a bizzard thing, see by your
self :

db.define_table('ref_fnaregistry',
Field('fnaregistry_id','id'),
Field('num_part1','string',
length=20,
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
Field('num_part2','string',
length=20,
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
Field('num_part3','string',
length=20,
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
#migrate=False,
sequence_name='ref_fnaregistry_fnaregistry_id_seq',
format=lambda row: '%s-%s-%s'\

%(row.num_part1.rstrip(),row.num_part2.rstrip(),row.num_part3.rstrip()))

# ref_vregistry
db.define_table('ref_vregistry',
Field('vregistry_id','id'),
Field('vol_num','integer',
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
Field('vol_fnaregistry_id',db.ref_fnaregistry),
#migrate=False,
sequence_name='ref_vregistry_vregistry_id_seq',
format='%(vol_num)s')

db.ref_vregistry.vol_fnaregistry_id.requires =
IS_IN_DB(db,'ref_fnaregistry.fnaregistry_id',db.ref_fnaregistry._format)

# ref_tregistry
db.define_table('ref_tregistry',
Field('tregistry_id','id'),
Field('tome_num','integer',
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
Field('vregistry_id',db.ref_vregistry),
Field('tom_fnaregistry_id',db.ref_fnaregistry),
#migrate=False,
sequence_name='ref_tregistry_tregistry_id_seq',
format='%(tome_num)s')

db.ref_tregistry.vregistry_id.requires =\

 IS_NULL_OR(IS_IN_DB(db,'ref_tregistry.vregistry_id',db.ref_tregistry._format))
db.ref_tregistry.tom_fnaregistry_id.requires =\

 
IS_NULL_OR(IS_IN_DB(db,'ref_fnaregistry.fnaregistry_id',db.ref_fnaregistry._format))

# ref_eregistry
db.define_table('ref_eregistry',
Field('eregistry_id','id'),
Field('exp_num','string',
length=255,
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))],
required=True
),
Field('tregistry_id',db.ref_tregistry),
#migrate=False,
sequence_name='ref_eregistry_eregistry_id_seq',
format='%(exp_num)s')


in ref_tregistry I can make relation with fnaregistry or vregistry... It was
causing the problem... I changed the name of the fnaregistry_id for
vol_fnaregistry_id and tom_fnaregistry_id that solve the duplicated field
name problem and I can load input with this modified controller from the
book :

def create_all_at_once():
db.ref_vregistry.vol_fnaregistry_id.readable=False
db.ref_vregistry.vol_fnaregistry_id.writable=False
db.ref_tregistry.vregistry_id.readable=False
db.ref_tregistry.vregistry_id.writable=False
db.ref_tregistry.tom_fnaregistry_id.readable=False
db.ref_tregistry.tom_fnaregistry_id.writable=False
db.ref_eregistry.tregistry_id.readable=False
db.ref_eregistry.tregistry_id.writable=False
form =
SQLFORM.factory(db.ref_fnaregistry,db.ref_vregistry,db.ref_tregistry,db.ref_eregistry)
if form.accepts(request.vars):
id =
db.ref_fnaregistry.insert(**db.ref_fnaregistry._filter_fields(form.vars))
form.vars.vol_fnaregistry_id=id
id =
db.ref_vregistry.insert(**db.ref_vregistry._filter_fields(form.vars))
form.vars.vregistry_id=id
id =
db.ref_tregistry.insert(**db.ref_tregistry._filter_fields(form.vars))
form.vars.tregistry_id=id
id =
db.ref_eregistry.insert(**db.ref_eregistry._filter_fields(form.vars))
response.flash='Thanks for filling the form'
return dict(form=form)

But I have to find a way to by pass the double relation problem I have... If
you have a idea... Maybe with list:reference multiple=True... But I don't
like this workaround it so much, since I have to use postgres function in my
SQL or relied entirely on web2py for query those tables... I prefer keep my
schema as simple as possible so it can be queried with basic SQL syntax


Richard

On Tue, Feb 15, 2011 at 7:37 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you provide an example of "form for many tables" this is not
> something web2py supports out of the box so it depends. I can see
> problems with it.
>
> On Feb 15, 3:08 pm, Richard Vézina 
> wrote:
> > Hello Massimo,
> >
> > Is there something wrong with this syntax :
> >
> > Field('table_id','id')
> > sequence_name='table_table_id_seq'
> >
> > You introduced it, a couples of month ago... It works just fine with
> > Postgres... But now I am facing problem.
> >
> > If I want to make one form for many tables, it is not possible since
> 

[web2py] where should I put those lines

2011-02-16 Thread Richard Vézina
Hello Massimo,

I would like to update the languages files at startup or once in a wild...

Where should I put those lines :

#
-
import os
import gluon.portalocker
import cPickle
from gluon.languages import read_dict, read_dict_aux, utf8_repr, write_dict
from gluon.cfs import getcfs
#
-

#
-
language = 'fr-ca'
application_path = request.application
path = os.path.join('applications', application_path, 'languages/') #
Enlever 'applications' lorsque transféré dans application
filename = os.path.join(path, '%s.py' % language)

language_fr_ca = read_dict(filename) # read_dict() est une fonction de
langugages.py et nécessite getcfs

dict_database_ui_en_fr = db(db.dict_database.table_name_en_ui != None)\
.select(db.dict_database.table_name_en_ui.name,
db.dict_database.table_name_fr_ui.name,
distinct=True)
#dict_new = {}
#for row in dict_database_ui_en_fr:
#   dict_new[row['table_name_en_ui']] = row['table_name_fr_ui']
#dict((row['table_name_en_ui'],row['table_name_fr_ui']) for row in
dict_database_ui_en_fr) # Replace the above 3 lines of code
language_fr_ca.update(dict((row['table_name_en_ui'],row['table_name_fr_ui'])
for row in dict_database_ui_en_fr)) # Replace the above 4 lines of code

#
-
write_dict(filename, language_fr_ca)
#
-

In model, controller with a action button to trigger it?

I do believe that fr-ca.py language file is locked during the read and write
operation since I use the imported read_dict and write_dict function from
gluon.languages... Can you confirmed this?

Thanks I appreciate.

Richard

PS.: Sorry to repeat, I am having trouble sending my emails and make them
appear on the list.


[web2py] Re: 1.92 update_record()

2011-02-16 Thread LightOfMooN
it's in the Shell. In the controller functions it works fine.

On 16 фев, 22:13, LightOfMooN  wrote:
> shop = db(db.shops.id==8).select().first()
>
> shop
>  \xd0\xbc\xd0\xb0\xd1\x88\xd0\xba\xd0\xb0', 'globalsearch': False,
> 'delete_key': '', 'owner': 2, 'active': False, 'id': 8, 'deletedate':
> None}>
>
> shop.update_record(active=True)
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/contrib/shell.py", line 225, in
> run
>     exec compiled in statement_module.__dict__
>   File "", line 1, in 
>   File "/home/www-data/web2py/gluon/dal.py", line 3241, in __getattr__
>     return self[key]
>   File "/home/www-data/web2py/gluon/dal.py", line 3232, in __getitem__
>     return dict.__getitem__(self, key)
> KeyError: 'update_record'
>
> It workes fine on 1.91.6


[web2py] 1.92 update_record()

2011-02-16 Thread LightOfMooN
shop = db(db.shops.id==8).select().first()

shop


shop.update_record(active=True)
Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/contrib/shell.py", line 225, in
run
exec compiled in statement_module.__dict__
  File "", line 1, in 
  File "/home/www-data/web2py/gluon/dal.py", line 3241, in __getattr__
return self[key]
  File "/home/www-data/web2py/gluon/dal.py", line 3232, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'update_record'

It workes fine on 1.91.6


[web2py] Re: broken images

2011-02-16 Thread villas
Yes of course all you are doing is referring to the existing path of
the images.

BTW  I think the URL code I gave may be a bit wrong:
Try this instead:
   {{u=URL('static','plugin_layouts',args=('layouts','Optimism'))}}

..., or, try this,

Replace the index function in your 'default.py' controller with this:

def index():
 
redirect(URL('static','plugin_layouts',args=('layouts','Optimism','index.html'))}}

You may have to play around with it a little.



[web2py] Re: Deleting a registered user

2011-02-16 Thread Massimo Di Pierro
It would be a security hazard to allow a user to delete himself and
all records referencing to the user.
Moreover it can be clicked accidentally.

I think is is better if you create your own action for that. Anyway,
instead of

auth.profile()

you can do

crud.update(db.auth_user,auth.user.id)


On Feb 16, 10:55 am, Michele Comitini 
wrote:
> Hi all!
>
> I do not see a way to show the delete checkbox on the Auth.profile()
> SQLFORM without modifying tools.py.
> Am I missing something?
>
> tnx
>
> mic


[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread LightOfMooN
THX for new URL!!!

On 16 фев, 19:52, Massimo Di Pierro 
wrote:
> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo


[web2py] Re: Issue 172 needs to be reopened

2011-02-16 Thread vortex
Am I allowed to reopen it?


On Feb 16, 4:29 pm, Massimo Di Pierro 
wrote:
> Please do so and I will take care.
>
> On Feb 16, 10:16 am, vortex  wrote:
>
> > I have made tests and bug of issue 172 seems to be still present in
> > the windows version of the code.
>
>


[web2py] Deleting a registered user

2011-02-16 Thread Michele Comitini
Hi all!

I do not see a way to show the delete checkbox on the Auth.profile()
SQLFORM without modifying tools.py.
Am I missing something?

tnx

mic


Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Bruno Rocha
Can we include #anchors to changelog page?

so accesing http://web2py.com/examples/default/changelog#1.92.1 shows the
latest change log.

or, inverting the order showing the newest version on top.


--
Bruno Rocha
http://about.me/rochacbruno/bio


2011/2/16 Massimo Di Pierro 

> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo


[web2py] Re: Issue 172 needs to be reopened

2011-02-16 Thread Massimo Di Pierro
Please do so and I will take care.

On Feb 16, 10:16 am, vortex  wrote:
> I have made tests and bug of issue 172 seems to be still present in
> the windows version of the code.


[web2py] Re: JSF 2.0 vs web2py

2011-02-16 Thread Massimo Di Pierro
I do not know too much about JSF but, as I understand it requires a
lot of XML coding and that is what web2py people (particularly me) do
not like. Yet in the last year many things have changed, in
particular:

- plugins and components
- a new more portable DAL
- a better routing mechanism
- more configuration options for built-in functions

components in particular help you do some of what JSF can do. They
allow to insert a {{=LOAD('controller','function',ajax=True)}} in a
web2py view and the actions /app/controller/function will manage its
own content. It can also communicate with other components and trigger
events. For example (complete program):

# models/db.py
db=DAL()
db.define_table('post',Field('body',notnull=True))
from gluon.tools import *
crud=Crud(globals(),db)

# controllers/default.py
def reload_posts(form):
response.js="web2py_ajax_page('get','%s',null,'posts')" %
URL('posts')
def index(): return dict()
def post(): return crud.create(db.post,onaccept=reload_posts)
def posts(): return SQLTABLE(db(db.post).select())

# views/index.html
{{extend 'layout.html'}}
{{=LOAD('default','post',ajax=True)}}
{{=LOAD('default','posts',ajax=True,target='posts')}}

post and posts are components embedded in the index page. submitting
an invalid post does not reload the page, only the component with its
errors and flash message. Submitting a valid post form, results in a
call (serverside) to reload_posts with sends a JS commend to the
client which forces an ajax reload of the list of previous posts.

On Feb 16, 8:55 am, sebastian  wrote:
> Hi Guys,
>
> I have used web2py successfully for few commercial projects in the
> past and I it saved me a LOT of time compared with J2EE + Spring/
> Struts + Hibernate etc... In fact most of the effort was for the UI as
> the business part was taken care by web2py !
>
> Now I am working on a project with  JSF 2.0 (Primeface ) and I have to
> say that I am impressed. I can add Ajax components very easily (see
> the primecase showcase) and the business part (Java) is incredibly
> easy bound the the components... (it is just a class with an
> annotation)
>
> As I haven't used web2py seriously for over a year, just wondering if
> web2py has added something similar (or better !) to JSF2.
>
> Thanks


Re: [web2py] decorator to block direct access by the url to auxiliairy function only call by main function

2011-02-16 Thread Richard Vézina
Great!

Thanks Anthony, that exactly what I needed.

Richard

On Wed, Feb 16, 2011 at 11:18 AM, Anthony  wrote:

> According to the book, controller functions that take arguments or that
> begin with a double underscore are not publicly exposed and therefore cannot
> be reached via a URL -- they can only be called from other functions. So,
> since last_hour_events function takes an argument, I think you're OK --
> access will automatically be restricted.
>
> See http://web2py.com/book/default/chapter/04#Dispatching
>
> Anthony
>
> On Wednesday, February 16, 2011 10:34:56 AM UTC-5, Richard wrote:
>
>> Hello,
>>
>> I used this scenario don't know if it good or not... I am open to
>> suggestion if it is not a good pratice.
>>
>>  def index():
>> """
>> Index page using the internationalization operator T and flash
>> rendered by views/default/index.html or views/generic.html
>> """
>> table,nb_events=last_hour_events(tables_list)
>> return dict(
>> table=table,
>> nb_events=nb_events)
>>
>>
>>  def last_hour_events(tables_list):
>> """
>> Establishing the list of last hour actions and return the 10 lasts of
>> the list
>> """
>> now = datetime.datetime.now()
>> time_one_hour_before_now = now - datetime.timedelta(hours=1)
>> last_hour_events_list = []
>> for t in tables_list:
>> for row in db(db[t].sdate >=
>> time_one_hour_before_now).select(db[t].id, orderby=db[t].sdate):
>> last_hour_events_list.append(A(T('This is a new event in the
>> last hour'),
>> _href=URL(r=request,c='test', f='read',args=(db[t],row.id
>> 
>> nb_events=len(last_hour_events_list)
>> table=TABLE(last_hour_events_list[0:10])
>> return (table,nb_events)
>>
>>  So I would like prevent the direct execution of the above function
>> ("last_hour_events").
>>
>> Wich decorator should I use?
>>
>> Also, I think listing all the decorator available with description into
>> one location somewhere in the book could be a great improvement of the
>> documentation, since there is no complete information about decorators
>> excepted mention here and there few decorator at a time.
>>
>> Richard
>>
>


Re: [web2py] decorator to block direct access by the url to auxiliairy function only call by main function

2011-02-16 Thread Anthony
According to the book, controller functions that take arguments or that 
begin with a double underscore are not publicly exposed and therefore cannot 
be reached via a URL -- they can only be called from other functions. So, 
since last_hour_events function takes an argument, I think you're OK -- 
access will automatically be restricted.
 
See http://web2py.com/book/default/chapter/04#Dispatching
 
Anthony

On Wednesday, February 16, 2011 10:34:56 AM UTC-5, Richard wrote:

> Hello, 
>
> I used this scenario don't know if it good or not... I am open to 
> suggestion if it is not a good pratice.
>
>  def index():
> """
> Index page using the internationalization operator T and flash
> rendered by views/default/index.html or views/generic.html
> """
> table,nb_events=last_hour_events(tables_list)
> return dict(
> table=table,
> nb_events=nb_events)
>
>
>  def last_hour_events(tables_list):
> """
> Establishing the list of last hour actions and return the 10 lasts of 
> the list
> """
> now = datetime.datetime.now()
> time_one_hour_before_now = now - datetime.timedelta(hours=1)
> last_hour_events_list = []
> for t in tables_list:
> for row in db(db[t].sdate >= 
> time_one_hour_before_now).select(db[t].id, orderby=db[t].sdate):
> last_hour_events_list.append(A(T('This is a new event in the 
> last hour'),
> _href=URL(r=request,c='test', f='read',args=(db[t],row.id
> 
> nb_events=len(last_hour_events_list)
> table=TABLE(last_hour_events_list[0:10])
> return (table,nb_events)
>
>  So I would like prevent the direct execution of the above function 
> ("last_hour_events").
>
> Wich decorator should I use?
>
> Also, I think listing all the decorator available with description into one 
> location somewhere in the book could be a great improvement of the 
> documentation, since there is no complete information about decorators 
> excepted mention here and there few decorator at a time.
>
> Richard
>


[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread Brian Meents
I just downloaded from source on Windows and installed it and I'm
seeing 1.92.1 here...

vortex wrote:
> I just downloaded and it says: version 1.91.6
>
> Also I think issue 172 is still present in the windows version.
>
>
>
>
> On Feb 16, 3:04 pm, Marin Pranjic  wrote:
> > I wanted to update from admin app but it gives me neverending "Checking for
> > upgrades..."
> > Not sure what is the problem, so better to report it :)
> >
> > Using 1.91.6 source code on windows, python2.7.1
> >
> > I tried restarting web2py and update in 2 browsers but no success.
> >
> > On Wed, Feb 16, 2011 at 3:52 PM, Massimo Di Pierro <
> >
> > massimo.dipie...@gmail.com> wrote:
> > > changelog:
> >
> > > much improved routing (thanks Jonathan)
> > > Expression.__mod__ (thanks Denes)
> > > admin has MULTI_USER_MODE (admin/models/0.py)
> > > support for count(distinct=...)
> > > has_permissions(...,group_id)
> > > IS_MATCH(...,strict=True)
> > > URL(...,scheme=,host=,port=), thanks Jonathan
> > > admin in Afrikaans, thanks Caleb
> > > auth.signature (experimental)
> > > many bug fixes
> >
> > > please test it and report any issue.
> >
> > > Massimo
> >
> >


[web2py] Issue 172 needs to be reopened

2011-02-16 Thread vortex
I have made tests and bug of issue 172 seems to be still present in
the windows version of the code.



[web2py] Re: Read-only CRUD fields don't work?

2011-02-16 Thread Massimo Di Pierro
Can you post a short example to reproduce the problem, and better,
open an issue.

On Feb 16, 9:47 am, Joe  Barnhart  wrote:
> The new release 1.92.1 seems to work -- at least halfway!
>
> It now shows the value of the field in a read-only fashion, but the
> field.represent is not triggered, rendering the field as an integer
> instead of its reference (id) representation.
>
> We're getting close!
>
> -- Joe
>
> On Feb 16, 5:11 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > This should be fixed in trunk. Get the nightly build from the download
> > page.
>
> > On Feb 16, 1:58 am, Joe  Barnhart  wrote:
>
> > > I have a simple CRUD "create" form that's driving me crazy.  I want to
> > > pre-load one of the fields in the form.  I want the field to show up,
> > > but be read-only so the user can see it but not change it.
>
> > > I've tried setting the "default" property of the field and then making
> > > it "readable=True" and "writable=False".  The field always shows up as
> > > "None" in the form.  I also tried setting the form.var.fieldname=value
> > > after the form is created, but before it is rendered.  Still no joy.
>
> > > In any case, if I make the field "writable=True" I can see the field
> > > is properly set.  I can also change the field, however, which is what
> > > I'm trying to prevent.
>
> > > I am using the current version of web2py and going slowing
> > > insane... ;-)


Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Vinicius Assef
A changelog is really important. :-)

Congrats Massimo.



On Wed, Feb 16, 2011 at 12:52 PM, Massimo Di Pierro
 wrote:
> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo


[web2py] Re: Read-only CRUD fields don't work?

2011-02-16 Thread Joe Barnhart
The new release 1.92.1 seems to work -- at least halfway!

It now shows the value of the field in a read-only fashion, but the
field.represent is not triggered, rendering the field as an integer
instead of its reference (id) representation.

We're getting close!

-- Joe

On Feb 16, 5:11 am, Massimo Di Pierro 
wrote:
> This should be fixed in trunk. Get the nightly build from the download
> page.
>
> On Feb 16, 1:58 am, Joe  Barnhart  wrote:
>
> > I have a simple CRUD "create" form that's driving me crazy.  I want to
> > pre-load one of the fields in the form.  I want the field to show up,
> > but be read-only so the user can see it but not change it.
>
> > I've tried setting the "default" property of the field and then making
> > it "readable=True" and "writable=False".  The field always shows up as
> > "None" in the form.  I also tried setting the form.var.fieldname=value
> > after the form is created, but before it is rendered.  Still no joy.
>
> > In any case, if I make the field "writable=True" I can see the field
> > is properly set.  I can also change the field, however, which is what
> > I'm trying to prevent.
>
> > I am using the current version of web2py and going slowing
> > insane... ;-)
>
>


Re: [web2py] Re: tip of the day. The power of routes

2011-02-16 Thread Bruno Rocha
Thats my working solution

http://snipt.net/rochacbruno/routespy/

 
http://snipt.net/rochacbruno/routesconf/


--
Bruno Rocha
http://about.me/rochacbruno/bio


2011/2/16 Johann Spies 

>
>
> On 29 November 2010 01:03, Bruno Rocha  wrote:
>
>> HI, I am trying to use autoroutes for the firsttime, what I want is my
>> site running in 127.0.0.1:8080/index instead of
>> 127.0.0.1/app/default/index.
>>
>> I tried the autoroutes and routes.conf explained here but i did't figure
>> out how to make the access to static files to work.
>>
>> I am using web2py 1.89.5 all functions as /index is working well, *but my
>> static files are unreachable.*
>>
>> Could you solve this problem about the static files?
>
> Regards
> Johann
> --
>  May grace and peace be yours in abundance through the full knowledge of
> God and of Jesus our Lord!  His divine power has given us everything we need
> for life and godliness through the full knowledge of the one who called us
> by his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>


[web2py] decorator to block direct access by the url to auxiliairy function only call by main function

2011-02-16 Thread Richard Vézina
Hello,

I used this scenario don't know if it good or not... I am open to suggestion
if it is not a good pratice.

def index():
"""
Index page using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
table,nb_events=last_hour_events(tables_list)
return dict(
table=table,
nb_events=nb_events)


def last_hour_events(tables_list):
"""
Establishing the list of last hour actions and return the 10 lasts of
the list
"""
now = datetime.datetime.now()
time_one_hour_before_now = now - datetime.timedelta(hours=1)
last_hour_events_list = []
for t in tables_list:
for row in db(db[t].sdate >=
time_one_hour_before_now).select(db[t].id, orderby=db[t].sdate):
last_hour_events_list.append(A(T('This is a new event in the
last hour'),
_href=URL(r=request,c='test', f='read',args=(db[t],row.id

nb_events=len(last_hour_events_list)
table=TABLE(last_hour_events_list[0:10])
return (table,nb_events)

So I would like prevent the direct execution of the above function
("last_hour_events").

Wich decorator should I use?

Also, I think listing all the decorator available with description into one
location somewhere in the book could be a great improvement of the
documentation, since there is no complete information about decorators
excepted mention here and there few decorator at a time.

Richard


[web2py] Re: VirtualFields are really slow with large datasets

2011-02-16 Thread Carlos
You can also use lazy virtual fields, such that they execute only when 
needed/called:

http://www.web2py.com/book/default/chapter/06?search=lazy

   Carlos



[web2py] cron doesn't work

2011-02-16 Thread LightOfMooN
Hello
I have web2py installed with setup-web2py-ubuntu.sh
It runs with Apache mod_wsgi.

Crontab of myapp is:
*/1  *  *  *  *  root  *cron/test

And function:
def test():
shop = db(db.shops.id==8).select().first()
new = shop.daystodelete + 1
shop.update_record(daystodelete=new)
db.commit()
return 'done'
test()

manually function works fine. But not with cron. Seems it's not
working.
Any ideas? Thx


Re: [web2py] Re: Spam control? and word filtering?

2011-02-16 Thread Jonathan Lundell
On Feb 16, 2011, at 5:10 AM, Massimo Di Pierro wrote:
> 
> I am not an expert on bad words in english, I could do a better job in
> Italian. ;-)

No doubt...

It's a tough problem, regardless, and it's awfully easy to get false positives. 
Better not misspell shiitake mushrooms.

> 
> On Feb 15, 11:20 pm, Jonathan Lundell  wrote:
>> On Feb 15, 2011, at 11:21 AM, Massimo Di Pierro wrote:
>> 
>> 
>> 
>>> import base64, re
>>> BADWORDS=re.compile(base64.b64decode("""KGFob2xlfGFudXN8YXNoMGxlfGFzaDBsZXN 
>>> 8YXNob2xlc3xhc3N8YXNzfGFzc2ZhY2V8YXNzaDBs
>> 
>> There are some very peculiar choices (and omissions) in that list.
>> 
>> rautenberg? job?
>> 
>> honkey, but not honky (or its orginal, bohunk).
>> 
>> Aside from the word choice, if you're going to use it, change match to 
>> search, bracket the pattern with \b's, and make it case-insensitive.




[web2py] database access

2011-02-16 Thread stargate
When running web2py how do i access the mysql database using a
applicaiton like


http://www.mysqlfront.de/wp/download/

Also when creating a new application using the application wizard it
has no indication to specify a user login for the database.  Where can
i change this.



[web2py] Re: web2py 1.92.1 is OUT

2011-02-16 Thread vortex
I just downloaded and it says: version 1.91.6

Also I think issue 172 is still present in the windows version.




On Feb 16, 3:04 pm, Marin Pranjic  wrote:
> I wanted to update from admin app but it gives me neverending "Checking for
> upgrades..."
> Not sure what is the problem, so better to report it :)
>
> Using 1.91.6 source code on windows, python2.7.1
>
> I tried restarting web2py and update in 2 browsers but no success.
>
> On Wed, Feb 16, 2011 at 3:52 PM, Massimo Di Pierro <
>
> massimo.dipie...@gmail.com> wrote:
> > changelog:
>
> > much improved routing (thanks Jonathan)
> > Expression.__mod__ (thanks Denes)
> > admin has MULTI_USER_MODE (admin/models/0.py)
> > support for count(distinct=...)
> > has_permissions(...,group_id)
> > IS_MATCH(...,strict=True)
> > URL(...,scheme=,host=,port=), thanks Jonathan
> > admin in Afrikaans, thanks Caleb
> > auth.signature (experimental)
> > many bug fixes
>
> > please test it and report any issue.
>
> > Massimo
>
>


Re: [web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Marin Pranjic
I wanted to update from admin app but it gives me neverending "Checking for
upgrades..."
Not sure what is the problem, so better to report it :)

Using 1.91.6 source code on windows, python2.7.1

I tried restarting web2py and update in 2 browsers but no success.


On Wed, Feb 16, 2011 at 3:52 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> changelog:
>
> much improved routing (thanks Jonathan)
> Expression.__mod__ (thanks Denes)
> admin has MULTI_USER_MODE (admin/models/0.py)
> support for count(distinct=...)
> has_permissions(...,group_id)
> IS_MATCH(...,strict=True)
> URL(...,scheme=,host=,port=), thanks Jonathan
> admin in Afrikaans, thanks Caleb
> auth.signature (experimental)
> many bug fixes
>
> please test it and report any issue.
>
> Massimo


[web2py] Re: How to do the following query?

2011-02-16 Thread vortex
I just downloaded the windows version and I think this issue still
continues in that version.


On Jan 31, 3:22 pm, vortex  wrote:
> It has been reported as issue 172.
>
> On Jan 31, 2:56 pm,vortex wrote:
>
> > I will do that now.
>
> > Thanks.
>
> > On Jan 31, 2:27 pm, Massimo Di Pierro 
> > wrote:
>
> > > You found a bug. What is the model?
>
> > > Can you post the model (just relevant field) and this example as an
> > > issue in google code. I will fix it asap.
>
> > > Massimo
>
> > > On Jan 31, 7:42 am,vortex wrote:
>
> > > > More info on this:
>
> > > > the (db.read.of_section != db.item.of_section) part is translating
> > > > into:
>
> > > > (rfid_read.of_section IS NOT NULL)
>
> > > > On Jan 31, 1:26 pm,vortex wrote:
>
> > > > > SELECT * FROM item JOIN read on read.of_item=item.id WHERE
> > > > > item.of_section <> read.of_section
>
> > > > > I tried:
>
> > > > > db((db.item.id == db.read.of_of_item) & (db.read.of_section !=
> > > > > db.item.of_section)).select()
>
> > > > > but I don't want a join. I just want the where cause to be:
> > > > > (db.read.of_section != db.item.of_section).
>
>


[web2py] Re: SQLFORM.widgets.date.widget problem

2011-02-16 Thread DenesL
Hi sipiatti,

you can change the translation of '%Y-%m-%d' in your language file.


On Feb 16, 5:58 am, sipiatti  wrote:
> Hi,
>
> I am very new in web2py (but I love it from the first met:) ), and
> faced a problem
> what I could solve with a workaround but I think it is not the right
> way.
>
> I have a custom form what I created with SQLFORM:
> form=SQLFORM(db.assets,
>
> fields=["assetno","subassetno","qty","costuser","name","serialno","activationdate","type_id"],
>                 col3={'qty':'No. of records will be
> created!','serialno':'E.g. S/N of a product'})
>
> I am using this in the table definiton for field activationdate:
> Field("activationdate","date",label="Date of
> activation",widget=SQLFORM.widgets.date.widget)
>
> If the quantity is greater then 1, I must insert additional entries to
> the db.
>
> I made this in the controller in order to achieve this:
>     if len(request.vars)>0:
>         qty=int(request.vars.qty)
>         if qty>1:
>             request.vars.qty='1'
>         if form.accepts(request.vars, session):
>             response.flash = '%s records inserted' % qty
>             if qty>1:
>                 for i in range(1,qty):
>
> db.assets.insert(assetno=request.vars.assetno,subassetno=request.vars.subassetno,qty=1,costuser=request.vars.costuser,name=request.vars.name,serialno=request.vars.serialno,activationdate=request.vars.activationdate,type_id=int(request.vars.type_id))
>                 db.commit()
>         elif form.errors:
>             response.flash = 'Bad data!'
>
> it fails at db.insert, because I have hungarian locale and the date
> from the date widget comes in this format:
> .mm.dd.
> and not in this format:
> YYY-mm-dd
>
> I used this solution (converting the datestring :/ ):
> db.assets.insert(assetno=request.vars.assetno,subassetno=request.vars.subassetno,qty=1,costuser=request.vars.costuser,name=request.vars.name,serialno=request.vars.serialno,activationdate=datetime.datetime.strptime(request.vars.activationdate,"%Y.
> %m.%d.").date().isoformat(),type_id=int(request.vars.type_id))
>
> My question is:
> Is there any other more simple way to handle such problems?
>
> PS: I've translated the variable names in the code to english to be
> more understandable (most of them were hungarian), could be I've some
> typo :)


Re: [web2py] Re: jqgrid-problem

2011-02-16 Thread Johann Spies
On 16 February 2011 16:32, Massimo Di Pierro wrote:

> Please check with firebug what the ajax call does and how it fails.
> Without that information I cannot say.
>
>
I am afraid I am a bit lost on this one.  I have never programmed Ajax
before and have no clue what Firebug is telling me or where the errors are
in this case.

Maybe you can try and see for yourself:  http://kbase.sun.ac.za/artikelsjq

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] JSF 2.0 vs web2py

2011-02-16 Thread sebastian
Hi Guys,

I have used web2py successfully for few commercial projects in the
past and I it saved me a LOT of time compared with J2EE + Spring/
Struts + Hibernate etc... In fact most of the effort was for the UI as
the business part was taken care by web2py !

Now I am working on a project with  JSF 2.0 (Primeface ) and I have to
say that I am impressed. I can add Ajax components very easily (see
the primecase showcase) and the business part (Java) is incredibly
easy bound the the components... (it is just a class with an
annotation)

As I haven't used web2py seriously for over a year, just wondering if
web2py has added something similar (or better !) to JSF2.

Thanks


[web2py] web2py 1.92.1 is OUT

2011-02-16 Thread Massimo Di Pierro
changelog:

much improved routing (thanks Jonathan)
Expression.__mod__ (thanks Denes)
admin has MULTI_USER_MODE (admin/models/0.py)
support for count(distinct=...)
has_permissions(...,group_id)
IS_MATCH(...,strict=True)
URL(...,scheme=,host=,port=), thanks Jonathan
admin in Afrikaans, thanks Caleb
auth.signature (experimental)
many bug fixes

please test it and report any issue.

Massimo


[web2py] Re: broken images

2011-02-16 Thread stargate
It worked when i go to the following URL all the images are working
now

http://localhost:8000/template/static/plugin_layouts/layouts/Pluralism/index.html

But that isn't the right way to view the application. So the only work
around is to provide full path for the image is this correct.

One method that was used was this one

Create the string:
  {{u=URL('static',args=('plugin_layouts','layouts','Optimism'))}}

Use it wherever you wish in the view:
  

Would that be the best method.

Thanks everybody for all the help



On Feb 15, 4:37 pm, villas  wrote:
> I think I now understand,  you want the plugin to work like it does
> online.
>
> After you install a new app e.g. 'alayout' and then the layout plugin
> 'Optimism',  the layout is copied over the top of views/layout.html.
> This is visible from:  http://localhost:8000/alayout/ But the images
> and urls etc are not adjusted.
>
> Of course you are just using the html to give you a head start and
> will need to rebuild layout.html with your own data etc.
>
> If you want to the see the page with all the links/images working go
> to this 
> page:http://localhost:8000/alayout/static/plugin_layouts/layouts/Optimism/...
>
> This is the equivalent of what you are seeing in the preview atwww.web2py.com
> Is that what you mean?
> -D
>
> On Feb 15, 8:04 pm, stargate  wrote:
>
> > If you go here
>
> >http://www.web2py.com/layouts
>
> > then preview Optimism.  How come when you go to view source the image
> > path is /images and the image file name.  But when you click on view
> > image it will show you the exact path of the images.
>
> > I am just wondering why can't i just do /images/folder/myfile_name
> > instead of typing the exact location of the template
>
> > On Feb 15, 2:56 pm, villas  wrote:
>
> > > The plugin replaces your layout.html
>
> > > Open up views/layout.html
> > > Search for: images/
> > > Replace with: static/plugin_layouts/layouts/Pluralism/images/
>
> > > Does that help?
>
> > > I should mention that the plugin is just to get you a head start.
> > > You're going to have to do more work to assimilate it into your site.
> > > I am not very familiar with it, but someone may be able to help.
>
> > > On Feb 15, 4:57 pm, stargate  wrote:
>
> > > > The broken images started when i created a new application and applied
> > > > the following layout plugin to it
>
> > > >http://www.web2py.com/layouts/static/plugin_layouts/layouts/Pluralism...
>
> > > > The problem is when you see the preview all the images are intact but
> > > > when i try to do it all the images are broken not to sure why
>
> > > > On Feb 15, 11:33 am, stargate  wrote:
>
> > > > > This line generates a error
>
> > > > > 
>
> > > > > Not sure why
>
> > > > > On Feb 15, 9:40 am, villas  wrote:
>
> > > > > > 'base' is for when all links on that page are to the same place.  
> > > > > > You
> > > > > > have to decide that.
>
> > > > > > However,  I don't think 'response.files' is right for that. Maybe 
> > > > > > this
> > > > > > would be better...
> > > > > > 
>
> > > > > > -D
>
> > > > > > On Feb 15, 1:28 pm, stargate  wrote:
>
> > > > > > > Wouldn't it also better to use
>
> > > > > > >  > > > > > > href="{{response.files.append(URL(request.application,'static','plugin_layouts/
> > > > > > > layouts/Optimism/'))}} " />
>
> > > > > > > This would cut time for inserting the code in every image tag on 
> > > > > > > the
> > > > > > > page.  Please correct me if i am wrong.
>
> > > > > > > On Feb 15, 1:04 am, villas  wrote:
>
> > > > > > > > > Why would you have another folder called layouts.
>
> > > > > > > > I only copied what was in the other post to demonstrate a 
> > > > > > > > different
> > > > > > > > (more recent) syntax.
>
> > > > > > > > If you look in the views/layout.html file you will see how the
> > > > > > > > other .js files are included,
> > > > > > > > e.g. {{response.files.append(URL('static','js/superfish.js'))}}
>
> > > > > > > > It is best if you examine your own paths,  then you will see 
> > > > > > > > where
> > > > > > > > your files are located and be able to learn to link to them
> > > > > > > > accordingly.  Do you have this file? :  
> > > > > > > > static/plugin_layout/Optimism/
> > > > > > > > js/cufon-yui.js
> > > > > > > > If so, then what you have should be OK.
>
> > > > > > > > I think this would be more recommended:
> > > > > > > > {{response.files.append(URL('static','plugin_layout/Optimism/js/cufon-
> > > > > > > > yui.js'))}}
>
> > > > > > > > If you have Firefox browser,  experiment with the Firebug 
> > > > > > > > plug-in.
> > > > > > > > You can see exactly what is being found and included in your 
> > > > > > > > pages. It
> > > > > > > > is a good, worthwhile tool.
>
> > > > > > > > -D
>
> > > > > > > > On Feb 15, 3:21 am, stargate  wrote:
>
> > > > > > > > > I am trying to figure out a proper structure.  Right now i 
> > > > > > > > > have it
> > > > > > > > > like this.
>
> > > > > > > > > ..//static/plugin_layouts/Optimism/images/img17.jpg

Re: [web2py] Re: a few DAL proposes

2011-02-16 Thread Vasile Ermicioi
>
> About 1). Are you asking to be able to extend class Table for a
> specific define_table? Or doyou specifically need the move methods?


I want to be able to extend class Table and to use those classes with define
table (see attached file)

db.define_table("categories",
Field("title"),
act_as=OrderedTree
)

db.define_table("images",
Field("category", db.categories),
Field("title"),
act_as=OrderedList,
)

db.define_table("videos",
Field("category", db.categories),
Field("title"),
)

then
db.images.move_before(2, 1) #move 2 before 1, 2 will be first


ordered.py
Description: Binary data


[web2py] Re: jqgrid-problem

2011-02-16 Thread Massimo Di Pierro
Please check with firebug what the ajax call does and how it fails.
Without that information I cannot say.

massimo

On Feb 16, 7:47 am, Johann Spies  wrote:
> On 15 February 2011 16:35, Massimo Di Pierro 
> wrote:
>
> > check with firebug. It is possible the ajax requests of jqgrid are
> > failing. This could be because on your deployment you are using
> > routes.
>
> I am indeed using routes on the deployment server!  Thanks.  Do I need to
> adjust the routes then?  I am using autorouting.
>
>
>
> > also clear or tickets. Run jqgrid and check for tickets when it
> > fails.
>
> Thanks for the tip.
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a


[web2py] Re: Doctests and aut - Difference being logged in or not

2011-02-16 Thread Massimo Di Pierro
One trick is to replace

@auth.requires_login()

with

@auth.requires(auth.user or request.function=='_TEST')


On Feb 16, 7:33 am, Oskari  wrote:
> Hi,
>
> I'm writing doctests to my application. Most of my functions are
> decorated with @auth.requires_login().
>
> Running doctests through the web IDE runs the tests in a different
> environment depending on if I'm logged in in the app.
> What kind of pattern is here meant to be used to test logged-in
> features (the normal usage) possibly without self first logging in
> through the app?
> And also of course test that you cannot access the function without
> logging in?
>
> And also, considering an app with no data in database, how to test for
> example empty forms and lists easily?
>
> I am a bit confused with the way web2py is really supposed to be
> tested, the book lacks examples and discussion on that.
>
> Thanks already!


[web2py] Re: Importing an already existing MySQL database

2011-02-16 Thread DenesL

It is there in all the sources I have:

/web2py_x.xx_dir/scripts/

which version do you have? which OS?.


[web2py] Re: a few DAL proposes

2011-02-16 Thread Massimo Di Pierro
OK. 2 is in trunk.

About 1). Are you asking to be able to extend class Table for a
specific define_table? Or doyou specifically need the move methods?

On Feb 16, 7:16 am, DenesL  wrote:
> On Feb 16, 7:12 am, elffikk  wrote:
>
>
>
>
>
>
>
>
>
> > hi,
>
> > I propose to add a few things to DAL
>
> > 1) an 'act_as' parameter in define_table so I can extend Table class
> > and use it as regular table
>
> > for e.g.
>
> > db.define_table("images",
> >     Field("category", db.categories),
> >     Field("title"),
> >     act_as=OrderedList,
> > )
>
> > OrderedList is a class that extends Table class and adds a 'line'
> > column,
> > overrides insert and __del__ methods and adds 2 other methods:
> > move_before, move_after
>
> > required changes to gluon dal:
> > - add 'act_as' to the allowed keyword list in define_table method
> > ['migrate', 'primarykey', 'fake_migrate', 'format', 'trigger_name',
> > 'sequence_name', 'act_as']
> > - act_as = args.get('act_as',Table)  - Table is the default for
> > 'act_as'
> > - t = self[tablename] = act_as(self, tablename, *fields, 
>
> > usages:
> > _id = db.images.insert(... )
> > db.images.move_before(_id,  2)
>
> Not sure I understand this one.
> Could you expand on it?.
>
> > 2) please add __mod__ to Expression class so I can use it in dal
> > expressions
>
> > I want that
>
> > #move last image to first position and all other images positions are
> > increased by 1
> > db(db.images).update(line=db.images.line % _count +1)
>
> > but I am forced to use raw sql
> > db.executesql('UPDATE images SET line = line %% %s +1', (_count,))
>
> +1 from me, it is easy to add in:
>
> to class BaseAdapter add
>
> def
> MOD(self,first,second):
>     return '(%s %% %s)' %
> (self.expand(first),self.expand(second,first.type))
>
> and to class Expression add
>
> def __mod__(self,
> other):
>     return
> Expression(self.db,self.db._adapter.MOD,self,other,self.type)


Re: [web2py] Re: tip of the day. The power of routes

2011-02-16 Thread Johann Spies
On 29 November 2010 01:03, Bruno Rocha  wrote:

> HI, I am trying to use autoroutes for the firsttime, what I want is my site
> running in 127.0.0.1:8080/index instead of 127.0.0.1/app/default/index.
>
> I tried the autoroutes and routes.conf explained here but i did't figure
> out how to make the access to static files to work.
>
> I am using web2py 1.89.5 all functions as /index is working well, *but my
> static files are unreachable.*
>
> Could you solve this problem about the static files?

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Importing an already existing MySQL database

2011-02-16 Thread Rupesh Pradhan
I could not find the folder or file under web2py folder? Where is it?


Re: [web2py] Re: jqgrid-problem

2011-02-16 Thread Johann Spies
On 15 February 2011 16:35, Massimo Di Pierro wrote:

> check with firebug. It is possible the ajax requests of jqgrid are
> failing. This could be because on your deployment you are using
> routes.
>

I am indeed using routes on the deployment server!  Thanks.  Do I need to
adjust the routes then?  I am using autorouting.


>
> also clear or tickets. Run jqgrid and check for tickets when it
> fails.
>
>
Thanks for the tip.

Regards
Johann


-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: php to web2py

2011-02-16 Thread stargate
Just was confused when it said it was old blog that is all

On Feb 16, 5:25 am, Albert Abril  wrote:
> Stargate, all the tags in the article are correct.
> I guess you confused because it says 'Old web2py blog', but html and web2py
> are all correct.
>
> On Wed, Feb 16, 2011 at 10:51 AM, Vinicius Assef wrote:
>
> > Which tags?
>
> > On Wed, Feb 16, 2011 at 2:07 AM, stargate  wrote:
> > > I came across the following URLS
>
> > >http://web2py.com/AlterEgo/default/show/106
>
> > >http://www.web2py.com/AlterEgo/default/show/167
>
> > > Where is the updated content with the new web2py tags
>
>


[web2py] Doctests and aut - Difference being logged in or not

2011-02-16 Thread Oskari
Hi,

I'm writing doctests to my application. Most of my functions are
decorated with @auth.requires_login().

Running doctests through the web IDE runs the tests in a different
environment depending on if I'm logged in in the app.
What kind of pattern is here meant to be used to test logged-in
features (the normal usage) possibly without self first logging in
through the app?
And also of course test that you cannot access the function without
logging in?

And also, considering an app with no data in database, how to test for
example empty forms and lists easily?

I am a bit confused with the way web2py is really supposed to be
tested, the book lacks examples and discussion on that.

Thanks already!


[web2py] Re: a few DAL proposes

2011-02-16 Thread DenesL


On Feb 16, 7:12 am, elffikk  wrote:
> hi,
>
> I propose to add a few things to DAL
>
> 1) an 'act_as' parameter in define_table so I can extend Table class
> and use it as regular table
>
> for e.g.
>
> db.define_table("images",
> Field("category", db.categories),
> Field("title"),
> act_as=OrderedList,
> )
>
> OrderedList is a class that extends Table class and adds a 'line'
> column,
> overrides insert and __del__ methods and adds 2 other methods:
> move_before, move_after
>
> required changes to gluon dal:
> - add 'act_as' to the allowed keyword list in define_table method
> ['migrate', 'primarykey', 'fake_migrate', 'format', 'trigger_name',
> 'sequence_name', 'act_as']
> - act_as = args.get('act_as',Table)  - Table is the default for
> 'act_as'
> - t = self[tablename] = act_as(self, tablename, *fields, 
>
> usages:
> _id = db.images.insert(... )
> db.images.move_before(_id,  2)

Not sure I understand this one.
Could you expand on it?.

> 2) please add __mod__ to Expression class so I can use it in dal
> expressions
>
> I want that
>
> #move last image to first position and all other images positions are
> increased by 1
> db(db.images).update(line=db.images.line % _count +1)
>
> but I am forced to use raw sql
> db.executesql('UPDATE images SET line = line %% %s +1', (_count,))

+1 from me, it is easy to add in:

to class BaseAdapter add

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

and to class Expression add

def __mod__(self,
other):
return
Expression(self.db,self.db._adapter.MOD,self,other,self.type)



[web2py] Re: Read-only CRUD fields don't work?

2011-02-16 Thread Massimo Di Pierro
This should be fixed in trunk. Get the nightly build from the download
page.

On Feb 16, 1:58 am, Joe  Barnhart  wrote:
> I have a simple CRUD "create" form that's driving me crazy.  I want to
> pre-load one of the fields in the form.  I want the field to show up,
> but be read-only so the user can see it but not change it.
>
> I've tried setting the "default" property of the field and then making
> it "readable=True" and "writable=False".  The field always shows up as
> "None" in the form.  I also tried setting the form.var.fieldname=value
> after the form is created, but before it is rendered.  Still no joy.
>
> In any case, if I make the field "writable=True" I can see the field
> is properly set.  I can also change the field, however, which is what
> I'm trying to prevent.
>
> I am using the current version of web2py and going slowing
> insane... ;-)


  1   2   >