[web2py] Validators for webservices?

2011-03-20 Thread Marcel Luethi
Hi all

I'm looking for a way to validate the record data I receive from a
webservice.
Because there is no form associated it seems that I cannot use SQLFORM
and form.accepts().

Is there any other way to use the already defined validators to do the
check?

I'm searching for something like (untested):

@service.jsonrpc
def update(record):
errors = validate(db.mytable, record)
if errors:
return dict(success=False, msg=', '.join(errors))
else:
db(db.mytable.id == record.id).update(record)
return dict(success=True)


TIA - Marcel


[web2py] Re: Validators for webservices?

2011-03-20 Thread Marcel Luethi
Hi Massimo

After upgrading to 1.94.5 it works perfectly.
Thank you very much!

Is there anywhere some documentation regarding request.restful()
besides your video and the thread here on Google groups?
Great stuff!

Regards,
Marcel





On 20 Mrz., 15:20, Massimo Di Pierro 
wrote:
> This:
>
> @service.jsonrpc
> def update(record):
>     errors = validate(db.mytable, record)
>     if errors:
>         return dict(success=False, msg=', '.join(errors))
>     else:
>         db(db.mytable.id == record.id).update(record)
>         return dict(success=True)
>
> should be
>
> @request.restful()
> def update:
>     def PUT(id,**record):
>        errors = db.mytbale._validate(**record).values()
>        if errors:
>            return dict(success=False, msg=', '.join(errors))
>        else:
>            db(db.mytable.id == id).update(**record)
>            return dict(success=True)
>     return locals()
>
> and call it with a PUT method at URL:
>
> /.../?field=value
>
> Massimo
>
> On Mar 20, 3:56 am, Marcel Luethi  wrote:
>
>
>
>
>
>
>
> > Hi all
>
> > I'm looking for a way to validate the record data I receive from a
> > webservice.
> > Because there is no form associated it seems that I cannot use SQLFORM
> > and form.accepts().
>
> > Is there any other way to use the already defined validators to do the
> > check?
>
> > I'm searching for something like (untested):
>
> > @service.jsonrpc
> > def update(record):
> >     errors = validate(db.mytable, record)
> >     if errors:
> >         return dict(success=False, msg=', '.join(errors))
> >     else:
> >         db(db.mytable.id == record.id).update(record)
> >         return dict(success=True)
>
> > TIA - Marcel


[web2py] Re: Validators for webservices?

2011-03-20 Thread Marcel Luethi
Hi Kevin

Thanks for your input!
This is a valuable solution. But I would still need to add all my
already existing validators to SQLFORM.factory. Wouldn't I?
Therefore I tried Massimo's solution first.

Best regards,
Marcel





On 20 Mrz., 15:43, Kevin Ivarsen  wrote:
> Massimo's method may be better -- I haven't personally experimented with the
> restful stuff yet.
>
> But you can still use SQLFORM or SQLFORM.factory with form.accepts() to run
> the validators. You just don't display the form anywhere if you don't need
> to. You also need to pass formname=None to accepts(). Doing this,
> form.accepts() will run your values through the validators, transform them
> as needed, and populate form.errors based on the GET and POST variables
> provided by whatever is calling your web service.
>
> Here's a simple example I cobbled together that adds two numbers. Example
> use:http://localhost:8000/app/controller/add?val1=3.14&val2=2.718
>
> def add():
>     form = SQLFORM.factory(
>         Field('val1', 'double', requires=IS_FLOAT_IN_RANGE(0, 10)),
>         Field('val2', 'double', requires=IS_FLOAT_IN_RANGE(0, 10))
>     )
>
>     if form.accepts(request.vars, formname=None):
>         return form.vars.val1 + form.vars.val2
>
>     else:
>         errors = "Errors:\n"
>         for fieldname in form.errors:
>             errors += "%s: %s\n" % (fieldname, form.errors[fieldname])
>
>         raise HTTP(400, errors)
>
> Cheers,
> Kevin


[web2py] Re: odata

2011-04-01 Thread Marcel Luethi
Just skimmed over it. Looks very powerful and promising.
If it's easy to implement with parse_as_rest it would be a great
feature for web2py!

There are still not many "consumers" (http://www.odata.org/consumers),
but nevertheless it'd be worth IMHO.
(Unfortunately no Python client library seems to exist.)




On 31 Mrz., 05:47, Massimo Di Pierro 
wrote:
> what do you think about this?
>
> http://www.odata.org/developers/protocols/uri-conventions
>
> perhaps the new db.parse_as_rest(patterns,args,vars) should also
> support odata formats db.parse_as_rest('odata',args,vars) It would not
> take that much work. Is it valuable?


[web2py] Re: MongoDB and Web2Py

2011-04-01 Thread Marcel Luethi
Despite a lot of time, I'd like to help as well.
MongoDB looks promising.




On 1 Apr., 04:58, Massimo Di Pierro 
wrote:
> Lots of people asked for support but nobody volunteered to help test
> it.
> If you are interested and can help with some regular tests we can make
> it work in relatively short time.
>
> Massimo
>
> On Mar 31, 9:09 pm, luckysmack  wrote:
>
>
>
>
>
>
>
> > I have read a few older messages about mongoDB being made to work with
> > the DAL. But they all seem to be pretty dated and have not specified
> > what was working and what wasnt. massimo menitoned that it may be
> > ready by january of this year. But under the supported list it wasnt
> > listed. So im just curious as to what the status of using mongoDB is
> > with web2py and if anyone has a basic example on how I would use it.
> > Thanks


[web2py] "extra" arguments for Table and Field

2011-04-03 Thread Marcel Luethi
Hello.

I'm trying to implement common grid operations (with Ext JS,
GridPanel) for all tables in my app.
Now I would need some extra info on table and field levels as hints,
ex. default sort order of a table, column width of a field.

The easiest way would be to have a "extra" argument in gluon.dal.Table
and gluon.dal.Field in which I could store all the associated info.
Otherwise I have to store it in separate place, not directly related
to the tables & fields.

What do you think about this?
Good or not necessary?

Thanks for your feedback!

Regards,
Marcel




[web2py] Re: "extra" arguments for Table and Field

2011-04-03 Thread Marcel Luethi
Wow! Great!

And many thanks for the superfast reply!




On 3 Apr., 17:57, Massimo Di Pierro 
wrote:
> You can already do:
>
> db.table.field.extra = {}
>
> "extra" is not a keyword but you can attach attributes to a field
> object. You can do it with tables too but they must be preceded by and
> underscore to avoid naming conflicts with fields:
>
> db.table._extra = {}
>
> Massimo
>
> On Apr 3, 10:51 am, Marcel Luethi  wrote:
>
>
>
>
>
>
>
> > Hello.
>
> > I'm trying to implement common grid operations (with Ext JS,
> > GridPanel) for all tables in my app.
> > Now I would need some extra info on table and field levels as hints,
> > ex. default sort order of a table, column width of a field.
>
> > The easiest way would be to have a "extra" argument in gluon.dal.Table
> > and gluon.dal.Field in which I could store all the associated info.
> > Otherwise I have to store it in separate place, not directly related
> > to the tables & fields.
>
> > What do you think about this?
> > Good or not necessary?
>
> > Thanks for your feedback!
>
> > Regards,
> > Marcel


[web2py] Re: A requested feature...

2011-05-08 Thread Marcel Luethi
Not exactly a deployment solution - but TurnKey Linux (http://
www.turnkeylinux.org/) would be a good foundation for Amazon EC2.
There's already a "TKLPatch for web2py framework" (http://
www.turnkeylinux.org/forum/general/20110107/tklpatch-web2py-framework)
which Massimo created (http://www.turnkeylinux.org/forum/general/
20100217/web2py-appliance) but unfortunately there is still no web2py
virtual appliance in the library.

I didn't find the time to test TKL but this seems a great way to setup
and operate web2py servers in the cloud: https://hub.turnkeylinux.org/

Marcel



[web2py] Re: A requested feature...

2011-05-09 Thread Marcel Luethi
As far as I understand their "hub" is only a front-end to Amazon's
EC2: "Deploy in seconds 45+ free server apps to Amazon EC2".
And it's free as well. From their web site:

- Your TurnKey Hub account is free
- Pay Amazon directly for the cloud resources you use
- No setup, cancellation or monthly fees
- No risk, no commitments

You're right. LAMP/LAPP gives a fast start and with the "web2py build
notes" on 
http://www.turnkeylinux.org/forum/general/20110107/tklpatch-web2py-framework
installation should be easy.
I'll try it as well asap.




On 8 Mai, 18:52, pbreit  wrote:
> Could be interesting if they have made mostly good config decisions. The
> LAMP or LAPP stack gets you almost all the way there. Then only a few lines
> of script to install Web2py. I might give it a try but I'm not sure I want
> to use their hub or Amazon.


[web2py] Problem starting cron job

2011-05-24 Thread Marcel Luethi
Hi everybody!

I'm trying to start a cron job, which fails:

2011-05-24 10:40:00,517 - web2py.cron - WARNING - WEB2PY CRON Call
returned code 1:
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.95.1 (2011-04-25 15:04:14)
Database drivers available: SQLite3, pymysql, Oracle
Traceback (most recent call last):
  File "/opt/ecc/web2py/web2py.py", line 19, in 
gluon.widget.start(cron=True)
  File "/opt/ecc/web2py/gluon/widget.py", line 804, in start
import_models=options.import_models, startfile=options.run)
  File "/opt/ecc/web2py/gluon/shell.py", line 203, in run
execfile(startfile, _env)
IOError: [Errno 2] No such file or directory: 'applications/ecc/cron/
ecc_importer.py'


This is my contab entry:
0-59/5   ****eswsys *applications/ecc/
cron/ecc_importer.py


With a logger.warning call and os.getcwd() just before the execfile I
get:
2011-05-24 10:40:00,468 - web2py - WARNING - EXECFILE: applications/
ecc/cron/ecc_importer.py, working dir: /opt/ecc/web2py

The curent working directory seems to be ok and ecc_importer.py is in
the right place with 755 rights.

The job run fine on my Windows development machine but now doesn't
work when I moved it to our Linux server (Red Hat 5.2 (Tikanga) /
CentOS, 64bit).

Any ideas what I'm doing wrong?
Do I have to use PYTHONSTARTUP somehow?

TIA -.- Marcel


[web2py] Re: Problem starting cron job

2011-05-24 Thread Marcel Luethi
This is so embarrassing...!

Sorry for the last post - I found the problem:
I changed the name of the script slighly before the deployment to the
server.

Now it works perfectly. ;-)

Have a nice day.
Marcel



On 24 Mai, 10:52, Marcel Luethi  wrote:
> Hi everybody!
>
> I'm trying to start a cron job, which fails:
>
> 2011-05-24 10:40:00,517 - web2py.cron - WARNING - WEB2PY CRON Call
> returned code 1:
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2011
> Version 1.95.1 (2011-04-25 15:04:14)
> Database drivers available: SQLite3, pymysql, Oracle
> Traceback (most recent call last):
>   File "/opt/ecc/web2py/web2py.py", line 19, in 
>     gluon.widget.start(cron=True)
>   File "/opt/ecc/web2py/gluon/widget.py", line 804, in start
>     import_models=options.import_models, startfile=options.run)
>   File "/opt/ecc/web2py/gluon/shell.py", line 203, in run
>     execfile(startfile, _env)
> IOError: [Errno 2] No such file or directory: 'applications/ecc/cron/
> ecc_importer.py'
>
> This is my contab entry:
> 0-59/5   *        *        *        *        eswsys *applications/ecc/
> cron/ecc_importer.py
>
> With a logger.warning call and os.getcwd() just before the execfile I
> get:
> 2011-05-24 10:40:00,468 - web2py - WARNING - EXECFILE: applications/
> ecc/cron/ecc_importer.py, working dir: /opt/ecc/web2py
>
> The curent working directory seems to be ok and ecc_importer.py is in
> the right place with 755 rights.
>
> The job run fine on my Windows development machine but now doesn't
> work when I moved it to our Linux server (Red Hat 5.2 (Tikanga) /
> CentOS, 64bit).
>
> Any ideas what I'm doing wrong?
> Do I have to use PYTHONSTARTUP somehow?
>
> TIA -.- Marcel


[web2py] How do you document your apps?

2011-06-14 Thread Marcel Luethi
Hello!

I just finished an internal project using web2py (1.95.1) and have to
document it for my colleagues.
Preferably it is a system based of doc strings. Maybe Sphinx?

Question:
What are you using?
Do you have any suggestions?

Thanks in advance for your input!

Best regards,
Marcel



[web2py] Re: How do you document your apps?

2011-06-16 Thread Marcel Luethi
Hello everybody

Thank you very much for your answers!
I think I'll try a combination of plugin_wiki with epydoc.

Have a nice day!
Marcel

@Pierre: I'm using PyCharm instead of pydev - but thank you anyway!




On 15 Jun., 19:29, Pierre Thibault  wrote:
> I like epydoc. It is supported by pydev. It is simple. Sphinx is more both
> more powerful and more complex.
>
> I am sending my epydoc Eclipse external tool as an attachment. I think you
> just have to put the file somewhere in an open project to make it available
> as a external tool. To use it, click on your project and choose the command
> from the external tool menu available in the tool bar.
>
> 2011/6/15 Marcel Luethi 
>
>
>
>
>
>
>
>
>
> > Hello!
>
> > I just finished an internal project using web2py (1.95.1) and have to
> > document it for my colleagues.
> > Preferably it is a system based of doc strings. Maybe Sphinx?
>
> > Question:
> > What are you using?
> > Do you have any suggestions?
>
> > Thanks in advance for your input!
>
> > Best regards,
> > Marcel
>
> --
>
> A+
>
> -
> Pierre
> My blog and profile
> (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com>
> YouTube page 
> (http://www.youtube.com/user/tubetib)<http://www.youtube.com/user/tubetib>
> Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2>
>
>  Epydoc.launch
> 1KAnzeigenHerunterladen


[web2py] Re: Deployment Confusion

2011-08-08 Thread Marcel Luethi
Hi Gour

As a current customer of djangohosting.ch I'm interested to know how
you did the web2py setup.
Until now I'm only using it for static web sites, but plan to
implement a web2py site in the near future.

Thank you for your help.

Regards,
Marcel




On 7 Aug., 18:05, Gour-Gadadhara Dasa  wrote:
> On Sun, 30 Jan 2011 14:46:02 -0200
>
> Bruno Rocha  wrote:
> > AS I said,I know only two host options where you can simply put the
> > files there and everything runs without the need of configuration.
> > ['Google App Engine', 'webfaction']
>
> I use djangohosting.ch (djangoeurope.com) for PHP sites, but soon, I hope so,
> I'll move to web2py.
>
> Let me add that before that I was not able to use my own Cherokee webserver
> Under webfaction and can recommend djanghosting.ch which is very
> flexible...especially for users in Europe.
>
> Sincerely,
> Gour
>
> --
> “In the material world, conceptions of good and bad are
> all mental speculations…” (Sri Caitanya Mahaprabhu)
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1 KBAnzeigenHerunterladen