[web2py] Uploading a zip file

2011-04-05 Thread Paul Gerrard
I'm trying to export some files generated from my application and
provide them as a zip file to the user. I'm creating a zip file using
Python zipfile module and the zip file is created fine. Then I upload
that file to the DB to allow them to download it from the usual
uploads directory. The code snippet below works fine and a file is
uploaded, but the file is corrupted somehow.

db.py
db.define_table("exportitem",
SQLField("org_id", db.organisations, notnull=True,
writable=False, default=session.org_id),
SQLField("app_id", "integer", default=session.app_id,
notnull=True),
SQLField("proj_id", "integer", default=session.proj_id,
notnull=True),
SQLField("title", "string", length=50, notnull=True,
label="Title"),
SQLField("created", "datetime", notnull=True,
default=datetime.today(), label="Created", writable=False),
SQLField("created_by", db.auth_user, notnull=True,
default=session.user_id, writable=False),
SQLField("exportfile", "upload", notnull=True),
migrate=migrate,fake_migrate=fake_migrate)

testzip()
fname=''.join((str(session.org_id),str(datetime.today(
my_crypt = CRYPT(key=auth.settings.hmac_key)
zname = ''.join((my_crypt(fname)[0],'.zip'))

 
zfile='/'.join((request.env.web2py_path,'applications',request.application,'temp',zname))
#
# zipfile created here in temp directory
#

#
#   now store the file in the database.
#
zid=db.exportitem.insert(title='testing the zip file
generator',exportfile=db.exportitem.exportfile.store(open(zfile,'rb')))

The file stored in the uploads directory is corrupted - and not
identical to the original of course.

Am I missing something?


[web2py] Uploading a zip file

2011-04-05 Thread Paul Gerrard
I'm trying to export some files generated from my application. I'm
creating a zip file with the file in directly (using Python) and the
zip file is created fine. Then I want to upload that file to the DB to
allow them to download it from the uploads directory. The code snippet
below works fine and a file is uploaded, but the file is corrupted (it
has just a few hundred byeted in it.

db.py
db.define_table("exportitem",
SQLField("org_id", db.organisations, notnull=True,
writable=False, default=session.org_id),
SQLField("app_id", "integer", default=session.app_id,
notnull=True),
SQLField("proj_id", "integer", default=session.proj_id,
notnull=True),
SQLField("title", "string", length=50, notnull=True,
label="Title"),
SQLField("created", "datetime", notnull=True,
default=datetime.today(), label="Created", writable=False),
SQLField("created_by", db.auth_user, notnull=True,
default=session.user_id, writable=False),
SQLField("exportfile", "upload", notnull=True),
migrate=migrate,fake_migrate=fake_migrate)

testzip()
fname=''.join((str(session.org_id),str(datetime.today(
my_crypt = CRYPT(key=auth.settings.hmac_key)
zname = ''.join((my_crypt(fname)[0],'.zip'))

 
zfile='/'.join((request.env.web2py_path,'applications',request.application,'temp',zname))
#
#
#
#
#   now store the file in the database.
#
zid=db.exportitem.insert(title='testing the zip file
generator',exportfile=db.exportitem.exportfile.store(open(zfile,'rb')))


[web2py] Re: Putting logic back to controller

2011-04-05 Thread kedai


On Apr 5, 11:40 pm, Ross Peoples  wrote:
> You should really be joining the queries:
>
> records = db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL)
>
> Then in your view, you access this by using:
>
> {{for record in records:}}
>     {{=record.person.name}}: {{=record.cats.name}}
> {{pass}}

Thanks for the info.  Works great for web2py.  However not that great
if I deployed to gae.

Got this traceback:
ERROR2011-04-06 06:43:17,658 restricted.py:55] In FILE: /home/kdie/
projek/web2py/applications/init/controllers/my.py

Traceback (most recent call last):
  File "/home/kdie/projek/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
  File "/home/kdie/projek/web2py/applications/init/controllers/
my.py:e2011", line 72, in 
  File "/home/kdie/projek/web2py/gluon/globals.py", line 124, in

self._caller = lambda f: f()
  File "/home/kdie/projek/web2py/gluon/tools.py", line 2331, in f
return action(*a, **b)
  File "/home/kdie/projek/web2py/applications/init/controllers/
my.py:e2011", line 14, in e2011
  File "/home/kdie/projek/web2py/gluon/dal.py", line 5097, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "/home/kdie/projek/web2py/gluon/dal.py", line 2977, in select
(items, tablename, fields) =
self.select_raw(query,fields,attributes)
  File "/home/kdie/projek/web2py/gluon/dal.py", line 2926, in
select_raw
tablename = self.get_table(query)
  File "/home/kdie/projek/web2py/gluon/dal.py", line 962, in get_table
raise RuntimeError, "Too many tables selected"
RuntimeError: Too many tables selected

line 14 refers to records =
db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL,
orderby=db.cats.id)


[web2py] Re: PDF writing under GAE

2011-04-05 Thread andrej burja
hi

pyftpdf (included in web2py) does not have unicode support
does anybody know are there some unicode problems in reportlab too?
maby font problems?

i would like to see code example for reportlab on gae (since the
example in the book does not work :)

andrej


On Apr 5, 3:15 pm, Massimo Di Pierro 
wrote:
> It would be nice if fpdf were to work on GAE out of the box. Moreover
> I think PIL is available on GAE.
>
> On Apr 5, 5:19 am, Martín Mulone  wrote:
>
>
>
>
>
>
>
> > Well I browse the code of fpdf.py and pil is only using to check is the file
> > is and image format, I think is easy to do to support gae, changing in gae
> > to api or make the check like IS_IMAGE from web2py.
>
> > Anyways there are other tools you can use to write pdf reports like PISA,
> > Reportlab.
>
> > 2011/4/5 Arbie Samong 
>
> > > @martin - that helped me passed the try-except block at the beginning,
> > > but when the Image module is used on the other parts of the code it
> > > went haywire. I'll look into it probably more changes to make it adapt
> > > with GAE.
>
> > > @howesc - I was able to make it work without using the file system
> > > read and write, but this is like heaven sent :)
>
> > > On Apr 5, 3:11 am, howesc  wrote:
> > > > hopefully not a red herring, but google gave us gifts last week, one of
> > > them
> > > > was file "reading" and "writing" from the blobstore:
> > >http://googleappengine.blogspot.com/2011/03/announcing-app-engine-143...
>
> > > > i have not looked at how to connect things to it, but might help here.
>
> > > > cfh
>
> > --
> > My blog:http://martin.tecnodoc.com.ar
> > Expert4Solution:http://www.experts4solutions.com/e4s/default/expert/6http://www.cvsta...


[web2py] Re: rawsql & like operator

2011-04-05 Thread cyber
Denes, you opened my eyes to me again.
***
I tried to use %%s%% and there was an error message.
So, the only one character % separated me from the correct result!

And say what way is more preferable to use: db.select() or
db.executesql() ?

By the way, thank you very much!
***

On 5 апр, 23:48, DenesL  wrote:
> ... or the equivalent raw sql
>
> results=db.executesql("SELECT * FROM autos WHERE num LIKE %%%s%%;"
> %n)
>
> On Apr 5, 4:45 pm, DenesL  wrote:
>
>
>
>
>
>
>
> > I believe you want
>
> > results=db(db.autos.num.contains(n)).select()
>
> > On Apr 5, 3:58 pm, cyber  wrote:
>
> > > I need a hint!
>
> > > It seems that LIKE operator doesn't work.Or... I'm not so clever
> > > human...
>
> > > Say, how can I deal with rawsql query? I need to find all records but
> > > I know only some part of exact value. The code:
>
> > > n=request.vars.num  ### it returns only number
> > > results=db.executesql("SELECT * FROM autos WHERE num LIKE %s;" %(n))
> > > ### select
> > > return dict(results=results) ### it returns rows with exact n values
> > > only
>
> > > ... how can I find all records (not only n) including missed nums and
> > > chars?


[web2py] Re: web2py/poweredby problem

2011-04-05 Thread guruyaya
Awsome!

On Apr 5, 4:14 pm, Massimo Di Pierro 
wrote:
> was a design issue. changed.
>
> On Apr 5, 4:15 am, Kenneth Lundström 
> wrote:
>
> > Why is there no link to poweredby page on the frontpage or did I miss it?
>
> > That sounds strange that you have to login, I don t know why. But if you
> > click on the name below the screencapture of the site you don t have to
> > login.
>
> > Kenneth
>
> > > I've been looking aroundhttp://www.web2py.com/poweredbysection, and
> > > decided to go into one of the websites. I don't get why it asked me to
> > > log in, but I can understand this is website policy. The problem I had
> > > was this.
> > > Examine this url:
> > >http://web2py.com/poweredby/default/user/login?_next=/poweredby/defau...
> > > After logging in, via openid OR google, it redirected me to the index,
> > > not to the website I wanted to see. I had to look for it all over
> > > again. Not cool.
>
> > > Hope you can get it to work better.
>
> > > Yaya
>
>


[web2py] Re: Modularity

2011-04-05 Thread pierreth
On 5 avr, 22:38, pbreit  wrote:
> Applications are totally discrete so there would be no chance of a collision
> (if I understand correctly).
>
> app1
>     modules
>         mypackage1
>
> app2
>     modules
>         mypackage2
>
> Nothing in app1 knows about anything app2 (and vice versa).

The 'modules' directory is not in the Python path so we have to use
local_import to load them.

The applications are not so discrete because they share the same
process and the same modules.

I found that I cannot import from a package to get a module in another
package in the same "modules" directory if I don't use a relative
import. So I do:

import sys

if sys.argv[0] != "web2py.py":
import p2
else:
from .. import p2

This way my module will use an absolute import, the Python
recommendation, if used outside of web2py and a relative import when
used in web2py.

But the Pydev static analyzer is giving me an error. This looks like a
bug because the code is working well.

>
> If you don't want to maintain two copies of the same code, you could put it
> in "site-packages" in the "web2py" directory. That folder is accessible by
> any of your apps.

Yes but I would like my applications to be self-contain so I prefer to
use the "modules" directory.


Re: [web2py] Re: Python Message Queue

2011-04-05 Thread pbreit
Was anyone able to make any progress with Celery? I am very interested as I 
am not having much luck with cron and background processes.

[web2py] Re: Modularity

2011-04-05 Thread pbreit
Applications are totally discrete so there would be no chance of a collision 
(if I understand correctly).

app1
modules
mypackage1

app2
modules
mypackage2

Nothing in app1 knows about anything app2 (and vice versa).

If you don't want to maintain two copies of the same code, you could put it 
in "site-packages" in the "web2py" directory. That folder is accessible by 
any of your apps.


[web2py] Re: Adding a Widget to a simple FORM() input()

2011-04-05 Thread DenesL

OK, now I understand.
I would modify web2py_ajax.html at the beginning to include:

response.files.append("http://ajax.googleapis.com/ajax/libs/jqueryui/
1.7.2/jquery-ui.js")

or a similar line, and then in the web2py_ajax_init function add:

jQuery('input.jqdate').datepicker({dateFormat:'yy-mm-dd'})

after that you can _class="jddate" your INPUT fields.



On Apr 5, 9:13 pm, Lennon  wrote:
> I am aware of that method but I really don't like the default date and
> datetime widget.
>
> I want to use the one from that web2py slice.
>
> On Apr 5, 7:12 pm, DenesL  wrote:
>
>
>
>
>
>
>
> > Just add _class="date" to your INPUT field definition.
>
> > On Apr 5, 5:58 pm, Lennon  wrote:
>
> > > I'm trying to add the jquery UI datepicker from this web2py 
> > > slice:http://web2pyslices.com/main/slices/take_slice/22
>
> > > It works well with SQLFORM, but I want to use it on a form I've
> > > defined with the FORM() helper.
>
> > > Is there a way to do this using a simple syntax similar to the
> > > widget=date_widget syntax?
>
> > > Do I have to somehow change the default way an input with a class of
> > > "date" is rendered?
>
> > > Do I just have to do a normal integration using css?
>
> > > Thanks for any help you can give.


[web2py] Re: Modularity

2011-04-05 Thread pierreth
Oups! It does like that it does not work. I was loading old code in my
tests. The modules were not reloaded. I have to find another
solution...

On 5 avr, 22:04, pierreth  wrote:
> I wanted to share code from one web2py application to another.
>
> So I created two packages with the same name in two different web2py
> applications. I load the code of the package modules with local_import
> from the controllers of both application. The two applications are
> having almost the same packages in their "modules" directories. The
> names of the modules are the same but the code is a little bit
> different. Here, I am trying to have name collisions on purpose.
>
> I was expecting collisions because the packages in the 'modules'
> directories of my applications are using standard python imports. But
> no, I have no collision based on my tests even if my packages are
> referencing other packages also located in the "modules" directory.
>
> Is it really safe to do what I do? It is a bit magical.


[web2py] Problem with error_message in routes.py

2011-04-05 Thread pbreit
I uncommented the "error_message" config in my global routes.py file and it 
broke my whole site. It seemed to block stylesheets from loading but some 
site content actually did load. "error_message_ticket" works OK. Is anyone 
using this successfully?

[web2py] Create a new window.

2011-04-05 Thread Mike Veltman

Well as a beginner with web2py I first have to say that I like it. So thank 
you to all the people who work on it.

I am also a beginner with Python so do not expect very complicated questions 
(yet)

Well I am building a application to deploy AIX unix installs on power 
machines. My application creates the logical volumes on the storage, creates 
the virtual machines and starts the deployments. Its all coordinated with 
web2py.

Now my question.

When I start a deployment the function could take a while and one solution 
would be to create a new window with the status of the deployment. Would it be 
possible to spawn a separate window and let the original form go on ?

Thanks in advance.

Mike Veltman


[web2py] Modularity

2011-04-05 Thread pierreth
I wanted to share code from one web2py application to another.

So I created two packages with the same name in two different web2py
applications. I load the code of the package modules with local_import
from the controllers of both application. The two applications are
having almost the same packages in their "modules" directories. The
names of the modules are the same but the code is a little bit
different. Here, I am trying to have name collisions on purpose.

I was expecting collisions because the packages in the 'modules'
directories of my applications are using standard python imports. But
no, I have no collision based on my tests even if my packages are
referencing other packages also located in the "modules" directory.

Is it really safe to do what I do? It is a bit magical.


[web2py] Re: auto-update/refresh content

2011-04-05 Thread mart
Thanks for the replies! :) May be fun to compare...   If all goes, i
can do this tonight (maybe)

Thanks guys!

Mart :)

On Apr 5, 9:20 pm, David Warnock  wrote:
> > Note, if you're using Comet/long-polling techniques, I think it keeps a
> > request open for a long time, so if you're using a server that blocks a
> > thread for each request, you could run out of threads if you have lots of
> > users connected at once. In that case, you may need to look into a
> > non-blocking server that can handle lots of open connections.
>
> I guess following the other thread that not blocking with the session would
> be an especially good idea in this situation.
>
> Dave
>
> --
> Dave Warnock:http://42.blogs.warnock.me.uk
> Cycling Blog:http://42bikes.warnock.me.uk


[web2py] Re: Require login for whole application

2011-04-05 Thread pbreit
Slight correction:

if auth.user is None:
redirect(URL('default','user', args='login'))

And if you want "next" functionality (not tested):

if auth.user is None:
redirect(URL('default','user', args='login', vars={'_next': request.url}
))


Re: [web2py] Re: auto-update/refresh content

2011-04-05 Thread David Warnock
>
> Note, if you're using Comet/long-polling techniques, I think it keeps a
> request open for a long time, so if you're using a server that blocks a
> thread for each request, you could run out of threads if you have lots of
> users connected at once. In that case, you may need to look into a
> non-blocking server that can handle lots of open connections.
>

I guess following the other thread that not blocking with the session would
be an especially good idea in this situation.

Dave

-- 
Dave Warnock: http://42.blogs.warnock.me.uk
Cycling Blog: http://42bikes.warnock.me.uk


[web2py] Re: auto-update/refresh content

2011-04-05 Thread Anthony
I think that's another term for Comet, which is just a general term for 
various server push techniques: 
http://en.wikipedia.org/wiki/Comet_(programming)
 
Note, if you're using Comet/long-polling techniques, I think it keeps a 
request open for a long time, so if you're using a server that blocks a 
thread for each request, you could run out of threads if you have lots of 
users connected at once. In that case, you may need to look into a 
non-blocking server that can handle lots of open connections.
 
You might also look at the web2py comet_messaging.py in /gluon/contrib. It 
uses the new HTML5 WebSockets (so technically I guess it's not actually 
Comet) and the Tornado web server (which is non-blocking, so can handle lots 
of open connections). Note, it won't work in older browsers, including IE8 
and earlier.
 
Anthony

On Tuesday, April 5, 2011 8:01:23 PM UTC-4, mart wrote:

> reverse ajax, eh? alright, then I think it should be reversed! :)  Of 
> course I usually start anything with the word "reversed" in it with 
> large pot of of coffee! 
>
> stay tuned! 
>
> thanks, 
> Mart :) 
>
> On Apr 5, 7:23 pm, DenesL  wrote: 
> > There is something called reverse ajax, one site explaining the 
> > technique ishttp://www.obviously.com/tech_tips/slow_load_technique 
> > 
> > I have not had the need for it but I would like to hear from you if 
> > you get around to use it. 
> > 
> > On Apr 5, 5:21 pm, mart  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Wow! didn't know that - You know, there is so much out there, that we 
> > > (well, me for sure) rarely take the time to discover things fully. I 
> > > love that when I know in advance that there is something to be had by 
> > > sticking to something and looking deeper than we (me) usually would! 
> > 
> > > Thanks for the tip, I will certainly look into this :) 
> > 
> > > Mart 
> > 
> > > On Apr 5, 10:31 am, Ross Peoples  wrote: 
> > 
> > > > That's basically how it works. Although as you learn more about AJAX, 
> you'll 
> > > > find that there are a bunch of different ways to do this, including 
> more 
> > > > 2-way types of communication, where you would do something with the 
> data 
> > > > returned from the controller before or after displaying it on the 
> page. Once 
> > > > you start to open your mind a bit and get the hang of how it all 
> works, 
> > > > you'll start to figure out some really cool ways to tackle problems.



[web2py] Re: Adding a Widget to a simple FORM() input()

2011-04-05 Thread Lennon
I am aware of that method but I really don't like the default date and
datetime widget.

I want to use the one from that web2py slice.

On Apr 5, 7:12 pm, DenesL  wrote:
> Just add _class="date" to your INPUT field definition.
>
> On Apr 5, 5:58 pm, Lennon  wrote:
>
>
>
>
>
>
>
> > I'm trying to add the jquery UI datepicker from this web2py 
> > slice:http://web2pyslices.com/main/slices/take_slice/22
>
> > It works well with SQLFORM, but I want to use it on a form I've
> > defined with the FORM() helper.
>
> > Is there a way to do this using a simple syntax similar to the
> > widget=date_widget syntax?
>
> > Do I have to somehow change the default way an input with a class of
> > "date" is rendered?
>
> > Do I just have to do a normal integration using css?
>
> > Thanks for any help you can give.


[web2py] Re: Error messages for radio validation

2011-04-05 Thread bluemoth
Hi,

I originally thought the FIELDSET might hold the solution but no.
Maybe it can be used.

Otherwise, I think the solution might be to recognise that the radio
buttons relate to the same field and treat them as a group. But we
still need an appropriate place/target to report the error. This could
be after the last input (radio button) or a defined target in the
validator e.g., require=IS_NOT_EMPTY(error_target='target')

It's not an urgent issue. I did some searching and couldn't find the
solution. I will want to overcome this later but don't want to
implement my own solution if one exists or can be added.

Cheers, Duane.

On Apr 6, 12:55 pm, bluemoth  wrote:
> Thanks DenesL,
>
> It was probably the wrong example. I simplified my case but in my case
> I do expect errors to be reported so I was wanting to group the error
> messages for the radio buttons into one message.
>
> Cheers, Duane.
>
> On Apr 6, 10:56 am, DenesL  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > to eliminate the possibility of an error message, I would rewrite as:
>
> > db.languages.language.default = 'english' # or any other in the list
> > db.languages.language.requires = IS_IN_SET(['english', 'french',
> > 'german'])
> > db.languages.language.widget = SQLFORM.widgets.radio.widget
>
> > On Apr 5, 6:32 pm, bluemoth  wrote:
>
> > > Hello all,
>
> > > If I have the following:
> > > db.define_table('languages', Field('language', 'string'))
>
> > > db.languages.language.requires = \
> > >                 [IS_IN_SET(['english', 'french', 'german']), \
> > >                  IS_NOT_EMPTY(error_message='Value required')]
> > > db.languages.language.widget = SQLFORM.widgets.radio.widget
>
> > > and I render a form that when submitted has no entry, it places an
> > > error message under each radio button.
>
> > > Is there a way to present the one error message for the entire group
> > > of radio buttons?
>
> > > Thanks for you help.
>
> > > Cheers, Duane.


[web2py] Re: Error messages for radio validation

2011-04-05 Thread bluemoth
Thanks DenesL,

It was probably the wrong example. I simplified my case but in my case
I do expect errors to be reported so I was wanting to group the error
messages for the radio buttons into one message.

Cheers, Duane.

On Apr 6, 10:56 am, DenesL  wrote:
> Hello,
>
> to eliminate the possibility of an error message, I would rewrite as:
>
> db.languages.language.default = 'english' # or any other in the list
> db.languages.language.requires = IS_IN_SET(['english', 'french',
> 'german'])
> db.languages.language.widget = SQLFORM.widgets.radio.widget
>
> On Apr 5, 6:32 pm, bluemoth  wrote:
>
>
>
>
>
>
>
> > Hello all,
>
> > If I have the following:
> > db.define_table('languages', Field('language', 'string'))
>
> > db.languages.language.requires = \
> >                 [IS_IN_SET(['english', 'french', 'german']), \
> >                  IS_NOT_EMPTY(error_message='Value required')]
> > db.languages.language.widget = SQLFORM.widgets.radio.widget
>
> > and I render a form that when submitted has no entry, it places an
> > error message under each radio button.
>
> > Is there a way to present the one error message for the entire group
> > of radio buttons?
>
> > Thanks for you help.
>
> > Cheers, Duane.


Re: [web2py] too many redirect during checking condition

2011-04-05 Thread Stifan Kristi
it clear for me right now, thank you so much


On Wed, Apr 6, 2011 at 7:02 AM, Martín Mulone wrote:

> @auth.requires_login()
> def index():
>return dict(message=T('Hello World'))
>
> 2011/4/5 黄祥 
>
>> hi,
>>
>> i want to use condition that if user not log in will redirect to login
>> page, and if logged in will redirect to index page, heres my
>> controller :
>>
>> if not session.authorized:
>>redirect(URL('user'))
>> else:
>>redirect(URL('index'))
>>
>> def index():
>>return dict(message=T('Hello World'))
>>
>> def user():
>>return dict(form = auth())
>>
>> i know there is a mistook code on my own, could there anybody show me
>> where is the wrong part?
>> i've tried the other code too, but got the same result :
>>
>> if not auth.is_logged_in():
>>redirect(URL('user'))
>> else:
>>redirect(URL('index'))
>>
>> def index():
>>return dict(message=T('Hello World'))
>>
>> def user():
>>return dict(form = auth())
>>
>> thank you so much before
>
>
>
>
> --
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
> http://www.cvstash.com/profile/Xzi5bWCdD
>
>
>


[web2py] Re: Worked with joined data

2011-04-05 Thread pbreit
Yeah, I was trying to avoid the "row.table" thing. Not a big issue, just 
wondering.

Re: [web2py] too many redirect during checking condition

2011-04-05 Thread Martín Mulone
@auth.requires_login()
def index():
   return dict(message=T('Hello World'))

2011/4/5 黄祥 

> hi,
>
> i want to use condition that if user not log in will redirect to login
> page, and if logged in will redirect to index page, heres my
> controller :
>
> if not session.authorized:
>redirect(URL('user'))
> else:
>redirect(URL('index'))
>
> def index():
>return dict(message=T('Hello World'))
>
> def user():
>return dict(form = auth())
>
> i know there is a mistook code on my own, could there anybody show me
> where is the wrong part?
> i've tried the other code too, but got the same result :
>
> if not auth.is_logged_in():
>redirect(URL('user'))
> else:
>redirect(URL('index'))
>
> def index():
>return dict(message=T('Hello World'))
>
> def user():
>return dict(form = auth())
>
> thank you so much before




-- 
My blog: http://martin.tecnodoc.com.ar
Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
http://www.cvstash.com/profile/Xzi5bWCdD


[web2py] Re: auto-update/refresh content

2011-04-05 Thread mart
reverse ajax, eh? alright, then I think it should be reversed! :)  Of
course I usually start anything with the word "reversed" in it with
large pot of of coffee!

stay tuned!

thanks,
Mart :)

On Apr 5, 7:23 pm, DenesL  wrote:
> There is something called reverse ajax, one site explaining the
> technique ishttp://www.obviously.com/tech_tips/slow_load_technique
>
> I have not had the need for it but I would like to hear from you if
> you get around to use it.
>
> On Apr 5, 5:21 pm, mart  wrote:
>
>
>
>
>
>
>
> > Wow! didn't know that - You know, there is so much out there, that we
> > (well, me for sure) rarely take the time to discover things fully. I
> > love that when I know in advance that there is something to be had by
> > sticking to something and looking deeper than we (me) usually would!
>
> > Thanks for the tip, I will certainly look into this :)
>
> > Mart
>
> > On Apr 5, 10:31 am, Ross Peoples  wrote:
>
> > > That's basically how it works. Although as you learn more about AJAX, 
> > > you'll
> > > find that there are a bunch of different ways to do this, including more
> > > 2-way types of communication, where you would do something with the data
> > > returned from the controller before or after displaying it on the page. 
> > > Once
> > > you start to open your mind a bit and get the hang of how it all works,
> > > you'll start to figure out some really cool ways to tackle problems.


[web2py] Re: Worked with joined data

2011-04-05 Thread DenesL


On Apr 5, 7:05 pm, pbreit  wrote:
> Is there some way to work with joined data like this?
>
> rows = ((db.item.status=='active') &
>             (db.item.created_by==db.auth_user.id)).select()
>
> return (rows=rows)
>
> {{for item, user in rows.item, rows.auth_user:}}
>     {{=item.id}} by {{=user.first_name}}
> {{pass}}
>
> I'm not sure if it's possible or how to do this part:
>
>      {{for item, user in rows.item, rows.user:}}


I believe you want:

{{for row in rows:}}
  {{=row.item.id}} by {{=row.auth_user.first_name}}
{{pass}}


[web2py] too many redirect during checking condition

2011-04-05 Thread 黄祥
hi,

i want to use condition that if user not log in will redirect to login
page, and if logged in will redirect to index page, heres my
controller :

if not session.authorized:
redirect(URL('user'))
else:
redirect(URL('index'))

def index():
return dict(message=T('Hello World'))

def user():
return dict(form = auth())

i know there is a mistook code on my own, could there anybody show me
where is the wrong part?
i've tried the other code too, but got the same result :

if not auth.is_logged_in():
redirect(URL('user'))
else:
redirect(URL('index'))

def index():
return dict(message=T('Hello World'))

def user():
return dict(form = auth())

thank you so much before


[web2py] Re: Join breaks virtual fields in the new web2py

2011-04-05 Thread pbreit
There's no way to use trunk with the Mac download, correct?

[web2py] Re: auto-update/refresh content

2011-04-05 Thread DenesL

There is something called reverse ajax, one site explaining the
technique is
http://www.obviously.com/tech_tips/slow_load_technique

I have not had the need for it but I would like to hear from you if
you get around to use it.


On Apr 5, 5:21 pm, mart  wrote:
> Wow! didn't know that - You know, there is so much out there, that we
> (well, me for sure) rarely take the time to discover things fully. I
> love that when I know in advance that there is something to be had by
> sticking to something and looking deeper than we (me) usually would!
>
> Thanks for the tip, I will certainly look into this :)
>
> Mart
>
> On Apr 5, 10:31 am, Ross Peoples  wrote:
>
>
>
>
>
>
>
> > That's basically how it works. Although as you learn more about AJAX, you'll
> > find that there are a bunch of different ways to do this, including more
> > 2-way types of communication, where you would do something with the data
> > returned from the controller before or after displaying it on the page. Once
> > you start to open your mind a bit and get the hang of how it all works,
> > you'll start to figure out some really cool ways to tackle problems.


[web2py] Re: Adding a Widget to a simple FORM() input()

2011-04-05 Thread DenesL

Just add _class="date" to your INPUT field definition.


On Apr 5, 5:58 pm, Lennon  wrote:
> I'm trying to add the jquery UI datepicker from this web2py 
> slice:http://web2pyslices.com/main/slices/take_slice/22
>
> It works well with SQLFORM, but I want to use it on a form I've
> defined with the FORM() helper.
>
> Is there a way to do this using a simple syntax similar to the
> widget=date_widget syntax?
>
> Do I have to somehow change the default way an input with a class of
> "date" is rendered?
>
> Do I just have to do a normal integration using css?
>
> Thanks for any help you can give.


[web2py] Worked with joined data

2011-04-05 Thread pbreit
Is there some way to work with joined data like this?

rows = ((db.item.status=='active') &
(db.item.created_by==db.auth_user.id)).select()
return (rows=rows)

{{for item, user in rows.item, rows.auth_user:}}
{{=item.id}} by {{=user.first_name}}
{{pass}}

I'm not sure if it's possible or how to do this part:

 {{for item, user in rows.item, rows.user:}}


[web2py] Re: Error messages for radio validation

2011-04-05 Thread DenesL
Hello,

to eliminate the possibility of an error message, I would rewrite as:

db.languages.language.default = 'english' # or any other in the list
db.languages.language.requires = IS_IN_SET(['english', 'french',
'german'])
db.languages.language.widget = SQLFORM.widgets.radio.widget



On Apr 5, 6:32 pm, bluemoth  wrote:
> Hello all,
>
> If I have the following:
> db.define_table('languages', Field('language', 'string'))
>
> db.languages.language.requires = \
>                 [IS_IN_SET(['english', 'french', 'german']), \
>                  IS_NOT_EMPTY(error_message='Value required')]
> db.languages.language.widget = SQLFORM.widgets.radio.widget
>
> and I render a form that when submitted has no entry, it places an
> error message under each radio button.
>
> Is there a way to present the one error message for the entire group
> of radio buttons?
>
> Thanks for you help.
>
> Cheers, Duane.


[web2py] Error messages for radio validation

2011-04-05 Thread bluemoth
Hello all,

If I have the following:
db.define_table('languages', Field('language', 'string'))

db.languages.language.requires = \
[IS_IN_SET(['english', 'french', 'german']), \
 IS_NOT_EMPTY(error_message='Value required')]
db.languages.language.widget = SQLFORM.widgets.radio.widget

and I render a form that when submitted has no entry, it places an
error message under each radio button.

Is there a way to present the one error message for the entire group
of radio buttons?

Thanks for you help.

Cheers, Duane.


[web2py] z index of plugin mmodal and youtube

2011-04-05 Thread kawate
Hello every body:

I have youtube video over the mmodal window in a plugin wiki page.
How to change plugin_wiki elements.
Is there hidden parameter in widget?

It is nice to control the z index of page element.

Thank you in advance.


[web2py] Adding a Widget to a simple FORM() input()

2011-04-05 Thread Lennon
I'm trying to add the jquery UI datepicker from this web2py slice:
http://web2pyslices.com/main/slices/take_slice/22

It works well with SQLFORM, but I want to use it on a form I've
defined with the FORM() helper.

Is there a way to do this using a simple syntax similar to the
widget=date_widget syntax?

Do I have to somehow change the default way an input with a class of
"date" is rendered?

Do I just have to do a normal integration using css?

Thanks for any help you can give.


[web2py] Re: auto-update/refresh content

2011-04-05 Thread mart
Wow! didn't know that - You know, there is so much out there, that we
(well, me for sure) rarely take the time to discover things fully. I
love that when I know in advance that there is something to be had by
sticking to something and looking deeper than we (me) usually would!

Thanks for the tip, I will certainly look into this :)

Mart


On Apr 5, 10:31 am, Ross Peoples  wrote:
> That's basically how it works. Although as you learn more about AJAX, you'll
> find that there are a bunch of different ways to do this, including more
> 2-way types of communication, where you would do something with the data
> returned from the controller before or after displaying it on the page. Once
> you start to open your mind a bit and get the hang of how it all works,
> you'll start to figure out some really cool ways to tackle problems.


[web2py] Re: Require login for whole application

2011-04-05 Thread pbreit
And maybe add something like: vars={'_next': request.url} to the URL()

[web2py] Re: rawsql & like operator

2011-04-05 Thread DenesL
... or the equivalent raw sql

results=db.executesql("SELECT * FROM autos WHERE num LIKE %%%s%%;"
%n)


On Apr 5, 4:45 pm, DenesL  wrote:
> I believe you want
>
> results=db(db.autos.num.contains(n)).select()
>
> On Apr 5, 3:58 pm, cyber  wrote:
>
>
>
>
>
>
>
> > I need a hint!
>
> > It seems that LIKE operator doesn't work.Or... I'm not so clever
> > human...
>
> > Say, how can I deal with rawsql query? I need to find all records but
> > I know only some part of exact value. The code:
>
> > n=request.vars.num  ### it returns only number
> > results=db.executesql("SELECT * FROM autos WHERE num LIKE %s;" %(n))
> > ### select
> > return dict(results=results) ### it returns rows with exact n values
> > only
>
> > ... how can I find all records (not only n) including missed nums and
> > chars?


[web2py] Re: rawsql & like operator

2011-04-05 Thread DenesL

I believe you want

results=db(db.autos.num.contains(n)).select()


On Apr 5, 3:58 pm, cyber  wrote:
> I need a hint!
>
> It seems that LIKE operator doesn't work.Or... I'm not so clever
> human...
>
> Say, how can I deal with rawsql query? I need to find all records but
> I know only some part of exact value. The code:
>
> n=request.vars.num  ### it returns only number
> results=db.executesql("SELECT * FROM autos WHERE num LIKE %s;" %(n))
> ### select
> return dict(results=results) ### it returns rows with exact n values
> only
>
> ... how can I find all records (not only n) including missed nums and
> chars?


[web2py] rawsql & like operator

2011-04-05 Thread cyber
I need a hint!

It seems that LIKE operator doesn't work.Or... I'm not so clever
human...

Say, how can I deal with rawsql query? I need to find all records but
I know only some part of exact value. The code:

n=request.vars.num  ### it returns only number
results=db.executesql("SELECT * FROM autos WHERE num LIKE %s;" %(n))
### select
return dict(results=results) ### it returns rows with exact n values
only

... how can I find all records (not only n) including missed nums and
chars?


[web2py] Re: Require login for whole application

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 3:13:22 PM UTC-4, Ross Peoples wrote: 
>
> Using the @auth.requires_login() on every function is the only way I know 
> of. However, you may be able to put something like this at the top of each 
> controller: 
>
> if auth.user is None:
> redirect(URL('default', 'login'))
>
> However, it might cause a problem if you put that in your default 
> controller. In this case, you'd still want to use the decorator for each 
> action in the default controller, but all of your other controllers should 
> work with this at the top.
>
 
Alternatively, maybe put something like this your model file (right after 
auth is defined):
 
if not auth.user_id and not (request.controller=='default' and 
request.function=='user'):
redirect(URL('default', 'user'))
 
That will redirect to the login page if the current user isn't logged in, 
unless the current request is already for the login page.
 
Anthony


[web2py] Re: Require login for whole application

2011-04-05 Thread Ross Peoples
Using the @auth.requires_login() on every function is the only way I know 
of. However, you may be able to put something like this at the top of each 
controller:

if auth.user is None:
redirect(URL('default', 'login'))

However, it might cause a problem if you put that in your default 
controller. In this case, you'd still want to use the decorator for each 
action in the default controller, but all of your other controllers should 
work with this at the top.


[web2py] Re: HTML tags vs HTML?

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 1:52:48 PM UTC-4, VP wrote: 
>
>
>
> On Apr 5, 11:09 am, Massimo Di Pierro  
> wrote: 
> > My rule is: 
> > 
> > - use html in views 
> > - use html helpers in controllers and models 
> > - always use URL to generate urls (*) 
>
>
> Should HTML helpers appear frequently in controllers/models?   I can 
> see in some ajax stuffs, but other than that, probably not much?  If 
> true, how useful are html helpers?  Just a thought.

 
Good point. Note, the FORM and SQLFORM helpers are obviously heavily used, 
and they comprise many other helpers, such as table helpers, DIV, etc. You 
can also use the TAG helper to parse HTML into a tree structure of helpers 
and then do server-side DOM parsing with the helpers.


Re: [web2py] Re: web2py DAL, requests, threads and memory

2011-04-05 Thread Vasile Ermicioi
I think DAL connection  was  designed with web2py design in mind:
on each request a controller is executed and also are executed all models
files including database connection,
and after request memory is freed and connection close,

I used it successfully in a long running app with a few hundreads of
greenthreads (gevent), but I forced a close after each db query
db._adapter.connection.close()

and app always consumes less that 70Mb of RAM


[web2py] Re: web2py DAL, requests, threads and memory

2011-04-05 Thread Mengu
you can create a new request class extending from the original one and
via using config.set_request_factory(YourReqClass)and make dal an
attribute of it. whenever the request ends, you can close the
connection.

On Apr 5, 7:29 pm, Gleb  wrote:
> Hi All,
>
> I'm building an app on Pyramid framework and would like to use the
> web2py-DAL with it. Pyramid makes every request in a single thread, so
> how should I manage the DAL object?
>
> Should it be created once and then passed to every thread? If I do so
> and some frequent queries are passed to the DAL (simple reads by
> SELECT), I  get errors like "invalid cursor state", "cannot close a
> closed cursor" and so on. That is because a single cursor is accessed
> form different threads, so one thread closes the cursor while the
> other assumes it to be open.
>
> Should the DAL object be created on each request(like root =
> DAL("sqlite://blah"))? If I do so, the cursor state errors go, but a
> memory problem appears. Each request allocates memory for a new DAL
> object and that memory is never released. After some dozens requests
> I've got some hundredths MB of wasted memory.
>
> How is the thread per request - DAL access managed by the web2py?
>
> Thanks!


Re: [web2py] Re: HTML tags vs HTML?

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 10:52 AM, VP wrote:
> 
> On Apr 5, 11:09 am, Massimo Di Pierro 
> wrote:
>> My rule is:
>> 
>> - use html in views
>> - use html helpers in controllers and models
>> - always use URL to generate urls (*)
> 
> 
> Should HTML helpers appear frequently in controllers/models?   I can
> see in some ajax stuffs, but other than that, probably not much?  If
> true, how useful are html helpers?  Just a thought.

It's up to you. Some of the helpers do quite a bit more than output the html 
tags.

[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread Anthony
https://groups.google.com/d/topic/web2py/HkkZ_-kMUYE/discussion

On Tuesday, April 5, 2011 1:55:35 PM UTC-4, pbreit wrote:

> I think we need a new repository for information. I'm not sure Slices is 
> quite the right approach. A wiki might work better.



[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread pbreit
I think we need a new repository for information. I'm not sure Slices is 
quite the right approach. A wiki might work better.

[web2py] Re: HTML tags vs HTML?

2011-04-05 Thread VP


On Apr 5, 11:09 am, Massimo Di Pierro 
wrote:
> My rule is:
>
> - use html in views
> - use html helpers in controllers and models
> - always use URL to generate urls (*)


Should HTML helpers appear frequently in controllers/models?   I can
see in some ajax stuffs, but other than that, probably not much?  If
true, how useful are html helpers?  Just a thought.



[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 12:51:46 PM UTC-4, pbreit wrote: 
>
> Perception is reality, even more so on these topics.

 
Yeah, maybe instead of flashing a warning, the FAQ should just include dates 
on the postings.


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 1:19:04 PM UTC-4, Jonathan Lundell wrote: 
>
> On Apr 5, 2011, at 9:55 AM, Anthony wrote:
> > Yes, that's a race condition with writing. My point was that even if the 
> first action is merely reading (but not doing any writing), you can have 
> problems. For example:
> >  
> > Action 1: read session
> > Action 2: read session
> > Action 2: write session
> > Action 1: make some decision/calculation based on session data that is no 
> longer up to date
> > 
>
> Actually, I don't see that sequence as a real problem, because the result 
> is identical to this sequence: 
>
> Action 1: read session
> Action 1: make some decision/calculation based on session data that 
> predates write-2
> Action 2: read session
> Action 2: write session 
>
> That is, action 1 shouldn't rely on the timing of action 2. If only one of 
> the actions is writing, then they both have a consistent view of the 
> session.
>
I'm saying Action 1 might depend on having up-to-date session data in order 
to return a correct result, so Action 1 might want to prevent Action 2 from 
happening until Action 1 is complete. In other words, Action 1 may need to 
assume that no additional Action 2's are happening in between the time it 
reads the session and the time it renders its result. Granted, probably not 
a common problem, and probably not as big a deal as a race condition on 
writing.


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 8:26 AM, VP wrote:
> 
> 
>> read-1
>> read-2
>> write-2
>> write-1
>> 
>> ...so any changes #2 makes are lost.
> 
> I think this sequence is okay, as long as the write's are atomic and
> they use up-to-date information.
> 
> It would be undesirable for read-1 to extract a variable and to update
> it with write-1.  But if write-1 manipulates variables atomically,
> then we  don't problems.  Consider a simple example with a counter
> like this.
> 
> 
> a = read-1
> b = read-2
> write-2.update(counter = counter + 1, a = "hello")
> write-1.update(counter = counter + 1)

Unless by "update" you mean that the agent re-reads the session file under the 
write lock, the above sequence will only increment counter once.

> 
> We don't have any problem.  I think databases automatically take care
> of these synchronization.  Even if process 1 does  something with "a",
> after process 2 modifies it.  Conceptually, that should be okay.
> Information process 1 gets is stale, but that's life.
> 
> I don't think this is a problem either:
> 
>>> A database ... would not automatically handle locking
>>> while an application function is potentially manipulating the session (prior
>>> to updating it in the database).
> 




[web2py] web2py DAL, requests, threads and memory

2011-04-05 Thread Gleb
Hi All,

I'm building an app on Pyramid framework and would like to use the
web2py-DAL with it. Pyramid makes every request in a single thread, so
how should I manage the DAL object?

Should it be created once and then passed to every thread? If I do so
and some frequent queries are passed to the DAL (simple reads by
SELECT), I  get errors like "invalid cursor state", "cannot close a
closed cursor" and so on. That is because a single cursor is accessed
form different threads, so one thread closes the cursor while the
other assumes it to be open.

Should the DAL object be created on each request(like root =
DAL("sqlite://blah"))? If I do so, the cursor state errors go, but a
memory problem appears. Each request allocates memory for a new DAL
object and that memory is never released. After some dozens requests
I've got some hundredths MB of wasted memory.

How is the thread per request - DAL access managed by the web2py?

Thanks!


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 9:55 AM, Anthony wrote:
> Yes, that's a race condition with writing. My point was that even if the 
> first action is merely reading (but not doing any writing), you can have 
> problems. For example:
>  
> Action 1: read session
> Action 2: read session
> Action 2: write session
> Action 1: make some decision/calculation based on session data that is no 
> longer up to date
> 

Actually, I don't see that sequence as a real problem, because the result is 
identical to this sequence:

Action 1: read session
Action 1: make some decision/calculation based on session data that predates 
write-2
Action 2: read session
Action 2: write session

That is, action 1 shouldn't rely on the timing of action 2. If only one of the 
actions is writing, then they both have a consistent view of the session.

[web2py] Re: a few comments on session handling

2011-04-05 Thread VP
>>My question is: in your locking policy above, what's the purpose of locking 
>>at all?

If you don't lock during writes (e.g. when updating the counter), two
writes might happen "simultaneously" and cause inconsistent results.
Essentially, this is what I think how SQLite works:  concurrent reads
are allowed, but only 1 write at a time.


>>> write-2.update(counter = counter + 1, a = "hello")
>>> write-1.update(counter = counter + 1)

>>Unless by "update" you mean that the agent re-reads the session file under 
>>the write lock, the above sequence will only increment counter once.

Yes, "re-reading" if you want to think of it like that.  The point
here is changing session variables should be done atomically (meaning
a lock is acquired) and quickly.   If you do it like this, "update" is
an atomic synchronized operation.   This is clearly better than having
the whole controller function as an atomic operation (which is
currently the case).


[web2py] Re: HTML tags vs HTML?

2011-04-05 Thread pbreit
Perfect. Good to know.


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 9:46:41 AM UTC-4, Jonathan Lundell wrote: 
>
> On Apr 4, 2011, at 11:22 PM, Anthony wrote:
> > You might also want to lock the session even if it is merely being read 
> -- otherwise, if a second action writes to the session after a first action 
> has read it in, then the first action will be working with a version of the 
> session that is no longer up-to-date.
> > 
>
> In particular, you have the possible sequence with two overlapping 
> requests: 
>
> read-1
> read-2
> write-2
> write-1 
>
> ...so any changes #2 makes are lost.
>
Yes, that's a race condition with writing. My point was that even if the 
first action is merely reading (but not doing any writing), you can have 
problems. For example:
 
Action 1: read session
Action 2: read session
Action 2: write session
Action 1: make some decision/calculation based on session data that is no 
longer up to date
 


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 9:25 AM, David Warnock wrote:
> Jonathan,
> 
> > This policy is okay, but not good for reasons argued above.  It is
> > better not acquiring a lock unless you need one than to keeping a lock
> > unless you don't need it.
> 
> My question is: in your locking policy above, what's the purpose of locking 
> at all?
> 
> I wonder whether it would be possible to have a strategy as follows:
> 
> - default behaviour stays as now (for compatibility)
> 
> - an additional decorator is added to specify that this method should be 
> called without locking the session
> 
> To allow fine grained session control for long running methods maybe we could 
> have the following method added
> - reload_session (to reload the session. If we have not locked the session 
> then it might have been changed by another process since we loaded it. This 
> will refresh our copy so the values are up-to-date. If another process has 
> the session locked then we will pause here until the lock is released. This 
> method should have an argument to control whether the session is locked when 
> it is reloaded so then we can safely modify the session knowing it is both 
> up-to-date and locked).

I've been trying to work out logic along those lines. 

A decorator would be difficult, because the locking happens very early in a 
request, and it'd be tricky to communicate from the decorator to the locker. 
But that's an implementation detail. An alternative would be to flag an entire 
application as taking responsibility for its own session logic. In that case, 
the request logic would not call session.connect at all, but leave it for the 
app to do first thing in its model. At that point, the controller and function 
have been determined, so the app can do whatever it wants to with the session. 
(This is already what happens, more or less, when sessions are kept in a 
database, as with GAE.)

Then the app could implement several different request-dependent policies:

1. don't use the session at all: never read it, never lock it

2. read-only: read the session under a shared lock (to ensure atomicity) and 
immediately unlock

3. read-modify-write: same as existing logic, including a call to 
session.forget as soon as the write is complete

4. hybrid: start out read-only, but later switch to read-modify-write. This 
would require re-reading the session under the exclusive lock, which could be 
quite tricky depending on the app's logic (re-reading isn't tricky, but dealing 
with changes to the session data might be).


As a case in point, session.flash is in effect a global variable shared by all 
the requests in a session. If requests in a session that use request.flash are 
not serialized, then the session.flash logic is going to break. 



[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread pbreit
Perception is reality, even more so on these topics.


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 12:25:13 PM UTC-4, David Warnock wrote: 
>
> Jonathan, 
>
>   > This policy is okay, but not good for reasons argued above.  It is
>> > better not acquiring a lock unless you need one than to keeping a lock
>> > unless you don't need it.
>>
>> My question is: in your locking policy above, what's the purpose of 
>> locking at all?
>
>
> I wonder whether it would be possible to have a strategy as follows:
>
> - default behaviour stays as now (for compatibility)
>
> - an additional decorator is added to specify that this method should be 
> called without locking the session
>
 
I think the session is locked (if it exists) by the framework *before* any 
application code is executed, so web2py would have no way of knowing not to 
lock the session. As an alternative, I suppose there could be some kind of 
configuration file that the framework could read to determine whether to 
lock the session, conditional on the particular controller and/or function 
in the request. A current workaround could be to create a model file that 
gets executed first (e.g., 00_sessions.py) and have it unlock the session 
for a pre-specified set of controllers/functions. The unlocking would 
probably happen within milliseconds of the initial locking by the framework, 
so there would be minimal unnecessary locking.
 

> To allow fine grained session control for long running methods maybe we 
> could have the following method added
> - reload_session (to reload the session. If we have not locked the session 
> then it might have been changed by another process since we loaded it. This 
> will refresh our copy so the values are up-to-date. If another process has 
> the session locked then we will pause here until the lock is released. This 
> method should have an argument to control whether the session is locked when 
> it is reloaded so then we can safely modify the session knowing it is both 
> up-to-date and locked).
>
 
Isn't that what session.connect() does?
 
Anthony


[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 12:13:45 PM UTC-4, mikech wrote: 
>
> Thanks Anthony, that's the information I'm looking for.  The only downside 
> re: the blog is that it's marked as old.  Is there an updated source?

 
There's a flash message saying the blog is old, but not all the entries are 
actually that old (and just because a particular entry is old doesn't mean 
its content is necessarily out of date). I don't think entry 260 is more 
than a few months old. Maybe Massimo can provide some insight.
 
Anthony


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread David Warnock
Jonathan,

> This policy is okay, but not good for reasons argued above.  It is
> > better not acquiring a lock unless you need one than to keeping a lock
> > unless you don't need it.
>
> My question is: in your locking policy above, what's the purpose of locking
> at all?


I wonder whether it would be possible to have a strategy as follows:

- default behaviour stays as now (for compatibility)

- an additional decorator is added to specify that this method should be
called without locking the session

To allow fine grained session control for long running methods maybe we
could have the following method added
- reload_session (to reload the session. If we have not locked the session
then it might have been changed by another process since we loaded it. This
will refresh our copy so the values are up-to-date. If another process has
the session locked then we will pause here until the lock is released. This
method should have an argument to control whether the session is locked when
it is reloaded so then we can safely modify the session knowing it is both
up-to-date and locked).

Dave


-- 
Dave Warnock: http://42.blogs.warnock.me.uk
Cycling Blog: http://42bikes.warnock.me.uk


[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread mikech
Thanks Anthony, that's the information I'm looking for.  The only downside 
re: the blog is that it's marked as old.  Is there an updated source?

[web2py] Re: HTML tags vs HTML?

2011-04-05 Thread Anthony
The helpers are useful if you need to do server-side DOM parsing (
http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing) -- 
otherwise, I suppose it's a matter of preference. I think the URL function 
is generally recommended, particularly if there's a chance you might need to 
do any URL rewriting.
 
Anthony

On Tuesday, April 5, 2011 12:02:29 PM UTC-4, pbreit wrote:

> What are people's thoughts on using HTML tags vs plain HTML? I'm thinking 
> of going more towards pure HTML. Will I be losing anything major? 
>
> For example:
>
> {{=item.title}}
>
> {{=A(item.title, _href=URL('default', 'item', extension='', args=item.id
> ))}}
>


[web2py] Require login for whole application

2011-04-05 Thread Fredrik
Hi,

is there any suggested way to require login for a whole application.
Our application in web2py is for registered customers (whom we
manually add) only. For each action we currently have a decorator
stating that the user must be logged in. Is there any way to this in
one place for the whole app? It would be nice to never have to worry
about forgetting an action and be sure that only logged in users can
access the application.


Best regards
Fredrik


[web2py] Re: HTML tags vs HTML?

2011-04-05 Thread Massimo Di Pierro
My rule is:

- use html in views
- use html helpers in controllers and models
- always use URL to generate urls (*)

So in your example

{{=item.title}}

The first two rules are a matter of test but (*) is not. Soon or later
your code breaks if you do not follow (*).

On Apr 5, 11:02 am, pbreit  wrote:
> What are people's thoughts on using HTML tags vs plain HTML? I'm thinking of
> going more towards pure HTML. Will I be losing anything major?
>
> For example:
>
> {{=item.title}}
>
> {{=A(item.title, _href=URL('default', 'item', extension='', args=item.id))}}


Re: [web2py] HTML tags vs HTML?

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 9:02 AM, pbreit wrote:
> What are people's thoughts on using HTML tags vs plain HTML? I'm thinking of 
> going more towards pure HTML. Will I be losing anything major?
> 
> For example:
> 
> {{=item.title}}
> 
> {{=A(item.title, _href=URL('default', 'item', extension='', args=item.id))}}

At a minimum you should use URL, or you won't be able to use routing. And URL 
does some encoding (eg of spaces) that you'd have to do manually otherwise.

Re: [web2py] components and args

2011-04-05 Thread Anthony
On Tuesday, April 5, 2011 10:00:52 AM UTC-4, Richard wrote: 
>
>  Also, is that view the 'create.html' view (so, you're loading a 'create' 
>> component on the 'create' page itself)?
>>
>
> Yes, I was in a pretty early stage of testing the component... I get 
> recursion when it "works"... I mean when I use {{=LOAD(c='ref', 
> f='create.load', ajax=True)}}... It recursively load the entire page since I 
> can't make it load my table form only... I try to load my component on an 
> other view instead.
>
 
Hmm, I wouldn't think you would get recursion with the component using the 
'create.load' view, assuming the 'create.load' view does not also include a 
call to LOAD (does it?).
 


[web2py] Re: a few comments on session handling

2011-04-05 Thread VP

> read-1
> read-2
> write-2
> write-1
>
> ...so any changes #2 makes are lost.

I think this sequence is okay, as long as the write's are atomic and
they use up-to-date information.

It would be undesirable for read-1 to extract a variable and to update
it with write-1.  But if write-1 manipulates variables atomically,
then we  don't problems.  Consider a simple example with a counter
like this.


a = read-1
b = read-2
write-2.update(counter = counter + 1, a = "hello")
write-1.update(counter = counter + 1)

We don't have any problem.  I think databases automatically take care
of these synchronization.  Even if process 1 does  something with "a",
after process 2 modifies it.  Conceptually, that should be okay.
Information process 1 gets is stale, but that's life.

I don't think this is a problem either:

>>A database ... would not automatically handle locking
>>while an application function is potentially manipulating the session (prior
>>to updating it in the database).



Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 8:33 AM, VP wrote:
> 
>>> I think the policy is quite simple:  you don't lock session, if you
>>> are only reading session variables.  You lock only if you modify
>>> session certain variables; and you lock it immediately before you
>>> write, and unlock immediately before you write.
>> 
>> If that's your locking policy, I don't see the point of locking at all.
> 
> 
> As I understand it, currently, reading and writing will lock sessions.
> And the point where the lock is acquired is when the control function
> is called, and released when it finishes.
> 
> Then, we have a problem: a long running controller function will lock
> session even if it is not touching session variables at all.
> 
> This means other controller functions will have to wait for it to
> finish.   The current remedy is to ask the long-running process to
> release lock if it doesn't need it.
> 
> This policy is okay, but not good for reasons argued above.  It is
> better not acquiring a lock unless you need one than to keeping a lock
> unless you don't need it.

My question is: in your locking policy above, what's the purpose of locking at 
all?

[web2py] HTML tags vs HTML?

2011-04-05 Thread pbreit
What are people's thoughts on using HTML tags vs plain HTML? I'm thinking of 
going more towards pure HTML. Will I be losing anything major?

For example:

{{=item.title}}

{{=A(item.title, _href=URL('default', 'item', extension='', args=item.id))}}


[web2py] python 2.5 hmac issues

2011-04-05 Thread Matt
I recently attempted to move my web2py install to a different server.
All went well except for passwords failing to validate.  It turns out
that the version of python I was using (2.5.1) had an issue with
hmac.  Essentialy the following will give an incorrect digest on this
version of python:

hmac.new("salt", "password", hashlib.sha512).hexdigest()

Although this is clearly an issue with python rather than web2py, I
was wondering about the best way to deal with this.  I can move the
hmac.py from the old install but don't want to break any other
functionality.  What is the best approach?

Thanks.


[web2py] Re: Putting logic back to controller

2011-04-05 Thread Ross Peoples
You should really be joining the queries:

records = db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL)

Then in your view, you access this by using:

{{for record in records:}}
{{=record.person.name}}: {{=record.cats.name}}
{{pass}}


[web2py] Re: a few comments on session handling

2011-04-05 Thread VP

>
> > I think the policy is quite simple:  you don't lock session, if you
> > are only reading session variables.  You lock only if you modify
> > session certain variables; and you lock it immediately before you
> > write, and unlock immediately before you write.
>
> If that's your locking policy, I don't see the point of locking at all.


As I understand it, currently, reading and writing will lock sessions.
And the point where the lock is acquired is when the control function
is called, and released when it finishes.

Then, we have a problem: a long running controller function will lock
session even if it is not touching session variables at all.

This means other controller functions will have to wait for it to
finish.   The current remedy is to ask the long-running process to
release lock if it doesn't need it.

This policy is okay, but not good for reasons argued above.  It is
better not acquiring a lock unless you need one than to keeping a lock
unless you don't need it.




[web2py] Putting logic back to controller

2011-04-05 Thread kedai
Hi

I'm enjoying my dive with web2py.  I would like to seek help/pointers
re putting logic back at controller.

I have two tables,

db.define_table('person', Field('name'))

db.define_table('cats', Field('name'), Field('owner', db.person))

I have a controller default/index

def index():
records = db().select(db.cats.ALL)
return dict(records=records)

in index.html, I have

{{extend 'layout.html'}}
{{=A('insert record',_href=URL('create'))}}

{{for record in records:}}

{{=db(db.person.id == record.id).select().first().name}} 
{{=A('edit', _href=URL('edit', args=record.id))}}
{{=record.name}}
Majority: {{=record.majority}} | undi rosak: {{=record.undi_rosak}} |
jumlah undi: {{=record.jumlah_undi}} | %: {{=record.peratus}}

{{pass}}


My Q: any way I can put
{{=db(db.person.id == record.id).select().first().name}}
somewhere else? e.g in controller?

I know I can use a function in my views, but think that would be a
problem should I have complex function?

tia
~


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 5, 2011, at 8:13 AM, VP wrote:
> 
> I think the policy is quite simple:  you don't lock session, if you
> are only reading session variables.  You lock only if you modify
> session certain variables; and you lock it immediately before you
> write, and unlock immediately before you write.

If that's your locking policy, I don't see the point of locking at all.


[web2py] Re: a few comments on session handling

2011-04-05 Thread VP


> > Instead of "locking by default unless explicitly forgetting", we
> > require locking *only if* sessions is saved/written/modified.
>
> You might also want to lock the session even if it is merely being read --
> otherwise, if a second action writes to the session after a first action has
> read it in, then the first action will be working with a version of the
> session that is no longer up-to-date.
>


> > Further, processes/functions that do not modify sessions should be
> > allow to read sessions.
>
> Perhaps, but with the knowledge that the session might be updated by another
> function sometime after the session has been read in.
>


I think it's a matter of policy.  From the performance point of view,
not locking on read is good.   It is true that reading an unlocked
session, might yield in stale information -- perhaps inconsistent .
But I don't think there is much harm in that.  There might be some
issues if users of the same session are using highly interrelated
session variables to make a decision.  I think this use case is slim.
Other than that, locking on read is a performance penalty.

The use case is this.  When a user is executing a long-running
controller function, he won't be able to use other controller
functions, unless he has to session.forget(response) at an appropriate
place in the long-running process.

There are many issues:

(1) Clearly, not being able to use other controller functions while
something is running, is undesirable, in terms of useability.

(2) Sometime, it might be difficult AND/OR inconvenient to run the
long-running function as a background process.   To avoid (1),
session.forget(response) must be placed at *appropriate* places.  If
the the long-running function is also extracting session information
(e.g. form variables), he can only session.forgetting after getting
out those information.

(3) If a function takes 5 minutes to run, clearly something needs to
be done.  But there are deceptively dangerous cases when it takes 20
seconds to run.  I am only guessing here, but I think a few
programmers will avoid the extra work to be done (e.g. running as a
background process), and just let users wait 20 seconds.  It's only 20
seconds right?   But i think it will accumulate to a bad user
experience.


==

I think the policy is quite simple:  you don't lock session, if you
are only reading session variables.  You lock only if you modify
session certain variables; and you lock it immediately before you
write, and unlock immediately before you write.





[web2py] Re: auto-update/refresh content

2011-04-05 Thread Ross Peoples
That's basically how it works. Although as you learn more about AJAX, you'll 
find that there are a bunch of different ways to do this, including more 
2-way types of communication, where you would do something with the data 
returned from the controller before or after displaying it on the page. Once 
you start to open your mind a bit and get the hang of how it all works, 
you'll start to figure out some really cool ways to tackle problems.

Re: [web2py] components and args

2011-04-05 Thread Richard Vézina
I would like to use the component with jquery ui tabs plugin... So I would
like my different form to be accessible in different tabs on the same
page... The components seems to me the way to go...

Richard

On Mon, Apr 4, 2011 at 8:51 PM, pbreit  wrote:

> I would suggest only using components in certain situations. For example,
> if you wanted to display a dynamically-generated list tags or categories or
> users in the sidebar of every page in your site. You could use a component
> to load that section discreetly from the rest of the page.
>
> If this is your first time using components, best is to start simple and
> add complexity. So just do something like this:
>
> {{=LOAD('components', 'test.load', ajax=True)}}
> (same as {{=LOAD('components', 'test', extension='load', ajax=True)}})
> (same as {{=LOAD(c='components', f='test', extension='load', ajax=True)}})
>
> And then in "components.py":
>
> def test():
> return 'this is a test'
>
> If that works, then maybe hook up a database call. Try one where you don't
> have to pass any data to the controller. Just hard code in a db record:
>
> def test():
> user = db.auth_user['1']
> return dict(user=user)
>
> One trick if your pages use vars or args is to just pass them right
> through. For example:
>
> {{=LOAD('components', 'test.load', args=request.args, vars=request.vars,
> ajax=True)}}
>
> But looking at your code, I don't think it's a great candidate for
> components.
>


[web2py] SourceKit webeditor - Great Alternative to web editing - works great with dropbox + web2py

2011-04-05 Thread Bruno Rocha
A Textmate like lightweight programmer's text editor right inside of
Chrome. It saves files directly to Dropbox, so if you have the Dropbox
sync software installed, the changes will appear locally as if you did
so with a text editor! Changes will be stored remotely so naturally
this same extension will pull up the same copy of the file everywhere!



https://chrome.google.com/webstore/detail/iieeldjdihkpoapgipfkeoddjckopgjg#






--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] Re: ajax function

2011-04-05 Thread Ross Peoples
Could you be a little more specific? Are you trying to pass args and vars? 
Or are you trying to load HTML using AJAX and sending it to a target DIV? If 
you are using web2py's ajax function, you may be limited to what you can do. 
Worst case, you can always try calling jQuery's load() method:

var url = {{=URL('ajax_view.load', args={'arg1': 'my', 'arg2', 'value'})}};
jQuery('#target').load(url);

Or like this:

var url = {{=URL('ajax_view.load')}};
jQuery('#target').load(url, {arg1: 'my', arg2, 'value'});

Does this help?


Re: [web2py] components and args

2011-04-05 Thread Richard Vézina
Answer below

On Mon, Apr 4, 2011 at 7:14 PM, Anthony  wrote:

> You're saying when the page loads, the LOAD component shows "loading...",
> but the create form never actually loads there? Can you reproduce the
> problem with a somewhat more simplified example?
>
>

Yes and I will try to reproduce the problem in a dedicated app...


> Also, is that view the 'create.html' view (so, you're loading a 'create'
> component on the 'create' page itself)?
>

Yes, I was in a pretty early stage of testing the component... I get
recursion when it "works"... I mean when I use {{=LOAD(c='ref',
f='create.load', ajax=True)}}... It recursively load the entire page since I
can't make it load my table form only... I try to load my component on an
other view instead.

Richard

>
> Anthony
>
> On Monday, April 4, 2011 4:11:16 PM UTC-4, Richard wrote:
>
>> Hello Anthony,
>>
>>  I have no problem using generic.load view for now...
>>
>> My problem is mostly related to the fact I use table name as args in my
>> url and without args 0 my function can't do anything...
>>
>> That why I tried with extension='.load'
>>
>> Here some code :
>>
>>
>> ## CONTROLLER :
>>  @auth.requires_login()
>> def create():
>> if request.args(0) in ref_tables_list:
>> redirection_argument=request.args(0)
>> if en_ui_tables_names[request.args(0)]!=None :
>> table_name = str.lower(en_ui_tables_names[request.args(0)])
>> else:
>> table_name = request.args(0).replace('ref_','')
>> page_title=T('Form for : ')
>> if auth.has_membership(auth.id_group('admin')):
>> crud.settings.formstyle='divs'
>> form = crud.create(db[request.args(0)])
>> elif auth.has_membership(auth.id_group('user1')):
>> crud.settings.formstyle='divs'
>> form = crud.create(db[request.args(0)])
>> elif auth.has_membership(auth.id_group('user2')):
>> crud.settings.formstyle='divs'
>> form = crud.create(db[request.args(0)])
>> else:
>> return
>> dict(form=None,page_title=page_title,table_name=table_name,\
>> not_allow_permission='you are not allow
>> (permission)',permission_denied='Permission denied')
>> if form.accepts(request.vars, session):
>> response.flash = T('form accepted')
>> redirect(URL(r=request, f='read/'+redirection_argument,args=
>> form.vars.id))
>> elif form.errors:
>> response.flash = T('form has errors')
>> else:
>> response.flash = T('please fill out the form')
>> return
>> dict(form=form,page_title=page_title,table_name=table_name,\
>> not_allow_permission=None,permission_denied=None)
>> else:
>> redirect(URL(request.application,'default','index'))
>> session.flash = T('invalid request')
>>
>>
>> ## VIEW :
>>  {{extend 'layout.html'}}
>>
>>  
>> @import
>> "{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";
>> 
>> @import
>> "{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/demos/demos.css')}}";
>> 
>> 
>>
>> > src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/js/jquery-1.4.4.min.js')}}">
>> 
>> > src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.core.js')}}">
>> 
>> > src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.widget.js')}}">
>> 
>> > src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.tabs.js')}}">
>> 
>> 
>> $(function() {
>> $( "#tabs" ).tabs();
>> });
>> 
>>
>>
>> 
>>
>> 
>> 
>> {{=T('folder').capitalize()}}
>> {{=T('volume').capitalize()}}
>> {{=T('tome').capitalize()}}
>> {{=T('report').capitalize()}}
>> 
>> 
>> {{if form!=None:}}
>> {{=page_title}} {{=T(table_name)}}
>> 
>> {{=form}}
>> {{else:}}
>> {{=permission_denied}}
>> 
>> {{=not_allow_permission}}
>> {{pass}}
>> {{pass}}
>> 
>> 
>> test2
>> 
>> 
>> test3
>> 
>> 
>>
>>  
>> {{=LOAD(c='ref',f='create',args='ref_eregistry',extension='.load',ajax=True)}}
>> 
>> 
>>
>> 
>>
>>
>> Thanks for your help.
>>
>> Richard
>>
>> On Mon, Apr 4, 2011 at 3:08 PM, Anthony  wrote:
>>
>>> I'm not sure if this is your only problem, but isn't it supposed to be
>>> extension='load' rather than extension='.load'? Also, have you actually
>>> created a 'myfunction.load' view file (inside the /views/mycontroller/
>>> folder)? If not, web2py should attempt to use the 'generic.load' view.
>>>
>>> Anthony
>>>
>>> On Monday, April 4, 2011 2:46:53 PM UTC-4, Richard wrote:
>>>
 Hello,

  It seems that I have to modified completly my app to make it work with
 compo

Re: [web2py] .represent = ... in left join

2011-04-05 Thread Richard Vézina
I did not use export_to_csv for now... I just test it sometimes ago... But I
guest you should define your .represent for stream table before try to apply
them to your csv output...

Hope it helps.

Richard

On Tue, Apr 5, 2011 at 3:27 AM, Johann Spies  wrote:

> On 5 April 2011 09:16, Johann Spies  wrote:
>
>>
>> Thanks!  That solved the problem.  I could not find something in the book
>> about a 'zero option' though.
>>
>>
> Now .represent works on the screen but not in the CSV-output.  I have used:
>
> {{
> import cStringIO
> stream=cStringIO.StringIO()
> rows.export_to_csv_file(stream,represent=True)
> response.headers['Content-Type']='application/vnd.ms-excel'
> response.write(stream.getvalue(), escape=False)
> }}
>
> but putting the option 'represent=True) in there did not make any
> difference.
>
> Regards
> Johann
> --
>  May grace and peace be yours in abundance through the full knowledge of
> God and of Jesus our Lord!  His divine power has given us everything we need
> for life and godliness through the full knowledge of the one who called us
> by his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>
>


Re: [web2py] .represent = ... in left join

2011-04-05 Thread Richard Vézina
About zero option, search in page for zero :
http://www.web2py.com/book/default/chapter/07

There is some explanation
near IS_IN_SET...

There maybe more detailed information somewhere else too... I don't use it
in my code since it arrive after I start my dev or I was not aware at the
begining... I should make refoctoring ;-)

Richard

On Tue, Apr 5, 2011 at 3:16 AM, Johann Spies  wrote:

> On 4 April 2011 16:11, Richard Vézina  wrote:
>
>> Are course_week1 and course_week2 not null??
>>
>>
> No.
>
>
>> If not you need ...requires=IS_NULL_OR(IS_IN_DB(your requires) and in
>> ...represent= you should use zero option (see book about that) or something
>> like that :
>>
>> db.t_registration_form.course_week1.represent=\
>> lambda value: (value!=None and "%(code)s" %db.courses[value]) or
>> 'None'
>>
>>
> Thanks!  That solved the problem.  I could not find something in the book
> about a 'zero option' though.
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of
> God and of Jesus our Lord!  His divine power has given us everything we need
> for life and godliness through the full knowledge of the one who called us
> by his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>


Re: [web2py] Re: a few comments on session handling

2011-04-05 Thread Jonathan Lundell
On Apr 4, 2011, at 11:22 PM, Anthony wrote:
> You might also want to lock the session even if it is merely being read -- 
> otherwise, if a second action writes to the session after a first action has 
> read it in, then the first action will be working with a version of the 
> session that is no longer up-to-date.
> 

In particular, you have the possible sequence with two overlapping requests:

read-1
read-2
write-2
write-1

...so any changes #2 makes are lost.

[web2py] Re: PDF writing under GAE

2011-04-05 Thread Massimo Di Pierro
It would be nice if fpdf were to work on GAE out of the box. Moreover
I think PIL is available on GAE.

On Apr 5, 5:19 am, Martín Mulone  wrote:
> Well I browse the code of fpdf.py and pil is only using to check is the file
> is and image format, I think is easy to do to support gae, changing in gae
> to api or make the check like IS_IMAGE from web2py.
>
> Anyways there are other tools you can use to write pdf reports like PISA,
> Reportlab.
>
> 2011/4/5 Arbie Samong 
>
>
>
>
>
>
>
>
>
> > @martin - that helped me passed the try-except block at the beginning,
> > but when the Image module is used on the other parts of the code it
> > went haywire. I'll look into it probably more changes to make it adapt
> > with GAE.
>
> > @howesc - I was able to make it work without using the file system
> > read and write, but this is like heaven sent :)
>
> > On Apr 5, 3:11 am, howesc  wrote:
> > > hopefully not a red herring, but google gave us gifts last week, one of
> > them
> > > was file "reading" and "writing" from the blobstore:
> >http://googleappengine.blogspot.com/2011/03/announcing-app-engine-143...
>
> > > i have not looked at how to connect things to it, but might help here.
>
> > > cfh
>
> --
> My blog:http://martin.tecnodoc.com.ar
> Expert4Solution:http://www.experts4solutions.com/e4s/default/expert/6http://www.cvstash.com/profile/Xzi5bWCdD


[web2py] Re: web2py/poweredby problem

2011-04-05 Thread Massimo Di Pierro
was a design issue. changed.

On Apr 5, 4:15 am, Kenneth Lundström 
wrote:
> Why is there no link to poweredby page on the frontpage or did I miss it?
>
> That sounds strange that you have to login, I don t know why. But if you
> click on the name below the screencapture of the site you don t have to
> login.
>
> Kenneth
>
>
>
>
>
>
>
> > I've been looking aroundhttp://www.web2py.com/poweredbysection, and
> > decided to go into one of the websites. I don't get why it asked me to
> > log in, but I can understand this is website policy. The problem I had
> > was this.
> > Examine this url:
> >http://web2py.com/poweredby/default/user/login?_next=/poweredby/defau...
> > After logging in, via openid OR google, it redirected me to the index,
> > not to the website I wanted to see. I had to look for it all over
> > again. Not cool.
>
> > Hope you can get it to work better.
>
> > Yaya


Re: [web2py] Re: PDF writing under GAE

2011-04-05 Thread contatogilson...@gmail.com
There's this plugin for web2py: https://github.com/lucasdavila/appreport
__ ___
*Gilson Filho*
*Web Developer
http://gilsondev.com*


[web2py] Re: Web2py version 1.94.6 bug?

2011-04-05 Thread Christopher Steel
Understood, just being really lazy ; ) thanks for the fix.

http://commons.wikimedia.org/wiki/Category:Erlenmeyer_flasks
http://commons.wikimedia.org/wiki/Category:Chemistry_icons


On Apr 4, 2:12 pm, Massimo Di Pierro 
wrote:
> I just fixed this in trunk. please remove the .xml(). The wizard is
> still experimental and small things like this may still change.
> Sorry about the trouble but there were good reasons for this change.
>
> Massimo
>
> On Apr 4, 11:45 am, Christopher Steel  wrote:
>
> > Running the latest version of Web2py and Python 2.7 on OS X  the I get
> > the following error when running wizard created applicaitons:
>
> > File "/Users/username/webapps/2010_04_04/web2py/applications/a/models/
> > menu.py", line 8, in 
>
> > (T('Index'),URL('default','index').xml()==URL().xml(),URL('default','index' 
> > ),
> > []),
>
> > AttributeError: 'str' object has no attribute 'xml'
>
>


[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-05 Thread Christopher Steel
It could be interesting to have an IDE configuration section. As far
as Eclipse is concerned you can look at these:

http://code.google.com/p/neo-web2py2eclipse/
http://pierrethibault.posterous.com/2010/10/web2py-eclipse-pydev-recipe.html

Are you currently using an IDE???, which one?

On Apr 4, 1:21 pm, mikech  wrote:
> I'd like to see some FAQ topics that can be pointed to on the usual FUD
> about Web2py.  For instance:
>
> In web2py the code you write for the controller layer (views) goes into
> files that are not Python modules because they don't include any imports to
> give context to external identifiers. Web2py loads, compiles, and executes
> those modules at runtime passing a global context using Python's exec()
> function. That strange (and unjustified) way of doing things disables
> important capabilities of modern IDEs (code completion, code hints, help,
> static checking, refactoring) because those files are not Python modules. It
> also makes it very difficult to write unit tests for the controller layer,
> because the global runtime context of web2py cannot be mocked.
>
> I tried to look for the Google thread in which Massimo addressed these and
> other issues, but the search didn't easily retrieve it, and though I knew
> that I had participated in it my profile history only showed posts thru the
> end of 2010.  


[web2py] ajax function

2011-04-05 Thread leone
Hi,
sometimes I need to use ajax function passing as second argument a
list of ids and costants. There is a way to pass to callback values of
elements by id, AND string costants?
Thanks for help.


Re: [web2py] Re: PDF writing under GAE

2011-04-05 Thread Martín Mulone
Well I browse the code of fpdf.py and pil is only using to check is the file
is and image format, I think is easy to do to support gae, changing in gae
to api or make the check like IS_IMAGE from web2py.

Anyways there are other tools you can use to write pdf reports like PISA,
Reportlab.

2011/4/5 Arbie Samong 

> @martin - that helped me passed the try-except block at the beginning,
> but when the Image module is used on the other parts of the code it
> went haywire. I'll look into it probably more changes to make it adapt
> with GAE.
>
> @howesc - I was able to make it work without using the file system
> read and write, but this is like heaven sent :)
>
> On Apr 5, 3:11 am, howesc  wrote:
> > hopefully not a red herring, but google gave us gifts last week, one of
> them
> > was file "reading" and "writing" from the blobstore:
> http://googleappengine.blogspot.com/2011/03/announcing-app-engine-143...
> >
> > i have not looked at how to connect things to it, but might help here.
> >
> > cfh
>



-- 
My blog: http://martin.tecnodoc.com.ar
Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
http://www.cvstash.com/profile/Xzi5bWCdD


Re: [web2py] web2py/poweredby problem

2011-04-05 Thread Kenneth Lundström

Why is there no link to poweredby page on the frontpage or did I miss it?

That sounds strange that you have to login, I don´t know why. But if you 
click on the name below the screencapture of the site you don´t have to 
login.



Kenneth


I've been looking around http://www.web2py.com/poweredby section, and
decided to go into one of the websites. I don't get why it asked me to
log in, but I can understand this is website policy. The problem I had
was this.
Examine this url:
http://web2py.com/poweredby/default/user/login?_next=/poweredby/default/site_read/74
After logging in, via openid OR google, it redirected me to the index,
not to the website I wanted to see. I had to look for it all over
again. Not cool.

Hope you can get it to work better.

Yaya




[web2py] web2py/poweredby problem

2011-04-05 Thread guruyaya
I've been looking around http://www.web2py.com/poweredby section, and
decided to go into one of the websites. I don't get why it asked me to
log in, but I can understand this is website policy. The problem I had
was this.
Examine this url:
http://web2py.com/poweredby/default/user/login?_next=/poweredby/default/site_read/74
After logging in, via openid OR google, it redirected me to the index,
not to the website I wanted to see. I had to look for it all over
again. Not cool.

Hope you can get it to work better.

Yaya


[web2py] Re: passing data as post params rather than URL vars/args

2011-04-05 Thread Brian Will
Using session occurred to me, but I was put off by the idea of
cluttering session with one-time use data. Is it good practice to then
remove the data from session after use? Probably doesn't matter, I
guess.

On Apr 5, 12:47 am, Arbie Samong  wrote:
> From what I can understand you want your data available even after a
> redirect. POST won't have that, so you should either store it on the
> session, with cookies or with the database. If it's just temporary I
> would suggest using session variables.
>
> Regards,
> Arbie
>
> On Apr 5, 3:38 pm, Brian Will  wrote:
>
>
>
>
>
>
>
> > I assumed there would simply be a Storage in the response object I
> > could just stuff things into, but it seems not. So my question is
> > what's the easiest way to append POST data to a response (for both
> > cases: a redirect and a non-redirect)?
>
> > Maybe I'm going about this the wrong way. I have a simple 'bad
> > request' error page which I'd like to redirect to when the URL is no
> > good, e.g. a bad id passed as an arg. I'd like to pass a message to
> > this error page, e.g. 'No such post.', but I'd rather that text not
> > show up in the URL, so I'd like to pass it as POST data.


[web2py] auto-update/refresh content

2011-04-05 Thread mart
Hi,

I'm trying to do these 2 things:

1)
I have a directory structure which stores sioftware builds (many
builds daily), all versioned and sortable, many products, branches,
blablabla..., alright.

i would like new arrivals to "magically" announce their arrival in
some section of a web page (but without having to refresh the page).
This may at time appear to be scrolling (at least, that's the desired
affect).

2) similar...
each build has a set of logs/reports (most of which is stored in a
DB). I would like to have some of that data follow those magically
appearing build paths and effectively slide down the column along with
the build announcement...


Anybody have an idea? a direction or something to look at for ideas? I
just need the mechanics on how something like that can be setup in a
web page... an alternative would be an embedded Flex app, which can be
easily achieved, but I would rather not go there


Thanks a bunch in advance,
Mart :)


[web2py] Re: passing data as post params rather than URL vars/args

2011-04-05 Thread Brian Will
Come to think of it, not sure why I'm thinking it has to get passed as
POST data: the redirect isn't triggering a second request, right? I
just want to pass data from the action to the view. (Though I'm still
curious how to POST data in the response.)

I also realized I can manually set response.view and then put my data
in the return dict. This works, but I don't like how I have to embed
the name of the view instead of the action. Logically this is a
redirect from one action to another, so I'd like to do my redirects
consistently by specifying the action name 'error' rather than its
view name 'default/error.html'. Also, in other cases I would want the
other action handler to execute rather than bypass it and use just its
view. I guess I could stuff the data into the request or response
before calling the action directly. Still seems a bit odd.

So I guess my question is: I want some way to redirect to another
action in the app and pass it data, but I don't want to pass it as URL
vars/args.

On Apr 5, 12:38 am, Brian Will  wrote:
> I assumed there would simply be a Storage in the response object I
> could just stuff things into, but it seems not. So my question is
> what's the easiest way to append POST data to a response (for both
> cases: a redirect and a non-redirect)?
>
> Maybe I'm going about this the wrong way. I have a simple 'bad
> request' error page which I'd like to redirect to when the URL is no
> good, e.g. a bad id passed as an arg. I'd like to pass a message to
> this error page, e.g. 'No such post.', but I'd rather that text not
> show up in the URL, so I'd like to pass it as POST data.


[web2py] Re: passing data as post params rather than URL vars/args

2011-04-05 Thread Arbie Samong
>From what I can understand you want your data available even after a
redirect. POST won't have that, so you should either store it on the
session, with cookies or with the database. If it's just temporary I
would suggest using session variables.

Regards,
Arbie

On Apr 5, 3:38 pm, Brian Will  wrote:
> I assumed there would simply be a Storage in the response object I
> could just stuff things into, but it seems not. So my question is
> what's the easiest way to append POST data to a response (for both
> cases: a redirect and a non-redirect)?
>
> Maybe I'm going about this the wrong way. I have a simple 'bad
> request' error page which I'd like to redirect to when the URL is no
> good, e.g. a bad id passed as an arg. I'd like to pass a message to
> this error page, e.g. 'No such post.', but I'd rather that text not
> show up in the URL, so I'd like to pass it as POST data.


[web2py] passing data as post params rather than URL vars/args

2011-04-05 Thread Brian Will
I assumed there would simply be a Storage in the response object I
could just stuff things into, but it seems not. So my question is
what's the easiest way to append POST data to a response (for both
cases: a redirect and a non-redirect)?

Maybe I'm going about this the wrong way. I have a simple 'bad
request' error page which I'd like to redirect to when the URL is no
good, e.g. a bad id passed as an arg. I'd like to pass a message to
this error page, e.g. 'No such post.', but I'd rather that text not
show up in the URL, so I'd like to pass it as POST data.


Re: [web2py] .represent = ... in left join

2011-04-05 Thread Johann Spies
On 5 April 2011 09:16, Johann Spies  wrote:

>
> Thanks!  That solved the problem.  I could not find something in the book
> about a 'zero option' though.
>
>
Now .represent works on the screen but not in the CSV-output.  I have used:

{{
import cStringIO
stream=cStringIO.StringIO()
rows.export_to_csv_file(stream,represent=True)
response.headers['Content-Type']='application/vnd.ms-excel'
response.write(stream.getvalue(), escape=False)
}}

but putting the option 'represent=True) in there did not make any
difference.

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


  1   2   >