[web2py] Re: response.view does not work with @cache

2011-01-27 Thread selecta
very nice, thank you

On Jan 26, 6:19 pm, Massimo Di Pierro 
wrote:
> You can put this in a model:
>
> if application.function='option': response.view='default.html'
>
> On Jan 26, 9:41 am, selecta  wrote:
>
>
>
> > this will not work since the inforamtion that a different view should
> > be userd is not chached
> > @cache(request.env.path_info, time_expire=360, cache_model=cache.ram)
> > def option():
> >     items = []
> >     items.append( ITEM_SLINK('&Books', URL(r=request, f='index'),
> > 'back') )
> >     ...
> >     response.view='default.html'
> >     return dict( content = TAG[''](items) )
>
> > i am not sure if there is/will be a solution to this problem, but i
> > wanted to let you know that this problem exists
>
> > ... but if there is a solution, please let me know


[web2py] Re: PDF Reports with Pisa

2011-01-27 Thread mart
This is nice stuff!

On Jan 26, 9:56 pm, "Lucas D'Avila"  wrote:
> Hi!
>
> I added support for Pisa [1] on appreport plugin [2], appreport now has two
> engines to generate PDF documents: the pyfpdf and Pisa.
>
> Simply import the appreport plugin in web2py and use, no need to install
> other dependent packages.
>
> --
>
> Download and documentation, visit the wiki [3], i also added in the wiki, a
> new example about how to generate complex reports, rendering the web2py
> views (taking advantage of the ease embedding python code in views).
>
> [1]http://www.xhtml2pdf.com/
> [2]https://github.com/lucasdavila/plugin-appreport
> [3]https://github.com/lucasdavila/plugin-appreport/wiki
>
> Hug!
>
> --
> Lucas D'Avilahttp://flavors.me/lucasdavila


[web2py] Test controller again

2011-01-27 Thread walter
Excuse me. May be I'm stupid, but I don't understand how to test next
case. I want to test that a response.status really has 303.

Bit of my code:

def show():
if request.args(0) == None:
redirect(URL('index'))

How should I write a doctest for this?


[web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-01-27 Thread cjrh
On Jan 27, 4:09 am, Rupesh Pradhan  wrote:
> I have made enough of mistakes in learing how to code and analyse software
> coding properly and now my application are basically a bloatware and
> increasing in complexity year after year.

Good!  That application is probably your greatest source of learning.

> I am trying to standardize the way I code, the way i name my variables,
> table, fields etc. Basically, i need help in standardizing my programming
> techniques. PLEASE FEEL FREE TO COMMENT ON ANY OR ALL OF MY CODING.

Very good to ask for critique: that's a great sign of maturity.
However, naming of things, or indent level, or capitalization have
very little to with good coding.  They are simply good manners.

I read this somewhere once:

- A novice understands the difference between data and code.

- An expert understands that all code is data.

- A master understands that all data is code.

(If you find that last one difficult to understand, here is a hint:

"I will, in fact, claim that the difference between a bad programmer
and a good one is whether he considers his code or his data structures
more important. Bad programmers worry about the code. Good programmers
worry about data structures and their relationships."--Torvalds, Linus
(2006-06-27). Message to Git mailing list. )


[web2py] Re: Change in URL args handling

2011-01-27 Thread cjrh
On Jan 27, 7:04 am, Jonathan Lundell  wrote:
> This applies to both the old and new URL rewrite paths, regardless of whether 
> there's any rewriting going on.

I had another fight with the old routes.py yesterday.   Is there any
kind of timeline on the new router making it into stable? :))


[web2py] Modify calendar.js

2011-01-27 Thread luifran
I would like to change the calendar.js date format, I want the format
d / m / y   instead ofy / m / d
¿It´s possible?


[web2py] Re: can web2py support RESTful api calls? if so any pointers on how to build one?I

2011-01-27 Thread superavit
awesome thanks for the pointer!

On Jan 26, 7:50 pm, pbreit  wrote:
> It should be possible. After all, REST is usually just making GETs and POSTs
> to URLs/URIs. Web2py has some features to help out. Take a look at the
> chapter on Services:http://web2py.com/book/default/chapter/09
>
> RESTful systems are typically expecting XML or JSON data formats which are
> both supported conveniently.


[web2py] AJAX in Web2py -> Synchronous

2011-01-27 Thread Phoboss
Hi Experts,

how can I turn off asynchron AJAX in web2py?
It sounds strange but I need it synchronous!

BTW, I implemented this example:
http://www.web2py.com/book/default/chapter/10#Ajax-Form-Submission

Thank you so much!

Best Regards

Phoboss


[web2py] web2py hosting on google app engine and pointing to my own domain

2011-01-27 Thread superavit
Can anybody suggest how to host a web2py app? I know that google app
engine is an option, but if I use that can I make it show as my own
domain? Any other hosting options better?

I appreciate the help

Jason


[web2py] Re: Another instance of No such file or directory: '/opt/web-apps/web2py/applications/admin/..

2011-01-27 Thread Ed Greenberg
Hi Massimo,

I posted an issue on Google code for checking the return value of
app_create. That is only a side-issue for me, since the real real
question is why app_create is failing.

After much poking around, I discovered that I was missing the file
welcome.w2p from the web2py directory. This caused w2p_unpack() to
fail silently (it doesn't return anything anyway) which caused
failures up the chain.

I'd like to open a googlecode issue for this also, but I don't know
where I was supposed to get welcome.w2p in the first place. It's not
in the zip file we started from, so why does my original desktop
version of web2py have it?  Once I know how I was supposed to get it,
I'll determine if it was my error, or file a cogent bug report as to
why it was not created.

Thanks,
Ed

On Jan 26, 9:01 am, Massimo Di Pierro 
wrote:
> My todo list is getting long today. Can you please open a googlecode
> issue?
>
> On Jan 25, 9:28 pm, Ed Greenberg  wrote:
>
> > I have a new centos installation. I followed the script 
> > athttp://web2pyslices.com/main/slices/take_slice/98. When I use the new
> > application wizard,  I get the same traceback that others have
> > posted:
>
> > Traceback (most recent call last):
> >   File "/opt/web-apps/web2py/gluon/restricted.py", line 188, in
> > restricted
> >     exec ccode in environment
> >   File "/opt/web-apps/web2py/applications/admin/controllers/
> > wizard.py", line 572, in 
> >   File "/opt/web-apps/web2py/gluon/globals.py", line 95, in 
> >     self._caller = lambda f: f()
> >   File "/opt/web-apps/web2py/applications/admin/controllers/
> > wizard.py", line 200, in step6
> >     create(form.vars)
> >   File "/opt/web-apps/web2py/applications/admin/controllers/
> > wizard.py", line 489, in create
> >     file=open(meta,'wb')
> > IOError: [Errno 2] No such file or directory: '/opt/web-apps/web2py/
> > applications/admin/../xxx/wizard.metadata'
>
> > When I use the "New Simple Application" part of the admin page, all I
> > get is a "Flash" that says, "unable to create application "
>
> > I've poked around in the code, and I believe that the problem takes
> > place a few lines BEFORE the offending line 489, as follows:
>
> > On line 485, we find
> > "app_create(app,request,force=True,key=params['security_key'])"
>
> > App_create, which is defined in gluon/admin.py, needs to create the
> > directory in applications to hold the app. This function returns True
> > or False, but line 485 does not check the return value.
>
> > My first thought was that the os.mkpath in app_create was failing. I
> > still believe this, since the directory is not being created.
>
> > I checked the permissions. The applications directory is owned by
> > 'apache'.  The web server is running as apache. Even WSGI is set to
> > run as apache. So how can os.mkdir(path) fail?
>
> > No errors are generated in the web server's error log for this, and
> > the only clue I have is the traceback when using the wizard.
>
> > Any help appreciated.
>
>


[web2py] how to user the html helper?

2011-01-27 Thread web2pyer
I tried the below what is given in the official documentation
>>> a = DIV(SPAN('a', 'b'), 'c')
>>> print a
abc
>>> del a[1]
>>> a.append(B('x'))
>>> a[0][0] = 'y'
>>> print a
ybx

I typed
>>>a = DIV(SPAN('a', 'b'), 'c')
>>>print a
abc
but when I typed
 >>> del a[1]
>>> a.append(B('x'))
>>> a[0][0] = 'y'
>>> print a
abc
It returned abc,nothing changed?
I got confused.
What is the reason?
TKS!


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam

If this isn't something anyone else has encountered, can anyone clue
me in as to how to start digging into this?

I'm not sure whether to start with my own set-up (Windows, Version
1.91.6), or dive into the web2py source, which I've not had reason to
do before...


[web2py] creating html for the user to save or copy/paste

2011-01-27 Thread Ed Greenberg
I have a controller function that we can call "next()" since that's
what it is called :)

I have created a block of html in that function, contained in a
string.

I'd like to return it to the user so he can reuse it (not just view it
in the browser.)

Sending it to the browser causes the various special characters of
html to be converted to entities (like ampersand-gt-semicolon.)

I think what I need to do is return it as type text/plain or as type
application/octet-stream.

How do I construct the dict that I am going to return in the
controller function so that web2py will know what to send to the user?

Thanks,

Ed G


Re: [web2py] Re: URL formation in CRUD

2011-01-27 Thread web2py noob
ref: http://web2py.com/book/default/chapter/07#CRUD

crud.settings.controller = 'crm'


2011/1/27 Running Clam :
>
> If this isn't something anyone else has encountered, can anyone clue
> me in as to how to start digging into this?
>
> I'm not sure whether to start with my own set-up (Windows, Version
> 1.91.6), or dive into the web2py source, which I've not had reason to
> do before...
>


Re: [web2py] creating html for the user to save or copy/paste

2011-01-27 Thread Bruno Rocha
Try XML with escape set to True/False

{{=XML(htmlobject, escape=True|False)}}


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


2011/1/27 Ed Greenberg 

> I have a controller function that we can call "next()" since that's
> what it is called :)
>
> I have created a block of html in that function, contained in a
> string.
>
> I'd like to return it to the user so he can reuse it (not just view it
> in the browser.)
>
> Sending it to the browser causes the various special characters of
> html to be converted to entities (like ampersand-gt-semicolon.)
>
> I think what I need to do is return it as type text/plain or as type
> application/octet-stream.
>
> How do I construct the dict that I am going to return in the
> controller function so that web2py will know what to send to the user?
>
> Thanks,
>
> Ed G


Re: [web2py] Re: Represent not working in details on Powertable

2011-01-27 Thread web2py noob
good job jclevy. i hope the fix for this could reach stable version soon.

2011/1/26 jclevy :
> Bruno Rocha  writes:
>
>>
>>
>> 2011/1/21 web2py noob 
>>
>>
>>
>> bruno, what you say above is wrong. the workaround is:
>>
>> db.define_table('tablename',
>>     Field('fieldname',db.othertable, represent=lambda
> f:db.othertable[f].fieldname))
>>
>> best regards.
>
> I found that on of last changesets changed the sqlhtml.py file at lite 1337,
> introducing :
>
>                elif field.type.startswith('reference'):
>                    pass
>
> prevents the SQLTABLE to take care of the 'represent' clause (see
> http://code.google.com/p/web2py/issues/detail?id=141#makechanges).
>
>


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam
Hi,

On Jan 27, 1:56 pm, web2py noob  wrote:
> ref:http://web2py.com/book/default/chapter/07#CRUD
>
> crud.settings.controller = 'crm'
>

D'Oh!

Will retest and report back as to how I got on.


--

Clam


[web2py] IS_IN_SET texts

2011-01-27 Thread Kenneth Lundström
I have a field priority = integer, can be anything between 1-5 (or 6 in 
Python way)


but I´d like to make a dropdown with options, '1, Fixed yesterday', '2, 
to be fixed today', '3, fixed before release' and so on. Is this 
possible with IS_IN_SET or do I have to make my own form?


When viewing the data a number is enough, it´s only when making the 
priority that the text is needed.



Kenneth



[web2py] Re: how to user the html helper?

2011-01-27 Thread DenesL
The original works for me.
Do a 'print a' after each command and see how it changes.


On Jan 27, 1:55 am, web2pyer  wrote:
> I tried the below what is given in the official documentation>>> a = 
> DIV(SPAN('a', 'b'), 'c')
> >>> print a
>
> abc>>> del a[1]
> >>> a.append(B('x'))
> >>> a[0][0] = 'y'
> >>> print a
>
> ybx
>
> I typed>>>a = DIV(SPAN('a', 'b'), 'c')
> >>>print a
>
> abc
> but when I typed
>  >>> del a[1]>>> a.append(B('x'))
> >>> a[0][0] = 'y'
> >>> print a
>
> abc
> It returned abc,nothing changed?
> I got confused.
> What is the reason?
> TKS!


[web2py] Re: AJAX in Web2py -> Synchronous

2011-01-27 Thread DenesL
Hi Phoboss,

web2py uses the jQuery.ajax API which has a parameter named async for
that.

Try changing your app's web2py_ajax.html file where the jQuery.ajax
calls are made and specify async : false .

Denes

On Jan 27, 3:53 am, Phoboss  wrote:
> Hi Experts,
>
> how can I turn off asynchron AJAX in web2py?
> It sounds strange but I need it synchronous!
>
> BTW, I implemented this 
> example:http://www.web2py.com/book/default/chapter/10#Ajax-Form-Submission
>
> Thank you so much!
>
> Best Regards
>
> Phoboss


[web2py] Can't generate index.yaml

2011-01-27 Thread devGS
Hello,
I'm can't make my GAE Launcher to generate the indexes file. I tried
to clean the datastore locally, tried to play with  models/0.py file,
to place my own index.yaml in web2py folder with "# AUTOGENERATED",
but so far nothing have worked. I use Janrain for logging in, and the
only table at db.py is 'auth_user', please help.
Thanks.


[web2py] Re: AJAX in Web2py -> Synchronous

2011-01-27 Thread Phoboss
Hi Denes,

firstly thank you for your swift response!

I'm now at work. So in 4 hours or so I'll try it at home.
After that I'll report here if it's works.

Best Regards

Phoboss

On 27 Jan., 15:49, DenesL  wrote:
> Hi Phoboss,
>
> web2py uses the jQuery.ajax API which has a parameter named async for
> that.
>
> Try changing your app's web2py_ajax.html file where the jQuery.ajax
> calls are made and specify async : false .
>
> Denes
>
> On Jan 27, 3:53 am, Phoboss  wrote:
>
>
>
>
>
>
>
> > Hi Experts,
>
> > how can I turn off asynchron AJAX in web2py?
> > It sounds strange but I need it synchronous!
>
> > BTW, I implemented this 
> > example:http://www.web2py.com/book/default/chapter/10#Ajax-Form-Submission
>
> > Thank you so much!
>
> > Best Regards
>
> > Phoboss


[web2py] Re: web2py hosting on google app engine and pointing to my own domain

2011-01-27 Thread Anthony
Here's my answer from Stackoverflow:
http://stackoverflow.com/questions/4810295/web2py-hosting-on-google-app-engine-and-pointing-to-my-own-domain/4813410#4813410
 
Welcome to the list.
 
Anthony

On Wednesday, January 26, 2011 9:27:17 PM UTC-5, superavit wrote:

> Can anybody suggest how to host a web2py app? I know that google app 
> engine is an option, but if I use that can I make it show as my own 
> domain? Any other hosting options better? 
>
> I appreciate the help 
>
> Jason



Re: [web2py] Re: Change in URL args handling

2011-01-27 Thread Jonathan Lundell
On Jan 27, 2011, at 6:16 AM, cjrh wrote:
> 
> On Jan 27, 7:04 am, Jonathan Lundell  wrote:
>> This applies to both the old and new URL rewrite paths, regardless of 
>> whether there's any rewriting going on.
> 
> I had another fight with the old routes.py yesterday.   Is there any
> kind of timeline on the new router making it into stable? :))

It should be in the next stable release. I'm not sure when that will be; 1.91.6 
was January 3. I'm guessing that there are enough changes that Massimo will 
bump it to 1.92.

Please make sure that the new URL router in the trunk is working for you, 
though, so any problems get resolved ASAP.

[web2py] Re: web2py Turnkey Linux Appliance (collaborator needed)

2011-01-27 Thread ghoulmann
I've gotten feedback from one person, but could use some more. If
anyone has a chance, please check out the ISO (preferably) or virtual
appliances derived from the TKLpatch; they're available at http://9while9.com.
I appreciate the time you may commit to testing this.

Much appreciated,
Rik Goldman

On Jan 7, 1:57 am, ghoulmann  wrote:
> I completed and submitted the patch to create a web2py/postgres/apache
> appliance fromTurnKeyLinux'sLAPP 11.0 (Lucid). The post the the
> general forum at TKL, with the patch attached, is 
> athttp://www.turnkeylinux.org/forum/general/20110107/tklpatch-web2py-fr
> Athttp://9while9.com, I've posted the patch, virtual machines, and an
> ISO derived from the patch. I used the last two or three lines of the
> script for configuring ubuntu for an inithook to run at first boot so
> the user can set the web2py admin password. I also used the "default"
> apache configuration file for the patch.
>
> Feedback, suggestions, concerns, are all encouraged. I'm eager for
> feedback so I know whether to revise the patch. I posted it to TKL
> before Massimo could offer feedback because I'm eager for it to be
> released with the second part of TKL's 11.0 library. I was eager to
> make sure web2py was given due consideration. Nevertheless, the patch
> can still be revised.
>
> On Dec 31 2010, 8:57 am, ghoulmann  wrote:
>
> > Thanks Chris,
> > I've got the patch worked out for the most part. (incidentally to
> > patching eden). Just incorporating Massimo's suggestions and
> > blueprint, then getting together the first run script to set the
> > password are my remaining concerns.
>
> > On Dec 31, 1:47 am, Christopher Steel  wrote:
>
> > > Hi Rik,
>
> > >Turnkeylooks interesting...
>
> > > You can get a working Web2py /Turnkeysystem up and running fairly
> > > quickly using the "vanilla"Turnkeyinstallation and then running a
> > > slightly modified version of the "setup-we2py-ubuntu.sh script on the
> > > same system. This will allow you to break down the task into pieces
> > > and you can slowly "convert" the bash script to Python rather than
> > > taking on the entire task in one fell swoop in addition to getting a
> > > "working system" along the way.
>
> > > setup-we2py-ubuntu.sh could be modified or run manually in some places
> > > where sudo is used.
> > > So for example near the end of the script instead of:
>
> > > sudo -u www-data python -c "from gluon.widget import console;
> > > console();"
> > > and
> > > sudo -u www-data python -c "from gluon.main import save_password;
> > > save_password(raw_input('admin password: '),443)"u
>
> > > you could "become" the www-data user with
> > > su www-data
> > > change to /home/www-data/web2py
> > > and then run the commands:
>
> > > python -c "from gluon.widget import console; console();"
>
> > > and
>
> > > python -c "from gluon.main import save_password;
> > > save_password(raw_input('admin password: '),443)"
> > > echo "done!"
>
> > > In the mean time I am going to try it myself... looks like fun.
>
> > > Cheers,
>
> > > Chris
>
> > > On Dec 30, 10:36 am,ghoulmann wrote:
>
> > > > However, I don't know Python well enough produce the script. I also
> > > > don't know where web2py wants passwords kept or whether there's
> > > > hashing involved. So given example scripts for other appliances, is
> > > > there anyone willing to collaborate - either write the script for
> > > > incorporation, or if it has to be the case, mentor me so I can produce
> > > > the script with my students?
>
> > > > This blog post and the subsequent thread explains and provides
> > > > examples:http://www.turnkeylinux.org/blog/end-to-default-passwords
>
> > > > I look forward to working together on this contribution to web2py and
> > > >TurnKeyLinux.
>
> > > > Rik Goldman


Re: [web2py] Change in URL args handling

2011-01-27 Thread Jason Brower

I wonder if there is an example where this could be an advantage for us?
BR,
Jason

On Wed, 26 Jan 2011, Jonathan Lundell wrote:


This applies to both the old and new URL rewrite paths, regardless of whether 
there's any rewriting going on.

Previously, a trailing slash after args would cause an extra arg to be added to 
the list with a value of '' (empty string). In the old logic, an embedded empty 
arg was illegal.

That is:

/a/c/f/arg1

gave args as ['arg1']

/a/c/f/arg1/

gave args as ['arg1', '']

/a/c/f/arg1//arg2

was illegal.

Now, trailing slashes are stripped, so the first two examples about give 
['arg1'], as does /a/c/f/arg1/

Also, embedded empty args are legal, so the arg2 example above yields ['', 
'arg2']




[web2py] Re: We should have this plugin...

2011-01-27 Thread Massimo Di Pierro
This is doable...

On Jan 27, 1:19 am, Jason Brower  wrote:
> How many plugin...
> It would, every once in a while, at triggers etc.. tweet some session
> variable.
> The reason I say this is I think it would be cool to see tweets of how
> many downloads a day we get from web2py.com and how many where the
> plugin wiki.  Etc...
> It could be useful for other things too obviously. :D
> BR,
> Jason


[web2py] Re: web2py launcher for Debian package

2011-01-27 Thread Massimo Di Pierro
The message is still there for me.

On Jan 27, 1:24 am, José L.  wrote:
> This message has disappeared from the web2py google groups site . I don't
> know why.
> So, I'm bumping it
>
>
>
>
>
>
>
> On Wednesday, January 26, 2011 8:33:37 PM UTC+1, José L. wrote:
>
> > Hello, in order to do the packaging of web2py, I've done these things:
> > - moved gluon to be a standard library of the system, integrated in the
> > PYTHONPATH
> > - moved :
> > applications  deposit  logs  site-packages  VERSION  web2py.py  welcome.w2p
> > to /usr/share/web2py
> > -add created a web2py launcher at /usr/bin/
>
> > this web2py launcher is available athttp://paste.debian.net/105739/
>
> > I've tried to keep:
> > - the normal behaviour of web2py,
> > - fulfill the FHS
> > - respect the user changes in his permissions land
> > - when a new version of the web2py package is installed the admin and
> > welcome application are upgraded to the user (gluon and all the stuff at
> > /usr/share/web2py are upgraded), but the upgrading doesn't disturb other
> > applications the user has created in his userland, or the admin
> > configurations the user has done.
>
> > I'd like to know your opinion about these steps, specially if the web2py
> > launcher is clean or it can raise any problem in the future.
>
> > Also, when launcher starts from the Desktop menu, it should ask always for
> > the port and password admin, and then launch the web browser. As
> > gluon.widget.start(cron=True)
> > begins the server loop, I'd like to know any idea about how to launch an
> > external process (the web browser), after it has started.
>
> > Regards.
> > José L.


[web2py] Re: Test controller again

2011-01-27 Thread Massimo Di Pierro
def show():
"""
>>> request.args.clear()
>>> try: print show()
>>> except HTTP, http: print 'ok'
ok
"""
    if request.args(0) == None:
        redirect(URL('index'))

On Jan 27, 4:08 am, walter  wrote:
> Excuse me. May be I'm stupid, but I don't understand how to test next
> case. I want to test that a response.status really has 303.
>
> Bit of my code:
>
> def show():
>     if request.args(0) == None:
>         redirect(URL('index'))
>
> How should I write a doctest for this?


[web2py] Re: Change in URL args handling

2011-01-27 Thread Massimo Di Pierro
Correct. I am trying to close the majority of open issues are release
1.92 next week.

On Jan 27, 9:21 am, Jonathan Lundell  wrote:
> On Jan 27, 2011, at 6:16 AM, cjrh wrote:
>
>
>
> > On Jan 27, 7:04 am, Jonathan Lundell  wrote:
> >> This applies to both the old and new URL rewrite paths, regardless of 
> >> whether there's any rewriting going on.
>
> > I had another fight with the old routes.py yesterday.   Is there any
> > kind of timeline on the new router making it into stable? :))
>
> It should be in the next stable release. I'm not sure when that will be; 
> 1.91.6 was January 3. I'm guessing that there are enough changes that Massimo 
> will bump it to 1.92.
>
> Please make sure that the new URL router in the trunk is working for you, 
> though, so any problems get resolved ASAP.


Re: [web2py] Change in URL args handling

2011-01-27 Thread Jonathan Lundell
On Jan 27, 2011, at 9:25 AM, Jason Brower wrote:
> 
> I wonder if there is an example where this could be an advantage for us?

The change was driven by a report that /a/c/f/arg and /a/c/f/arg/ generated 
different request.args lists, when we ordinarily expect a trailing slash to be 
ignored.

The primary motivation was to have *some* definite spec for how empty args 
should be handled, and the resolution was the spec below: strip trailing 
slashes, but otherwise permit empty args items. It's not the only possible 
resolution, but it seems reasonable.

If an application is counting on trailing empty args (by 'empty arg' I mean an 
arg with a value of an empty string, ''), it will have to interpret missing 
args at the end of the list as empty. In the past, empty args were treated as 
errors, except for the case of a single trailing slash.



> BR,
> Jason
> 
> On Wed, 26 Jan 2011, Jonathan Lundell wrote:
> 
>> This applies to both the old and new URL rewrite paths, regardless of 
>> whether there's any rewriting going on.
>> 
>> Previously, a trailing slash after args would cause an extra arg to be added 
>> to the list with a value of '' (empty string). In the old logic, an embedded 
>> empty arg was illegal.
>> 
>> That is:
>> 
>> /a/c/f/arg1
>> 
>> gave args as ['arg1']
>> 
>> /a/c/f/arg1/
>> 
>> gave args as ['arg1', '']
>> 
>> /a/c/f/arg1//arg2
>> 
>> was illegal.
>> 
>> Now, trailing slashes are stripped, so the first two examples about give 
>> ['arg1'], as does /a/c/f/arg1/
>> 
>> Also, embedded empty args are legal, so the arg2 example above yields ['', 
>> 'arg2']
>> 
>> 




[web2py] Re: Callable as Field.default

2011-01-27 Thread Bernd Rothert
Sorry, I just saw that you had to revert the change, most probably
because it makes test_dal.py fail. Row and Reference are callable() as
well! This patch passes the tests but unfortunately doesn't make
represent() look any nicer.


diff -r 7c6da73479e7 gluon/dal.py
--- a/gluon/dal.py  Wed Jan 26 22:48:10 2011 -0600
+++ b/gluon/dal.py  Thu Jan 27 15:54:20 2011 +0100
@@ -1070,7 +1070,7 @@
 return self.log_execute(*a, **b)

 def represent(self, obj, fieldtype):
-if isinstance(obj,(types.LambdaType,types.FunctionType)):
+if callable(obj) and not isinstance(obj, (Row, Reference)):
 obj = obj()
 if isinstance(fieldtype, SQLCustomType):
 return fieldtype.encoder(obj)
@@ -2307,7 +2307,7 @@
 class NoSQLAdapter(BaseAdapter):

 def represent(self, obj, fieldtype):
-if isinstance(obj,(types.LambdaType,types.FunctionType)):
+if callable(obj) and not isinstance(obj, (Row, Reference)):
 obj = obj()
 if isinstance(fieldtype, SQLCustomType):
 return fieldtype.encoder(obj)


I didn't look deep into this but maybe it would help a lot to subclass
Field (StringField, IntegerField, BooleanField, ReferenceField,...).
It could well remove the if cascades from represent(), parse() - seems
like these are the "hot spots". Of course this is not an easy thing to
do and as I understand dal has just been redesigned.


Cheers,
Bernd

On 26 Jan., 01:36, Bernd Rothert  wrote:
> A table definition from the DAL chapter of the Web2py book:
>
> db.define_table('person',
>     Field('uuid', length=64, default=uuid.uuid4()),
>     Field('modified_on', 'datetime', default=now),
>     Field('name'),
>     format='%(name)s')
>
> "now" usually contains the current datetime from request.now and
> that's fine but the default for "uuid" would be identical for all
> inserts. Although the example doesn't use the default so it is not a
> problem there.
>
> If you omit the parenthesis behind "default=uuid.uuid4()" and simple
> pass the uuid4 function as the default it works as expected - the
> default is evaluated at insert time and yields a fresh uuid for each
> new record. I assume this is the intended behaviour although I
> couldn't find it documented(!?).
>
> Strangely replacing "default=now" in the same way with e.g.
> "default=datetime.datetime.now" does not work:
>
> now=datetime.datetime.now
> db.define_table('person',
>     Field('uuid', length=64, default=uuid.uuid4),
>     Field('modified_on', 'datetime', default=now),
>     Field('name'),
>     format='%(name)s')
>
> db.person.insert(name='Ernie')
> db.person.insert(name='Bert')
>
> db(db.person).select()
>
> >>> ValueError: invalid literal for int() with base 10: '
> Umm,...
>
> db.executesql(db(db.person)._select())>>> [(1,
>
>   u'b35cc052-3800-42a9-b7eb-bb9bc8ada271',
>   u'',
>   u'Ernie'),
>  (2,
>   u'003ab438-f3aa-4474-8c24-b07d85406930',
>   u'',
>   u'Bert')]
>
> (only works with Sqlite - MySQL would throw an error earlier)
>
> I think this check in BaseAdapter.represent (dal.py) is the culprit:
>
>     def represent(self, obj, fieldtype):
>         if type(obj) in (types.LambdaType, types.FunctionType):
>             obj = obj()
>
> print type(datetime.datetime.now) in (types.LambdaType,
> types.FunctionType)
>
> >>> False
>
> This version lets you use any callable for generating "dynamic"
> default values (plus it's 3-4 times faster):
>
>     def represent(self, obj, fieldtype):
>         if callable(obj):
>             obj = obj()
>
> I hope this doesn't cause any side effects - at least I could not find
> any (at this late/early hour)...
>
> Thanks


Re: [web2py] Re: Adding fields to the default register form;

2011-01-27 Thread Vinicius Assef
On Thu, Jan 27, 2011 at 3:27 AM, Bruno Rocha  wrote:
> Thinking a bit more, taking the Vinicius comment and some examples of
> another O.O frameworks.
> I was wondering about...
> #2
> auth.settings.formstyle = 'divs'
> form = auth()
> print form #  return the HTML with divs

OK, but formstyle isn't related to auth in anyway, but it is to form, right?
If auth wouldn't be showed (rendered) as a form, this property never
needed to be used.

> #3
> form = auth()
> print form # should return the HTML with tables

Yes, the default behaviour. :-)
Let's go on.

> ...
> form.formstyle = 'divs' # sets the self.formstyle to 'divs'
> and immediately raises a redraw method
> #alternatively call explicitly the form.redraw() method
> print form # should now return HTML with 'divs'
>
> I think Vinicius are talking about the case #3, which I think it is possible
> to implement, but I don't know the caveats,

Yes Bruno. You catched my mind.

Actually, formstyle='divs' is a SQLFORM form property. It is the way
print will show the generated HTML for this form instance.

So, conceptually it is a form property.

Your 3rd example show an intuitive method do implement this feature.

I didn't have time to see the source code yet (I plan to do this
tonight), but I see no reason to generate HTML code before the print
call.

--
Vinicius Assef.


Re: [web2py] Callable as Field.default

2011-01-27 Thread Ole Martin Maeland
instead of default=now use default = request.now

also change default = now in modified_on to update=request.now

regards
Martin

On Wed, Jan 26, 2011 at 1:36 AM, Bernd Rothert wrote:

> A table definition from the DAL chapter of the Web2py book:
>
> db.define_table('person',
>Field('uuid', length=64, default=uuid.uuid4()),
>Field('modified_on', 'datetime', default=now),
>Field('name'),
>format='%(name)s')
>
> "now" usually contains the current datetime from request.now and
> that's fine but the default for "uuid" would be identical for all
> inserts. Although the example doesn't use the default so it is not a
> problem there.
>
> If you omit the parenthesis behind "default=uuid.uuid4()" and simple
> pass the uuid4 function as the default it works as expected - the
> default is evaluated at insert time and yields a fresh uuid for each
> new record. I assume this is the intended behaviour although I
> couldn't find it documented(!?).
>
> Strangely replacing "default=now" in the same way with e.g.
> "default=datetime.datetime.now" does not work:
>
> now=datetime.datetime.now
> db.define_table('person',
>Field('uuid', length=64, default=uuid.uuid4),
>Field('modified_on', 'datetime', default=now),
>Field('name'),
>format='%(name)s')
>
> db.person.insert(name='Ernie')
> db.person.insert(name='Bert')
>
>
> db(db.person).select()
> >>> ValueError: invalid literal for int() with base 10: '
> Umm,...
>
> db.executesql(db(db.person)._select())
> >>> [(1,
>  u'b35cc052-3800-42a9-b7eb-bb9bc8ada271',
>  u'',
>  u'Ernie'),
>  (2,
>  u'003ab438-f3aa-4474-8c24-b07d85406930',
>  u'',
>  u'Bert')]
>
> (only works with Sqlite - MySQL would throw an error earlier)
>
>
> I think this check in BaseAdapter.represent (dal.py) is the culprit:
>
>def represent(self, obj, fieldtype):
>if type(obj) in (types.LambdaType, types.FunctionType):
>obj = obj()
>
>
> print type(datetime.datetime.now) in (types.LambdaType,
> types.FunctionType)
> >>> False
>
>
> This version lets you use any callable for generating "dynamic"
> default values (plus it's 3-4 times faster):
>
>def represent(self, obj, fieldtype):
>if callable(obj):
>obj = obj()
>
>
> I hope this doesn't cause any side effects - at least I could not find
> any (at this late/early hour)...
>
> Thanks
>



-- 
Hilsen
Ole Martin
Mob: 95227471


[web2py] Re: Can't generate index.yaml

2011-01-27 Thread Michael McGinnis
I had a similar experience. My app ran fine on web2py and on the GAE
SDK, but when I deployed it, the indexes (which surely were created
while running it on the SDK), never arrived.

On Jan 27, 8:49 am, devGS  wrote:
> Hello,
> I'm can't make my GAE Launcher to generate the indexes file. I tried
> to clean the datastore locally, tried to play with  models/0.py file,
> to place my own index.yaml in web2py folder with "# AUTOGENERATED",
> but so far nothing have worked. I use Janrain for logging in, and the
> only table at db.py is 'auth_user', please help.
> Thanks.


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam
Hi,

OK, specifying the controller as follows: -

crud.settings.controller = 'crm'

...as suggested by web2py.n00b resolves the controller name issue, and
I feel suitably foolish for having overlooked it.

However, the omission of the "data" function name still happens when I
drill down to a record: -

- at [app]/crm/data/tables I see my list of tables, and can drill down
to one, e.g. "client".

- at [app]/crm/data/select/client I see my list of clients, but in the
link behind the ID it omits the function name "data", and so takes me
to [app]/crm/read/client/1 which throws rightly throws "invalid
function (crm/read)", instead of the correct URL of "[app]/crm/data/
read/client/1".

What am I missing?

--

Clam


[web2py] Re: Can't generate index.yaml

2011-01-27 Thread devGS
So, is there any way to fix that today? Unlike what you'd mentioned,
my indexes are not created at all.

On Jan 27, 6:11 pm, Michael McGinnis  wrote:
> I had a similar experience. My app ran fine on web2py and on the GAE
> SDK, but when I deployed it, the indexes (which surely were created
> while running it on the SDK), never arrived.
>
> On Jan 27, 8:49 am, devGS  wrote:
>
>
>
>
>
>
>
> > Hello,
> > I'm can't make my GAE Launcher to generate the indexes file. I tried
> > to clean the datastore locally, tried to play with  models/0.py file,
> > to place my own index.yaml in web2py folder with "# AUTOGENERATED",
> > but so far nothing have worked. I use Janrain for logging in, and the
> > only table at db.py is 'auth_user', please help.
> > Thanks.


Re: [web2py] Extend Field Type "upload" to a CDN

2011-01-27 Thread Bruno Rocha
I am in the way of doing that to work with DropBox API.


2011/1/27 Art Zemon 

>  Has anyone extended or overloaded the Field type "upload" to work with a
> CDN such as Rackspace Cloud Files or Amazon S3 instead of a local
> filesystem?
>
> Thanks,
> -- Art Z.
>
> --
>
> Art Zemon, President
> Hen's Teeth Network 
> The source of reliable, secure e-commerce web 
> hosting
> Phone: (866)HENS-NET or (636)447-3030 ext. 200
>


Re: [web2py] Re: Adding fields to the default register form;

2011-01-27 Thread Anthony
On Thursday, January 27, 2011 11:00:45 AM UTC-5, viniciusban wrote: 
>
> On Thu, Jan 27, 2011 at 3:27 AM, Bruno Rocha  wrote:
> > Thinking a bit more, taking the Vinicius comment and some examples of
> > another O.O frameworks.
> > I was wondering about...
> > #2
> > auth.settings.formstyle = 'divs'
> > form = auth()
> > print form #  return the HTML with divs 
>
> OK, but formstyle isn't related to auth in anyway, but it is to form, 
> right?
> If auth wouldn't be showed (rendered) as a form, this property never
> needed to be used.
>
Auth does a number of things, one of which is to generate various forms 
related to authentication (e.g., registration, login, recover password, 
etc.), so it seems relevant for it to have settings telling it how to render 
the forms it generates.

> > ...
> > form.formstyle = 'divs' # sets the self.formstyle to 'divs'
> > and immediately raises a redraw method
> > #alternatively call explicitly the form.redraw() method
> > print form # should now return HTML with 'divs'
> >
> > I think Vinicius are talking about the case #3, which I think it is 
> possible
> > to implement, but I don't know the caveats, 
>
> Yes Bruno. You catched my mind. 
>
> Actually, formstyle='divs' is a SQLFORM form property. It is the way
> print will show the generated HTML for this form instance.
>
When you create a SQLFORM form, it actually generates the HTML for the form, 
which is then passed to the view. There isn't a separate HTML-generation 
step at "print" time. So any properties that affect the HTML have to be set 
before the form is created (so, 'formstyle' is passed as an argument to the 
SQLFORM __init__ method).

> So, conceptually it is a form property. 
>
> Your 3rd example show an intuitive method do implement this feature. 
>
> I didn't have time to see the source code yet (I plan to do this
> tonight), but I see no reason to generate HTML code before the print
> call.
>
At what point would you prefer to generate the HTML? Would you prefer an 
explicit extra step to call a render method on the form sometime after it is 
initially created (either before or after passing it to the view)? What are 
the benefits of that approach?
 
Best,
Anthony


[web2py] Auth callbacks when using Janrain

2011-01-27 Thread scausten
I'm using Janrain and I need to perform some actions post-
registration, but the usual auth callbacks don't seem to be working.
I'm running a very simple test function in my model:

db.define_table('user_data',Field('testfield'))
auth.settings.register_onvalidation.append(lambda
form:db.user_data.insert(testfield="test value"))

I figure the problem may be because I've got the usual
auth.settings.actions_disabled =
['register','change_password','request_reset_password'], so 'register'
is never called.

Is there a way round this?


Re: [web2py] Re: Adding fields to the default register form;

2011-01-27 Thread David J.


The fact that auth is so tightly coupled with the view is very frustrating;

It would be better if auth return an object that was wrappable; in 
FORM(); rather than the rendered form


This way you can do things like addfield() to the form before it is 
rendered or just render it as it is;


I asked before "what is the easiest way to add a non-database field to 
the registration form"



Right now I dont see an easy way to do this;



On 1/27/11 11:55 AM, Anthony wrote:

On Thursday, January 27, 2011 11:00:45 AM UTC-5, viniciusban wrote:

On Thu, Jan 27, 2011 at 3:27 AM, Bruno Rocha 
wrote:
> Thinking a bit more, taking the Vinicius comment and some
examples of
> another O.O frameworks.
> I was wondering about...
> #2
> auth.settings.formstyle = 'divs'
> form = auth()
> print form #  return the HTML with divs

OK, but formstyle isn't related to auth in anyway, but it is to
form, right?
If auth wouldn't be showed (rendered) as a form, this property never
needed to be used.

Auth does a number of things, one of which is to generate various 
forms related to authentication (e.g., registration, login, recover 
password, etc.), so it seems relevant for it to have settings telling 
it how to render the forms it generates.


> ...
> form.formstyle = 'divs' # sets the self.formstyle to 'divs'
> and immediately raises a redraw method
> #alternatively call explicitly the form.redraw() method
> print form # should now return HTML with 'divs'
>
> I think Vinicius are talking about the case #3, which I think it
is possible
> to implement, but I don't know the caveats,

Yes Bruno. You catched my mind.

Actually, formstyle='divs' is a SQLFORM form property. It is the way
print will show the generated HTML for this form instance.

When you create a SQLFORM form, it actually generates the HTML for the 
form, which is then passed to the view. There isn't a separate 
HTML-generation step at "print" time. So any properties that affect 
the HTML have to be set before the form is created (so, 'formstyle' is 
passed as an argument to the SQLFORM __init__ method).


So, conceptually it is a form property.

Your 3rd example show an intuitive method do implement this feature.

I didn't have time to see the source code yet (I plan to do this
tonight), but I see no reason to generate HTML code before the print
call.

At what point would you prefer to generate the HTML? Would you 
prefer an explicit extra step to call a render method on the form 
sometime after it is initially created (either before or after passing 
it to the view)? What are the benefits of that approach?

Best,
Anthony




[web2py] Pass variables from javascript to a controller

2011-01-27 Thread Ialejandro
Hi! I'm playing with web2py, and I'm making a booking system,

I have a model as follow:

db.define_table('room',
Field('name','string'),
Field('location','string'))

I'm showing the rooms as a list with jqueryUI selectable (http://
jqueryui.com/demos/selectable/display-grid.html), so every room is
shown as a square, I need that one user can select multiple rooms, and
book them, so I need to pass the result of which rooms the user
selected to a controller that make the booking (into the bookings
model)

but the question is, how do I get the values of the selected rooms to
the controller and make the index of the list (rooms squares)
correspond to the ID of each room

sorry if the question is quite confusing, but my mind is the same, I'm
lost with this.

I don't know if a postback should work, I read something about
json. but I don't know.

Thanks!


[web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-01-27 Thread Rupesh Pradhan
Thanks a lot for sharing the philosophy behind coding!!! I get the point.

Now for some *real* help by nitpicking at my coding!


Re: [web2py] Re: Adding fields to the default register form;

2011-01-27 Thread Bruno Rocha
2011/1/27 David J. 

> I asked before "what is the easiest way to add a non-database field to the
> registration form"
>
>
> Right now I dont see an easy way to do this;
>

You can interact with the HTML for the FORM object.

form = auth()
form.elements[0].append(SOME_OTHER_ELEMENT)

The FORM is rendered as HTML by the web2py template system, it happens just
when it is passed to response.write (which is similar to print statement)

If you try

in controllers/default.py
def myauth(): return dict(form=auth())

then in view you do:

{{=dir(response._vars['form'])}}
{{=type(response._vars['form'])}}

You get:
*DIR*
['FIELDKEY_DELETE_RECORD', 'FIELDNAME_REQUEST_DELETE', 'ID_LABEL_SUFFIX',
'ID_ROW_SUFFIX', '__class__', '__delattr__', '__delitem__', '__dict__',
'__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__',
'__init__', '__len__', '__module__', '__new__', '__nonzero__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_fixup', '_postprocessing',
'_setnode', '_traverse', '_validate', '_wrap_components', '_xml', 'accepts',
'append', 'attributes', 'components', 'custom', 'element', 'elements',
'errors', 'factory', 'field_parent', 'fields', 'flatten', 'formkey',
'formname', 'formstyle', 'hidden_fields', 'ignore_rw', 'insert',
'keepvalues', 'latest', 'parent', 'record', 'record_changed', 'record_id',
'regex_attr', 'regex_class', 'regex_id', 'regex_tag', 'request_vars',
'session', 'sibling', 'siblings', 'table', 'tag', 'update', 'vars',
'widgets', 'xml']

*TYPE*


If you try

{{=form}} which is the same as {{respose.write(form)}} then you get the
object rendered as HTML.

Until this point you have only a object types as 

*Manipulation of the SQLFORM object*

{{=form.elements()[0].insert(0,LABEL('test:',INPUT(_type='text')))}}

or in a more comprehensive way

{{=form.elements('form tr td')[0].insert(0,INPUT())}}

But, I think it is possible to catch that *class* object and perform some
kind of redraw method before the html rendering.


[web2py] Re: Callable as Field.default

2011-01-27 Thread Bernd Rothert
On Jan 27, 5:08 pm, Ole Martin Maeland  wrote:
> instead of default=now use default = request.now
>
> also change default = now in modified_on to update=request.now
>
> regards
> Martin
>

You are right - that works because request.now is a datetime value.
The point is that it should be possible to pass a function as a
field's default that yields a new value for each insert (see other
ORMS, e.g. Django).

uuid.uuid4 is a good example and it actually works out of the box:

...
Field('uuid', length=64, default=uuid.uuid4),
...

Multiple inserts for the same request should get unique uuids of
course, so we need a function here.

Some other functions like "datetime.datetime.now" and most probably
others don't work the same way leading to inconsistent behaviour.


Cheers,
Bernd

> On Wed, Jan 26, 2011 at 1:36 AM, Bernd Rothert wrote:
>
>
>
>
>
>
>
>
>
> > A table definition from the DAL chapter of the Web2py book:
>
> > db.define_table('person',
> >    Field('uuid', length=64, default=uuid.uuid4()),
> >    Field('modified_on', 'datetime', default=now),
> >    Field('name'),
> >    format='%(name)s')
>
> > "now" usually contains the current datetime from request.now and
> > that's fine but the default for "uuid" would be identical for all
> > inserts. Although the example doesn't use the default so it is not a
> > problem there.
>
> > If you omit the parenthesis behind "default=uuid.uuid4()" and simple
> > pass the uuid4 function as the default it works as expected - the
> > default is evaluated at insert time and yields a fresh uuid for each
> > new record. I assume this is the intended behaviour although I
> > couldn't find it documented(!?).
>
> > Strangely replacing "default=now" in the same way with e.g.
> > "default=datetime.datetime.now" does not work:
>
> > now=datetime.datetime.now
> > db.define_table('person',
> >    Field('uuid', length=64, default=uuid.uuid4),
> >    Field('modified_on', 'datetime', default=now),
> >    Field('name'),
> >    format='%(name)s')
>
> > db.person.insert(name='Ernie')
> > db.person.insert(name='Bert')
>
> > db(db.person).select()
> > >>> ValueError: invalid literal for int() with base 10: '
> > Umm,...
>
> > db.executesql(db(db.person)._select())
> > >>> [(1,
> >  u'b35cc052-3800-42a9-b7eb-bb9bc8ada271',
> >  u'',
> >  u'Ernie'),
> >  (2,
> >  u'003ab438-f3aa-4474-8c24-b07d85406930',
> >  u'',
> >  u'Bert')]
>
> > (only works with Sqlite - MySQL would throw an error earlier)
>
> > I think this check in BaseAdapter.represent (dal.py) is the culprit:
>
> >    def represent(self, obj, fieldtype):
> >        if type(obj) in (types.LambdaType, types.FunctionType):
> >            obj = obj()
>
> > print type(datetime.datetime.now) in (types.LambdaType,
> > types.FunctionType)
> > >>> False
>
> > This version lets you use any callable for generating "dynamic"
> > default values (plus it's 3-4 times faster):
>
> >    def represent(self, obj, fieldtype):
> >        if callable(obj):
> >            obj = obj()
>
> > I hope this doesn't cause any side effects - at least I could not find
> > any (at this late/early hour)...
>
> > Thanks
>
> --
> Hilsen
> Ole Martin
> Mob: 95227471


Re: [web2py] creating html for the user to save or copy/paste

2011-01-27 Thread Bruno Rocha
Sorry my mistake.

I mean:
{{=XML(htmlobject, sanitize=True|False)}  #not escape


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


2011/1/27 Bruno Rocha 

> Try XML with escape set to True/False
>
> {{=XML(htmlobject, escape=True|False)}}
>
>
> --
> Bruno Rocha
> http://about.me/rochacbruno/bio
>
>
> 2011/1/27 Ed Greenberg 
>
> I have a controller function that we can call "next()" since that's
>> what it is called :)
>>
>> I have created a block of html in that function, contained in a
>> string.
>>
>> I'd like to return it to the user so he can reuse it (not just view it
>> in the browser.)
>>
>> Sending it to the browser causes the various special characters of
>> html to be converted to entities (like ampersand-gt-semicolon.)
>>
>> I think what I need to do is return it as type text/plain or as type
>> application/octet-stream.
>>
>> How do I construct the dict that I am going to return in the
>> controller function so that web2py will know what to send to the user?
>>
>> Thanks,
>>
>> Ed G
>
>
>


[web2py] Re: Pass variables from javascript to a controller

2011-01-27 Thread Mathew Grabau
Have you tried anything yet?

A skeleton solution/recommendation:

- If I assume correctly that the values are the HTML INPUT values,
then use the selected event on the jQueryUI objects
- for the above event, the handler adds the selected rooms to a stored
collection (Array perhaps) in client-side script
- when the form is submitted (stop the event)/when you call the
controller use $.post(CONTROLLER_URL, {'rooms': roomArray}, function
HANDLER))

On the server side, request.vars.rooms will be the list of selected
rooms, ready for you to do whatever might be required.

On Jan 27, 11:34 am, Ialejandro  wrote:
> Hi! I'm playing with web2py, and I'm making a booking system,
>
> I have a model as follow:
>
> db.define_table('room',
>     Field('name','string'),
>     Field('location','string'))
>
> I'm showing the rooms as a list with jqueryUI selectable (http://
> jqueryui.com/demos/selectable/display-grid.html), so every room is
> shown as a square, I need that one user can select multiple rooms, and
> book them, so I need to pass the result of which rooms the user
> selected to a controller that make the booking (into the bookings
> model)
>
> but the question is, how do I get the values of the selected rooms to
> the controller and make the index of the list (rooms squares)
> correspond to the ID of each room
>
> sorry if the question is quite confusing, but my mind is the same, I'm
> lost with this.
>
> I don't know if a postback should work, I read something about
> json. but I don't know.
>
> Thanks!


Re: [web2py] Re: Adding fields to the default register form;

2011-01-27 Thread Anthony
Sorry, my misunderstanding. Thanks for clarifying, Bruno.
 
Anthony
 

On Thursday, January 27, 2011 12:53:34 PM UTC-5, rochacbruno wrote:

>
> 2011/1/27 David J. 
>
>> I asked before "what is the easiest way to add a non-database field to the 
>> registration form"
>>
>>
>> Right now I dont see an easy way to do this;
>>
>
> You can interact with the HTML for the FORM object.
>
> form = auth()
> form.elements[0].append(SOME_OTHER_ELEMENT)
>
> The FORM is rendered as HTML by the web2py template system, it happens just 
> when it is passed to response.write (which is similar to print statement)
>
> If you try
>
> in controllers/default.py
> def myauth(): return dict(form=auth())
>
> then in view you do:
>
>  {{=dir(response._vars['form'])}}
> {{=type(response._vars['form'])}}
>
> You get:
> *DIR*
> ['FIELDKEY_DELETE_RECORD', 'FIELDNAME_REQUEST_DELETE', 'ID_LABEL_SUFFIX', 
> 'ID_ROW_SUFFIX', '__class__', '__delattr__', '__delitem__', '__dict__', 
> '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', 
> '__init__', '__len__', '__module__', '__new__', '__nonzero__', '__reduce__', 
> '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', 
> '__str__', '__subclasshook__', '__weakref__', '_fixup', '_postprocessing', 
> '_setnode', '_traverse', '_validate', '_wrap_components', '_xml', 'accepts', 
> 'append', 'attributes', 'components', 'custom', 'element', 'elements', 
> 'errors', 'factory', 'field_parent', 'fields', 'flatten', 'formkey', 
> 'formname', 'formstyle', 'hidden_fields', 'ignore_rw', 'insert', 
> 'keepvalues', 'latest', 'parent', 'record', 'record_changed', 'record_id', 
> 'regex_attr', 'regex_class', 'regex_id', 'regex_tag', 'request_vars', 
> 'session', 'sibling', 'siblings', 'table', 'tag', 'update', 'vars', 
> 'widgets', 'xml'] 
>
> *TYPE*
> 
>
> If you try
>
> {{=form}} which is the same as {{respose.write(form)}} then you get the 
> object rendered as HTML.
>
> Until this point you have only a object types as  'gluon.sqlhtml.SQLFORM'>
>
> *Manipulation of the SQLFORM object*
>
> {{=form.elements()[0].insert(0,LABEL('test:',INPUT(_type='text')))}}
>
> or in a more comprehensive way
>
> {{=form.elements('form tr td')[0].insert(0,INPUT())}}
>
> But, I think it is possible to catch that *class* object and perform some 
> kind of redraw method before the html rendering.
>
>

[web2py] Fix for kpaxcms

2011-01-27 Thread Martin Barnard
Hi. 
I've been lurking here whilst trying out web2py (thanks for the software, 
Massimo!). I'm looking at building something similar to kpax, with a few 
modified tweaks. However, when I tried to change group permissions, I'd get 
this error. It's in access.py controller, change function:

Error Traceback (pastie.org) 

A little bit of poking, found an apparent solution from somebody, which was to 
call the first object in the list, as opposed to the variable directly. 
This didn't work for me (for some reason), so I have provided another fix, 
which appears to work.
I don't know where or how I can submit this as a patch, so I thought the group 
could have it.
The most interesting lines are the last few. I basically take the first segment 
of the *request.vars.forward* variable, split it & remove leading space (which 
for some reason is there), then call redirect with the URL decorator.

I hope it's of some use to somebody...
Martin

if not session.token: redirect(LOGIN)

def change():
if len(request.args)<2: redirect(MAIN)
table_name=request.args[0]
record_id=request.args[1]
if not is_owner(user_id,table_name,record_id):
session.flash="not authorized"
redirect(MAIN)
access_types=db[table_name].access_types
rows=db(db.access.table_name==table_name)\
   (db.access.record_id==record_id)\
   (db.access.users_group==db.users_group.id)\
   .select(orderby=db.access.id)
group_keys=dict([(r.users_group.id,r.access.access_type) for r in rows])
keys=dict([(r.access.id,r.access.access_type) for r in rows])
accesses=[]
for g in session.groups:
if table_name=='users_group' and g.id==int(record_id): continue
item=Storage()
item.group_id=g.id
item.group_name=g.name
item.membership_type=g.membership_type
if group_keys.has_key(g.id): item.access_type=group_keys[g.id] 
else: item.access_type='none'
accesses.append(item)
ch=False
for key,value in request.vars.items():
if key=='forward': continue
ch=True
g=int(key[1:])
if g==g_tuple[1]: continue
if g==g_tuple[0] and user_id!=1: continue
if group_keys.has_key(g):
s=db(db.access.users_group==g)\
(db.access.record_id==record_id)\
(db.access.table_name==table_name)
if value=='none': 
s.delete()
elif value in access_types: 
s.update(access_type=value)
elif value!='none' and value in access_types:
db.access.insert(users_group=g,
 table_name=table_name,
 record_id=record_id,
 access_type=value)
if ch:
uuu=request.vars.forward[0].split('/')[1:]
if len(uuu) ==3:
redirect(URL(uuu[0],uuu[1],uuu[2]))
elif len(uuu) ==2:
redirect(URL(uuu[0],uuu[1]))

else:
st=request.vars.forward
raise HTTP(500, "cannot redirect!%s%d"%(uuu, len(uuu)))
return dict(accesses=accesses,access_types=access_types)


[web2py] Re: GAE Flow doesn't seems work. (fixed & closed)

2011-01-27 Thread Arun K.Rajeevan
Actually the problem was something I really do not expected.

items.append(DIV(DIV(*[data[item]], _id = 'wrap'), _id = 
'ui-tabs-'+str(i))) 

needed to be

items.append(DIV(DIV([data[item]], _id = 'wrap'), _id = 'ui-tabs-'+str(i)))

No star (*) needed!!!


Re: [web2py] django admin like app/plugin in web2py

2011-01-27 Thread Richard Vézina
appadmin is for the admin and not for users since there is no CRUD
restriction that apply to the db views that appear into it. It not
accessible in prod deployment instead you access your app in https mode
(with ssl certificat).

I am not aware of any appadmin goodies (other appadmin implementation) that
could bring more features.

Richard

On Wed, Jan 26, 2011 at 11:37 PM, William  wrote:

> Hi all,
> I just got started in web2py and like it so far.
> I noticed that it has a admin and an appadmin for each app.
>
> but i think appadmin is not for the users, right? is there an app or plugin
> like django admin or django grappelli?
>
> Thanks,
> Bill
>


[web2py] Re: django admin like app/plugin in web2py

2011-01-27 Thread rif
I requested this feature in uservoice: 
http://web2py.uservoice.com/forums/42577-general

You can vote for it.

rif

On Jan 27, 6:37 am, William  wrote:
> Hi all,
> I just got started in web2py and like it so far.
> I noticed that it has a admin and an appadmin for each app.
>
> but i think appadmin is not for the users, right? is there an app or plugin
> like django admin or django grappelli?
>
> Thanks,
> Bill


[web2py] Re: Change in URL args handling

2011-01-27 Thread DenesL
Hi Jonathan,

On Jan 27, 12:04 am, Jonathan Lundell  wrote:
> This applies to both the old and new URL rewrite paths, regardless of whether 
> there's any rewriting going on.
>
> Previously, a trailing slash after args would cause an extra arg to be added 
> to the list with a value of '' (empty string). In the old logic, an embedded 
> empty arg was illegal.
>
> That is:
>
> /a/c/f/arg1
>
> gave args as ['arg1']
>
> /a/c/f/arg1/
>
> gave args as ['arg1', '']
>
> /a/c/f/arg1//arg2
>
> was illegal.
>
> Now, trailing slashes are stripped, so the first two examples about give 
> ['arg1'], as does /a/c/f/arg1/

Maybe that should be parsed as ['arg1', '', '', '', '']

> Also, embedded empty args are legal, so the arg2 example above yields ['', 
> 'arg2']

Did you mean ['arg1', '', 'arg2'] ?

I have not checked, but are those series of slashes legal according to
an RFC?.

Denes.


On Jan 27, 12:04 am, Jonathan Lundell  wrote:
> This applies to both the old and new URL rewrite paths, regardless of whether 
> there's any rewriting going on.
>
> Previously, a trailing slash after args would cause an extra arg to be added 
> to the list with a value of '' (empty string). In the old logic, an embedded 
> empty arg was illegal.
>
> That is:
>
> /a/c/f/arg1
>
> gave args as ['arg1']
>
> /a/c/f/arg1/
>
> gave args as ['arg1', '']
>
> /a/c/f/arg1//arg2
>
> was illegal.
>
> Now, trailing slashes are stripped, so the first two examples about give 
> ['arg1'], as does /a/c/f/arg1/
>
> Also, embedded empty args are legal, so the arg2 example above yields ['', 
> 'arg2']


[web2py] Re: IS_IN_SET texts

2011-01-27 Thread DenesL

You can use
requires=IS_IN_SET({1:'Fixed yesterday', 2:'to be fixed today', ...})


On Jan 27, 9:32 am, Kenneth Lundström 
wrote:
> I have a field priority = integer, can be anything between 1-5 (or 6 in
> Python way)
>
> but I d like to make a dropdown with options, '1, Fixed yesterday', '2,
> to be fixed today', '3, fixed before release' and so on. Is this
> possible with IS_IN_SET or do I have to make my own form?
>
> When viewing the data a number is enough, it s only when making the
> priority that the text is needed.
>
> Kenneth


[web2py] Re: New User - a few simple questions...

2011-01-27 Thread g...@rtplanb.com

Cheers Anthony, Ill get started on the menu's. Not far from being able
to deploy my first Web2Py website!!!


Re: [web2py] Re: Change in URL args handling

2011-01-27 Thread Jonathan Lundell
On Jan 27, 2011, at 11:54 AM, DenesL  wrote:

> Hi Jonathan,
> 
> On Jan 27, 12:04 am, Jonathan Lundell  wrote:
>> This applies to both the old and new URL rewrite paths, regardless of 
>> whether there's any rewriting going on.
>> 
>> Previously, a trailing slash after args would cause an extra arg to be added 
>> to the list with a value of '' (empty string). In the old logic, an embedded 
>> empty arg was illegal.
>> 
>> That is:
>> 
>> /a/c/f/arg1
>> 
>> gave args as ['arg1']
>> 
>> /a/c/f/arg1/
>> 
>> gave args as ['arg1', '']
>> 
>> /a/c/f/arg1//arg2
>> 
>> was illegal.
>> 
>> Now, trailing slashes are stripped, so the first two examples about give 
>> ['arg1'], as does /a/c/f/arg1/
> 
> Maybe that should be parsed as ['arg1', '', '', '', '']

Maybe, but it seems to me that it's confusing unless we also recognize a single 
trailing slash as an empty arg. I don't have a strong opinion.

> 
>> Also, embedded empty args are legal, so the arg2 example above yields ['', 
>> 'arg2']
> 
> Did you mean ['arg1', '', 'arg2'] ?

Right.

> 
> I have not checked, but are those series of slashes legal according to
> an RFC?.

Good question. I'll have a look.

RFC 3986 (generic URI) allows segments to be empty. However, a relative URL of 
the form '//a/b' is supposed to interpret a as the authority (domain). That's 
not an issue for web2py, since we'll always have a function at least before 
args unless someone does a really strange rewrite, in which case they need to 
avoid that pattern.

> 
> Denes.
> 
> 
> On Jan 27, 12:04 am, Jonathan Lundell  wrote:
>> This applies to both the old and new URL rewrite paths, regardless of 
>> whether there's any rewriting going on.
>> 
>> Previously, a trailing slash after args would cause an extra arg to be added 
>> to the list with a value of '' (empty string). In the old logic, an embedded 
>> empty arg was illegal.
>> 
>> That is:
>> 
>> /a/c/f/arg1
>> 
>> gave args as ['arg1']
>> 
>> /a/c/f/arg1/
>> 
>> gave args as ['arg1', '']
>> 
>> /a/c/f/arg1//arg2
>> 
>> was illegal.
>> 
>> Now, trailing slashes are stripped, so the first two examples about give 
>> ['arg1'], as does /a/c/f/arg1/
>> 
>> Also, embedded empty args are legal, so the arg2 example above yields ['', 
>> 'arg2']


[web2py] Re: Overwriting the default "register" action

2011-01-27 Thread DenesL
Please post your 'register' controller and related models.


[web2py] Re: Change in URL args handling

2011-01-27 Thread DenesL
> >> Now, trailing slashes are stripped, so the first two examples about give 
> >> ['arg1'], as does /a/c/f/arg1/
>
> > Maybe that should be parsed as ['arg1', '', '', '', '']
>
> Maybe, but it seems to me that it's confusing unless we also recognize a 
> single trailing slash as an empty arg. I don't have a strong opinion.
>

Note that the number of empty strings ('') is one less than the number
of slashes:

/arg1/
/arg1/empty/empty/empty/empty/nothing_here


[web2py] Re: can web2py support RESTful api calls? if so any pointers on how to build one?I

2011-01-27 Thread howesc
while the current version does not prescribe to RESTfulness very well, check 
out http://starmakerapp.com/ this iPhone app's database backend is web2py on 
GAE.

it's still  kinda beta version, but many enhancements (including converting 
the website for the app to web2py) are coming!

so yes, it's possible to have an iphone app interact with web2py.

cfh


[web2py] Re: Test controller again

2011-01-27 Thread howesc
to enhance massimo's response, you can test the HTTP status code in the 
except block:

>>> try:
...   index()
... except HTTP, e:
...   assert(e.status == 400)
...   assert(e.body == "Not permitted")
...



[web2py] GAE belongs (how to map long list)

2011-01-27 Thread Arun K.Rajeevan
Hi, 

I know belongs is not supported on GAE

>From http://www.web2py.com/AlterEgo/default/show/248 
>
 

*it's clear that we have to convert*

rows = db(purchase.buyer.belongs((kenny,cartman)))\
 .select(orderby=purchase.quantity)

*to*
*


*
*

rows = (db(purchase.buyer==kenny).select()|db(purchase.buyer==cartman).select())

*
*


*
*


*
*

But if the list is too big (here only kenny and cartman)

*
, it'll become quite tedious.

Will someone have something to make it easier?
for eg: a lambda expression.
It's crucial as of now.
Please give me a solution if you got the idea.


Re: [web2py] Re: Powertable remarks

2011-01-27 Thread António Ramos
That was an excelent question!
Any answer from Bruno?

Thanks
António

2011/1/18 Johann Spies 

> I started this thread:
>
>
> On 17 December 2010 12:11, Johann Spies  wrote:
>
>>
>> * I have tested it this morning on a table with more  just over 8200
>> entries and it took 70-90  seconds on Firefox and 30-35 secondes no Chrome
>> to reload the page from localhost.  That is not usable.  Plugin_wiki's
>> jqgrid does this in less than a second.
>>   It seems that it loads the whole table and does not make use of paging
>> while executing the query.
>>
>>
> After the plugin was updated and I returned from holiday, I did the same
> test today:
>
> Firefox - about 45 seconds
> Chrome - about 37 seconds.
>
> So there is an improvement on Firefox, but not on Chrome.
>
> But it still too slow to use on larger datasets without some other
> pagination help - which is a pity.  I have tried to get it to load a table
> of 135000 entries but gave up after a long time.
>
> Unfortunately my knowlege of javascript is almost zero so I do not know
> whether it is possible to get the javascript to handle the sql-queries in a
> way that does not need to load all the data into memory.
>
>
> 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: django admin like app/plugin in web2py

2011-01-27 Thread William
Just vote it!
why nobody care this? They claim django admin is the kill feature of django.


[web2py] Re: can web2py support RESTful api calls? if so any pointers on how to build one?I

2011-01-27 Thread William
Thanks cfh.
I am wondering could you write a blog or forum post about the post interface 
you did? that will be very helpful.

-Bill


Re: [web2py] Re: T-Shirts web2py

2011-01-27 Thread mikech
+1
Zazzle is another alternative.  I don't know if you've ordered t-shirts from 
Cafe Express, but I did some time ago, and they seemed very lightweight. 
 Don't know if Zazzle is
any better.  
Here is a comparison: 
http://www.squidoo.com/cafepress_alternative


Re: [web2py] Re: Callable as Field.default

2011-01-27 Thread Vinicius Assef
On Thu, Jan 27, 2011 at 3:54 PM, Bernd Rothert  wrote:
>
> Multiple inserts for the same request should get unique uuids of
> course, so we need a function here.

I faced this problem some time ago.

Default values defined in models are not assigned in INSERT time, but
in REQUEST time.

So, if you have a loop with insert inside it, all records will have
the same default values.

This is a web2py feature, in spite my thought explained that time that
it should be different. When you talk about database, default values
should be evaluated as in SQL INSERT: in insert time.

--
Vinicius Assef.


Re: [web2py] Re: Change in URL args handling

2011-01-27 Thread Jonathan Lundell
On Jan 27, 2011, at 12:48 PM, DenesL wrote:
> 
 Now, trailing slashes are stripped, so the first two examples about give 
 ['arg1'], as does /a/c/f/arg1/
>> 
>>> Maybe that should be parsed as ['arg1', '', '', '', '']
>> 
>> Maybe, but it seems to me that it's confusing unless we also recognize a 
>> single trailing slash as an empty arg. I don't have a strong opinion.
>> 
> 
> Note that the number of empty strings ('') is one less than the number
> of slashes:
> 
> /arg1/
> /arg1/empty/empty/empty/empty/nothing_here

Yes. 

Still, it bothers me that arg1 == arg1/ != arg1//;  seems like an odd rule.

Notice also that '/'.join(['arg1', '']) is 'arg1/', not 'arg1//'.

I'm open to changing it if you (or someone else) feels strongly about it--I'd 
just have to change a call to rstrip to a conditional trim-one-character if the 
string endswith('/'), so it's not a big deal. The important thing is for it to 
be well defined.


[web2py] Troubles with index action

2011-01-27 Thread walter
This is my code. I specifically made it so primitive.

def index():
'''
>>> db.news.insert(title="Test", body="Test-test")

'''
return dict(table="news")


Next code is my db:

db.define_table('news',
Field('title'),
Field('body', 'text'),
Field('created_at', 'datetime', default=request.now,
readable=False, writable=False),
Field('updated_at', 'datetime', update=request.now,
readable=False, writable=False))

db.news.body.requires = IS_NOT_EMPTY()

Database is a sqlite3.


When I try to run doctest I get next exception

Line 2, in default.py: index
Failed example:
db.news.insert(title="Test", body="Test-test")
Exception raised:
Traceback (most recent call last):
  File "/usr/lib/python2.6/doctest.py", line 1253, in __run
compileflags, 1) in test.globs
  File "", line 1, in 
  File "/home/vladimir/web/eng_w2p/gluon/dal.py", line 3875, in
insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/home/vladimir/web/eng_w2p/gluon/dal.py", line 704, in
insert
raise e
OperationalError: database is locked


What happens? Where do I wrong?

P.S. In other action this doctest was run successfully.


Re: [web2py] Troubles with index action

2011-01-27 Thread Bruno Rocha
You can try

def index():
>'''
>>>> db.news.insert(title="Test", body="Test-test")
>
  >>> db.commit()

>
>'''
>return dict(table="news")
>

sqlite locks on multiple connections.


[web2py] Re: Troubles with index action

2011-01-27 Thread walter
Many thanks


[web2py] Re: AJAX in Web2py -> Synchronous

2011-01-27 Thread Phoboss
OK, I tried to change the code of web2py_ajax.html BUT all function
code was commented out!! What is going on?
Why is all commented out? Is it commented out because all the code in
web2py_ajax.html is only for changing AJAX-settings? Like turning
asynchronisation off?
I built my app by using the form field "New simple application". After
that the web2py-system makes automatically a copy of the "welcome"-
app. And after that I never changed the web2py_ajax.html file!

Well, I commented "in" the "function ajax(u,s,t)".
Within this function there is the mentioned jQuery-Command:

jQuery.ajax({type: "POST", url: u, data: query, async: false, success:
function(msg) { if(t) { if(t==':eval') eval(msg); else jQuery("#" +
t).html(msg); } } });

So, finally it works now, however, I don't get why everything was
commented out.

Again, Thank you!

Regards

Phoboss


On 27 Jan., 15:54, Phoboss  wrote:
> Hi Denes,
>
> firstly thank you for your swift response!
>
> I'm now at work. So in 4 hours or so I'll try it at home.
> After that I'll report here if it's works.
>
> Best Regards
>
> Phoboss
>
> On 27 Jan., 15:49, DenesL  wrote:
>
>
>
>
>
>
>
> > Hi Phoboss,
>
> > web2py uses the jQuery.ajax API which has a parameter named async for
> > that.
>
> > Try changing your app's web2py_ajax.html file where the jQuery.ajax
> > calls are made and specify async : false .
>
> > Denes
>
> > On Jan 27, 3:53 am, Phoboss  wrote:
>
> > > Hi Experts,
>
> > > how can I turn off asynchron AJAX in web2py?
> > > It sounds strange but I need it synchronous!
>
> > > BTW, I implemented this 
> > > example:http://www.web2py.com/book/default/chapter/10#Ajax-Form-Submission
>
> > > Thank you so much!
>
> > > Best Regards
>
> > > Phoboss


[web2py] Re: AJAX in Web2py -> Synchronous

2011-01-27 Thread Anthony
On Thursday, January 27, 2011 6:55:24 PM UTC-5, Phoboss wrote: 
>
> OK, I tried to change the code of web2py_ajax.html BUT all function 
> code was commented out!! What is going on?

 
Here's the file in trunk: 
http://code.google.com/p/web2py/source/browse/applications/welcome/views/web2py_ajax.html
 
Is your version the same? When you say the code is commented out, are you 
referring to the  just inside the script tags? If so, that is 
commonly done so that older browsers that don't support Javascript won't end 
up displaying the Javascript code as if it were plain text (the opening and 
closing HTML comment tags tell the browser to ignore everything in between). 
See http://www.javascripter.net/faq/hidingjs.htm.
 
Anthony


[web2py] Fwd: web2py basic auth

2011-01-27 Thread miguel
I suppose this is mentioned in the Change Log by:
"on_failed_authorization can be a function, thanks Niphold"

How is this used? could the function be a lambda, does it take params,
is it an action (i.e. a controller function)?

Also, is it possible to allow the usual login redirection in case it
is not a service call? I'm thinking in these lines:

def theFunction():
if request.function == 'call':
# return case forservice call
else:
# redirect to login form

This would be useful for publishing the same service both for browsers
and for other apps, like it is mentioned in 
p://www.web2pyslices.com/main/slices/take_slice/48
(see "Authentication"). This solution would also be useful for other
non-browser-based clients. Would it work? How is the function used?

Txs,
Miguel



-- Forwarded message --
From: mdipierro 
Date: Sep 23 2010, 2:34 pm
Subject: web2py basic auth
To: web2py-users


Against trunk please. It is ok if you just send me a replacement file.
I will diff and study it.

On Sep 23, 8:52 am, Niphlod  wrote:



> Never done a patch before, but I think in the night (here are 3PM) I
> can manage to have a first draft.

> I'd have to test it out, but for the beginning .. What wuold be the
> patch against ? tools.py in trunk or tools.py in 1.85.3?

> On 23 Set, 14:52, mdipierro  wrote:

> > You are right. That would be best. Want to send me a patch?

> > On Sep 23, 2:26 am, Niphlod  wrote:


[web2py] CRUD onaccept - get inserted record id?

2011-01-27 Thread DJ
Hi there,

I would like to perform another database transaction using 
crud.settings.create_onaccept 
soon after a CRUD create action using the newly created record id. 

That is, does CRUD create return the ID of the new record for downstream 
processing? If so, how do I get it? 

If this is not possible, can you recommend any other ways to accomplish the 
same (using crud)?

Thanks,
sebastian





[web2py] Re: CRUD onaccept - get inserted record id?

2011-01-27 Thread DenesL
Hi,

onaccept is called with form as a parameter after the form is
accepted, so form.vars.id has the newly inserted record id.

You can multiple functions called by onaccept:
onaccept=lambda form: (f1(form),f2(form),f3(form),...)

Denes.



On Jan 27, 8:16 pm, DJ  wrote:
> Hi there,
>
> I would like to perform another database transaction using 
> crud.settings.create_onaccept
> soon after a CRUD create action using the newly created record id.
>
> That is, does CRUD create return the ID of the new record for downstream
> processing? If so, how do I get it?
>
> If this is not possible, can you recommend any other ways to accomplish the
> same (using crud)?
>
> Thanks,
> sebastian


[web2py] Re: Can any help me with new dal in trunk?

2011-01-27 Thread drayco
Hi, Now my old application is work's with trunk.

Thank's a lot to fix it.

Hi, Now one of my old application is work's with trunk version.

Thanks a lot to fix it.

However I obtain the same issue with mysql and legacy database, this
is other old application, this is the issue

Traceback (most recent call last):
  File "/home/drayco/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
  File "/home/drayco/web2py/applications/iscada/models/cfedb.py", line
16, in 
migrate = False)
  File "/home/drayco/web2py/gluon/dal.py", line 3457, in define_table
sequence_name=sequence_name))
  File "/home/drayco/web2py/gluon/dal.py", line 3741, in __init__
"primarykey must be a list of fields from table '%s " % tablename
SyntaxError: primarykey must be a list of fields from table
'med_dnpmst_4

http://groups.google.com/group/web2py/browse_thread/thread/72e91e281e0610d8/099e21f098ae8501#099e21f098ae8501

How can I avoid this situation?

Thank's in advance

On Jan 18, 6:17 pm, drayco  wrote:
> Hi, When we have available that change?
>
> And Can you give us a little example?
>
> Because, I'm testing my application on the trunk version and I keep
> getting the same error.
>
> On Jan 8, 4:40 pm, Massimo Di Pierro 
> wrote:
>
> > We should have a flag to change this behavior DAL(...,lowercase=True).
> > I would take a patch.
>
> > On Jan 8, 2:58 pm, Thadeus Burgess  wrote:
>
> > >  All I know is that tables are issued as lowercase, but you can still 
> > > access
> > > your table as an uppercase attribute.
>
> > > There is an inconsistency in the DAL somewhere because of this... 
> > > Somewhere
> > > it is forgetting to convert to lower case. I don't know why converting 
> > > table
> > > names to lower case is forced in web2py and I disagree with it.
>
> > > for example:
>
> > > db = DAL()
> > > db.define_table('TableA', Field('Superman'))
> > > # CREATE TABLE tablea WITH FIELDS superman
> > > db(db.TableA.Superman == "clark").select().first().Superman
> > > # SELECT * FROM tablea WHERE superman="clark"
>
> > > --
> > > Thadeus
>
> > > On Sat, Jan 8, 2011 at 1:17 AM, mart  wrote:
> > > > really? I didn't know, thanks for pointing that out...
>
> > > > just out of curiosity
>
> > > > in
>
> > > > in __getitem__
> > > >    return dict.__getitem__(self, str(key))
> > > > KeyError: 'tecnogradua'
>
> > > > don't the attribute lookups get done by python ultimately?  Just
> > > > trying to understand...
> > > > how could this have worked if doing x.__getitem__ ? Even if dal does a
> > > > string.lower() or something, once the table is named and created,
> > > > would something (outside of migrate) not catch that error and set off
> > > > the alarm even before any change need to happen?
>
> > > > Thanks,
> > > > Mart :)
>
> > > > On Jan 8, 1:44 am, Thadeus Burgess  wrote:
> > > > > I can also confirm this is a bug with the new DAL.
>
> > > > > It is only caused when using upper case characters in the table or 
> > > > > field
> > > > > names. It seems that web2py converts all of the tablenames to lower 
> > > > > case
> > > > > when issuing the SQL (so your actual tables are lower regardless of 
> > > > > what
> > > > you
> > > > > specify in the python). There is something in the migrations that 
> > > > > cause
> > > > this
> > > > > to come up, because it will work just fine one run and crash on 
> > > > > another
> > > > run
> > > > > after changing some unrelated tables.
>
> > > > > I don't think the DAL should force the tables to lowercase.
>
> > > > > --
> > > > > Thadeus
>
> > > > > On Sat, Jan 8, 2011 at 12:38 AM, mart  wrote:
> > > > > > no, this is python...
>
> > > > > > not sure how it could have worked before, but the key (technogradua)
> > > > > > in .keys() is not being picked up... dal is simply pointing that out
> > > > > > with the exception being thrown. I did notice when I made the switch
> > > > > > that a few more of my mistakes got picked up (or it could be that I
> > > > > > forgot that I changed something), but regardless... since switching 
> > > > > > to
> > > > > > the latest DAL release and fixing my mistakes that it quickly picked
> > > > > > up, I have had no problems (except those that I cause). I would 
> > > > > > simply
> > > > > > take those exceptions for cash, change the case and enjoy one less
> > > > > > exception ;)
>
> > > > > > Mart :)
>
> > > > > > On Jan 8, 1:19 am, drayco  wrote:
> > > > > > > Ok, I understand your point.
>
> > > > > > > But this is a issue of DAL or what?
>
> > > > > > > because I only update web2py to trunk version
>
> > > > > > > On Jan 8, 12:15 am, mart  wrote:
>
> > > > > > > > Probably just being unhappy with the case :)
>
> > > > > > > > tecnoGradua != tecnogradua
>
> > > > > > > > Mart :)
>
> > > > > > > > Field("tecnoGradua", 'string',
>
> > > > > > > > On Jan 8, 12:57 am, drayco  wrote:
>
> > > > > > > > > Hi, this code works with web2py 1.89.5 with mysql
>
> > > > > > > > > but with web2py in trunk and mysql it d

[web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-01-27 Thread Rupesh Pradhan
Thanks a lot MARTIN for the nitpick. REALLY needed that!

Inspite of what you mentioned that you are relatively new to web2py, that 
was a lot of help.

I don't know if other are going to help me out as much as you did. But since 
you did take the trouble to pore through my code, I was hoping that you 
would help me out a little bit more till such time you feel that you can 
spare time for it.

I do have a lot more queries and would like to tackle them one at a time. 

Can I request you to subscribe to this post so that you get a notification 
of any posts that I make so that you can reply to it?

Also, I don't know how the code from the db.py was missing. I will fix my 
code as per your guidelines and post it again.

Rupesh





[web2py] Possible DB bug on update;

2011-01-27 Thread David J.

I am using 1.9.1.4

I see a strange behavior

I am doing this simple test;

def update():
rows = db((db.nums.hold==False) & (db.nums.active==False)).select()
for row in rows.find(lambda row: row.num[len(row.num)-2:]=='55'):
row.update(hold=True)
db.commit()

return locals()

The view I have this

{{=rows }}

I see the row 55 has been updated with the "hold" status as True;

However this update does not persist to the DB;

after I have run the above code; I change to...


def update():
rows = db((db.nums.hold==False) & (db.nums.active==False)).select()
for row in rows.find(lambda row: row.num[len(row.num)-2:]=='56'):
row.update(hold=True)
db.commit()

return locals()


I will see row 55 with the "hold" status of False (which should be True 
as per our previous update) and then 56 should show True as well.



I am not sure why I am experiencing this;


The only thing I can think of is that perhaps because I specify this 
value as false in the table definition it keeps returning to false?


db.define_table('nums',signature,
Field('num','string'),
Field('active','boolean',default=False),
Field('hold','boolean',default=False),
)





[web2py] Re: Possible DB bug on update;

2011-01-27 Thread ron_m
>From the DAL chapter of the manual

update_record
update_record
web2py also allows updating a single record that is already in memory using 
update_record

1.
2.
3.

>>> rows = db(db.person.id > 2).select()
>>> row = rows[0]
>>> row.update_record(name='Curt')

This should not be confused with

1.

>>> row.update(name='Curt')

because for a single row, the method update updates the row object but not 
the database record, as in the case of update_record.




Re: [web2py] Re: Possible DB bug on update;

2011-01-27 Thread David J.

Darn; I missed that;

Thanks for the help;

I really thought I read the chapter through.

Thanks.



On 1/27/11 11:44 PM, ron_m wrote:

>From the DAL chapter of the manual


  |update_record|

update_record
web2py also allows updating a single record that is already in memory 
using |update_record|

1.
2.
3.

>>>  rows=db(db.person.id>  2).select()
>>>  row=rows[0]
>>>  row.update_record(name='Curt')

This should not be confused with

1.

>>>  row.update(name='Curt')

because for a single row, the method |update| updates the row object 
but not the database record, as in the case of |update_record|.



  |
  |






Re: [web2py] Re: Possible DB bug on update;

2011-01-27 Thread ron_m
It is quite a lot to learn, no problem. Glad I could help.


[web2py] image as background

2011-01-27 Thread mart
Hi,

Anybody know how to set an image as background  (would fit the entire
page)?

Thanks in advance,

Mart :)


[web2py] What is web2py best practice basis for modular site development?

2011-01-27 Thread JoeCodeswell
Dear web2py users,

I am developing a website that will have many features, some of which
are not yet specified by my client. Therefore and for other reasons, I
would like to develop it in a modular fashion.

Should I base my website on a web2py site with a single application,
with modularity achieved using Components and Plugins?

Would it be better and/or easier to have a multi-application web2py
site with a masterapp and CAS, along with shared layout, database,
session, etc.?

Do any of you have any other suggestions for web2py site development
modularity best practices?

Thanks for your help in advance.

Love and peace,

Joe


Re: [web2py] image as background

2011-01-27 Thread Kenneth Lundström
If you have a div that spans the whole page you can via css and 
background: url(../images/background.jpg) have a background.



Kenneth


Hi,

Anybody know how to set an image as background  (would fit the entire
page)?

Thanks in advance,

Mart :)




[web2py] Re: image as background

2011-01-27 Thread mart
Sweet!

Thanks for the tip! :)

On Jan 28, 1:50 am, Kenneth Lundström 
wrote:
> If you have a div that spans the whole page you can via css and
> background: url(../images/background.jpg) have a background.
>
> Kenneth
>
> Hi,
>
>
>
>
>
>
>
> > Anybody know how to set an image as background  (would fit the entire
> > page)?
>
> > Thanks in advance,
>
> > Mart :)


Re: [web2py] What is web2py best practice basis for modular site development?

2011-01-27 Thread Kenneth Lundström
My gut tells one application, having applications share layout, database 
and all is not piece of cake.


But I guess it depends on the application, but I would make it as one 
application.



Kenneth


Dear web2py users,

I am developing a website that will have many features, some of which
are not yet specified by my client. Therefore and for other reasons, I
would like to develop it in a modular fashion.

Should I base my website on a web2py site with a single application,
with modularity achieved using Components and Plugins?

Would it be better and/or easier to have a multi-application web2py
site with a masterapp and CAS, along with shared layout, database,
session, etc.?

Do any of you have any other suggestions for web2py site development
modularity best practices?

Thanks for your help in advance.

Love and peace,

Joe




[web2py] Re: PDF Reports with Pisa

2011-01-27 Thread mart
Just letting you now... I looking to see it in action (the custom
_code part looks really interesting), but am stumped as it tries to do
the local import ... it doesn't seem to see the plugin

On Jan 27, 4:30 am, mart  wrote:
> This is nice stuff!
>
> On Jan 26, 9:56 pm, "Lucas D'Avila"  wrote:
>
>
>
>
>
>
>
> > Hi!
>
> > I added support for Pisa [1] on appreport plugin [2], appreport now has two
> > engines to generate PDF documents: the pyfpdf and Pisa.
>
> > Simply import the appreport plugin in web2py and use, no need to install
> > other dependent packages.
>
> > --
>
> > Download and documentation, visit the wiki [3], i also added in the wiki, a
> > new example about how to generate complex reports, rendering the web2py
> > views (taking advantage of the ease embedding python code in views).
>
> > [1]http://www.xhtml2pdf.com/
> > [2]https://github.com/lucasdavila/plugin-appreport
> > [3]https://github.com/lucasdavila/plugin-appreport/wiki
>
> > Hug!
>
> > --
> > Lucas D'Avilahttp://flavors.me/lucasdavila