[web2py] OT working with semaphores

2011-01-12 Thread ron_m
Talk and free book by Prof Allen Downey on semaphores.

http://www.greenteapress.com/semaphores/

Coding plus observation tool in Python. Goes into some good usage patterns.


Re: [web2py] Re: Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread Kenneth Lundström
To fix the "Could not realiably determine." you have to add a 
ServerName line to your Apaches httpd.conf file. Without that Apache 
does not know what name to use.



Kenneth


Any post in particular you're pointing to?  I looked at several, and
they didn't work.

At the end of the install script are these lines:
/etc/init.d/apache2 restart
cd /home/www-data/web2py
sudo -u www-data python -c "from gluon.widget import console;
console();"
sudo -u www-data python -c "from gluon.main import save_password;
save_password(raw_input('admin password: '),443)"

Running line 1 reproduces this error:
* Restarting web server
apache2
apache2: Could not reliably determine the server's fully qualified
domain name, using 173.255.235.47 for ServerName
[Thu Jan 13 04:55:25 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts
  ... waiting .apache2: Could not reliably determine the server's fully
qualified domain name, using 173.255.235.47 for ServerName
[Thu Jan 13 04:55:27 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts

I fixed something in my etc/hosts file so that when I now ran lines
2-4, I was prompted to enter an admin password.  The admin interface
now works.

So while the admin interface works, I'm left with this other error
caused by restarting Apache.

On Jan 12, 11:01 pm, Felixdm || Augusto Félix Dal Mas
  wrote:

On Thu, Jan 13, 2011 at 12:40 AM, Chase Lee  wrote:

When I access the domain/admin over https, I get this message: admin
disabled because unable to access password file  =/
That'd be nice if I didn't have to worry about the error
On Jan 12, 10:04 pm, pbreit  wrote:

There's a chance that this is just a warning that you don't necessarily need
to worry about.
How are you accessing admin? Make sure you access it either with "https" or
"localhost".

http://groups.google.com/group/web2py/search?group=web2py&q=unable+to...




[web2py] Re: Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread Chase Lee
Any post in particular you're pointing to?  I looked at several, and
they didn't work.

At the end of the install script are these lines:
/etc/init.d/apache2 restart
cd /home/www-data/web2py
sudo -u www-data python -c "from gluon.widget import console;
console();"
sudo -u www-data python -c "from gluon.main import save_password;
save_password(raw_input('admin password: '),443)"

Running line 1 reproduces this error:
* Restarting web server
apache2
apache2: Could not reliably determine the server's fully qualified
domain name, using 173.255.235.47 for ServerName
[Thu Jan 13 04:55:25 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts
 ... waiting .apache2: Could not reliably determine the server's fully
qualified domain name, using 173.255.235.47 for ServerName
[Thu Jan 13 04:55:27 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts

I fixed something in my etc/hosts file so that when I now ran lines
2-4, I was prompted to enter an admin password.  The admin interface
now works.

So while the admin interface works, I'm left with this other error
caused by restarting Apache.

On Jan 12, 11:01 pm, Felixdm || Augusto Félix Dal Mas
 wrote:
> On Thu, Jan 13, 2011 at 12:40 AM, Chase Lee  wrote:
> > When I access the domain/admin over https, I get this message: admin
> > disabled because unable to access password file  =/
>
> > That'd be nice if I didn't have to worry about the error
>
> > On Jan 12, 10:04 pm, pbreit  wrote:
> >> There's a chance that this is just a warning that you don't necessarily 
> >> need
> >> to worry about.
>
> >> How are you accessing admin? Make sure you access it either with "https" or
> >> "localhost".
>
> http://groups.google.com/group/web2py/search?group=web2py&q=unable+to...


Re: [web2py] plugin_powertables: is this expected behavior?

2011-01-12 Thread rochacbruno
Hi,

I need to improve that, the fact is that details table runs in a different 
thread because it is called by ajax. So it have no access to the DAL instance 
used in main table's datasource. 

So in model It assign a new variable pointing to the instance of DAL in commom 
case it is db. But you can name it differently or have múltiple dbs. And that 
the only way I found to have the DAL instance 

In the top of model I referenced DAL again. Simply doing 
powertabledb = plugins.powertable.get('db', db )

I'll change that so it will assume db as default and you can pass a parameter 
if you want to use another db. 

I am rewriting the plugin from the scratch to implement server/json processing 
in a better way. 

Thank you for testing and reporting this issues. 

Bruno



Enviado via iPhone

Em 13/01/2011, às 00:58, mart  escreveu:

> I guess this is for Bruno,
> 
> I wanted try your tables plugin, and it seemed to have create
> duplicate copies of each and every table if the database with itself
> as prefix.
> 
> Example:
> 
> db.p4NewUserRequest
> 
> has been duplicated to
> 
> plugin_powertablesdb.p4NewUserRequest
> 
> And ALL tables are now like this.
> 
> Not a big deal, since it was just one of these throw away test apps.
> But just wanted to see if I didn't mis-configure something, or if this
> is expected, or  a bug, etc...
> 
> Anyways, has this happened t anyone else?
> 
> Thanks
> Mart :)


[web2py] Re: good news...

2011-01-12 Thread Massimo Di Pierro
My son is 5. To him I would suggest the aquarium. :-)

On Jan 12, 8:45 pm, Anthony  wrote:
> On Wednesday, January 12, 2011 10:50:25 AM UTC-5, Massimo Di Pierro wrote:
>
> > I hope some of you will be attending. It would be a shame if we do not
> > get a full room. ;-)
>
> Planning to take the family for a visit to Atlanta sometime around then (we
> used to live there) -- will do my best to overlap the dates so I can attend
> the web2py tutorial. I know web2py is easy to learn, but do you think you
> can teach it to a 2 year-old and a 4 year-old (otherwise, I guess I'll send
> my wife and kids to the aquarium). :-)
>
> Anthony


Re: [web2py] Re: Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread Felixdm || Augusto Félix Dal Mas
On Thu, Jan 13, 2011 at 12:40 AM, Chase Lee  wrote:
> When I access the domain/admin over https, I get this message: admin
> disabled because unable to access password file  =/
>
> That'd be nice if I didn't have to worry about the error
>
> On Jan 12, 10:04 pm, pbreit  wrote:
>> There's a chance that this is just a warning that you don't necessarily need
>> to worry about.
>>
>> How are you accessing admin? Make sure you access it either with "https" or
>> "localhost".

http://groups.google.com/group/web2py/search?group=web2py&q=unable+to+access+password+file+&qt_g=Search+this+group


[web2py] Re: Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread Chase Lee
When I access the domain/admin over https, I get this message: admin
disabled because unable to access password file  =/

That'd be nice if I didn't have to worry about the error

On Jan 12, 10:04 pm, pbreit  wrote:
> There's a chance that this is just a warning that you don't necessarily need
> to worry about.
>
> How are you accessing admin? Make sure you access it either with "https" or
> "localhost".


[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread drayco
I need that some of you guys check this, in my case, Pymysql have some
issues with legacy databases (First, I think this issue is of new dal,
but I'm not sure)
However mysqldb, my application work well

this is my report:

http://groups.google.com/group/web2py/browse_thread/thread/72e91e281e0610d8/099e21f098ae8501?lnk=gst&q=new+dal#099e21f098ae8501


On Jan 12, 11:46 am, Vasile Ermicioi  wrote:
> hi,
>
> Massimo, there is a new  version of pymysql
>
> I think pymysql has a few advantages
> - being pure Python, PyMySQL is easily patched by gevent and the likes to
> make it cooperative
>
> http://code.google.com/p/pymysql/wiki/WhyPyMySQL
>
> I use it with web2py and works fine


Re: [web2py] new router

2011-01-12 Thread pbreit
Could it be caught with a 404 and routed somewhere?

[web2py] Re: Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread pbreit
There's a chance that this is just a warning that you don't necessarily need 
to worry about.

How are you accessing admin? Make sure you access it either with "https" or 
"localhost".


[web2py] plugin_powertables: is this expected behavior?

2011-01-12 Thread mart
I guess this is for Bruno,

I wanted try your tables plugin, and it seemed to have create
duplicate copies of each and every table if the database with itself
as prefix.

Example:

db.p4NewUserRequest

has been duplicated to

plugin_powertablesdb.p4NewUserRequest

And ALL tables are now like this.

Not a big deal, since it was just one of these throw away test apps.
But just wanted to see if I didn't mis-configure something, or if this
is expected, or  a bug, etc...

Anyways, has this happened t anyone else?

Thanks
Mart :)


Re: [web2py] new router

2011-01-12 Thread Wikus van de Merwe
As Jonathan mentioned, to do that with old routes you will need to hardcode 
a list of your controllers. Then anything what is not a controller is a 
username. But this is not the best way to do it. I like better the way the 
new router works, that is using predefined defaults.

So what you could do is having a number of user function in a user 
controller, eg. /user/create, /user/update, /user/delete and set one of this 
functions as your application default, e.g. /user/show. Now, any request to 
/name for name not in controllers would be mapped to /user/show/name. Unless 
Jonathan will correct me here, as rather "name" would be used as function of 
the default controller, i.e. /user/name. But let's assume this will work 
fine, then for other functions you just use the user name as one of the 
arguments e.g. /settings/appearance.xml/bruno/1/?color=blue. An alternative 
option would be to use different subdomain for each user 
http://bruno.twitter.com/settings/appearance.json but I don't think this is 
supported in any way by new routes.

A more complete solution to tackle this (and other examples I mentioned in 
the beta routes thread) could be something similar to $label replacement 
used in old routes. With this implemented, an example usage for Bruno's case 
would look like this:
"/$user/$controller/$function/$args/$vars" -> 
"/$controller/$function/$args/$vars&client=$user" or
"/$user/$controller/$function/$args" -> 
"/$controller/$function/$user/$args".

How this should work? Each of the labels would simply match a regex of (.+) 
or maybe more limited ([\w.-]+) with exception of the last label (here $vars 
in example 1 and $args in example 2) which could contain also special 
characters [/+...@?=&;:,*!()']. Or maybe even to simplify things, everything 
between two "/" characters would be assigned to a label. Then the labels 
would be used to reorder parts of urls. After reorder is done the new router 
would deal with the string as if it was the original url. I assume all this 
is app-specific and domain and app parts are stripped before.

Notice that this would be quite general and you could do with it things 
like:
"/author/$name"  ->  "/books/author?name=$name"
or even url shortening like:
"/short-name"  ->  "/controller/func/arg1/arg2/arg3/arg4"

Alternative option would be having named routes like 
Routesdoes and instead of arbitrary 
label used specific ones for controller and 
function and treat the rest as query arguments of it, e.g:
"/{user}/new/{controller}/{function}" will give "/c/f/user=smith" for 
"/smith/new/c/f"
but I guess this is a bit too complex and not clearly better than the other 
method (although I like {label} notation better than $label).

OK, so I leave you with these ideas. Maybe we could find a nice way of 
making the new routes a bit more flexible by discussing this further.


[web2py] Error using setup-web2py-ubuntu.sh on Linode

2011-01-12 Thread Chase Lee
Hi,

When installing on Linode, I receive this message at the end of the
install:

 * Restarting web server
apache2
apache2: apr_sockaddr_info_get() failed for viasco
apache2: Could not reliably determine the server's fully qualified
domain name, using 127.0.0.1 for ServerName
[Thu Jan 13 02:22:14 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts
 ... waiting apache2: apr_sockaddr_info_get() failed for viasco
apache2: Could not reliably determine the server's fully qualified
domain name, using 127.0.0.1 for ServerName
[Thu Jan 13 02:22:15 2011] [warn] NameVirtualHost *:80 has no
VirtualHosts
 
[ OK ]
done!


Web2py is running when I visit the url, but the admin interface
doesn't want to work.

Any ideas?

Thanks,
Chase


[web2py] Re: good news...

2011-01-12 Thread Anthony
On Wednesday, January 12, 2011 10:50:25 AM UTC-5, Massimo Di Pierro wrote: 
>
> I hope some of you will be attending. It would be a shame if we do not 
> get a full room. ;-) 

 
Planning to take the family for a visit to Atlanta sometime around then (we 
used to live there) -- will do my best to overlap the dates so I can attend 
the web2py tutorial. I know web2py is easy to learn, but do you think you 
can teach it to a 2 year-old and a 4 year-old (otherwise, I guess I'll send 
my wife and kids to the aquarium). :-)
 
Anthony


Re: [web2py] new router

2011-01-12 Thread Jonathan Lundell
On Jan 12, 2011, at 4:56 PM, Bruno Rocha wrote:
> I am trying to configure a different way of routing, may be you can help me 
> or point some hint about it,
> It is a system where the user will register himself and get instant access to 
> an account (just like twitter), and the system will give a profile URL to the 
> user http://system.com/username and the actions needs to be as 
> http://system.com/username/controller/action.
> 
> I cant figure out how can I include the 'username' part.
> 
> For better understanding I am attaching an image about it. 
> (http://twitpic.com/3pi0cd)
> 
> Any ideas?
> 

I need to give that some thought.

It's somewhat similar to the way that the new router handles languages, except 
that the list of supported languages is static.

You'd need to have some reserved controller names that would never be user 
names, to allow for access to some functions before users are registered or 
logged in. Or some equivalent functionality.

With the regex rewriter, I suppose you could unconditionally move the first URL 
element to the query string, and always invoke the default controller, which 
would look at the query string and decide what to do, interpreting the reserved 
names as required. 

In my mechanism there's no way to do that. My intention originally was to allow 
for user-defined hooks, and I still might do that. You could define callback 
functions that would be called at strategic points, so you could look at the 
first URL element, stash it somewhere, pop it from the URL, and continue—same 
effect.

Or maybe what you want to do is sufficiently general that we could support it 
as a new mechanism: if the URL element in the controller position doesn't match 
a list of reserved names, save the element in request or request.env and set 
the controller to some designated value.



[web2py] Re: How to rename a FORM submit button?

2011-01-12 Thread dederocks
Awsome, thank you!

On 13 jan, 01:59, Bruno Rocha  wrote:
> FORM(INPUT(_type='submit',_value='Click here'))
>
> 2011/1/12 dederocks 
>
> > If you have
> > FORM(INPUT(_type='submit'))
> > just to display a button, is it possible to change the button label
> > value?
>
>


Re: [web2py] How to rename a FORM submit button?

2011-01-12 Thread Bruno Rocha
FORM(INPUT(_type='submit',_value='Click here'))

2011/1/12 dederocks 

> If you have
> FORM(INPUT(_type='submit'))
> just to display a button, is it possible to change the button label
> value?


[web2py] How to rename a FORM submit button?

2011-01-12 Thread dederocks
If you have
FORM(INPUT(_type='submit'))
just to display a button, is it possible to change the button label
value?


[web2py] new router

2011-01-12 Thread Jonathan Lundell
With one more patch pending, the new URL router is looking pretty stable. There 
are some features pending, but they'll have to wait.

I thought I'd describe some of the possibilities with a few use cases.


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

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

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

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

...where normal shortening would be ambiguous.


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



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

http://myapp/en/some/path

or (rewritten)

http://en/some/path

Here's how:

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

Now an incoming URL like this:

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

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

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

will be mapped to:

applications/myapp/static/it/filename

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

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

...will still map to:

applications/myapp/static/base.css

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

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


Domain mapping is supported as well.

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

does what you'd expect.

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

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


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

[web2py] Re: experts

2011-01-12 Thread Massimo Di Pierro
I agree. We created a google group for members. You should have
received an invite. This discussions should move there and be
privately. If you did not get an invite I will make sure you get
another email.

Massimo


On Jan 12, 4:27 pm, Alexandre Andrade 
wrote:
> I think we have to emphasize the organizational aspect of
> experts4solutions.
>
> Otherwise, it will be just another portfolio website.
>
> I understand it is begining, but I think it will not be relevant without a
> organizational aspect.
>
> Things to think:
>
> 1. Who will receive demand, collect proposals and select the team/developer
> 2. What garanties the organization will give to contractor about time and
> costs
> 3. What percentage of project will be retained to maintain the organization?
> 4. How the organization will follow the project to make it a sucess
> everytime?
>
> Atenciosamente
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos e Inteligentes
>
> 2011/1/12 Michael McGinnis 
>
>
>
>
>
>
>
>
>
> > But the home page also says, "...or contact us and we will assemble
> > for you a well-balanced and cost-effective international team to work
> > on your project." Should we use the
> >http://experts4solutions.com/e4s/default/contact
> > to start that process, or should the home page be changed to de-
> > emphasize that option?
>
> > I could use help with the procedure anyway. I did use the contact page
> > in an attempt to reach an expert, but I don't know if I asked the
> > right questions or gave the right information.
>
> > Michael
>
> > On Jan 12, 7:09 am, Kenneth Lundström 
> > wrote:
> > > Look at the list onwww.experts4solutions.com), select an expert and
> > > contact directly.
>
> > > Kenneth
>
> > > > To Massimo:
>
> > > > what is the procedure to utilise the experts, please layout the
> > > > procedure. I will have a task in shortly.Debebe
>
> --


Re: [web2py] Re: experts

2011-01-12 Thread Alexandre Andrade
I think we have to emphasize the organizational aspect of
experts4solutions.

Otherwise, it will be just another portfolio website.

I understand it is begining, but I think it will not be relevant without a
organizational aspect.

Things to think:

1. Who will receive demand, collect proposals and select the team/developer
2. What garanties the organization will give to contractor about time and
costs
3. What percentage of project will be retained to maintain the organization?
4. How the organization will follow the project to make it a sucess
everytime?




Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


2011/1/12 Michael McGinnis 

> But the home page also says, "...or contact us and we will assemble
> for you a well-balanced and cost-effective international team to work
> on your project." Should we use the
> http://experts4solutions.com/e4s/default/contact
> to start that process, or should the home page be changed to de-
> emphasize that option?
>
> I could use help with the procedure anyway. I did use the contact page
> in an attempt to reach an expert, but I don't know if I asked the
> right questions or gave the right information.
>
> Michael
>
> On Jan 12, 7:09 am, Kenneth Lundström 
> wrote:
> > Look at the list onwww.experts4solutions.com), select an expert and
> > contact directly.
> >
> > Kenneth
> >
> >
> >
> >
> >
> >
> >
> > > To Massimo:
> >
> > > what is the procedure to utilise the experts, please layout the
> > > procedure. I will have a task in shortly.Debebe
>



--


[web2py] Re: list:reference update

2011-01-12 Thread dederocks
Great, thank you!

On 12 jan, 23:03, Massimo Di Pierro 
wrote:
> The update should be
>
> db(db.groupe.id==1).update(groupusers=[1,2])
>
> or one of the following
>
> db.groupe[1].update_record(groupusers=[1,2])
> db.groupe(1).update_record(groupusers=[1,2])
> db.groupe(id=1).update_record(groupusers=[1,2])
> db.groupe(db.groupe.id==1).update_record(groupusers=[1,2])
>
> but NOT
>
> db.groupe(db.groupe.id==1).update(groupusers=[1,2])
>
> On Jan 12, 3:22 pm, dederocks  wrote:
>
> > I'm trying to update a 'list:reference' field programaticaly, but this
> > doesn't work so far.
>
> > Say I have this model:
>
> > db.define_table('person', Field('name'))
> > db.define_table('groupe',Field('groupname'), Field('groupusers',
> > 'list:reference person'))
>
> > assume I have already entered three persons, with ids 1,2,3 and, also
> > defined a group with id=1
>
> > Then
> > db.groupe(db.groupe.id==1).update(groupusers=[1,2])
>
> > doesn't change the record. Does someone see what I'm doing wrong?
>
> > Thanks in advance for any cue on this.
>
> > Andre
>
>


[web2py] Re: if user is logged out

2011-01-12 Thread pk
one question:
def user():
if request.args(0) == 'logout':
db(query).delete()
return dict(form=auth())

what is if i need there the auth.user.id???
this is my query:
db(db.nao.userid==auth.user.id).update(db.nao.ipadress="")

On 12 Jan., 22:55, pk  wrote:
> super thanks so much! :)
>
> On 12 Jan., 22:45, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > Ops, Sorry, Copy & Paste mistake!
>
> > forget my last mail.
>
> > This the code
> > 
> > def user():
> >     if request.args(0) == 'logout':
> >         #do something here
> >         db(query).delete()
> >     return dict(form=auth())
> > 
> > --
>
> > Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Trunk hangs at startup

2011-01-12 Thread dederocks
It must be one of the updates done within the last six hours, I would
say.

On 12 jan, 23:00, Massimo Di Pierro 
wrote:
> Any way you can tell which revision causes the problem?
>
> On Jan 12, 2:50 pm, dederocks  wrote:
>
> > And restarting the computer didn't solve the issue!
>
> > On 12 jan, 21:40, dederocks  wrote:
>
> > > Stopping doesn't work either -- need to kill the app.
>
> > > On 12 jan, 21:35, dederocks  wrote:
>
> > > > Running the latest trunk on Win7, FF, web2py hangs after starting the
> > > > server ('waiting for 127.0.0.1...'), but appears to work otherwise:
> > > > e.g. if I specify the url of an application, it works.
> > > > Admin works as well.
> > > > Hope this helps.
>
>


[web2py] Re: list:reference update

2011-01-12 Thread Massimo Di Pierro
The update should be

db(db.groupe.id==1).update(groupusers=[1,2])

or one of the following

db.groupe[1].update_record(groupusers=[1,2])
db.groupe(1).update_record(groupusers=[1,2])
db.groupe(id=1).update_record(groupusers=[1,2])
db.groupe(db.groupe.id==1).update_record(groupusers=[1,2])

but NOT

db.groupe(db.groupe.id==1).update(groupusers=[1,2])


On Jan 12, 3:22 pm, dederocks  wrote:
> I'm trying to update a 'list:reference' field programaticaly, but this
> doesn't work so far.
>
> Say I have this model:
>
> db.define_table('person', Field('name'))
> db.define_table('groupe',Field('groupname'), Field('groupusers',
> 'list:reference person'))
>
> assume I have already entered three persons, with ids 1,2,3 and, also
> defined a group with id=1
>
> Then
> db.groupe(db.groupe.id==1).update(groupusers=[1,2])
>
> doesn't change the record. Does someone see what I'm doing wrong?
>
> Thanks in advance for any cue on this.
>
> Andre


[web2py] Re: Trunk hangs at startup

2011-01-12 Thread Massimo Di Pierro
Any way you can tell which revision causes the problem?

On Jan 12, 2:50 pm, dederocks  wrote:
> And restarting the computer didn't solve the issue!
>
> On 12 jan, 21:40, dederocks  wrote:
>
>
>
>
>
>
>
> > Stopping doesn't work either -- need to kill the app.
>
> > On 12 jan, 21:35, dederocks  wrote:
>
> > > Running the latest trunk on Win7, FF, web2py hangs after starting the
> > > server ('waiting for 127.0.0.1...'), but appears to work otherwise:
> > > e.g. if I specify the url of an application, it works.
> > > Admin works as well.
> > > Hope this helps.


[web2py] Re: Trunk hangs at startup

2011-01-12 Thread Massimo Di Pierro
Will look into this.

On Jan 12, 2:50 pm, dederocks  wrote:
> And restarting the computer didn't solve the issue!
>
> On 12 jan, 21:40, dederocks  wrote:
>
>
>
>
>
>
>
> > Stopping doesn't work either -- need to kill the app.
>
> > On 12 jan, 21:35, dederocks  wrote:
>
> > > Running the latest trunk on Win7, FF, web2py hangs after starting the
> > > server ('waiting for 127.0.0.1...'), but appears to work otherwise:
> > > e.g. if I specify the url of an application, it works.
> > > Admin works as well.
> > > Hope this helps.


[web2py] Re: if user is logged out

2011-01-12 Thread pk
super thanks so much! :)

On 12 Jan., 22:45, Bruno Rocha  wrote:
> Ops, Sorry, Copy & Paste mistake!
>
> forget my last mail.
>
> This the code
> 
> def user():
>     if request.args(0) == 'logout':
>         #do something here
>         db(query).delete()
>     return dict(form=auth())
> 
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio


Re: [web2py] if user is logged out

2011-01-12 Thread Bruno Rocha
Ops, Sorry, Copy & Paste mistake!

forget my last mail.

This the code

def user():
if request.args(0) == 'logout':
#do something here
db(query).delete()
return dict(form=auth())

-- 

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


Re: [web2py] if user is logged out

2011-01-12 Thread Bruno Rocha
Do you mean this?

# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without
limitations

#
## This is a samples controller
## - index is the default action of any application
## - user is required for authentication and authorization
## - download is for downloading files uploaded in the db (does streaming)
## - call exposes all registered services (none by default)
#
def family():
datasource = db(db.hijo.id>0).select()
return dict(table=SQLTABLE(datasource),
  powertable=plugin_powerTable(datasource))


@auth.requires_login()
def clientes():
"""
Lista todos os clientes cadastrados
"""

class Virtual(object):
@virtualsettings(label=T('Nome do Cliente:'))
def virtualtooltip(self):
text = 'Endereço: %s'
tooltiptext = T(text % self.cliente.endereco)
return tooltiptext

# Consultando todos os clientes
query = db.cliente.id > 0 and db.cliente.aniversario <= request.now
clientes = db(query).select(orderby=db.cliente.nome)

#Preparando a tabela
table = plugins.powerTable
table.datasource = clientes
table.uitheme = 'redmond'
table.dtfeatures['sPaginationType'] = 'scrolling'
table.keycolumn = 'cliente.id'
table.columns = ['cliente.nome','cliente.endereco','cliente.telefone']
table.headers = 'labels'
table.showkeycolumn = False
table.columnsearch = True
table.extra =
dict(details={'detailscolumns':'cliente.nome,cliente.endereco,cliente.telefone'},
   tooltip={'type':'virtual'}
   )
table.virtualfields = Virtual()

#return dict(table=SQLTABLE(clientes))

# Caso nao tiver nenhum registro mostrar mensagem
if clientes:
# Retornando os registros
return dict(clientes=clientes, table = table.create())
else:
return dict(clientes = clientes, mensagem = T('sem_registros'))


def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
class Virtual(object):
@virtualsettings(label=T('User Information:'))
def virtualtooltip(self):
text = 'This user mail address is %s'
tooltiptext = T(text % self.auth_user.email)
return tooltiptext

response.flash = T('You are successfully running web2py.')

# Consultando todos os funcionarios cadastrados
# no sistema
query = db.auth_user.id>0
funcionarios = db(query).select(orderby=db.auth_user.first_name)

#Preparando a tabela
table = plugins.powerTable
table.datasource = funcionarios
table.uitheme = 'redmond'
table.dtfeatures['sPaginationType'] = 'scrolling'
table.keycolumn = 'auth_user.id'
table.columns = ['auth_user.first_name','auth_user.last_name']
table.headers = 'labels'
table.showkeycolumn = False
table.columnsearch = True
table.extra = dict(details={'detailscolumns':'auth_user.email,
auth_user.id'},
   tooltip={'type':'virtual'}
   )

table.virtualfields = Virtual()


return dict(table=table.create())

def user():
if request.args(0) == 'logout':
#do something here
db(db.table.id==someid).delete()
return dict(form=auth())

2011/1/12 pk 

> hi togehter,
>
> how can i edit my own commands (for example i will delete something in
> a db table) if
> user get logged out? where can i do this?
>
> thanks peter




-- 

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


[web2py] Re: list:reference update

2011-01-12 Thread dederocks
Hi Kenneth,

Thanks a lot for getting back.
Actualy, to my understanding, the 'list:reference' provides a way to
bypass the third table, and most importantly the joins that don't work
on GAE. A list of records is represented as a string with the ids
separated by '¦'. E.g. in my example, the groupusers should have been
'1¦2' (or '¦1¦2¦', I'm not sure).

That said, the update issue remains -- or do you have a hint?

BR, Andre

On 12 jan, 22:35, Kenneth Lundström 
wrote:
> I might be completly wrong but shouldn t it be like this:
>
> db.define_table('person', Field('name'), Field('groupe',
> 'list:reference groupe'))
> db.define_table('groupe',Field('groupname'))
>
> db.groupe(db.person.id<3).update(groupe=1)
>
> If one users can be in many groups you get a many-to-many relationship
> and you need a third table to now to what group a user belongs.
>
> Kenneth
>
> > I'm trying to update a 'list:reference' field programaticaly, but this
> > doesn't work so far.
>
> > Say I have this model:
>
> > db.define_table('person', Field('name'))
> > db.define_table('groupe',Field('groupname'), Field('groupusers',
> > 'list:reference person'))
>
> > assume I have already entered three persons, with ids 1,2,3 and, also
> > defined a group with id=1
>
> > Then
> > db.groupe(db.groupe.id==1).update(groupusers=[1,2])
>
> > doesn't change the record. Does someone see what I'm doing wrong?
>
> > Thanks in advance for any cue on this.
>
> > Andre
>
>


Re: [web2py] list:reference update

2011-01-12 Thread Kenneth Lundström

I might be completly wrong but shouldn´t it be like this:

db.define_table('person', Field('name'), Field('groupe',
'list:reference groupe'))
db.define_table('groupe',Field('groupname'))

db.groupe(db.person.id<3).update(groupe=1)

If one users can be in many groups you get a many-to-many relationship 
and you need a third table to now to what group a user belongs.



Kenneth


I'm trying to update a 'list:reference' field programaticaly, but this
doesn't work so far.

Say I have this model:

db.define_table('person', Field('name'))
db.define_table('groupe',Field('groupname'), Field('groupusers',
'list:reference person'))

assume I have already entered three persons, with ids 1,2,3 and, also
defined a group with id=1

Then
db.groupe(db.groupe.id==1).update(groupusers=[1,2])

doesn't change the record. Does someone see what I'm doing wrong?

Thanks in advance for any cue on this.

Andre




[web2py] if user is logged out

2011-01-12 Thread pk
hi togehter,

how can i edit my own commands (for example i will delete something in
a db table) if
user get logged out? where can i do this?

thanks peter


[web2py] Re: Combining left outer join how to?

2011-01-12 Thread Uolter
Hi,

I got the trick 

users=db().select(db.auth_user.ALL, db.auth_group.ALL,
  left=[db.auth_membership.on(db.auth_user.id ==
db.auth_membership.user_id),
db.auth_group.on(db.auth_group.id ==
db.auth_membership.user_id) ] )


Indeed, this the query I need!! And it works fine.

:-)


On Jan 10, 6:10 pm, Uolter  wrote:
> Hi DenesL,
>
> thank you very much for your feedback.
>
> I gave it a go, but I'm still getting doubled records.
>
> User John appears twice even if in the auth_user table he is alone.
>
> Uolter
>
> On Jan 6, 3:30 pm, DenesL  wrote:
>
> > Just make a list of theleftjoins:
>
> > users=db().select(db.auth_user.ALL,
> > db.auth_group.ALL,
> >  left=[db.auth_membership.on(db.auth_user.id ==
> > db.auth_membership.user_id),
> >         db.auth_group.on(db.auth_user.id ==
> > db.auth_membership.user_id) ] )
>
> > On Jan 6, 5:25 am, Uolter  wrote:
>
> > > Hi all,
>
> > > I have this sql query that combine twoleftouterjoin.
>
> > > select * from auth_user
> > >    LEFTOUTERJOINauth_membership on
> > > auth_membership.user_id=auth_user.id
> > >    LEFTOUTERJOINauth_group on auth_membership.user_id=auth_user.id
>
> > > basically, it returns all users with their role when they have a role
> > > or not.
>
> > > It works fine in sqlite and I wonder how run it in Web2py?
>
> > > I'm trying something like this, but it doesn't work as expected:
>
> > > users=db().select(db.auth_user.ALL, db.auth_group.ALL,
> > >left=db.auth_membership.on(db.auth_user.id ==
> > > db.auth_membership.user_id & db.auth_group.id ==
> > > db.auth_membership.group_id))
>
> > > Need some help!!!
>
> > > Thanks in advance
>
> > > Uolter
>
> > > twitter:@uollter
>
> > > linkedin:http://it.linkedin.com/in/wtraspad
>
>


[web2py] list:reference update

2011-01-12 Thread dederocks
I'm trying to update a 'list:reference' field programaticaly, but this
doesn't work so far.

Say I have this model:

db.define_table('person', Field('name'))
db.define_table('groupe',Field('groupname'), Field('groupusers',
'list:reference person'))

assume I have already entered three persons, with ids 1,2,3 and, also
defined a group with id=1

Then
db.groupe(db.groupe.id==1).update(groupusers=[1,2])

doesn't change the record. Does someone see what I'm doing wrong?

Thanks in advance for any cue on this.

Andre


[web2py] Need Help Using CRUD with Self-Referencing Tables

2011-01-12 Thread SaltyCow
Hello there...

I'm hoping that this is a common problem with a simple solution.

I'm attempting to create an app that uses self-referencing tables, in
one case to refer to employees and their managers (who themselves are
also employees). I used the app wizard to generate the scaffolding. I
am able to add records, but the boilerplate crud read and crud select
functions return the following error: Using a recursive select, but
encountered a broken reference. Also, the form generated by the crud
create function does not generate a drop-down selection box as it
normally would for a reference field.

So, my question is, really, do I need to write custom crud functions
to work with self-referencing tables and, if so, does anyone know the
best way to do this? I've read the part in the docs about using
"with_alias" but I can't seem to make heads or tails of it. (Not a
problem with the manual, just my limited knowledge of SQL.)

I'd appreciate any further direction anyone can give me.

Thanks...>Jeff



[web2py] Re: Trunk hangs at startup

2011-01-12 Thread dederocks
And restarting the computer didn't solve the issue!

On 12 jan, 21:40, dederocks  wrote:
> Stopping doesn't work either -- need to kill the app.
>
> On 12 jan, 21:35, dederocks  wrote:
>
> > Running the latest trunk on Win7, FF, web2py hangs after starting the
> > server ('waiting for 127.0.0.1...'), but appears to work otherwise:
> > e.g. if I specify the url of an application, it works.
> > Admin works as well.
> > Hope this helps.
>
>


[web2py] Re: Trunk hangs at startup

2011-01-12 Thread dederocks
Stopping doesn't work either -- need to kill the app.

On 12 jan, 21:35, dederocks  wrote:
> Running the latest trunk on Win7, FF, web2py hangs after starting the
> server ('waiting for 127.0.0.1...'), but appears to work otherwise:
> e.g. if I specify the url of an application, it works.
> Admin works as well.
> Hope this helps.


[web2py] Trunk hangs at startup

2011-01-12 Thread dederocks
Running the latest trunk on Win7, FF, web2py hangs after starting the
server ('waiting for 127.0.0.1...'), but appears to work otherwise:
e.g. if I specify the url of an application, it works.
Admin works as well.
Hope this helps.



Re: [web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Vasile Ermicioi
hi,

Massimo, there is a new  version of pymysql

I think pymysql has a few advantages
- being pure Python, PyMySQL is easily patched by gevent and the likes to
make it cooperative

http://code.google.com/p/pymysql/wiki/WhyPyMySQL

I use it with web2py and works fine


[web2py] Re: What is queue.yaml

2011-01-12 Thread Massimo Di Pierro
Good idea. I added a comment.

On Jan 12, 10:01 am, Luther Goh Lu Feng  wrote:
> On Jan 12, 11:58 pm, Jonathan Lundell  wrote:
>
> > On Jan 12, 2011, at 1:29 AM, Luther Goh Lu Feng wrote:
>
> > > Looking at the source, I 
> > > seehttp://code.google.com/p/web2py/source/browse/queue.yaml
> > > and wonder what it is used for. Any ideas?
>
> >http://code.google.com/appengine/docs/python/config/queue.html
>
> Thanks. Perhaps I can suggest a one line comment, such as the link
> above?


[web2py] Re: experts

2011-01-12 Thread Michael McGinnis
But the home page also says, "...or contact us and we will assemble
for you a well-balanced and cost-effective international team to work
on your project." Should we use the 
http://experts4solutions.com/e4s/default/contact
to start that process, or should the home page be changed to de-
emphasize that option?

I could use help with the procedure anyway. I did use the contact page
in an attempt to reach an expert, but I don't know if I asked the
right questions or gave the right information.

Michael

On Jan 12, 7:09 am, Kenneth Lundström 
wrote:
> Look at the list onwww.experts4solutions.com), select an expert and
> contact directly.
>
> Kenneth
>
>
>
>
>
>
>
> > To Massimo:
>
> > what is the procedure to utilise the experts, please layout the
> > procedure. I will have a task in shortly.Debebe


[web2py] Re: What is queue.yaml

2011-01-12 Thread Luther Goh Lu Feng


On Jan 12, 11:58 pm, Jonathan Lundell  wrote:
> On Jan 12, 2011, at 1:29 AM, Luther Goh Lu Feng wrote:
>
>
>
> > Looking at the source, I 
> > seehttp://code.google.com/p/web2py/source/browse/queue.yaml
> > and wonder what it is used for. Any ideas?
>
> http://code.google.com/appengine/docs/python/config/queue.html

Thanks. Perhaps I can suggest a one line comment, such as the link
above?


Re: [web2py] What is queue.yaml

2011-01-12 Thread Jonathan Lundell
On Jan 12, 2011, at 1:29 AM, Luther Goh Lu Feng wrote:
> 
> Looking at the source, I see 
> http://code.google.com/p/web2py/source/browse/queue.yaml
> and wonder what it is used for. Any ideas?

http://code.google.com/appengine/docs/python/config/queue.html

[web2py] Storing the Original Filename in the official web2py book

2011-01-12 Thread carlo
def display_form():
record = db.person(request.args(0)) or redirect(URL('index'))
url = URL('download')
form = SQLFORM(db.person, record, deletable=True,
   upload=url, fields=['name', 'image'])
if request.vars.image!=None:
form.vars.image_filename = request.vars.image.filename
if form.accepts(request.vars, session):
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)

I think:

if request.vars.image!=None ## always True

should be

if request.vars.image


carlo


[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Massimo Di Pierro
It is more portable because it is pure python (mysqldb includes c
libraries).

About faster, I remember reading something about that but this
everything I could find today:

  http://code.google.com/p/pymysql/wiki/Performance



On Jan 12, 9:40 am, Luther Goh Lu Feng  wrote:
> Btw, is there a link I can read about pymysql being faster and more
> portable?
>
> On Jan 12, 10:47 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > that should do it. but why? pymysql is faster and more portable.
>
> > On Jan 12, 8:38 am, Luther Goh Lu Feng  wrote:
>
> > > I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> > > features, replacing mysqldb.
>
> > > I would like to ask if it is possible to do an override and use
> > > mysqldb instead of pymysql. If this is not possible, would editing
> > > gluon/dal.py to revert the patch be a possible 
> > > hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> > > Thanks in advance.


[web2py] Re: good news...

2011-01-12 Thread Massimo Di Pierro
I hope some of you will be attending. It would be a shame if we do not
get a full room. ;-)

Massimo

On Jan 12, 9:26 am, Robert  wrote:
> Nice! 2011 the year of web2py! :)


[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Luther Goh Lu Feng
Btw, is there a link I can read about pymysql being faster and more
portable?

On Jan 12, 10:47 pm, Massimo Di Pierro 
wrote:
> that should do it. but why? pymysql is faster and more portable.
>
> On Jan 12, 8:38 am, Luther Goh Lu Feng  wrote:
>
>
>
>
>
>
>
> > I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> > features, replacing mysqldb.
>
> > I would like to ask if it is possible to do an override and use
> > mysqldb instead of pymysql. If this is not possible, would editing
> > gluon/dal.py to revert the patch be a possible 
> > hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> > Thanks in advance.


[web2py] Re: good news...

2011-01-12 Thread Robert
Nice! 2011 the year of web2py! :)

[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Luther Goh Lu Feng
Anyway these are some of the open pymysql issues 
http://code.google.com/p/pymysql/issues/list

On Jan 12, 11:02 pm, Luther Goh Lu Feng  wrote:
> There are some concerns that pymysql might not be ready for production
> yet. Nothing specific. But mysqldb is definitely stable and tested.
>
> On Jan 12, 10:47 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > that should do it. but why? pymysql is faster and more portable.
>
> > On Jan 12, 8:38 am, Luther Goh Lu Feng  wrote:
>
> > > I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> > > features, replacing mysqldb.
>
> > > I would like to ask if it is possible to do an override and use
> > > mysqldb instead of pymysql. If this is not possible, would editing
> > > gluon/dal.py to revert the patch be a possible 
> > > hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> > > Thanks in advance.


[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Luther Goh Lu Feng
There are some concerns that pymysql might not be ready for production
yet. Nothing specific. But mysqldb is definitely stable and tested.

On Jan 12, 10:47 pm, Massimo Di Pierro 
wrote:
> that should do it. but why? pymysql is faster and more portable.
>
> On Jan 12, 8:38 am, Luther Goh Lu Feng  wrote:
>
>
>
>
>
>
>
> > I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> > features, replacing mysqldb.
>
> > I would like to ask if it is possible to do an override and use
> > mysqldb instead of pymysql. If this is not possible, would editing
> > gluon/dal.py to revert the patch be a possible 
> > hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> > Thanks in advance.


[web2py] Re: Using mysqldb instead of pymysql

2011-01-12 Thread Massimo Di Pierro
that should do it. but why? pymysql is faster and more portable.

On Jan 12, 8:38 am, Luther Goh Lu Feng  wrote:
> I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> features, replacing mysqldb.
>
> I would like to ask if it is possible to do an override and use
> mysqldb instead of pymysql. If this is not possible, would editing
> gluon/dal.py to revert the patch be a possible 
> hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> Thanks in advance.


[web2py] Re: recursive select bug

2011-01-12 Thread Massimo Di Pierro
It works in the normal shell

python web2py.py -S yourapp -M -n

It does not  work on the web based shell for the same reason here:

http://groups.google.com/group/web2py/browse_thread/thread/f33577079802501e#

On Jan 12, 8:36 am, dederocks  wrote:
> I've tried to run the following example, a copy-paste from the book.
> What am I doing wrong?
>
> my model:
>
> db.define_table('person', Field('name'))
>
> db.define_table('dog', Field('name'), Field('owner',db.person))
>
> in the shell:
> web2py Shell Version 1.91.6 (2011-01-10 20:54:45)
> In [1] : db.person.insert(name='Alex')
> 1
>
> In [2] : db.person.insert(name='Bill')
> 2
>
> In [3] : db.dog.insert(name='medor',owner=1)
> 1
>
> In [4] : dogs = db(db.dog.id>0).select()
>
> In [5] : for dog in dogs: print dog.name, dog.owner.name
> Traceback (most recent call last):
>   File "C:\Users\Andre\Documents\web2py\gluon\contrib\shell.py", line
> 225, in run
>     exec compiled in statement_module.__dict__
>   File "", line 1, in 
> AttributeError: 'dict' object has no attribute 'name'


[web2py] Using mysqldb instead of pymysql

2011-01-12 Thread Luther Goh Lu Feng
I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
features, replacing mysqldb.

I would like to ask if it is possible to do an override and use
mysqldb instead of pymysql. If this is not possible, would editing
gluon/dal.py to revert the patch be a possible hack?
http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835b4d0dc0e6c06a85e3f282a8&r=fc75444ca55590835b4d0dc0e6c06a85e3f282a8&format=side&path=/gluon/dal.py


Thanks in advance.


[web2py] recursive select bug

2011-01-12 Thread dederocks
I've tried to run the following example, a copy-paste from the book.
What am I doing wrong?

my model:

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

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

in the shell:
web2py Shell Version 1.91.6 (2011-01-10 20:54:45)
In [1] : db.person.insert(name='Alex')
1

In [2] : db.person.insert(name='Bill')
2

In [3] : db.dog.insert(name='medor',owner=1)
1

In [4] : dogs = db(db.dog.id>0).select()

In [5] : for dog in dogs: print dog.name, dog.owner.name
Traceback (most recent call last):
  File "C:\Users\Andre\Documents\web2py\gluon\contrib\shell.py", line
225, in run
exec compiled in statement_module.__dict__
  File "", line 1, in 
AttributeError: 'dict' object has no attribute 'name'


[web2py] Re: upload widgets problem with nullable compound validators

2011-01-12 Thread Massimo Di Pierro
good catch. Let me think about this...

On Jan 12, 1:12 am, kenji4569  wrote:
> I applied the follwing validators for upload fields in version 1.91.6:
>
> requires = [
>     IS_NULL_OR(IS_UPLOAD_FILENAME(extension='pdf')),
>     IS_NULL_OR(IS_LENGTH(1048576, 1024)),
> ]
>
> Everything was fine until I used a SQLFORM object with an upload
> keyword for editing.
>
> Then, a delete checkbox of an upload widget falsely disappeared which
> should be displayed with a link to the uploaded file.
>
> This is the result of the code in UploadWidget class of gluon/
> sqlhtml.py:
>
> if requires == [] or isinstance(requires, IS_EMPTY_OR):
>     inp = DIV(, ...,
>                      UploadWidget.ID_DELETE_SUFFIX),
>                      ...)
>
> And, the next patch would tentatively fix the problem:
>
> if (requires == [] or isinstance(requires, IS_EMPTY_OR) or
>     (isinstance(requires, (list, tuple)) and
>      reduce(lambda a,b:a&b, [isinstance(r, IS_EMPTY_OR) for r in
> requires]))):
>     ...
>
> But, I am not sure if the above patch is smart.
> Is there any way to implement such validation without patches nor
> custom validators?


[web2py] upload widgets problem with nullable compound validators

2011-01-12 Thread kenji4569
I applied the follwing validators for upload fields in version 1.91.6:

requires = [
IS_NULL_OR(IS_UPLOAD_FILENAME(extension='pdf')),
IS_NULL_OR(IS_LENGTH(1048576, 1024)),
]

Everything was fine until I used a SQLFORM object with an upload
keyword for editing.

Then, a delete checkbox of an upload widget falsely disappeared which
should be displayed with a link to the uploaded file.

This is the result of the code in UploadWidget class of gluon/
sqlhtml.py:

if requires == [] or isinstance(requires, IS_EMPTY_OR):
inp = DIV(, ...,
 UploadWidget.ID_DELETE_SUFFIX),
 ...)

And, the next patch would tentatively fix the problem:

if (requires == [] or isinstance(requires, IS_EMPTY_OR) or
(isinstance(requires, (list, tuple)) and
 reduce(lambda a,b:a&b, [isinstance(r, IS_EMPTY_OR) for r in
requires]))):
...

But, I am not sure if the above patch is smart.
Is there any way to implement such validation without patches nor
custom validators?


[web2py] Re: how to show multiple controller's views on the same page?

2011-01-12 Thread Mirek Zvolský
> I am wondering whether it is possible to show multiple controller's views...

Inside the controller code you can change to other view:
if something:
response.view='xxx.html'

In the view itself you can have more named parts.
In such case the extended layout has not only one {{include}} command,
but more {{include xxx}} commands /I don't remember the syntax
exactly/.
Inside such partial views you can control use of that html part by
{{if something:}} Output html here {{pass}}


Re: [web2py] experts

2011-01-12 Thread Kenneth Lundström
Look at the list on www.experts4solutions.com), select an expert and 
contact directly.



Kenneth


To Massimo:

what is the procedure to utilise the experts, please layout the
procedure. I will have a task in shortly.Debebe




[web2py] experts

2011-01-12 Thread debebe asefa
To Massimo:

what is the procedure to utilise the experts, please layout the
procedure. I will have a task in shortly.Debebe


Re: [web2py] Email gateway

2011-01-12 Thread Alexandre Andrade
see http://web2py.com/book/default/chapter/06?search=upload+#Manual-Uploads



2011/1/10 Kenneth Lundström 

>  Thank You Bruno and Alexandre for your answers.
>
> I think I have now downloaded the attachment but not written it anywhere
> yet. Would it be possible to use the uploads function i web2py to save the
> file in uploads and update a table with info about the new file?
>
>
> Kenneth
>
>
>
>
> You should look to the built in modules:
>
>  from poplib import *
>
>   or
>
>   from imaplib import *
>
>  I used poplib to get raw text messages, but I never get attached files,
> but I guess it can do it.
>
>
> 2011/1/10 Kenneth Lundström 
>
> A gateway that works the other way. Instead of sending emails from web2py
> I悲 like to receive emails.
>
> I惴 working on a app where you upload PDF:s containing receipts. Those PDF:s
> are usually scanned in a photocopier that emails the PDF to your email. Then
> you have to login in to my app and upload it. So my idea was to give the
> photocopier another email adress which my app reads and extracts the PDF
> from it
>
> Has anybody made anything like this? Where should I start? I guess it
> should be some kind of pop/imap client polling the postbox and reading and
> extrating everything from it.
>
>
> Kenneth
>
>
>
>
> --
>
>  Bruno Rocha
> http://about.me/rochacbruno/bio
>
>
>


-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos e Inteligentes


[web2py] Bugreport

2011-01-12 Thread Kenneth Lundström
I´m working on a new application which I created with the online wizard. 
I just created a new record and then updated it via those crud forms 
which are created for all tables.


This tabel was created by hand by editing the database models file and 
then I copied those crud forms too.


But when I now tried to update that record I got this error ticket. 
There is a copy of the relevant part of the my database models file.


Apache, mod_wsgi, MySQL


Kenneth


.2011-01-12.12-33-23.f900b81c-a5d5-45ac-8fcc-88b3bc0c3589
Version
web2py™ Version 1.91.6 (2011-01-03 17:55:14)
Python Python 2.6.5: /usr/bin/python
Traceback

Traceback (most recent call last):
File "/data/domains/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/data/domains/web2py/applications/kenneths/controllers/stuff.py", 
line 162, in 

File "/data/domains/web2py/gluon/globals.py", line 95, in 
self._caller = lambda f: f()
File "/data/domains/web2py/gluon/tools.py", line 2297, in f
return action(*a, **b)
File "/data/domains/web2py/applications/kenneths/controllers/stuff.py", 
line 49, in payment_receiver_update

onaccept=crud.archive)
File "/data/domains/web2py/gluon/tools.py", line 2860, in update
callback(onaccept,form,table._tablename)
File "/data/domains/web2py/gluon/tools.py", line 50, in callback
[action(form) for action in actions]
File "/data/domains/web2py/gluon/tools.py", line 2757, in archive
id = archive_table.insert(**new_record)
File "/data/domains/web2py/gluon/dal.py", line 3875, in insert
return self._db._adapter.insert(self,self._listify(fields))
File "/data/domains/web2py/gluon/dal.py", line 704, in insert
raise e
InternalError: (1054, u"Unknown column 'f_address' in 'field list'")

Error snapshot help Detailed traceback description

((1054, u"Unknown 
column 'f_address' in 'field list'"))


inspect attributes
Exception instance attributes
__module__ 'gluon.contrib.pymysql.err'
__getslice__ 
__str__ 
__getattribute__ 
__dict__ {}
__sizeof__ 
__weakref__ None
__init__ 
__setattr__ 
__reduce_ex__ 
__new__ 
__format__ 
__class__ 
__doc__ 'Exception raised when the database encounters an...anymore, the 
transaction is\n out of sync, etc.'

__getitem__ 
__setstate__ 
__reduce__ 
args (1054, u"Unknown column 'f_address' in 'field list'")
__subclasshook__ 
__unicode__ 
__delattr__ 
__repr__ 
__hash__ 

Function argument list

(self=, table=0x2aaab020bc90>}>, fields=[(, 'Suomi 
Communications Oy'), (, '157230-403873'), 
(, 'Upseerinkatu 3 A'), (object>, '02600'), (, 'Espoo'), 
(, 'lasku...@suomicom.fi'), (object>, 'www.suomicom.fi'), (, '1713769-5'), 
(, True), (, 
datetime.datetime(2011, 1, 12, 12, 28, 44)), (, 
datetime.datetime(2011, 1, 12, 12, 28, 44)), (, 
1), (, 1), (, 3L)])

Code listing


try:
self.execute(query)
except Exception, e:
if isinstance(e,self.integrity_error_class()):
return None
raise e

if hasattr(table,'_primarykey'):
return dict( [ (k,fields[k]) for k in table._primarykey ])
id = self.lastrowid(table)
if not isinstance(id,int):

Variables
e InternalError(1054, u"Unknown column 'f_address' in 'field list'")



db.define_table('t_payment_receiver',
Field('id','id',
represent=lambda id:SPAN(id,' 
',A('view',_href=URL('payment_receiver_read',args=id,

Field('f_name', type='string',
label=T('Name')),
Field('f_bank_account', type='string',
label=T('Bank account')),
Field('f_address', type='string',
label=T('Address')),
Field('f_zip_code', type='string',
label=T('Zip Code')),
Field('f_city', type='string',
label=T('City')),
Field('f_email', type='string',
label=T('Email')),
Field('f_website', type='string',
label=T('Website')),
Field('f_business_id', type='string',
label=T('Business ID')),
Field('active','boolean',default=True,
label=T('Active'),writable=False,readable=False),
Field('created_on','datetime',default=request.now,
label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
label=T('Modified On'),writable=False,readable=False,
update=request.now),
Field('created_by',db.auth_user,default=auth.user_id,
label=T('Created By'),writable=False,readable=False),
Field('modified_by',db.auth_user,default=auth.user_id,
label=T('Modified By'),writable=False,readable=False,
update=auth.user_id),
format='%(f_name)s',
migrate=settings.migrate)



Re: [web2py] Re: Apache, Wsgi problem

2011-01-12 Thread Kenneth Lundström
I can´t be sure which application it is. But Iĺl do some stresstests 
later today and report more.



Kenneth


could this be a timeout issue? Could it be the app causes a deadlock
in the db? What app is this?

On Jan 11, 10:58 am, Kenneth Lundström
wrote:

I'm getting the same Premature end of script on a CentOS 5.?, MySQL, WSGI and 
Apache.

Never done any stresstests, I'll try later to day.

Kenneth

- Ursprungsmeddelande -








Update:
+ There seems to be no web2py error.   Thus, no traceback.
+ I don't remember if I got this error Premature end of script
headers: wsgihandler.py ) with sqlite, but having just tested again
with sqlite, I didn't get this error. At the moment, this error only
occurred with postgres (8.6.3 as I'm on Debian Lenny).
+ This error occurred sporadically.   Testing with ab ranging from 50
to 200 concurrent connections, I couldn't always duplicate the error.
Sometimes, it occurred.   Sometimes, it didn't.
PS: Someone asked about apache bench.   It's included in apache2-utils
(which can be installed by apt).   Pretty easy to use.   I used this: ab
-kc 200 -t 10http://yourdomain.com/to open 200 concurrent requests
in 10 seconds.
On Jan 11, 8:58 am, Massimo Di Pierro
wrote:

Can I see the error? Is there a traceback? Is the db server on the
machine?
Massimo
On Jan 9, 11:30 am, VP  wrote:

It is indeed the case that there was a segmentation fault, reported
in apache error log.
Perhaps, it's not clear, but this problem occurs under posgres under
debian lenny, not sqlite.  I am not running web2py as a CGI script.
  I am using the web2py deployment script (for setting up apache and
web2py):

   WSGIDaemonProcess web2py user=myusername group=myusername \
display-name=%{GROUP}
   WSGIProcessGroup web2py
   WSGIScriptAlias / /home/myusername/web2py/wsgihandler.py

On Jan 8, 9:59 pm, Graham Dumpleton
wrote:

You were possibly using a an old version of sqlite which isn't
safe to use in a multithreaded configuration.
The MPM settings are not going to help in this case as that error
could only come about because you are using mod_wsgi daemon mode
and so application is running in distinct process and not those
affected by the MPM or its settings.
The only other way you could get that error is that you are
actually running web2py as a CGI script.
Overall, that specific error message means your daemon mode
process that is running web2py crashed. You would likely find that
there is a segmentation fault messages in main Apache error log as
well at that time.
Crashing could be because of sqlite thread problems, but could
also be because you are forcing web2py to run in main interpreter
of daemon processes and at the same time are using a third party C
extension module for Python that is not safe for use in sub
interpreters.
So, ensure sqlite is up to date. And ensure that you have:
   WSGIApplicationGroup %{GLOBAL}
in configuration to force use of main interpreter.
Graham
On Sunday, January 9, 2011 6:44:14 AM UTC+11, VP wrote:

We occasionally got an Apache error so the page didn't get
displayed. So I decided to stress test using Apache Bench (ab).
  It seems the site suffered failure up to 50-100 concurrent
connection.
Apache error log showed this error:

Premature end of script headers: wsgihandler.py

After digging around, I found similar discussions and change
apache2.conf like this:
# prefork MPM
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
MaxRequestsPerChild 500
ServerLimit 256
Didn't seem to help.

A few notes:
+ It appears when I switched to sqlite instead of posgres, I
didn't have the problem.   (Sqlite had other problems, such as
occasional database locking, which is more serious)
+ I am on a VPS with 768MB with 1GB burstable.   While I'm doing
the stress test with Apache Bench (ab), using free on the server
revealed memory usage was about 450MB.  (Which is a lot, but is
still under limit).
=
In summary, memory was available.   But we got this wsgi error in
Apache with multiple requests.
Any idea please?
Thanks.




[web2py] What is queue.yaml

2011-01-12 Thread Luther Goh Lu Feng
Looking at the source, I see 
http://code.google.com/p/web2py/source/browse/queue.yaml
and wonder what it is used for. Any ideas?


[web2py] Re: web2py fabric, pip, virtualenv, virtualenvwrappers deployment scripts

2011-01-12 Thread mart
interesting. What I do for hard-to-please head bangers, like
those .cfg files you mention, is I would collect what needs to be
updated (an entire section if I have to), find the most efficient way
to update/resolve that data, incorporate that in the bootstrap
automation. So at install time, the automation would simply read those
files, resolve the data, and re-write the entire file (and obviously
do the equivalent  to other platform if required). This way, a brand
new an configured file s available, and without the hassle of
tokenizing and updating a few lines in aften large enough files (I
just replace the who thing :) )

Since I want to use the same script for all platforms, The first thing
to be loaded is a dictionary that contains platform specific
properties, which are specifically common within one group of
platforms. I.e. a simple check of the OS name being bootstrapped will
retrieve the correct values (I.e. 'home','Users','c:/') -> but these
are just defaults, I usually leave room to overwrite with a cmd line
param or something.

On a side note: after thinking about this posting this morning, I
decided that a good way to install web2py is to use web2py. There are
lots of modules in there that already know web2py and that can be used
outside of the web context (scripting). And... there's the DAL :),
which would serve as a great place to store/retrive the required data
(instead of all those cumbersome text files that carry the automation
data). As part of the bootstrap and once deployed correctly, the
automation can as a next step, automatically load a web2py APP, if
needed, start the server, pass in instructions through XMLRPC or
something like that and configure more of the deployment. As an
example, and for my own purposes, I would continue the bootstrap to
include an import of an up to date csv of a DB that is common to all
servers where I need web2py running. Once deployed, all web2py servers
are ready for production, in theory :)

BTW, I use web2py as part of my build & release system at work (in
both in and out of the web context). I made the build system to be
portable and installable anywhere, so that developers can use it in
non-production activity. So, web2py could potentially be installed and
used in hundreds of desktops and laptops at any given time, on any of
its supported platforms (and that's outside of production servers).
This is why this one-click-deployment effort is of huge interest. If
that easily and fully deployed, web2py becomes a great collaboration
tool for software development: one app on any computer (and
installable anywhere) could easily serve as host to things like code
review between developers, or can serve as a quick-to-get-up-and-
running means to demo or, this is my favorite, our QA teams can switch
there focus from a production server to any developer's computer to
download "test" builds, build repports or even large scale test
automation if they wanted... and they should be able to do that with
there eyes closed because, for them, it becomes just a matter of
changing a computer_name or an ip (even half way around the world with
VPN as an example).

Alright, enough rambling on for me...

Thanks,
Mart :)




On Jan 12, 2:01 am, cjrh  wrote:
> On Jan 12, 12:23 am, Christopher Steel  wrote:
>
> > If people are interested I will clean mine up a bit and post a link to
> > the code.
>
> I rolled out another site yesterday (manually, no script---we use
> fabric for successive deployments of the web2py applications, but not
> for initial setup).
>
> Everything goes reasonably smoothly using the HostMonster FCGI
> tutorial on web2pyslices, but Sqlite and pysqlite are a huge pain.
> If
>
> ~/local/bin/python setup.py build_static install
>
> doesn't work for you, then you have to build sqlite manually:
>
> ./configure --prefix=$HOME/local
> make
> make install
>
> Then you have to edit the setup.cfg to point to
>
> include_dirs=/home//local/includes
> library_dirs=/home//local/lib
>
> [Hint: "$HOME" does NOT work inside setup.cfg!  Noob error, wasted so
> much time on that]
>
> Then pysqlite will install correctly.
>
> You may want to incorporate some of these observations into your
> script.   I have the process down quite efficiently now, if you want
> to hear more detail.


[web2py] Re: ajax upload for components

2011-01-12 Thread weheh
Thanks Michele & selecta for your contributions. I'm checking them
both out. And Michele, I'm glad you kept pushing me towards
jquery.Form. Thanks.

On Jan 11, 7:37 am, Martín Mulone  wrote:
> Thanks, +1. For me I think this need to be default.
>
> 2011/1/11 selecta 
>
>
>
> > and just for completion my slice doing something similar
> >http://web2pyslices.com/main/slices/take_slice/113
>
> > On Jan 10, 11:35 pm, Michele Comitini 
> > wrote:
> > > I made a slice:
>
> > >http://web2pyslices.com/main/slices/take_slice/114
>
> > > mic
>
> > > 2011/1/10 K.R.Arun :
>
> > > > Can you show me an example with file upload using jQuery form plugin?
> > > > Michele Comitini wrote:
> > > >> sorry i have to repeat myself, use the following, it is working and it
> > > >> is simple:
> > > >>http://jquery.malsup.com/form/
>
> > > >> it does everything for you, and gives more control than
> > LOAD(...,ajax=True).
>
> > > >> mic
> > > >> 2011/1/9 Massimo Di Pierro :
>
> > > >> > On Jan 9, 2011, at 11:31 AM, Arun K.Rajeevan wrote:
>
> > > >> > iframe works its own. I'm not a pro on javascript.
> > > >> > May be there is a way in js to access parent document from within
> > iframe.
> > > >> > If there's so, you can write your own js code to update main page
> > (which
> > > >> > embeds iframe).
>
> > > >> > yes there is. windows. parent
> > > >> >http://developer.apple.com/internet/webcontent/iframe.html
>
> > > >> > I can tell you one more suggestion.
> > > >> > If the parts in the page to be uploaded after each upload is
> > represented
> > > >> > together in the document,
> > > >> > you can redesign the page so that, upload form and parts to be
> > updated
> > > >> > are separated out to a component and load it into iframe.
> > > >> > Since everything is within same scope (iframe) it'll work.
> > > >> > Sorry, I'm not an expert to suggest a way (if part to be uploaded
> > are
> > > >> > scattered in the main document)
> > > >> > (I'm pretty sure JS can do that.)  also you are not limited to use
> > only
> > > >> > uploadify there are others too.
> > > >> > --
> > > >> > mail from:GoogleGroups "web2py-developers" mailing list
> > > >> > make speech: web2py-develop...@googlegroups.com
> > > >> > unsubscribe: 
> > > >> > web2py-developers+unsubscr...@googlegroups.com
> > > >> > details :http://groups.google.com/group/web2py-developers
> > > >> > the project:http://code.google.com/p/web2py/
> > > >> > official :http://www.web2py.com/
>
> > > >> > --
> > > >> > mail from:GoogleGroups "web2py-developers" mailing list
> > > >> > make speech: web2py-develop...@googlegroups.com
> > > >> > unsubscribe: 
> > > >> > web2py-developers+unsubscr...@googlegroups.com
> > > >> > details :http://groups.google.com/group/web2py-developers
> > > >> > the project:http://code.google.com/p/web2py/
> > > >> > official :http://www.web2py.com/
>
> --
> Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/
> Paraná, Entre Ríos, Argentina (CP 3100).
>
> My blog:http://martin.tecnodoc.com.ar
> My portfolio *spanish*:http://www.tecnodoc.com.ar
> Checkout my last proyect instant-press:http://www.instant2press.com
> Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6