Re: [web2py] Re: book "bugs"

2011-03-24 Thread Martin Weissenboeck
 Trying http://web2py.com/book/ I got:

Internal errorTicket issued:
book/81.223.149.226.2011-03-25.06-02-53.5316f94b-b033-4197-a3ab-5e27e7d9edc2


2011/3/25 Marco Mansilla 

> El Thu, 24 Mar 2011 20:32:03 -0700 (PDT)
> Kevin Ivarsen  escribió:
>
> > Good catch. I've made the edit.
> >
> > Cheers,
> > Kevin
>
> is there any bug on the book site?, i get an invalid request and ticket
> on
>
> http://web2py.com/book/
>
> Marco.
>


Martin


Re: [web2py] Re: book "bugs"

2011-03-24 Thread Marco Mansilla
El Thu, 24 Mar 2011 20:32:03 -0700 (PDT)
Kevin Ivarsen  escribió:

> Good catch. I've made the edit.
> 
> Cheers,
> Kevin

is there any bug on the book site?, i get an invalid request and ticket
on 

http://web2py.com/book/ 

Marco.


[web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread LightOfMooN
it redirects me =\

On 25 мар, 08:02, pbreit  wrote:
> I posted a Fabirc script for installing 
> nginx/uwsgi:https://groups.google.com/d/msg/web2py/kd_A86Qwz6w/Fcv5g-sp98AJ
>
> I've been using it in development but not in production yet.


[web2py] Re: help with using rich text file.

2011-03-24 Thread pbreit
Well, I'm relatively new to Python and don't know all the ins and outs. It 
was more of a guess. Are you really trying to insert raw numbers? An RTF doc 
is text after all.

[web2py] Re: help with using rich text file.

2011-03-24 Thread andre . dwyer89
So in other words I can't append raw integer data, I have to append values of 
type "string".

Sent from my BlackBerry® device from Digicel

[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread pbreit
Oh, shoot, I figured that might be the answer but only had 
"register_onaccept" in my list.

I ended up writing a function since it seems assignments in lambdas are 
difficult. I tried setattr() and a nested function to no avail. Any ideas?

def set_paypal_email(form):
form.vars.paypal_email=form.vars.email
auth.settings.register_onvalidation.append(lambda form: 
set_paypal_email(form))


[web2py] Re: help with using rich text file.

2011-03-24 Thread pbreit
You probably need to do:

 section.append('500') 



[web2py] Re: book "bugs"

2011-03-24 Thread Kevin Ivarsen
Good catch. I've made the edit.

Cheers,
Kevin


[web2py] Unpack a MIME message (Gmail)

2011-03-24 Thread Ahmed Bani

Hello everyone,

I have found enough resources on how to send messages from my web2py 
application. 

Now, I need some information that could help me to  successfully unpack a 
MIME message and parse the results from Gmail.com.

Any ideas or suggestion are welcome. 

Thanks, 
Bani 













[web2py] Re: help with using rich text file.

2011-03-24 Thread Andre Dwyer


this is the code i have in web2py

def makertf():
import gluon.contrib.pyrtf as q
doc=q.Document()
section=q.Section()
doc.Sections.append(section)
section.append(500)
section.append(200)
response.headers['Content-Type']='text/rtf'
return q.dumps(doc)


[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread Massimo Di Pierro
auth.settings.register_onvalidation=lambda form: 
manipulate_form_before_insert(form)

On Mar 24, 2011, at 6:06 PM, pbreit wrote:

> OK, I see. Is there some way to intercept the user/register form.accepts to 
> set that default? 



[web2py] Re: help with using rich text file.

2011-03-24 Thread pbreit
Should be. Can you show some code?

[web2py] help with using rich text file.

2011-03-24 Thread Andre Dwyer
can numbers be written to rtf files. web2py constantly returns a
ticket each time i try


[web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread pbreit
I posted a Fabirc script for installing nginx/uwsgi:
https://groups.google.com/d/msg/web2py/kd_A86Qwz6w/Fcv5g-sp98AJ

I've been using it in development but not in production yet.


[web2py] Re: book "bugs"

2011-03-24 Thread niknok
Also in chapter 7,  SQLFORM.factory. Missing ":" in function
"form_from_factory()" example.

should read: "form_from_factory():"

In epydoc, INPUT component.

There are two examples for "radio" types. I suppose the other one is
meant for the "submit" type, which isn't listed at all?


On Mar 18, 8:02 am, niknok  wrote:
> In Validator section of Chapter 7, the  example for IS_DATE_IN_RANGE
> incorrectly uses IS_DATETIME where IS_DATE_IN_RANGE is expected:
>
> requires = IS_DATE(format=T('%Y-%m-%d'),
>                         minimum=datetime.date(2008,1,1),
>                         maximum=datetime.date(2009,12,31),
>                         error_message=T('must be -MM-DD!'))
>
> should be:
>
> requires = IS_DATE_IN_RANGE(format=T('%Y-%m-%d'),
>                         minimum=datetime.date(2008,1,1),
>                         maximum=datetime.date(2009,12,31),
>                         error_message=T('must be -MM-DD!'))
>
> The same error occured in the IS_DATETIME_IN_RANGE validator example:
>
> requires = IS_DATE(format=T('%Y-%m-%d'),
>                         minimum=datetime.date(2008,1,1),
>                         maximum=datetime.date(2009,12,31),
>                         error_message=T('must be -MM-DD!'))
>
> should read as:
>
> requires = IS_DATETIME_IN_RANGE(format=T('%Y-%m-%d'),
>                                 minimum=datetime.date(2008,1,1),
>                                 maximum=datetime.date(2009,12,31),
>                                 error_message=T('must be -MM-DD!'))
>
> hth


[web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread VP
I definitely agree that there should be a setup guide / script for
nginx/wsgi for web2py.

That said, I'm not giving up on Apache yet.  I think I found out what
the culprit to this high usage of RAM for Debian squeeze.

Short answer.  I think this will fix it:

sudo apt-get install apache2-mpm-prefork

===
Long answer.  I think it's more complicated that I understand, but my
understanding is that this has to do with how Apache2 handles multi-
processing.  Apparently, there 3 modules related to this: (1) prefork,
(2) worker and (3) event.   You can install each with apt-get (e.g.
apt-get install apache2-mpm-worker or apt-get install apache2-mpm-
event).

I think Debian 6 (squeeze) has "worker" as the default multi-
processing module.

Prefork is the non-threaded, traditional, tried-and-true mode of
Apache2.  Worker is the multithread version and it consumes a lot of
RAM.   Event is based on Worker.  It takes as much memory as Worker,
is experimental and is supposed to work well with applications having
lots of requests.

In my application, Worker consumes lots of RAM, but doesn't appear to
have any benefits.  Event actually produces the best result (the most
number of requests/sec and the lowest time per request), while
consumes as much RAM as Worker.

So, I think if your RAM is abundant, I'd suggest that you try the
apache2-mpm-event module.  If not, try apache2-mpm-prefork module.




While I am playing with these modules, I also discovered that with
web2py having more processes is much better than having more threads.
My current configuration of wsgi is processes=5 and threads=1.  This
works much better than for example processes=1 and threads=15 (which I
think is the default configuration).

Massimo might want to play around with this and might want to change
the official Apache guideline to reflect this.



With prefork, 5 processes, 1 thread, I'm quite happy.  Things are
quite snappy, and RAM are well under control.

So, until the next headache, there it is.




Re: [web2py] Does this seems familiar?

2011-03-24 Thread Marco Mansilla
Déjà vu!

> http://www.microsoft.com/web/post/web-development-101-using-webmatrix
> 
> layout, database, template language, helpers, intellisense, ...
> 
> I have seen all this before... but where?.


-- 
/* 
Marco Antonio Mansilla Gutierrez, alias "Big"
Medios de contacto adicionales:
Weblog: http://www.marcomansilla.com.ar
Jabber: conta...@marcomansilla.com.ar
Gtalk: conta...@marcomansilla.com.ar
MSN: conta...@marcomansilla.com.ar 

 http://www.saltalug.org.ar
 */


Re: [web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread Luis Díaz
I'd like to try the suggestion of Mr. massimo

but I have the time to learn on the fly

I hope the collaboration of someone on the list
I'm starting to develop systems in several vps
and I face this problem of memory.

cherokke could also be a good approximation ..
Whether this also in a script .sh  :)


Díaz Luis
http://www.facebook.com/diazluis2007
User Linux 532223
progjuegos.com
TSU Analisis de Sistemas
Universidad de Carabobo
Facultad de 
Odontología





2011/3/24 Massimo Di Pierro 

> web2py has a script to run with tornado.
> This video shows how to install and run it:
>
> http://vimeo.com/21185623
>
> Mind there is no benefit compared with the built-in rocket.
> I have seend web2py run with nginx+uwsgi and I stringly recommend it.
> Somebody should make a
>
> setup-nginx-wsgi.sh
>
> Massimo
>
>
>
> On Mar 24, 5:37 pm, Luis Díaz  wrote:
> > will try next week to conduct stress tests.
> > someone has a script-style "setup-web2py.sh?
> > allow me to implement a tornado server
> > and allows restart in case of failure
> >
> > Díaz Luishttp://www.facebook.com/diazluis2007
> > User Linux 532223
> > progjuegos.com
> > TSU Analisis de Sistemas
> > Universidad de Carabobo
> > Facultad de Odontología<
> http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar...>
> >
> > 2011/3/24 VP 
> >
> >
> >
> >
> >
> >
> >
> > > You can stop and restart apache to confirm that it takes that much
> > > RAM.
> >
> > > If you do a stress test, you'll probably see that it will eat all your
> > > RAM.
> >
> > > On Mar 24, 3:55 pm, Luis Díaz  wrote:
> > > > I just implement a VPS with "debian 6 / 64bit"
> > > > using the script setup-web2py.sh
> >
> > > > VPS administrator in me Proxmox typical samples
> > > > consumption of 669 ram and without using the application
> >
> > > > but from the console I see the following:http://tinypaste.com/fbb29
> >
> > > > the system has allocated a total of 1GB RAM and 500MB swap
> >
> > > > Díaz Luishttp://www.facebook.com/diazluis2007
> > > > TSU Analisis de Sistemas
> > > > Universidad de Carabobo
> > > > Facultad de Odontología<
> > >http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar..
> .>
> >
> > > > 2011/3/19 Luis Díaz 
> >
> > > > > next week I test with that configuration,
> > > > > whatever the result will comment
> >
> > > > > Díaz Luis
> > > > >http://www.facebook.com/diazluis2007
> > > > > TSU Analisis de Sistemas
> > > > > Universidad de Carabobo
> > > > > Facultad de Odontología<
> > >http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar..
> .>
> >
> > > > > 2011/3/19 VP 
> >
> > > > >> Anybody is using Apache2 with Debian 6?
> >
> > > > >> I just upgraded from Debian 5 to 6, and notice an obscene amount
> of
> > > > >> memory taken by Apache2, which almost 600MB.   Unbelievable.   In
> > > > >> Debian 5, it took about 300MB.
> >
> > > > >> I am guessing I'll have to go with another server then.
>


[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-24 Thread DenesL


On Mar 23, 12:29 pm, Massimo Di Pierro 
wrote:
> Thins constraint
>
> >   db.purchases.quantity.requires=IS_INT_IN_RANGE(0,10)
>
> is enforced in
>
> form=crud.create(db.purchases)
> form=crud.update(db.purchases,record)
> form=SQLFORM(db.purchases)
> form=SQLFORM.factory(...,db.purchases.quantity,...)
>
> It is not enforced in forms built manually, like HTML and FORM helper.

erm... ahem... I can use form.accepts with FORM objects.

> The Example 33 was written more then 3 years ago and needs to be
> revised.
>
> Massimo
>


[web2py] Does this seems familiar?

2011-03-24 Thread DenesL
http://www.microsoft.com/web/post/web-development-101-using-webmatrix

layout, database, template language, helpers, intellisense, ...

I have seen all this before... but where?.


[web2py] Re: onmouseover

2011-03-24 Thread DenesL


On Mar 24, 4:41 pm, Kenneth Lundström 
wrote:
>  > I am guessing you mean a Python variable
>
> Right
>
>  > so maybe:
>  > _onmouseover="displayText('info', {{=watchers[check_date]}} )",
>
> But I m building the table in the controller so I guess I can t use
> {{=     }}   ?

In that case:
_onmouseover="displayText('info', %s)" %watchers[check_date],

> Kenneth
>
>
>
>
>
>
>
> >> It is the watchers[check_date] that holds the text that should be sent
> >> to the javascript but nothing is sent.
>
> >> I have verified that the variable contains text and if I define
> >> _onmouseover="displayText('info', 'test_text')",
>
> >> it works.
>
> >> Kenneth


Re: [web2py] Re: File Upload and save to DB

2011-03-24 Thread Ismael Alejandro
Hi again, working with the original section, now I have this:


- On a CLIENT computer, I generate the INI file with this structure:
[Room]

name = room1
color = red
size = big

- I send it by FTP to the computer where web2py is running

- I have this script to parse and process the INI files on the server:

import os
import ConfigParser
import traceback

_configDir = "_configuploads"

def parse(filename):
try:
config = ConfigParser.ConfigParser()
print filename
config.read(filename)
rooms = config.sections()
print "Rooms: %s"%rooms
dictio = {}
for room in rooms:
dictio[rom] = {}
options = config.options(room)
print "Ops: %s"%options
for option in options:
dictio[room][option] = config.get(room,option)
print dictio
return 0
except:
print "Something failed!"
print traceback.format_exc()
return 1

objects = os.listdir(_configDir)

for item in objects:
fitem = os.path.join(os.getcwd(),_configDir,item)
parse(fitem)
print "="

this is a script placed on the root web2py directory (I'm using the source
version on a Windows PC)

So with this script I parse the INI and put the info in to a dictionary
called "dictio", now,  how could I use this dictio info for saving it in the
DB. Keys are generic and standard so they are the fields names. Values are
the Values :P


I'm not expert with python, in fact all above is made with some code of
here, some of there


Thanks! I hope you can help me!


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

2011-03-24 Thread pbreit
I think I'm in agreement. App-specific routing should be controlled at the 
app level. I was just saying that it might be tricky to figure out how to 
set up the default file structure and routes to both work and handle future 
updates.

Re: [web2py] Stopping Dev server

2011-03-24 Thread pbreit
I guess it is tricky. I was concerned about my crons causing 5 python 
processes to start every time I restarted web2py. The answer is probably not 
that simple. When you're in dev mode and only using Python with web2py, 
there might be a solution. Otherwise, I suppose you have to be careful about 
which Python threads you kill.

Re: [web2py] Stopping Dev server

2011-03-24 Thread Marco Mansilla
I've been wondering about it too, and for the same reasons, wouldn't be
possible to set a -reload parameter on development mode? or just a mode
that assumes it by itself, develmode or something like that. 

Marco

> Hi,
> 
> Just wondering if the admin application could off the option to
> restart the development webserver.
> 
> When running in development mode using "python2.5 web2py.py" there
> are a few times when the server needs to be stopped or restarted
> (install upgrade, adding routes.py).
> 
> I wondered whether it would be possible for the admin application to
> at least do a clean shutdown to save me needing to open an extra
> terminal and paste the "kill -SIGTERM " command. I even wonder if
> it would be possible to go one step further and automagically restart
> web2py
> 
> Obviously this is protected so it only works if logged into admin and
> running web2py directly (or maybe the GAE server as well) rather than
> using another server.
> 
> Dave
> 


[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread fib
Hi all
OK I got it to work

I found a MySQLdb for python 2.5 .exe on sourceforge
http://sourceforge.net/projects/mysql-python/files%2Fmysql-python%2F1.2.2/

then the rest I got sorted through the command line

apologies for idiocy
thank you for all your help it is much appreciated

On Mar 24, 8:03 pm, fib  wrote:
> Oh I think "reply to author" was an email - I think I replied but it is not
> showing here?


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

2011-03-24 Thread Martín Mulone
Sorry perhaps I don't express myself correctly, I'm not saying this is a bug
or I can't do with the current way. I'm only saying that I think better if
there are something like that in app level. It's an idea. Main routes.py to
control things up to the application, and the rest by the application.

Main: routes.py:

Domain Application
---
www.domain1.com domain1
www.domain2.com domain2

Aplication:  applications/domain1/routes/routes.py:

InOut
--
/favicon.ico /static/favicon.ico


Final result: routes.py + application/routes.

/domain1/static/favicon.icowww.domain1.com/favicon.ico


In my experience in production I never share things between application or
statics. I Think in the 97% or more of the application developed, to be in
production are completely independant from the others app.




2011/3/24 pbreit 

> +1 for a move towards routes default "on" and primarily controlled at the
> app level. But I do recognize there is an issue about what file should come
> in the main distribution and how to avoid it being overwritten with updates.
>
> The default files could duplicate the current default functionality for
> explicitness.
>



-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

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


Re: [web2py] Re: Class in the session

2011-03-24 Thread Rui Gomes
I guys,

The "order = cache.ram(session.name, lambda:Order(), 3600)", did work and
do exactly what I want thanks for the tips,
the part of not holding the data is no problem, if I want it to be
persistent data I will at some point insert in to the DB.

Regards
Rui Gomes

On Thu, Mar 24, 2011 at 3:51 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I have not tested is but I suspect cache.disk add some 10-20ms to
> every request. Only use it if to cache long queries, not cache pages.
> cache.ram is the way to go for many other cases even if you loose it
> upon restart.
>
> On Mar 24, 12:57 pm, Michele Comitini 
> wrote:
> > I would use cache.disk otherwise on restart everything would be lost
> >
> > 2011/3/24 Jose :
> >
> >
> >
> >
> >
> >
> >
> > >> You should use cache.
> >
> > >> order = cache.ram('order', lambda:Order(), 3600)
> >
> > > order = cache.ram(session.name, lambda:Order(), 3600)
> >
> > > Jose
>


[web2py] Stopping Dev server

2011-03-24 Thread David Warnock
Hi,

Just wondering if the admin application could off the option to restart the
development webserver.

When running in development mode using "python2.5 web2py.py" there are a few
times when the server needs to be stopped or restarted (install upgrade,
adding routes.py).

I wondered whether it would be possible for the admin application to at
least do a clean shutdown to save me needing to open an extra terminal and
paste the "kill -SIGTERM " command. I even wonder if it would be
possible to go one step further and automagically restart web2py

Obviously this is protected so it only works if logged into admin and
running web2py directly (or maybe the GAE server as well) rather than using
another server.

Dave

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


[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread pbreit
OK, I see. Is there some way to intercept the user/register form.accepts to 
set that default? 

[web2py] Re: Class in the session

2011-03-24 Thread Massimo Di Pierro
I have not tested is but I suspect cache.disk add some 10-20ms to
every request. Only use it if to cache long queries, not cache pages.
cache.ram is the way to go for many other cases even if you loose it
upon restart.

On Mar 24, 12:57 pm, Michele Comitini 
wrote:
> I would use cache.disk otherwise on restart everything would be lost
>
> 2011/3/24 Jose :
>
>
>
>
>
>
>
> >> You should use cache.
>
> >> order = cache.ram('order', lambda:Order(), 3600)
>
> > order = cache.ram(session.name, lambda:Order(), 3600)
>
> > Jose


[web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread Massimo Di Pierro
web2py has a script to run with tornado.
This video shows how to install and run it:

http://vimeo.com/21185623

Mind there is no benefit compared with the built-in rocket.
I have seend web2py run with nginx+uwsgi and I stringly recommend it.
Somebody should make a

setup-nginx-wsgi.sh

Massimo



On Mar 24, 5:37 pm, Luis Díaz  wrote:
> will try next week to conduct stress tests.
> someone has a script-style "setup-web2py.sh?
> allow me to implement a tornado server
> and allows restart in case of failure
>
> Díaz Luishttp://www.facebook.com/diazluis2007
> User Linux 532223
> progjuegos.com
> TSU Analisis de Sistemas
> Universidad de Carabobo
> Facultad de 
> Odontología
>
> 2011/3/24 VP 
>
>
>
>
>
>
>
> > You can stop and restart apache to confirm that it takes that much
> > RAM.
>
> > If you do a stress test, you'll probably see that it will eat all your
> > RAM.
>
> > On Mar 24, 3:55 pm, Luis Díaz  wrote:
> > > I just implement a VPS with "debian 6 / 64bit"
> > > using the script setup-web2py.sh
>
> > > VPS administrator in me Proxmox typical samples
> > > consumption of 669 ram and without using the application
>
> > > but from the console I see the following:http://tinypaste.com/fbb29
>
> > > the system has allocated a total of 1GB RAM and 500MB swap
>
> > > Díaz Luishttp://www.facebook.com/diazluis2007
> > > TSU Analisis de Sistemas
> > > Universidad de Carabobo
> > > Facultad de Odontología<
> >http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar...>
>
> > > 2011/3/19 Luis Díaz 
>
> > > > next week I test with that configuration,
> > > > whatever the result will comment
>
> > > > Díaz Luis
> > > >http://www.facebook.com/diazluis2007
> > > > TSU Analisis de Sistemas
> > > > Universidad de Carabobo
> > > > Facultad de Odontología<
> >http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar...>
>
> > > > 2011/3/19 VP 
>
> > > >> Anybody is using Apache2 with Debian 6?
>
> > > >> I just upgraded from Debian 5 to 6, and notice an obscene amount of
> > > >> memory taken by Apache2, which almost 600MB.   Unbelievable.   In
> > > >> Debian 5, it took about 300MB.
>
> > > >> I am guessing I'll have to go with another server then.


Re: [web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread Vasile Ermicioi
why don't you use nginx or cherokee with uwsgi ? they both consume much less
ram than apache


Re: [web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread Luis Díaz
will try next week to conduct stress tests.
someone has a script-style "setup-web2py.sh?
allow me to implement a tornado server
and allows restart in case of failure

Díaz Luis
http://www.facebook.com/diazluis2007
User Linux 532223
progjuegos.com
TSU Analisis de Sistemas
Universidad de Carabobo
Facultad de 
Odontología





2011/3/24 VP 

> You can stop and restart apache to confirm that it takes that much
> RAM.
>
> If you do a stress test, you'll probably see that it will eat all your
> RAM.
>
> On Mar 24, 3:55 pm, Luis Díaz  wrote:
> > I just implement a VPS with "debian 6 / 64bit"
> > using the script setup-web2py.sh
> >
> > VPS administrator in me Proxmox typical samples
> > consumption of 669 ram and without using the application
> >
> > but from the console I see the following:http://tinypaste.com/fbb29
> >
> > the system has allocated a total of 1GB RAM and 500MB swap
> >
> > Díaz Luishttp://www.facebook.com/diazluis2007
> > TSU Analisis de Sistemas
> > Universidad de Carabobo
> > Facultad de Odontología<
> http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar...>
> >
> > 2011/3/19 Luis Díaz 
> >
> >
> >
> >
> >
> >
> >
> > > next week I test with that configuration,
> > > whatever the result will comment
> >
> > > Díaz Luis
> > >http://www.facebook.com/diazluis2007
> > > TSU Analisis de Sistemas
> > > Universidad de Carabobo
> > > Facultad de Odontología<
> http://www.odontologia.uc.edu.ve/index.php?option=com_content&view=ar...>
> >
> > > 2011/3/19 VP 
> >
> > >> Anybody is using Apache2 with Debian 6?
> >
> > >> I just upgraded from Debian 5 to 6, and notice an obscene amount of
> > >> memory taken by Apache2, which almost 600MB.   Unbelievable.   In
> > >> Debian 5, it took about 300MB.
> >
> > >> I am guessing I'll have to go with another server then.
>


[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread Massimo Di Pierro
default does a take a lambda but one without arguments, because the info is 
used before the form is submitted so there is no data (r).



On Mar 24, 2011, at 5:30 PM, pbreit wrote:

> I don't think that's quite the behavior I'm looking for. I want it to 1) 
> default.paypal_email=email upon registration and 2) both email and 
> paypal_email editable independently in Edit Profile.
> 
> So this would be perfect:
>  
>  Field('paypal_email', length=128, default=lambda r: r.email))
> 
> But "default" apparently doesn't take a lambda.



[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread pbreit
I don't think that's quite the behavior I'm looking for. I want it to 1) 
default.paypal_email=email upon registration and 2) both email and 
paypal_email editable independently in Edit Profile.

So this would be perfect:
 
 Field('paypal_email', length=128, default=lambda r: r.email))

But "default" apparently doesn't take a lambda.


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

2011-03-24 Thread pbreit
+1 for a move towards routes default "on" and primarily controlled at the 
app level. But I do recognize there is an issue about what file should come 
in the main distribution and how to avoid it being overwritten with updates.

The default files could duplicate the current default functionality for 
explicitness.


[web2py] Re: squeeze + Apache2 = lots of RAM

2011-03-24 Thread VP
You can stop and restart apache to confirm that it takes that much
RAM.

If you do a stress test, you'll probably see that it will eat all your
RAM.

On Mar 24, 3:55 pm, Luis Díaz  wrote:
> I just implement a VPS with "debian 6 / 64bit"
> using the script setup-web2py.sh
>
> VPS administrator in me Proxmox typical samples
> consumption of 669 ram and without using the application
>
> but from the console I see the following:http://tinypaste.com/fbb29
>
> the system has allocated a total of 1GB RAM and 500MB swap
>
> Díaz Luishttp://www.facebook.com/diazluis2007
> TSU Analisis de Sistemas
> Universidad de Carabobo
> Facultad de 
> Odontología
>
> 2011/3/19 Luis Díaz 
>
>
>
>
>
>
>
> > next week I test with that configuration,
> > whatever the result will comment
>
> > Díaz Luis
> >http://www.facebook.com/diazluis2007
> > TSU Analisis de Sistemas
> > Universidad de Carabobo
> > Facultad de 
> > Odontología
>
> > 2011/3/19 VP 
>
> >> Anybody is using Apache2 with Debian 6?
>
> >> I just upgraded from Debian 5 to 6, and notice an obscene amount of
> >> memory taken by Apache2, which almost 600MB.   Unbelievable.   In
> >> Debian 5, it took about 300MB.
>
> >> I am guessing I'll have to go with another server then.


[web2py] Re: I goofed

2011-03-24 Thread pbreit
I'm sure the book format is great but if you are at your computer, I would 
suggest using the online version: http://web2py.com/book

[web2py] Re: Class in the session

2011-03-24 Thread Jose


On 24 mar, 14:57, Michele Comitini  wrote:
> I would use cache.disk otherwise on restart everything would be lost
>

Basically the concept is the same.

Jose


Re: [web2py] squeeze + Apache2 = lots of RAM

2011-03-24 Thread Luis Díaz
I just implement a VPS with "debian 6 / 64bit"
using the script setup-web2py.sh

VPS administrator in me Proxmox typical samples
consumption of 669 ram and without using the application

but from the console I see the following:
http://tinypaste.com/fbb29

the system has allocated a total of 1GB RAM and 500MB swap



Díaz Luis
http://www.facebook.com/diazluis2007
TSU Analisis de Sistemas
Universidad de Carabobo
Facultad de 
Odontología





2011/3/19 Luis Díaz 

> next week I test with that configuration,
> whatever the result will comment
>
> Díaz Luis
> http://www.facebook.com/diazluis2007
> TSU Analisis de Sistemas
> Universidad de Carabobo
> Facultad de 
> Odontología
>
>
>
>
>
> 2011/3/19 VP 
>
>> Anybody is using Apache2 with Debian 6?
>>
>> I just upgraded from Debian 5 to 6, and notice an obscene amount of
>> memory taken by Apache2, which almost 600MB.   Unbelievable.   In
>> Debian 5, it took about 300MB.
>>
>> I am guessing I'll have to go with another server then.
>>
>>
>


Re: [web2py] Re: onmouseover

2011-03-24 Thread Kenneth Lundström

> I am guessing you mean a Python variable

Right

> so maybe:
> _onmouseover="displayText('info', {{=watchers[check_date]}} )",

But I´m building the table in the controller so I guess I can´t use 
{{= }}   ?



Kenneth



It is the watchers[check_date] that holds the text that should be sent
to the javascript but nothing is sent.

I have verified that the variable contains text and if I define
_onmouseover="displayText('info', 'test_text')",

it works.

Kenneth




[web2py] I goofed

2011-03-24 Thread Hal Smith
Working on the view file this morning, I noticed my error. I had
copied the line numbers into the code when I copied the code from the
manual.

Today I removed those, and added the session counter code. Everything
works fine.


[web2py] Re: onmouseover

2011-03-24 Thread DenesL


On Mar 24, 4:55 am, Kenneth Lundström 
wrote:
> I got the onmouseover to work but how do I send text to the javascript
> from a variable. I have this code

I am guessing you mean a Python variable

>   TD(P(day, _class="text_black"), _class="red",
> _onmouseover="displayText('info', watchers[check_date])",
> _onmouseout="hideText('info')")

so maybe:
_onmouseover="displayText('info', {{=watchers[check_date]}} )",

> It is the watchers[check_date] that holds the text that should be sent
> to the javascript but nothing is sent.
>
> I have verified that the variable contains text and if I define
> _onmouseover="displayText('info', 'test_text')",
>
> it works.
>
> Kenneth


[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread fib
Oh I think "reply to author" was an email - I think I replied but it is not 
showing here?

Re: [web2py] Re: Scaffolding app with Twitter OAuth1.0a auth

2011-03-24 Thread Tito Garrido
Hi Albert,

Were you able to import it on webfaction? If yes, how did you do that?

Regards,

Tito

On Mon, Sep 6, 2010 at 7:50 AM, Albert Abril  wrote:

> Hi Michelle.
>
> Yes, As you said, I defined it in the db.py.
>
> Now, I'm having an error importing oauth2.
> I installed python-oauth2 in webfaction with 'easy_install'.
> But it seems like it can't import. I'll check the env.
>
> On Mon, Sep 6, 2010 at 12:47 PM, Michele Comitini <
> michele.comit...@gmail.com> wrote:
>
>> Hi Yannik,
>>
>> sorry for late answering...
>>
>> just go on http://developer.twitter.com and register an application.
>> After that you get the CLIENT_ID and CLIENT_SECRET, TOKEN_URL and
>> ACCESS_TOKEN_URL from twitter.
>> define those variables in a file called twitter_oauth_data.py in
>> modules dir under your application and keep the file *secret*.
>> After that any user that authenticates with the application will be
>> redirected to twitter and  twitter will let
>> your application act on behalf of the user.  You do not have to ask
>> any secret from the user!
>> For more info on how twitter authenticates see http://oauth.net
>>
>> michele
>>
>> 2010/9/5 Yannick :
>> > Hello Thanks for the note.
>> > I was using the Simple Authentication on my application to send
>> > tweets. I just noticed that twitter no longer support it.  I guess I
>> > have to switch to Twitter oAuth API.
>> > I was wondering because it looks like to send tweet, each user of my
>> > application should get a CLIENT_ID, CLIENT_SECRET  (oauth_token and
>> > oauth_token_secret). I wonder where they will get it from ? Should
>> > each of them have to register my application in their twitter Account
>> > to get it ?
>> >
>> > Thanks for your help,
>> > Yannick P.
>> >
>> >
>> > On Aug 30, 4:00 am, Michele Comitini 
>> > wrote:
>> >> Actually if you look on developer.twitter.com, you will find some
>> >> library that maps thetwitterREST api to
>> >> python methods.  But I did not relay on that as it would have added
>> >> more dependencies.
>> >> I think that is something that you can use depending the application
>> >> you are going to develop.
>> >>
>> >> Things are simple even without external libraries, look for instance
>> >> at the get_user method in db.py, how it gets user info:
>> http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
>> >>
>> >> def get_user(self):
>> >> if self.accessToken() is not None:
>> >> client =oauth.Client(self.consumer, self.accessToken())
>> >> resp, content =
>> >> client.request('
>> http://api.twitter.com/1/account/verify_credentials.json')
>> >> if resp['status'] != '200':
>> >> # cannot get user info. should check status
>> >> return None
>> >> u = json.loads(content)
>> >> return dict(username=u['screen_name'], name=u['name'],
>> >> registration_id=u['id'])
>> >>
>> >> so you build a client, make a request to a REST api url
>> >> (http://api.twitter.com/1/account/verify_credentials.json)
>> >>
>> >> To post a tweet see:http://dev.twitter.com/doc/post/statuses/update
>> >>
>> >> in your controller you should write something like this:
>> >>
>> >> import oauth2 asoauth
>> >> .
>> >> .
>> >> .
>> >> @auth.requires_login()
>> >> def sendtweet():
>> >>   token = auth.settings.login_form.accessToken() # you can use this
>> >> also if you prefer: token=session.access_token
>> >>   consumer =oauth.Consumer(CLIENT_ID, CLIENT_SECRET) #<- CLIENT_ID,
>> >> CLIENT_SECRET are defined in db.py
>> >>   client =oauth.Client(self.consumer, token)
>> >>   # encode the message
>> >>   message = 'My web2py post!"
>> >>   data=urlencode(status=message)
>> >>   #make a post
>> >>   resp, content =
>> >> client.request('http://api.twitter.com/1/statuses/update.json',
>> >> "POST", body=data)
>> >>   if resp['status'] != '200':
>> >> #manage the error
>> >> return dict(message="Could not send tweet! :-( ")
>> >>
>> >>   return dict(message="Succesfully sent! :-)")
>> >>
>> >> if you call method returning some data I suggest tu use the .json
>> >> version of it and use
>> >> simplejson to decode it to a python dictionary (see the get_user()
>> method above)
>> >>
>> >> hope that helps...
>> >> mic
>> >>
>> >> 2010/8/30 Albert Abril :
>> >>
>> >> > Just a question: what do you use for post a tweet, read statuses... ?
>> >> > Thanks in advance.
>> >>
>> >> > On Sun, Aug 29, 2010 at 12:39 PM, Albert Abril <
>> albert.ab...@gmail.com>
>> >> > wrote:
>> >>
>> >> >> :) Thank you!
>> >>
>> >> >> On Sun, Aug 29, 2010 at 1:45 AM, Michele Comitini
>> >> >>  wrote:
>> >>
>> >> >>> Hello all,
>> >>
>> >> >>> I've uploaded a scaffolding app as example of authentication with
>> >> >>>twitteroauth.  You can find source code here:
>> >>
>> >> >>>
>> https://code.google.com/r/michelecomitini-facebookaccess/source/brows...
>> >>
>> >> >>> Or you can clone the repository locally:
>> >> >>>
>> https://code.google.com/r/michelecomitini-

Re: [web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread Vasile Ermicioi
try to implement it with pymysql which is shipped with web2py
(gluon.contrib.pymysql)


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

2011-03-24 Thread Tom Atkins
Thanks Anthony - you're right and I do know this - just wrote the wrong
thing in my previous post - I meant to say 'change to pattern-based'... make
me wonder what other stupid mistakes I'm making... but double checked and I
think I have everything correct and as suggested by Massimo.

On 24 March 2011 18:02, Anthony  wrote:

> Tom, you cannot mix usage of the parameter-based and pattern-based routing
> systems, even if one is in the global routes.py and one is in an
> app-specific routes.py. You have to pick one system or the other, for now
> anyway.
>
> Anthony
>
>


Re: [web2py] Re: 1.94.5 auth pb form won't submit

2011-03-24 Thread Richard Vézina
Thanks!

Removing "required=True" solved the problem...

Richard

On Tue, Mar 22, 2011 at 2:38 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This should never have worked:
>
> Field('seizure_date','date',
>writable=False,
>...
>required=True
>),
>
> the field is not writable (so it does not appear in form) and yet it
> is required (must have a value when doing insert).
>
> On Mar 22, 11:49 am, Richard Vézina 
> wrote:
> > Hello,
> >
> > None of my form won't submit anymore when I try my app under 1.94.5...
> >
> > It seems to be related to auth problem coming from the refactoring.
> >
> > Here a example of form, model and trace that occure :
> >
> > Traceback (most recent call last):
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/restricte
> d.py",
> > line 188, in restricted
> > exec ccode in environment
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/applications/sg
> ddms/controllers/ref.py",
> > line 229, in 
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/globals.p
> y",
> > line 124, in 
> > self._caller = lambda f: f()
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/tools.py"
> ,
> > line 2331, in f
> > return action(*a, **b)
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/applications/sg
> ddms/controllers/ref.py",
> > line 26, in create
> > if form.accepts(request.vars, session):
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/sqlhtml.p
> y",
> > line 1197, in accepts
> > self.vars.id = self.table.insert(**fields)
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/dal.py",
> > line 4341, in insert
> > return self._db._adapter.insert(self,self._listify(fields))
> >   File
> >
> "/home/richard/Documents/programmation/version_194-5/web2py/gluon/dal.py",
> > line 4334, in _listify
> > raise SyntaxError,'Table: missing required field: %s' % ofield.name
> > SyntaxError: Table: missing required field: seizure
> >
> > ### Model ###
> > # ref_fnaregistry
> > db.define_table('ref_fnaregistry',
> > Field('fnaregistry_id','id'),
> > Field('num_part1','string',
> > length=20,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('num_part2','string',
> > length=20,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('num_part3','string',
> > length=20,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('title','text'),
> > Field('att_date','date',
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty')),
> > IS_DATE(format=T('%Y-%m-%d'),error_message=T('valid date of
> > format : -MM-DD!'))],
> > required=True
> > ),
> > Field('seizure','db.auth_user',
> > readable=False,
> > writable=False,
> > default=auth.user and auth.user.id,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('seizure_date','date',
> > readable=False,
> > writable=False,
> > default=request.now,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('last_action_by','db.auth_user',
> > readable=False,
> > writable=False,
> > default=auth.user and auth.user.id,
> > update=auth.user and auth.user.id,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > Field('sdate','datetime',
> > readable=False,
> > writable=False,
> > default=request.now,
> > update=request.now,
> > notnull=True,
> > requires=[IS_NOT_EMPTY(error_message=T('field can\'t be
> empty'))],
> > required=True
> > ),
> > migrate=False,
> > sequence_name='ref_fnaregistry_fnaregistry_id_seq',
> > format=lambda row: '%s-%s-%s / %s'\
> >
> >
> %(row.num_part1.rstrip(),row.num_part2.rstrip(),row.num_part3.rstrip(),row.
> title.rstrip()))
> >
> > ### 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:
> > tabl

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

2011-03-24 Thread Anthony
Tom, you cannot mix usage of the parameter-based and pattern-based routing 
systems, even if one is in the global routes.py and one is in an 
app-specific routes.py. You have to pick one system or the other, for now 
anyway.
 
Anthony

On Thursday, March 24, 2011 1:59:33 PM UTC-4, Tom A wrote:

> Thanks for this suggestion Massimo - it's the closest to what I'm looking 
> for.  I've tried to get it to work but no joy. 
>
> I've changed my global routes.py to use parameter based routing sand put 
> the first part of your code in the application specific routes.py.
>
> I've then put the 2nd part of your code into the default controller.  But 
> if you go to:
>
> myapp.com/Supersite/users
>
> I get:
>
> invalid controller (Supersite/users)
>
> I've tried but can't figure out a solution...
>
>
>
> On 23 March 2011 13:46, Massimo Di Pierro  wrote:
>
>> yes. For example: 
>>
>> routes_in = [
>>   ('/$yoursitename/users','/init/default/users/$yoursitename'),
>> ]
>>
>> the optionally
>>
>> @request.restful()
>> def users():
>>   def GET(yoursitename):
>>  return dict(message='your site name is: '+yoursitename)
>>   return locals() 
>>  
>>
>>
>>
>>
>>  On Mar 23, 2011, at 8:31 AM, Anthony wrote:
>>
>>  Massimo, I think Tom was referring to Flask's ability to include an arg 
>> at an arbitrary place in the URL path (e.g., '//users'), not 
>> the ability to specify the routes via decorators. I think the former *can* 
>> be achieved in web2py using the pattern-based rewrite system, right?
>>  
>> Anthony
>>
>> On Wednesday, March 23, 2011 9:17:31 AM UTC-4, Massimo Di Pierro wrote:
>>
>>> This is not an option in web2py because the controller is executed 
>>> after the requests arrives not imported before (as in Flask). Anyway, 
>>> that works better for simple apps but becomes a mess if you have many 
>>> functions because the routing info is scattered all over the place. 
>>> Moreover - when it comes to rest - it requires that you use the same 
>>> function for multiple methods (GET/POST/etc) by using multiple 
>>> decorators or that you use different functions with different names to 
>>> handle different names (I do not like that). 
>>>
>>> On Mar 22, 3:13 am, Tom Atkins  wrote: 
>>> > I might be being naive here but in Flask I can do: 
>>> > 
>>> > @app.route('//users') 
>>> > ... def editusers(yoursitename): pass 
>>> > 
>>> > print url_for('editprofile', yoursitename='Supersite') 
>>> > 
>>> > gives: 
>>> > 
>>> > /Supersite/users 
>>> > 
>>> > On 22 March 2011 05:23, Jonathan Lundell  wrote: 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote: 
>>> > 
>>> > > Agree, Flask way looks more elegant (see Variable Rules). It could be 
>>> nice 
>>> > > if this way also exists on Web2Py. 
>>> > 
>>> > > On 22 March 2011 06:05, Tom Atkins  wrote: 
>>> > 
>>> > >> I was playing with Flask and I have to say its solution to routing 
>>> is very 
>>> > >> nice: 
>>> > 
>>> > >>http://flask.pocoo.org/docs/quickstart/#routing 
>>> > 
>>> > >> The use of variable names anywhere within the URL structure is very 
>>> handy. 
>>> > >> Anything like this possible in web2py? 
>>> > 
>>> > > Flask doesn't really allow variable names anywhere; near as I can 
>>> tell 
>>> > > they're a considerably restricted version of web2py's args list.
>>
>>
>>
>

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

2011-03-24 Thread Tom Atkins
Thanks for this suggestion Massimo - it's the closest to what I'm looking
for.  I've tried to get it to work but no joy.

I've changed my global routes.py to use parameter based routing sand put the
first part of your code in the application specific routes.py.

I've then put the 2nd part of your code into the default controller.  But if
you go to:

myapp.com/Supersite/users

I get:

invalid controller (Supersite/users)

I've tried but can't figure out a solution...



On 23 March 2011 13:46, Massimo Di Pierro wrote:

> yes. For example:
>
> routes_in = [
>   ('/$yoursitename/users','/init/default/users/$yoursitename'),
> ]
>
> the optionally
>
> @request.restful()
> def users():
>   def GET(yoursitename):
>  return dict(message='your site name is: '+yoursitename)
>   return locals()
>
>
>
>
>
> On Mar 23, 2011, at 8:31 AM, Anthony wrote:
>
> Massimo, I think Tom was referring to Flask's ability to include an arg at
> an arbitrary place in the URL path (e.g., '//users'), not the
> ability to specify the routes via decorators. I think the former *can* be
> achieved in web2py using the pattern-based rewrite system, right?
>
> Anthony
>
> On Wednesday, March 23, 2011 9:17:31 AM UTC-4, Massimo Di Pierro wrote:
>
>> This is not an option in web2py because the controller is executed
>> after the requests arrives not imported before (as in Flask). Anyway,
>> that works better for simple apps but becomes a mess if you have many
>> functions because the routing info is scattered all over the place.
>> Moreover - when it comes to rest - it requires that you use the same
>> function for multiple methods (GET/POST/etc) by using multiple
>> decorators or that you use different functions with different names to
>> handle different names (I do not like that).
>>
>> On Mar 22, 3:13 am, Tom Atkins  wrote:
>> > I might be being naive here but in Flask I can do:
>> >
>> > @app.route('//users')
>> > ... def editusers(yoursitename): pass
>> >
>> > print url_for('editprofile', yoursitename='Supersite')
>> >
>> > gives:
>> >
>> > /Supersite/users
>> >
>> > On 22 March 2011 05:23, Jonathan Lundell  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote:
>> >
>> > > Agree, Flask way looks more elegant (see Variable Rules). It could be
>> nice
>> > > if this way also exists on Web2Py.
>> >
>> > > On 22 March 2011 06:05, Tom Atkins  wrote:
>> >
>> > >> I was playing with Flask and I have to say its solution to routing is
>> very
>> > >> nice:
>> >
>> > >>http://flask.pocoo.org/docs/quickstart/#routing
>> >
>> > >> The use of variable names anywhere within the URL structure is very
>> handy.
>> > >> Anything like this possible in web2py?
>> >
>> > > Flask doesn't really allow variable names anywhere; near as I can tell
>>
>> > > they're a considerably restricted version of web2py's args list.
>
>
>


Re: [web2py] Re: Class in the session

2011-03-24 Thread Michele Comitini
I would use cache.disk otherwise on restart everything would be lost

2011/3/24 Jose :
>> You should use cache.
>>
>> order = cache.ram('order', lambda:Order(), 3600)
>
> order = cache.ram(session.name, lambda:Order(), 3600)
>
> Jose


[web2py] Re: Class in the session

2011-03-24 Thread Jose
> You should use cache.
>
> order = cache.ram('order', lambda:Order(), 3600)

order = cache.ram(session.name, lambda:Order(), 3600)

Jose


[web2py] Re: Class in the session

2011-03-24 Thread Jose
Sorry, this is global, not per session. Could be used by renaming the
object in each session.

order = cache.ram(session.name, lambda:Order(), 3600)

Jose


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

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 10:35 AM, Anthony wrote:
> On Thursday, March 24, 2011 12:51:56 PM UTC-4, Martin.Mulone wrote:
> Yes but not in the application folder. The importance is to be distributed 
> with the application.

I think you two might be talking at cross purposes here. It goes in 
applications/myapp/

>  
> With both systesms, you can put a routes.py file in the application folder, 
> but at least with the older system, for that to work, you also need a 
> routes_app entry in the main routes.py file -- is that what you're saying you 
> don't want? In other words, you want no dependency on any central routes.py 
> file? Perhaps Jonathan can verify, but I think that may be possible with the 
> new system (i.e., having a routes.py file in your app folder without having a 
> routes.py file in the web2py root folder).
> 

Both versions of routing work the same way, in principle. You need a base 
(root) routes.py so that the router can figure out the application (otherwise 
it wouldn't know which app-specific routes.py to use). The rest of the routing 
information can be in each applications root folder.

The new router's syntax makes it pretty easy to have all the routing in the 
base routes.py, though, since each app can simply have its own routing dict.

[web2py] Re: Class in the session

2011-03-24 Thread Jose


On 24 mar, 11:04, NewBeen  wrote:
> Hello guys,
>
> I have this class in a model,
>
> Class Order:
>
>     def __init__(self):
>         self.basket={"product":{},"quantity":{}}
>
>    def addProduct(self, Item):
>        self.basket["product"]["name"]=item["name"]
>
> session.order=Order()
>
> So far so good, but when I execute this, the class is always been
> initialize, so I lose my basket between pages...
> Any ideas how can I fix this, if I put a class in a module and import
> it will it fix it?
>
> Regards
> Rui Gomes

Hi,

You should use cache.

order = cache.ram('order', lambda:Order(), 3600)


[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread Kevin Ivarsen
The extract_mysql_models.py script runs at the command line - either from 
cmd.exe in Windows or a Terminal window in Mac / Linux. Which operating 
system are you running? I can try to walk you through the steps.

Also, I don't believe MySQLdb is included with web2py by default, but it is 
easy to install. Again, depending on your operating system, I can try to 
help you out here.

Kevin


[web2py] New framework: whirlwind

2011-03-24 Thread pbreit
http://wiredset.com/2011/03/23/introducing-whirlwind-the-realtime-web-framework/

Tornado + mako + mongodb


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

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 12:51:56 PM UTC-4, Martin.Mulone wrote: 
>
> Yes but not in the application folder. The importance is to be distributed 
> with the application.

 
With both systesms, you can put a routes.py file in the application folder, 
but at least with the older system, for that to work, you also need a 
routes_app entry in the main routes.py file -- is that what you're saying 
you don't want? In other words, you want no dependency on any central 
routes.py file? Perhaps Jonathan can verify, but I think that may be 
possible with the new system (i.e., having a routes.py file in your app 
folder without having a routes.py file in the web2py root folder).
 
Anthony


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

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 9:57 AM, Martín Mulone wrote:
> For example I have a blog application with this url
> 
> http://www.mysite.com/blog/default/post/2010/10/10/my-article
> 
> I can short to this:
> 
> http://www.mysite.com/blog/2010/10/10/my-article
> 
> with this one route:
> 
> (r'.*:/blog/(?P(19|20)\d\d[- /.](0[1-9]|1[012])[- 
> /.](0[1-9]|[12][0-9]|3[01]).*)$',r'/blog/default/post/\g')
> 
> Not easy to read :) if I can make it transparent to the user that the user 
> not have to worried about routes. 

You can do this with the new router if you make post the default function of 
the blog app, and create a list of functions in blog/default. Something like 
this:

routers = dict(

blog = dict(
default_function='post',
functions=['index', 'user', 'post', 'whatever'],
),
)

You'll need to parse and validate the args in default/post.

By specifying a list of functions in the default controller, you're telling the 
router that it can unambiguously omit the 'post' name if there's no conflict. 
So with the router above, a URL like /blog/default/post/index would *not* be 
shortened to /blog/index, because that would conflict with the function named 
'index'.

> 
> 2011/3/24 Martín Mulone 
> Yes but not in the application folder. The importance is to be distributed 
> with the application.
> 
> 2011/3/24 Anthony 
> I believe this is already possible, no?
>  
> The book describes app-specific routing for the old system: 
> http://web2py.com/book/default/chapter/04#Pattern-Based-System
>  
> And  for the new system, the router.example.py file 
> (http://code.google.com/p/web2py/source/browse/router.example.py) mentions 
> you can have an app-specific router in applications/app/routes.py.
>  
> Anthony
> 
> On Thursday, March 24, 2011 11:49:58 AM UTC-4, Martin.Mulone wrote:
> I really want to see routes in the application folder. Routes in the past was 
> hard to follow, now I think the work of Johnatan make it more easy. But when 
> you have many applications, the routes for all is a bit messy. I don't know 
> if this can be done:
> 
> For example a simple case:
> 
> Main routes.py:
> ---
> 
> Domain Application
> -
> www.domain1.com domain1
> www.domain2.com domain2
> 
> 
> 
> Aplication:  applications/domain1/routes.py:
> ---
> 
> 
> [routes In]
> In Out
> --
> /favicon.ico /static/favicon.ico
> 
> 
> [routes Out]
> In Out
> --
> default/index /
> plugin_i2p/view/333 /view/333
> 
> 
> 2011/3/24 VP 
> 
> Noticing the version of web2py keeps interestingly increasing to 2.0,
> I think this is something Massimo might want to spend sometime
> thinking about.
> 
> As I understand it, because of "exec", controllers are called *after*
> the request arrives.  This allows web2py to do a few interesting
> things that other frameworks can't.
> 
> On the other hands, this is an example that shows an advantage of
> being able to manipulate controllers (concisely) *before* the request
> arrives.
> 
> I found myself constantly type checking controller arguments (e.g.
> making sure an "id" is a number).  This is another example where being
> able to specify a certain syntax to the URL is very helpful.
> 



[web2py] Re: Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Arbie Samong
This got rid of the errors. Thanks Massimo.

The only thing I added was a try-except block on search() when no people 
were found. The simpler version of the query also restricted the search 
somehow (had to search first name and last name with the right 
capitalization) but I guess that's the trade off. Will look for a way to 
improve the search with the GAE caveats in mind.


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

2011-03-24 Thread Martín Mulone
For example I have a blog application with this url

http://www.mysite.com/blog/default/post/2010/10/10/my-article

I can short to this:

http://www.mysite.com/blog/2010/10/10/my-article

with this one route:

(r'.*:/blog/(?P(19|20)\d\d[- /.](0[1-9]|1[012])[-
/.](0[1-9]|[12][0-9]|3[01]).*)$',r'/blog/default/post/\g')

Not easy to read :) if I can make it transparent to the user that the user
not have to worried about routes.

2011/3/24 Martín Mulone 

> Yes but not in the application folder. The importance is to be distributed
> with the application.
>
> 2011/3/24 Anthony 
>
>> I believe this is already possible, no?
>>
>> The book describes app-specific routing for the old system:
>> http://web2py.com/book/default/chapter/04#Pattern-Based-System
>>
>> And  for the new system, the router.example.py file (
>> http://code.google.com/p/web2py/source/browse/router.example.py) mentions
>> you can have an app-specific router in applications/app/routes.py.
>>
>> Anthony
>>
>> On Thursday, March 24, 2011 11:49:58 AM UTC-4, Martin.Mulone wrote:
>>
>>> I really want to see routes in the application folder. Routes in the past
>>> was hard to follow, now I think the work of Johnatan make it more easy. But
>>> when you have many applications, the routes for all is a bit messy. I don't
>>> know if this can be done:
>>>
>>> For example a simple case:
>>>
>>> Main routes.py:
>>> ---
>>>
>>> Domain Application
>>> -
>>> www.domain1.com domain1
>>> www.domain2.com domain2
>>>
>>>
>>>
>>> Aplication:  applications/domain1/routes.py:
>>> ---
>>>
>>>
>>> [routes In]
>>> In Out
>>> --
>>> /favicon.ico /static/favicon.ico
>>>
>>>
>>> [routes Out]
>>> In Out
>>> --
>>> default/index /
>>> plugin_i2p/view/333 /view/333
>>>
>>>
>>> 2011/3/24 VP 
>>>
>>> Noticing the version of web2py keeps interestingly increasing to 2.0,
 I think this is something Massimo might want to spend sometime
 thinking about.

 As I understand it, because of "exec", controllers are called *after*
 the request arrives.  This allows web2py to do a few interesting
 things that other frameworks can't.

 On the other hands, this is an example that shows an advantage of
 being able to manipulate controllers (concisely) *before* the request
 arrives.

 I found myself constantly type checking controller arguments (e.g.
 making sure an "id" is a number).  This is another example where being
 able to specify a certain syntax to the URL is very helpful.


>>>
>>>
>>> --
>>>  Pablo Martín Mulone (mar...@tecnodoc.com.ar)
>>> http://www.tecnodoc.com.ar/
>>>
>>> My blog: http://martin.tecnodoc.com.ar
>>> Expert4Solution Profile:
>>> http://www.experts4solutions.com/e4s/default/expert/6
>>>
>>>
>>>
>
>
> --
> Pablo Martín Mulone (mar...@tecnodoc.com.ar)
> http://www.tecnodoc.com.ar/
>
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution Profile:
> http://www.experts4solutions.com/e4s/default/expert/6
>
>
>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

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


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

2011-03-24 Thread Tom Atkins
The problem for me is not being able to mix the new parameter-based routing
with the pattern-based system (my regex skills are not good enough to make
the patten system do what I want) .

Is it possible to have parameter system in the global routes.py and then
pattern system in the app-specific routes.py?  That would solve my issues!

On 24 March 2011 16:06, Anthony  wrote:

> I believe this is already possible, no?
>
> The book describes app-specific routing for the old system:
> http://web2py.com/book/default/chapter/04#Pattern-Based-System
>
> And  for the new system, the router.example.py file (
> http://code.google.com/p/web2py/source/browse/router.example.py) mentions
> you can have an app-specific router in applications/app/routes.py.
>
> Anthony
>
> On Thursday, March 24, 2011 11:49:58 AM UTC-4, Martin.Mulone wrote:
>
>> I really want to see routes in the application folder. Routes in the past
>> was hard to follow, now I think the work of Johnatan make it more easy. But
>> when you have many applications, the routes for all is a bit messy. I don't
>> know if this can be done:
>>
>> For example a simple case:
>>
>> Main routes.py:
>> ---
>>
>> Domain Application
>> -
>> www.domain1.com domain1
>> www.domain2.com domain2
>>
>>
>>
>> Aplication:  applications/domain1/routes.py:
>> ---
>>
>>
>> [routes In]
>> In Out
>> --
>> /favicon.ico /static/favicon.ico
>>
>>
>> [routes Out]
>> In Out
>> --
>> default/index /
>> plugin_i2p/view/333 /view/333
>>
>>
>> 2011/3/24 VP 
>>
>> Noticing the version of web2py keeps interestingly increasing to 2.0,
>>> I think this is something Massimo might want to spend sometime
>>> thinking about.
>>>
>>> As I understand it, because of "exec", controllers are called *after*
>>> the request arrives.  This allows web2py to do a few interesting
>>> things that other frameworks can't.
>>>
>>> On the other hands, this is an example that shows an advantage of
>>> being able to manipulate controllers (concisely) *before* the request
>>> arrives.
>>>
>>> I found myself constantly type checking controller arguments (e.g.
>>> making sure an "id" is a number).  This is another example where being
>>> able to specify a certain syntax to the URL is very helpful.
>>>
>>>
>>
>>
>> --
>>  Pablo Martín Mulone (mar...@tecnodoc.com.ar)
>> http://www.tecnodoc.com.ar/
>>
>> My blog: http://martin.tecnodoc.com.ar
>> Expert4Solution Profile:
>> http://www.experts4solutions.com/e4s/default/expert/6
>>
>>
>>


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

2011-03-24 Thread Martín Mulone
Yes but not in the application folder. The importance is to be distributed
with the application.

2011/3/24 Anthony 

> I believe this is already possible, no?
>
> The book describes app-specific routing for the old system:
> http://web2py.com/book/default/chapter/04#Pattern-Based-System
>
> And  for the new system, the router.example.py file (
> http://code.google.com/p/web2py/source/browse/router.example.py) mentions
> you can have an app-specific router in applications/app/routes.py.
>
> Anthony
>
> On Thursday, March 24, 2011 11:49:58 AM UTC-4, Martin.Mulone wrote:
>
>> I really want to see routes in the application folder. Routes in the past
>> was hard to follow, now I think the work of Johnatan make it more easy. But
>> when you have many applications, the routes for all is a bit messy. I don't
>> know if this can be done:
>>
>> For example a simple case:
>>
>> Main routes.py:
>> ---
>>
>> Domain Application
>> -
>> www.domain1.com domain1
>> www.domain2.com domain2
>>
>>
>>
>> Aplication:  applications/domain1/routes.py:
>> ---
>>
>>
>> [routes In]
>> In Out
>> --
>> /favicon.ico /static/favicon.ico
>>
>>
>> [routes Out]
>> In Out
>> --
>> default/index /
>> plugin_i2p/view/333 /view/333
>>
>>
>> 2011/3/24 VP 
>>
>> Noticing the version of web2py keeps interestingly increasing to 2.0,
>>> I think this is something Massimo might want to spend sometime
>>> thinking about.
>>>
>>> As I understand it, because of "exec", controllers are called *after*
>>> the request arrives.  This allows web2py to do a few interesting
>>> things that other frameworks can't.
>>>
>>> On the other hands, this is an example that shows an advantage of
>>> being able to manipulate controllers (concisely) *before* the request
>>> arrives.
>>>
>>> I found myself constantly type checking controller arguments (e.g.
>>> making sure an "id" is a number).  This is another example where being
>>> able to specify a certain syntax to the URL is very helpful.
>>>
>>>
>>
>>
>> --
>>  Pablo Martín Mulone (mar...@tecnodoc.com.ar)
>> http://www.tecnodoc.com.ar/
>>
>> My blog: http://martin.tecnodoc.com.ar
>> Expert4Solution Profile:
>> http://www.experts4solutions.com/e4s/default/expert/6
>>
>>
>>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

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


Re: [web2py] Re: Class in the session

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 9:39 AM, Rui Gomes wrote:
> Regarding storing the class in the session is not a problem that work fine 
> for me(need to be careful some things can't be pickel), the problem is 
> re-write it at each call,
> 
> I already try something similar to 
> 
> order = session.order or Order()
> 
> I did,
> 
> if not isinstance("session.order",Order):
> session.order=Order()
> 
> that didnt work session.order look always like empty to the validation, since 
> a python module just get imported once, if I move the class out of the models 
> in the web2py and put it in a file and imported something 

A web2py model gets run on every request, so something like this should work OK 
(I think). Is it possible that session.order is there, but not recognized as 
Order? What happens if you test for: session.order is None?

> 
> from Order import *
> 
> Maybe thats work.
> 
> Any other ideas how to do this?
> 
> 
> BTW: Thanks for the help if in the mean while i figure this one out I will 
> post it here.
> 




Re: [web2py] Re: Class in the session

2011-03-24 Thread Rui Gomes
Regarding storing the class in the session is not a problem that work fine
for me(need to be careful some things can't be pickel), the problem is
re-write it at each call,

I already try something similar to

order = session.order or Order()

I did,

if not isinstance("session.order",Order):
session.order=Order()

that didnt work session.order look always like empty to the validation,
since a python module just get imported once, if I move the class out of the
models in the web2py and put it in a file and imported something

from Order import *

Maybe thats work.

Any other ideas how to do this?


BTW: Thanks for the help if in the mean while i figure this one out I will
post it here.

Regards
Rui Gomes



On Thu, Mar 24, 2011 at 3:51 PM, Jonathan Lundell wrote:

> On Mar 24, 2011, at 8:25 AM, Anthony wrote:
> > There is an additional problem, though. According to Massimo, web2py
> cannot store instances of classes in the session:
> https://groups.google.com/d/msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ. Perhaps
> Massimo has more to say regarding this example.
> >
>
> This is what Massimo wrote in that thread:
>
> > In web2py you cannot store instances of objects into session. While
> > Armin makes it tool like this is a web2py problem this is more complex
> > and general than that. In Python if you pickle and object that is
> > instance of a class defined in /path1/mymodule.py and then you
> > unpickle on a different installation where the class is defined in /
> > path2/mymodule.py you may run into problems. Because web2py does not
> > require installation (it is a feature) and has hot plug and play of
> > apps (another feature) we cannot pickle instances (the price we pay
> > for those features). To me it is worth it.
>
> I'd like to know a little more as well. It seems to me that since sessions
> are relatively transient (you're not going to preserve sessions if you move
> web2py elsewhere), the path to the class isn't going to change between
> session accesses.


[web2py] Re: Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Massimo Di Pierro
Could be a mistake in the packaging makefile. Will fix and repost
tonight.

On Mar 24, 9:19 am, Anthony  wrote:
> On Thursday, March 24, 2011 8:22:14 AM UTC-4, Arbie Samong wrote:
>
> > thanks for the reply, Anthony. The web2py source that I used came from
> > here:
> >http://www.web2py.com/examples/default/download
> > under Current, which is the file web2py_src.zip and it doesn't seem to
> > contain either app.yaml or queue.yaml or *.example.yaml
>
> You are right. It actually looks like the change from app.yaml to
> app.example.yaml was made prior to the 1.94.1 release.
>
> Massimo, why does app.example.yaml not appear in the current release (it's
> in trunk)?
>
> Anthony


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

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 8:04 AM, VP wrote:
> 
> Noticing the version of web2py keeps interestingly increasing to 2.0,
> I think this is something Massimo might want to spend sometime
> thinking about.
> 
> As I understand it, because of "exec", controllers are called *after*
> the request arrives.  This allows web2py to do a few interesting
> things that other frameworks can't.
> 
> On the other hands, this is an example that shows an advantage of
> being able to manipulate controllers (concisely) *before* the request
> arrives.
> 
> I found myself constantly type checking controller arguments (e.g.
> making sure an "id" is a number).  This is another example where being
> able to specify a certain syntax to the URL is very helpful.
> 

Notice that the routing mechanism you're talking about doesn't depend on the 
routing information being distributed as controller decoration; they can be 
presented in a table instead. In fact, putting them in a table has advantages 
over the decorator approach, in that a) you can see the whole routing policy in 
one place, and b) you can explicitly specify the order of evaluation.

Checking controller arguments is important, since they are, after all, user 
input and not trustworthy. And there's something to be said for checking them 
at the controller/function, since you're in a position to give more informative 
error messages if something is wrong. 

If you're using web2py forms, then the validators serve this purpose. If you're 
not, you can use the validators on their own.

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

2011-03-24 Thread Anthony
I believe this is already possible, no?
 
The book describes app-specific routing for the old system: 
http://web2py.com/book/default/chapter/04#Pattern-Based-System
 
And  for the new system, the router.example.py file (
http://code.google.com/p/web2py/source/browse/router.example.py) mentions 
you can have an app-specific router in applications/app/routes.py.
 
Anthony

On Thursday, March 24, 2011 11:49:58 AM UTC-4, Martin.Mulone wrote:

> I really want to see routes in the application folder. Routes in the past 
> was hard to follow, now I think the work of Johnatan make it more easy. But 
> when you have many applications, the routes for all is a bit messy. I don't 
> know if this can be done:
>
> For example a simple case:
>
> Main routes.py:
> ---
>
> Domain Application
> -
> www.domain1.com domain1
> www.domain2.com domain2
>
>
>
> Aplication:  applications/domain1/routes.py:
> ---
>
>
> [routes In]
> In Out
> --
> /favicon.ico /static/favicon.ico
>
>
> [routes Out]
> In Out
> --
> default/index /
> plugin_i2p/view/333 /view/333
>
>
> 2011/3/24 VP 
>
>> Noticing the version of web2py keeps interestingly increasing to 2.0,
>> I think this is something Massimo might want to spend sometime
>> thinking about.
>>
>> As I understand it, because of "exec", controllers are called *after*
>> the request arrives.  This allows web2py to do a few interesting
>> things that other frameworks can't.
>>
>> On the other hands, this is an example that shows an advantage of
>> being able to manipulate controllers (concisely) *before* the request
>> arrives.
>>
>> I found myself constantly type checking controller arguments (e.g.
>> making sure an "id" is a number).  This is another example where being
>> able to specify a certain syntax to the URL is very helpful.
>>
>>
>
>
> -- 
>  Pablo Martín Mulone (mar...@tecnodoc.com.ar)
> http://www.tecnodoc.com.ar/
>
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution Profile: 
> http://www.experts4solutions.com/e4s/default/expert/6
>
>
>

[web2py] Re: can web2py "internal webserver" handle serveral requests in parallel?

2011-03-24 Thread John Heenan

On Mar 22, 7:37 am, olivier  wrote:
> I plan to use web2py as a simple desktop app service (using the
> packaged web2py for windows).
> Will the web server (I don't know which server ships in the stand
> alone version) handle several requests in parallel if I use ajax calls
> to several controller functions?
>

Depends on what you mean by parallel.

In normal terms, that is if you are not depending on some state or
property that requires use of artifically managed parallel
transactions, the answer is yes.

Why not just test and see?

There are practical limits. A severe practical limit comes form the OS
overhead in using a thread for each web2py request to a controller
function.

The mentioned session and database locking issues are of course also
relevant. Just beacuse a session or database locks occurs does not
mean the request fails. They are just one more place queues or locks
occur. IO (input-output) OS (operating systems) queues or locks are
very common and are hidden.

I hope this adds a bit more insight.

John Heenan


[web2py] Re: new URL router use cases

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 11:04:39 AM UTC-4, VP wrote: 
>
> Noticing the version of web2py keeps interestingly increasing to 2.0, 
> I think this is something Massimo might want to spend sometime 
> thinking about.

 
 I don't think the xx part of 1.xx.y is to be interpreted as a decimal with 
a maximum of 99 -- I think it's just the number of releases within the 1.0 
series (so, can go over 99).


Re: [web2py] Re: Class in the session

2011-03-24 Thread Jonathan Lundell
On Mar 24, 2011, at 8:25 AM, Anthony wrote:
> There is an additional problem, though. According to Massimo, web2py cannot 
> store instances of classes in the session: 
> https://groups.google.com/d/msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ. Perhaps 
> Massimo has more to say regarding this example.
> 

This is what Massimo wrote in that thread:

> In web2py you cannot store instances of objects into session. While 
> Armin makes it tool like this is a web2py problem this is more complex 
> and general than that. In Python if you pickle and object that is 
> instance of a class defined in /path1/mymodule.py and then you 
> unpickle on a different installation where the class is defined in / 
> path2/mymodule.py you may run into problems. Because web2py does not 
> require installation (it is a feature) and has hot plug and play of 
> apps (another feature) we cannot pickle instances (the price we pay 
> for those features). To me it is worth it. 

I'd like to know a little more as well. It seems to me that since sessions are 
relatively transient (you're not going to preserve sessions if you move web2py 
elsewhere), the path to the class isn't going to change between session 
accesses.

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

2011-03-24 Thread Martín Mulone
I really want to see routes in the application folder. Routes in the past
was hard to follow, now I think the work of Johnatan make it more easy. But
when you have many applications, the routes for all is a bit messy. I don't
know if this can be done:

For example a simple case:

Main routes.py:
---

Domain Application
-
www.domain1.com domain1
www.domain2.com domain2



Aplication:  applications/domain1/routes.py:
---


[routes In]
In Out
--
/favicon.ico /static/favicon.ico


[routes Out]
In Out
--
default/index /
plugin_i2p/view/333 /view/333


2011/3/24 VP 

> Noticing the version of web2py keeps interestingly increasing to 2.0,
> I think this is something Massimo might want to spend sometime
> thinking about.
>
> As I understand it, because of "exec", controllers are called *after*
> the request arrives.  This allows web2py to do a few interesting
> things that other frameworks can't.
>
> On the other hands, this is an example that shows an advantage of
> being able to manipulate controllers (concisely) *before* the request
> arrives.
>
> I found myself constantly type checking controller arguments (e.g.
> making sure an "id" is a number).  This is another example where being
> able to specify a certain syntax to the URL is very helpful.
>
>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

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


[web2py] Re: Class in the session

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 10:04:47 AM UTC-4, NewBeen wrote: 
>
> Hello guys, 
>
> I have this class in a model, 
>
> Class Order: 
>
> def __init__(self): 
> self.basket={"product":{},"quantity":{}} 
>
>def addProduct(self, Item): 
>self.basket["product"]["name"]=item["name"] 
>
>
> session.order=Order() 
>
> So far so good, but when I execute this, the class is always been 
> initialize, so I lose my basket between pages... 
> Any ideas how can I fix this, if I put a class in a module and import 
> it will it fix it?

 
I think with that code, every request is just going to create a new Order() 
object and write it to session.order (replacing any existing session.order). 
If you want to add items to the order and maintain those items in the 
session in between page requests, then I would think at each request you 
would have to first check to see if there is an existing order stored in the 
session, and if so, retrieve it from the session, update it, and then write 
the updated order back to the session. Maybe something like:
 
order = session.order or Order()  # Note, if session.order doesn't exist, it 
will return None, and a new Order() will be created.
[insert code to update the order]
session.order = order
 
There is an additional problem, though. According to Massimo, web2py cannot 
store instances of classes in the session: 
https://groups.google.com/d/msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ. Perhaps 
Massimo has more to say regarding this example.
 
Finally, I think new-style classes are generally recommended, so you would 
do 'class Order(object):' instead of 'class Order:'.
 
Anthony


[web2py] Re: new URL router use cases

2011-03-24 Thread VP
Noticing the version of web2py keeps interestingly increasing to 2.0,
I think this is something Massimo might want to spend sometime
thinking about.

As I understand it, because of "exec", controllers are called *after*
the request arrives.  This allows web2py to do a few interesting
things that other frameworks can't.

On the other hands, this is an example that shows an advantage of
being able to manipulate controllers (concisely) *before* the request
arrives.

I found myself constantly type checking controller arguments (e.g.
making sure an "id" is a number).  This is another example where being
able to specify a certain syntax to the URL is very helpful.



[web2py] Re: new URL router use cases

2011-03-24 Thread VP
Can't this be done in web2py with something like this?

assert(request.args(1) == 'users')
yoursitename = request.args(0)


On Mar 23, 8:31 am, Anthony  wrote:
> Massimo, I think Tom was referring to Flask's ability to include an arg at
> an arbitrary place in the URL path (e.g., '//users'), not the
> ability to specify the routes via decorators. I think the former *can* be
> achieved in web2py using the pattern-based rewrite system, right?
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, March 23, 2011 9:17:31 AM UTC-4, Massimo Di Pierro wrote:
> > This is not an option in web2py because the controller is executed
> > after the requests arrives not imported before (as in Flask). Anyway,
> > that works better for simple apps but becomes a mess if you have many
> > functions because the routing info is scattered all over the place.
> > Moreover - when it comes to rest - it requires that you use the same
> > function for multiple methods (GET/POST/etc) by using multiple
> > decorators or that you use different functions with different names to
> > handle different names (I do not like that).
>
> > On Mar 22, 3:13 am, Tom Atkins  wrote:
> > > I might be being naive here but in Flask I can do:
>
> > > @app.route('//users')
> > > ... def editusers(yoursitename): pass
>
> > > print url_for('editprofile', yoursitename='Supersite')
>
> > > gives:
>
> > > /Supersite/users
>
> > > On 22 March 2011 05:23, Jonathan Lundell  wrote:
>
> > > > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote:
>
> > > > Agree, Flask way looks more elegant (see Variable Rules). It could be
> > nice
> > > > if this way also exists on Web2Py.
>
> > > > On 22 March 2011 06:05, Tom Atkins  wrote:
>
> > > >> I was playing with Flask and I have to say its solution to routing is
> > very
> > > >> nice:
>
> > > >>http://flask.pocoo.org/docs/quickstart/#routing
>
> > > >> The use of variable names anywhere within the URL structure is very
> > handy.
> > > >> Anything like this possible in web2py?
>
> > > > Flask doesn't really allow variable names anywhere; near as I can tell
> > > > they're a considerably restricted version of web2py's args list.


Re: [web2py] Re: Runnning my new app

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 10:07:07 AM UTC-4, Kenneth wrote: 
>
> 
> 2 
> 3 
> 4 {{=message}}
> 5 
> 6 
>
>
> This says all, I guess you have copied the whole text even the row numbers.
>
> You don´t need a HTML or BODY tag, the /views/default/index.html should 
> only contain
>
> {{=message}}
>
 
Good catch, Kenneth. Note, if he's following the example in the book, then 
he does need the HTML and BODY tag -- the book instructs you to overwrite 
the existing content of index.html with the above code (i.e., it does not 
extend layout.html).
Anthony


[web2py] Re: Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Anthony
On Thursday, March 24, 2011 8:22:14 AM UTC-4, Arbie Samong wrote: 
>
> thanks for the reply, Anthony. The web2py source that I used came from 
> here: 
> http://www.web2py.com/examples/default/download
> under Current, which is the file web2py_src.zip and it doesn't seem to 
> contain either app.yaml or queue.yaml or *.example.yaml
>
 
You are right. It actually looks like the change from app.yaml to 
app.example.yaml was made prior to the 1.94.1 release.
 
Massimo, why does app.example.yaml not appear in the current release (it's 
in trunk)?
 
Anthony
 


Re: [web2py] Re: Runnning my new app

2011-03-24 Thread Kenneth Lundström


2 
3 
4 {{=message}}
5 
6 


This says all, I guess you have copied the whole text even the row numbers.

You don´t need a HTML or BODY tag, the /views/default/index.html should 
only contain


{{=message}}


Row number is shown in the manual only so that it is easier in the text 
to explain things. Row number are not used in python.



Kenneth




Attached.


*From:* Anthony 
*To:* web2py@googlegroups.com
*Cc:* Hal Smith 
*Sent:* Wed, March 23, 2011 6:29:21 PM
*Subject:* Re: Runnning my new app

Hmm, that is odd. Can you send the whole app? On the admin Site page, 
just click the "pack all" button for the app, and it will pack 
everything into a .w2p file.


On Wednesday, March 23, 2011 6:15:18 PM UTC-4, Hal Smith wrote:

My controllers/default.py define index() has the return dic code.

My views/default/index.html contains only the code in the manual
(I deleted everything else).

Attached is a screen dump of the output.


*From:* Anthony 
*To:* web...@googlegroups.com
*Cc:* Hal Smith 
*Sent:* Wed, March 23, 2011 3:36:05 PM
*Subject:* Re: Runnning my new app

On Wednesday, March 23, 2011 4:58:45 PM UTC-4, Hal Smith wrote:

This is the kind of thing I have been wondering about: what is
going on under the hood?

I was simply doing what the manual told me to do - even if I
wasn't sure what it wanted. The manual needs to be updated.

Note, if you're on p. 88 doing the "Say Hello" example, you have
not yet gotten to the stuff about using layouts and {{include}} --
that stuff starts in p. 92 in the "Let's Count" section. Because
ch. 3 is tutorial style, explanations tend to be limited to what's
going on with the immediate example, so you learn the details
progressively. On p. 87, you learn that returning a string from
your controller function simply sends the string as is to the
browser (it's not inserted into any view/template). On p. 88, you
learn that if you return a dictionary (instead of a string),
web2py looks for the associated view file (and uses the generic
view if it can't be found). And then on p. 92, you learn about
extending a layout template.
I think the instruction about editing index.html on p. 88 could
probably be improved. First, where it says "the new file
associated with the action", it should probably say "the view file
associated with the action". Second, it should probably explicitly
say to completely replace the existing index.html content with the
example code to avoid confusion. I'll make some edits to help clarify.
As for the numbers above and below your message, I can't explain
that. Are you sure your index.html includes only the text from p.
88 and your controller is just:
def index():
return dict(message="Hello from MyApp")
Anthony





[web2py] Class in the session

2011-03-24 Thread NewBeen
Hello guys,

I have this class in a model,

Class Order:

def __init__(self):
self.basket={"product":{},"quantity":{}}

   def addProduct(self, Item):
   self.basket["product"]["name"]=item["name"]


session.order=Order()

So far so good, but when I execute this, the class is always been
initialize, so I lose my basket between pages...
Any ideas how can I fix this, if I put a class in a module and import
it will it fix it?

Regards
Rui Gomes



[web2py] Re: auth_user field default to other auth_user field?

2011-03-24 Thread Massimo Di Pierro
Field('paypal_email', length=128, writable=False, compute=lambda r:
r.email))

On Mar 24, 1:38 am, pbreit  wrote:
> I can't seem to figure out a (good) way to have one of my auth_user fields
> default to another auth_user field. I only want the default to take place
> once so not "compute".
>
> I tried defaulting to a lambda but that doesn't work.
>
> db.define_table('auth_user',
>     ...
>     Field('email', length=128, required=True, unique=True),
>     Field('paypal_email', length=128, default=lambda r: r.email))
>
> With any other forms I could probably set the form.vars or do an
> onvalidation but I'm not sure how or if I can do that with auth() forms.


[web2py] Re: IS_INT_IN_RANGE Behavior in Database Example

2011-03-24 Thread Massimo Di Pierro
Nope. It was added in 1.94.something

On Mar 23, 2011, at 4:45 PM, Anthony wrote:

> On Wednesday, March 23, 2011 5:33:45 PM UTC-4, Massimo Di Pierro wrote:
> 2) if you want the check done in insert you can call 
> db.table.validate_and_insert
>  
> How long has that been around? I don't think it's in the book, is it?



[web2py] Re: Is it possible to update or insert object to database in one command?

2011-03-24 Thread Massimo Di Pierro
You can do it without if as well:

db(query).update(...) or db.mytable.insert(...)


On Mar 24, 8:26 am, Massimo Di Pierro 
wrote:
> To know if it exist or not you must have condition in the form of a
> query. You can do
>
> if not db(query).update(...): db.mytable.insert(...)
>
> where ... is the field='value' list.
>
> On Mar 24, 4:46 am, Sergey Ozhigin  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > Is it possible in web2py to update or insert object (if doesn't exist)
> > to database in one command?
>
> > Does anybody know an answer?
>
> > wbr


[web2py] Re: Is it possible to update or insert object to database in one command?

2011-03-24 Thread Massimo Di Pierro
To know if it exist or not you must have condition in the form of a
query. You can do

if not db(query).update(...): db.mytable.insert(...)

where ... is the field='value' list.

On Mar 24, 4:46 am, Sergey Ozhigin  wrote:
> Hello,
>
> Is it possible in web2py to update or insert object (if doesn't exist)
> to database in one command?
>
> Does anybody know an answer?
>
> wbr


[web2py] Re: Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Massimo Di Pierro
I apologize. I thought I made all required changes but I missed one:

In controller replace:

friends = db(User.id==Link.source)
(Link.target==me).select(orderby=alphabetical)
requests = db(User.id==Link.target)
(Link.source==me).select(orderby=alphabetical)

with:


friends = db(Link.target==me).select()
requests = db(Link.source==me).select()

and change the friends.html view into:

{{extend 'layout.html'}}
Friendship Offered

  {{for friend in friends:}}
  
 
{{=A(name_of(db.auth_user(friend.source)),_href=URL('wall',args=friend.source))}}

{{if friend.accepted:}}accepted{{else:}}accept{{pass}}
   deny
  
  {{pass}}

Friendship Requested

  {{for friend in requests:}}
  
 
{{=A(name_of(db.auth_user(friend.target)),_href=URL('wall',args=friend.target))}}

{{if friend.accepted:}}accepted{{else:}}pending{{pass}}
remove
  
  {{pass}}


This is because GAE cannot do joins.

I also think that on GAE the current Query

query = reduce(lambda a,b:a&b,
   [User.first_name.contains(k)|
User.last_name.contains(k) \
for k in tokens])

is too complex and should be

query =
(User.first_name==tokens[0])&(User.last_name==tokens[1])



On Mar 24, 6:06 am, Arbie Samong  wrote:
> I actually tried the tutorial posted here:
>
> http://blip.tv/file/4912976
>
> and here are some information that wasn't mentioned but might be helpful for
> absolute beginners like me:
>
>    -
>
>    You must first register with janrain and take note of the application
>    name
>    -
>
>    In models/db_janrain.py, you need to set domain to the application name
>    you registered with. In the tutorial it is set to web2py. It is
>    https://blabla.rpxnow.com/, where blabla is the applciation name.
>    -
>
>    The file janrain_api_key.txt will contain only the secret api key, which
>    you can see in the janrain dashboard.
>    -
>
>    The web2py source does not have app.yaml. So you copy the one in
>    google_appengine/new_project_template over to web2py/.
>    -
>
>    Edit the file and set the application (first line) to the one you
>    registered with in app engine. Then set script to gaehandler.py (under
>    handlers)
>    -
>
>    When running the local app engine instance for the first time to build
>    indexes, be sure to change the url in models/db_janrain.py from
>    localhost:8000 to localhost:8080. If you don't it will redirect to the
>    web2py instance instead of the app engine instance, and the indexes will 
> not
>    be built causing an error when running it in appspot.com
>    -
>
>    When deploying, appcfg can be found under the google_appengine/ folder,
>    so just copy the full path.
>
> Now, for the question. The friends and search pages do not work when
> deploying on GAE, both on localhost:8080 and on the real server. It works
> fine when using the web2py server but not on the GAE. My best guess are
> database issues, since GAE might not be supporting the db calls used in the
> tutorial. The errors are:
>
>    -
>
>    on friends/default/friends/ when viewing the page
>
>    ERROR    2011-03-24 07:34:36,785 restricted.py:55] In FILE:
>    
> /home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/a 
> pplications/friends/controllers/default.py
>
>    Traceback (most recent call last):
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/restricted.py",
>    line 188, in restricted
>
>        exec ccode in environment
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> applications/friends/controllers/default.py:friends",
>    line 93, in 
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/globals.py",
>    line 124, in 
>
>        self._caller = lambda f: f()
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/tools.py",
>    line 2331, in f
>
>        return action(*a, **b)
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> applications/friends/controllers/default.py:friends",
>    line 68, in friends
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/dal.py",
>    line 5009, in select
>
>        return self.db._adapter.select(self.query,fields,attributes)
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/dal.py",
>    line 2892, in select
>
>        (items, tablename, fields) = self.select_raw(query,fields,attributes)
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/dal.py",
>    line 2841, in select_raw
>
>        tablename = self.get_table(query)
>
>      File
>    
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/ 
> gluon/dal.py",
>    line

[web2py] Re: delete online user

2011-03-24 Thread Massimo Di Pierro
You have to id the user session and delete it

On Mar 24, 6:30 am, Neveen Adel  wrote:
> Hello,
>
> Is there a way to when a user delete another online user , the deleted
> user logged out ?
>
> Thanks in Advance


[web2py] Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Arbie Samong


I actually tried the tutorial posted here:

http://blip.tv/file/4912976


and here are some information that wasn't mentioned but might be helpful for 
absolute beginners like me:

   - 
   
   You must first register with janrain and take note of the application 
   name
   - 
   
   In models/db_janrain.py, you need to set domain to the application name 
   you registered with. In the tutorial it is set to web2py. It is 
   https://blabla.rpxnow.com/, where blabla is the applciation name.
   - 
   
   The file janrain_api_key.txt will contain only the secret api key, which 
   you can see in the janrain dashboard.
   - 
   
   The web2py source does not have app.yaml. So you copy the one in 
   google_appengine/new_project_template over to web2py/.
   - 
   
   Edit the file and set the application (first line) to the one you 
   registered with in app engine. Then set script to gaehandler.py (under 
   handlers)
   - 
   
   When running the local app engine instance for the first time to build 
   indexes, be sure to change the url in models/db_janrain.py from 
   localhost:8000 to localhost:8080. If you don't it will redirect to the 
   web2py instance instead of the app engine instance, and the indexes will not 
   be built causing an error when running it in appspot.com
   - 
   
   When deploying, appcfg can be found under the google_appengine/ folder, 
   so just copy the full path.
   

Now, for the question. The friends and search pages do not work when 
deploying on GAE, both on localhost:8080 and on the real server. It works 
fine when using the web2py server but not on the GAE. My best guess are 
database issues, since GAE might not be supporting the db calls used in the 
tutorial. The errors are:

   - 
   
   on friends/default/friends/ when viewing the page
   
   ERROR2011-03-24 07:34:36,785 restricted.py:55] In FILE: 
   
/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py
   
   Traceback (most recent call last):
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/restricted.py",
 
   line 188, in restricted
   
   exec ccode in environment
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:friends",
 
   line 93, in 
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/globals.py",
 
   line 124, in 
   
   self._caller = lambda f: f()
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/tools.py",
 
   line 2331, in f
   
   return action(*a, **b)
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:friends",
 
   line 68, in friends
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
 
   line 5009, in select
   
   return self.db._adapter.select(self.query,fields,attributes)
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
 
   line 2892, in select
   
   (items, tablename, fields) = self.select_raw(query,fields,attributes)
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
 
   line 2841, in select_raw
   
   tablename = self.get_table(query)
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
 
   line 955, in get_table
   
   raise RuntimeError, "Too many tables selected"
   
   RuntimeError: Too many tables selected
   
   - 
   
   on friends/default/search/ when trying to search 
   
   ERROR2011-03-24 07:35:23,136 restricted.py:55] In FILE: 
   
/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py
   
   Traceback (most recent call last):
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/restricted.py",
 
   line 188, in restricted
   
   exec ccode in environment
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:search",
 
   line 93, in 
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/globals.py",
 
   line 124, in 
   
   self._caller = lambda f: f()
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/tools.py",
 
   line 2331, in f
   
   return action(*a, **b)
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:search",
 
   line 59, in search
   
 File 
   
"/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluo

[web2py] Is it possible to update or insert object to database in one command?

2011-03-24 Thread Sergey Ozhigin
Hello,

Is it possible in web2py to update or insert object (if doesn't exist)
to database in one command?

Does anybody know an answer?

wbr


[web2py] Re: Problems with Google App Engine

2011-03-24 Thread Arbie Samong
I encountered the same error because I tried to point the
handler.script field in app.yaml to web2py.py. I changed to
gaehandler.py and it worked.

So in app.yaml instead of -

handlers:
- url: .*
  script: web2py.py

I used -

handlers:
- url: .*
  script: gaehandler.py

Hope that helps.

Regards,
Arbie

On Mar 24, 10:19 am, Web2py Newbie
 wrote:
> Hi
>
> I have done a short app (actually just a couple of web pages strung
> together) that I wanted to load to the google app engine.  When I try
> to hook up web2py: python2.5 dev_appserver.py web2py
> the app starts, but fails when I load the page in a browser:
>
> ERROR    2011-03-23 23:00:16,549 dev_appserver.py:3285] Exception
> encountered handling request
> Traceback (most recent call last):
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 3245, in _HandleRequest
>     self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 3186, in _Dispatch
>     base_env_dict=env_dict)
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 531, in Dispatch
>     base_env_dict=base_env_dict)
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 2410, in Dispatch
>     self._module_dict)
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 2320, in ExecuteCGI
>     reset_modules = exec_script(handler_path, cgi_path, hook)
>   File "/data-current/programming/python/gae/google_appengine/google/
> appengine/tools/dev_appserver.py", line 2216, in ExecuteOrImportScript
>     exec module_code in script_module.__dict__
>   File "/data-current/programming/python/gae/web2py/web2py.py", line
> 9, in 
>     os.chdir(path)
> AttributeError: 'module' object has no attribute 'chdir'
>
> Any ideas on what's going on/how to fix?
> web2py version is most recent stable from the website this morning
> (1.94.5)
> Python version is Python 2.5.5 (r255:77872, Mar 24 2011, 09:36:33),
> but I get the same failure using python2.6
>
> Brendan


[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread fib
OK all I feel quite stupid
I think I need the ABC of running this
I have placed the file in a location where I know where it is and it
can be seen in the web2py list
I have tried putting the call into shell and into a web2py app
I have used IDLE  (python) and have tried shell on web2py
I believe mysqldb is meant to come with web2py so I dont believe I
need that ?

what do I actually type and where to call this and get it to output

Newbie needs hand held - apologies
thank you in advance


Oh and read chap on DAL - good stuff bought the book. I just think I
have a fundamental misunderstanding of what to put where and i will
think it was easy when I get it 

thank you all in advance and for patience

On Mar 22, 12:20 pm, selecta  wrote:
> > just trying to get to a point where i can do the db structure scrape to
> > create the web2py db code as i interpret that is what your code does
>
> yes the script uses the mysql and mysqldump excecutables to dump the
> table structures and parses that with regular expressions
>
> Nice work Kevin, I have had only created and used for it once to
> migrate our legacy db to pyMantis but I am planning to add this as a
> feature the pyMantis so this comes in very handy :D


Re: [web2py] Re: another video: web2py components

2011-03-24 Thread Martín Mulone
Also plugin comments, use components to load comments. See code in the page.

http://plugin2comment.appspot.com/comments/default/index

2011/3/24 skwasha 

> Is the source available anywhere? Would be nice to look thru for
> tutorial purposes.
>
> On Mar 22, 2:49 pm, Massimo Di Pierro 
> wrote:
> > http://vimeo.com/21363988
> >
> > Because we do not use them enough and feel we have room for
> > improvement.
> >
> > Massimo
>



-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

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


[web2py] Re: Running the web2py mini-fb clone demo (additional info and some questions)

2011-03-24 Thread Anthony
Thank you. This is helpful.
 
Note, the web2py source *does* come with a GAE app.yaml file -- it's in the 
root web2py/ folder (along with queue.yaml), as explained in the book: 
http://web2py.com/book/default/chapter/11#Configuration
 
Actually, in the current development version, app.yaml and queue.yaml have 
been replaced with app.example.yaml and queue.example.yaml so they don't get 
overwritten upon web2py upgrade. See this thread: 
https://groups.google.com/forum/?fromgroups#!searchin/web2py/app.example.yaml/web2py/cd8Smoiv1V0/x-INRnFgJNoJ.
 
The book should be changed to reflect this.
 
Anthony

On Thursday, March 24, 2011 7:06:31 AM UTC-4, Arbie Samong wrote:

> I actually tried the tutorial posted here:
>
> http://blip.tv/file/4912976
>
>
> and here are some information that wasn't mentioned but might be helpful 
> for absolute beginners like me:
>
>- 
>
>You must first register with janrain and take note of the application 
>name
>- 
>
>In models/db_janrain.py, you need to set domain to the application name 
>you registered with. In the tutorial it is set to web2py. It is 
>https://blabla.rpxnow.com/, where blabla is the applciation name.
>- 
>
>The file janrain_api_key.txt will contain only the secret api key, 
>which you can see in the janrain dashboard.
>- 
>
>The web2py source does not have app.yaml. So you copy the one in 
>google_appengine/new_project_template over to web2py/.
>- 
>
>Edit the file and set the application (first line) to the one you 
>registered with in app engine. Then set script to gaehandler.py (under 
>handlers)
>- 
>
>When running the local app engine instance for the first time to build 
>indexes, be sure to change the url in models/db_janrain.py from 
>localhost:8000 to localhost:8080. If you don't it will redirect to the 
>web2py instance instead of the app engine instance, and the indexes will 
> not 
>be built causing an error when running it in appspot.com
>- 
>
>When deploying, appcfg can be found under the google_appengine/ folder, 
>so just copy the full path.
>
>
> Now, for the question. The friends and search pages do not work when 
> deploying on GAE, both on localhost:8080 and on the real server. It works 
> fine when using the web2py server but not on the GAE. My best guess are 
> database issues, since GAE might not be supporting the db calls used in the 
> tutorial. The errors are:
>
>- 
>
>on friends/default/friends/ when viewing the page
>
>ERROR2011-03-24 07:34:36,785 restricted.py:55] In FILE: 
>
> /home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py
>
>Traceback (most recent call last):
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/restricted.py",
>  
>line 188, in restricted
>
>exec ccode in environment
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:friends",
>  
>line 93, in 
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/globals.py",
>  
>line 124, in 
>
>self._caller = lambda f: f()
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/tools.py",
>  
>line 2331, in f
>
>return action(*a, **b)
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py:friends",
>  
>line 68, in friends
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
>  
>line 5009, in select
>
>return self.db._adapter.select(self.query,fields,attributes)
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
>  
>line 2892, in select
>
>(items, tablename, fields) = 
>self.select_raw(query,fields,attributes)
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
>  
>line 2841, in select_raw
>
>tablename = self.get_table(query)
>
>  File 
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/gluon/dal.py",
>  
>line 955, in get_table
>
>raise RuntimeError, "Too many tables selected"
>
>RuntimeError: Too many tables selected
>
> - 
>
>on friends/default/search/ when trying to search 
>
>ERROR2011-03-24 07:35:23,136 restricted.py:55] In FILE: 
>
> /home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/applications/friends/controllers/default.py
>
>Traceback (most recent call last):

[web2py] delete online user

2011-03-24 Thread Neveen Adel
Hello,

Is there a way to when a user delete another online user , the deleted
user logged out ?

Thanks in Advance


[web2py] Re: another video: web2py components

2011-03-24 Thread skwasha
Is the source available anywhere? Would be nice to look thru for
tutorial purposes.

On Mar 22, 2:49 pm, Massimo Di Pierro 
wrote:
> http://vimeo.com/21363988
>
> Because we do not use them enough and feel we have room for
> improvement.
>
> Massimo


Re: [web2py] Re: OpenERP like widgets

2011-03-24 Thread Indra Gunawan
1. What stuff I need to build like that* web interface?
2. Is there ready to use Python classes that wrap for example ExtJS classes,
or the other?
3. Can you points me in general; steps building like that* website using
Web2Py?

For example.
1. You need this, this and this
2. Do like this in your controller and put like this in your template
3. Done, you get responsive ajax based web interface like that*

PS. Sorry my English :)

Thank you

On 24 March 2011 15:34, Mengu  wrote:

> what exactly do you need and want us to tell about?
>
> On Mar 23, 1:47 pm, Indra Gunawan  wrote:
> > Hi, any idea how to create application (I mean the view, javascript/ajax
> > widget etc) like thishttp://demo.openerp.com/?
> > Using Web2Py off course.
> >
> > OpenERP also build from python:
> > 1. Server (XML-RPC) -> Python
> > 2. Web Clienthttp://demo.openerp.com/-> TurboGears (this presentation
> > layer interest me)
> > 3. Desktop client -> Python with wxPython (I'm not interest) :D
> >
> > What tools do I need? How?
> >
> > PS. I'm new using web2py.
> >
> > Thank you
> >
> > --
> > coderbuzz
>



-- 
Salam
Indra Gunawan


Re: [web2py] Re: onmouseover

2011-03-24 Thread Kenneth Lundström
I got the onmouseover to work but how do I send text to the javascript 
from a variable. I have this code


 TD(P(day, _class="text_black"), _class="red", 
_onmouseover="displayText('info', watchers[check_date])", 
_onmouseout="hideText('info')")


It is the watchers[check_date] that holds the text that should be sent 
to the javascript but nothing is sent.


I have verified that the variable contains text and if I define 
_onmouseover="displayText('info', 'test_text')",


it works.


Kenneth


Yes. The error is probably in other order

TD(_onmouseover="","content") WRONG
TD("content",_onmouseover="") RIGHT

On Mar 23, 8:38 am, Kenneth Lundström
wrote:

Is it possible to use onmouseover when using helpers?

I tried to use TD(_onmouseover="" but get an error ticket saying

SyntaxError:invalid syntax

Kenneth




[web2py] Re: Problems with Google App Engine

2011-03-24 Thread Web2py Newbie
On Mar 24, 7:16 pm, Arbie Samong  wrote:
> I'm not sure if my reply was posted so I'm posting again. It happened to me
> because I tried to set handlers.script in app.yaml to web2py.py. I used
> gaehandler.py instead and it worked.

Wow! It worked!

Thanks

Brendan


[web2py] Re: OpenERP like widgets

2011-03-24 Thread Mengu
what exactly do you need and want us to tell about?

On Mar 23, 1:47 pm, Indra Gunawan  wrote:
> Hi, any idea how to create application (I mean the view, javascript/ajax
> widget etc) like thishttp://demo.openerp.com/?
> Using Web2Py off course.
>
> OpenERP also build from python:
> 1. Server (XML-RPC) -> Python
> 2. Web Clienthttp://demo.openerp.com/-> TurboGears (this presentation
> layer interest me)
> 3. Desktop client -> Python with wxPython (I'm not interest) :D
>
> What tools do I need? How?
>
> PS. I'm new using web2py.
>
> Thank you
>
> --
> coderbuzz


[web2py] Re: OpenERP like widgets

2011-03-24 Thread coderbuzz
Bump... any though?

On Mar 23, 6:47 pm, Indra Gunawan  wrote:
> Hi, any idea how to create application (I mean the view, javascript/ajax
> widget etc) like thishttp://demo.openerp.com/?
> Using Web2Py off course.
>
> OpenERP also build from python:
> 1. Server (XML-RPC) -> Python
> 2. Web Clienthttp://demo.openerp.com/-> TurboGears (this presentation
> layer interest me)
> 3. Desktop client -> Python with wxPython (I'm not interest) :D
>
> What tools do I need? How?
>
> PS. I'm new using web2py.
>
> Thank you
>
> --
> coderbuzz