[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Magnitus
But if you create "tasks" without doing it at the OS level, doesn't
that means that you won't really be able to take full advantage of
multi-processor hardware (since the OS handles the hardware and if the
OS doesn't know about it, it won't be able to do the required
optimizations with the hardware)?

Maybe I've done C/C++ for too long and am trying to micro-manage too
much, but a solution to I like to use for the problem of creating/
tearing down process threads is just to pre-create a limited number of
them (optimised for the number of CPUs you have) and recycle them to
do various tasks as needed.

Of course, that works best when you give your threads/processes longer
tasks to perform in parallel (else, the extra cost of managing it will
probably outweight the benefits of running it in parallel).

On May 20, 2:12 pm, Yarko Tymciurak 
wrote:
> On May 19, 6:18 pm, Yarko Tymciurak 
> wrote:
>
> > On May 19, 5:41 pm, amoygard  wrote:
>
> 
>
> > So - in general, you do not start subprocesses - with the exception of
> > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> I might better have said you do not _want_ to be starting subprocesses
> - besides the cost (compute time, memory, etc.), if you generally did
> this.   This (the inneficiency of spawning subrocesses) is why
> stackless  was created - and (among other things) used in a a very
> busy online game.  A lot of thought went into avoiding the costs of
> spawning subprocesses.
>
> If you haven't heard of it, stackless is an implementation of python
> that does not use the traditional "C" stack for local variables,
> etc.   Among other things, it has added "tasklets" to the language, so
> you can create and schedule tasks - without the overhead of doing so
> in your operating system.   There is a lot of discussion of benefit,
> efficiency.   Although there might be some discussion questioning the
> approach, other alternative approaches, one thing is clear:  the
> motivation to stay away from creating threads / subprocesses, and the
> costs involved.  it might be interesting to read up on it.
>
> - Yarko
>
>
>
> > - Yarko


[web2py] About differences bettwen T3 and cube9

2010-05-21 Thread GoldenTiger
Hi Massimo,

I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
attempt to rewrite T3. I love T3 !

Correct me if I am wrong about this:

The only way to check 'is_admin'  at T3 in models/db.py, is:

is_admin=(t2.logged_in and (not settings.administrator_emails or
t2.person_email in settings.administrator_emails))

All emails in settings.administratos_emails has 'is_admin' privileges,
hasn`t it?
And I have to set administrator_emails manually, is this correct?
Then if i am the only administrador and delete it by mistake,
'is_admin' will be always True, and all logged users will have
'is_admin' privileges
Am I missing something in current T3 about this?

Or is that the reason to rewrite cube9?
I am about to use T3 on production this week, but now i am confused.

T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
field=True by default  (I change to False, ok
)

cube9 checks variable 'is_admin' which depends on two records of
auth_user:

is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de

My dude is, if the first user (admin) is deleted by any reason, will
user_id be ==1 again in future registrations?

Anyway, which one to choose for production?  T3 or cube9? or web2py by
now?

Thanks alot, i hope i 'll contribute with web2py project some day :D

PD: sorry my poor english


[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Yarko Tymciurak
On May 21, 3:33 am, Magnitus  wrote:
> But if you create "tasks" without doing it at the OS level, doesn't
> that means that you won't really be able to take full advantage of
> multi-processor hardware (since the OS handles the hardware and if the
> OS doesn't know about it, it won't be able to do the required
> optimizations with the hardware)?

With the GIL, python itself does not utilize multiple processors, so
web2py is processor-bound (the only
effect of multi-core is that the o/s itself can "leave" a core to the
main python task, e.g.
it can grab an alternate core... other than that, you're running on
one core regardless -
unless you fire multiple instances of python interpreters, in which
case you are really only
going to communicate thru services anyway

See some of the discussion at http://bugs.python.org/issue7946,
http://stackoverflow.com/questions/990102/python-global-interpreter-lock-gil-workaround-on-multi-core-systems-using-tasks

... and so forth...

>
> Maybe I've done C/C++ for too long and am trying to micro-manage too
> much, but a solution to I like to use for the problem of creating/
> tearing down process threads is just to pre-create a limited number of
> them (optimised for the number of CPUs you have) and recycle them to
> do various tasks as needed.

Well - since you don't have that with python, you run the risk of I/O
blocking  which is why really lightweight
tasklets are so desireable (CCP Games runs 
http://en.wikipedia.org/wiki/Eve_Online
with many tens of thousands of simultaneous users, if I recall
correctly, and maintain stackless for this purpose).

>
> Of course, that works best when you give your threads/processes longer
> tasks to perform in parallel (else, the extra cost of managing it will
> probably outweight the benefits of running it in parallel).

There is much to cover in this - and I suppose reason to be happy that
python traditionally hasn't run multi-core.
See, for example, the discussions at:
http://stackoverflow.com/questions/203912/does-python-support-multiprocessor-multicore-programming

and http://docs.python.org/library/multiprocessing.html

Lots to read! ;-)

- Yarko

>
> On May 20, 2:12 pm, Yarko Tymciurak 
> wrote:
>
> > On May 19, 6:18 pm, Yarko Tymciurak 
> > wrote:
>
> > > On May 19, 5:41 pm, amoygard  wrote:
>
> > 
>
> > > So - in general, you do not start subprocesses - with the exception of
> > > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> > I might better have said you do not _want_ to be starting subprocesses
> > - besides the cost (compute time, memory, etc.), if you generally did
> > this.   This (the inneficiency of spawning subrocesses) is why
> > stackless  was created - and (among other things) used in a a very
> > busy online game.  A lot of thought went into avoiding the costs of
> > spawning subprocesses.
>
> > If you haven't heard of it, stackless is an implementation of python
> > that does not use the traditional "C" stack for local variables,
> > etc.   Among other things, it has added "tasklets" to the language, so
> > you can create and schedule tasks - without the overhead of doing so
> > in your operating system.   There is a lot of discussion of benefit,
> > efficiency.   Although there might be some discussion questioning the
> > approach, other alternative approaches, one thing is clear:  the
> > motivation to stay away from creating threads / subprocesses, and the
> > costs involved.  it might be interesting to read up on it.
>
> > - Yarko
>
> > > - Yarko


[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Graham Dumpleton


On May 21, 7:00 pm, Yarko Tymciurak 
wrote:
> On May 21, 3:33 am, Magnitus  wrote:
>
> > But if you create "tasks" without doing it at the OS level, doesn't
> > that means that you won't really be able to take full advantage of
> > multi-processor hardware (since the OS handles the hardware and if the
> > OS doesn't know about it, it won't be able to do the required
> > optimizations with the hardware)?
>
> With the GIL, python itself does not utilize multiple processors, so
> web2py is processor-bound (the only
> effect of multi-core is that the o/s itself can "leave" a core to the
> main python task, e.g.
> it can grab an alternate core... other than that, you're running on
> one core regardless -
> unless you fire multiple instances of python interpreters, in which
> case you are really only
> going to communicate thru services anyway
>
> See some of the discussion 
> athttp://bugs.python.org/issue7946,http://stackoverflow.com/questions/990102/python-global-interpreter-l...
>
> ... and so forth...
>
>
>
> > Maybe I've done C/C++ for too long and am trying to micro-manage too
> > much, but a solution to I like to use for the problem of creating/
> > tearing down process threads is just to pre-create a limited number of
> > them (optimised for the number of CPUs you have) and recycle them to
> > do various tasks as needed.
>
> Well - since you don't have that with python, you run the risk of I/O
> blocking  which is why really lightweight
> tasklets are so desireable (CCP Games 
> runshttp://en.wikipedia.org/wiki/Eve_Online
> with many tens of thousands of simultaneous users, if I recall
> correctly, and maintain stackless for this purpose).
>
>
>
> > Of course, that works best when you give your threads/processes longer
> > tasks to perform in parallel (else, the extra cost of managing it will
> > probably outweight the benefits of running it in parallel).
>
> There is much to cover in this - and I suppose reason to be happy that
> python traditionally hasn't run multi-core.
> See, for example, the discussions 
> at:http://stackoverflow.com/questions/203912/does-python-support-multipr...
>
> andhttp://docs.python.org/library/multiprocessing.html
>
> Lots to read! ;-)

Also read:

  http://blog.dscpl.com.au/2007/07/web-hosting-landscape-and-modwsgi.html
  http://blog.dscpl.com.au/2007/09/parallel-python-discussion-and-modwsgi.html

BTW, your prior descriptions about how web2py works under mod_wsgi
aren't overly accurate. You said:

"""
In a hosting environment, you have apache/wsgi (for example) running
a
wsgi-thred that is web2py - that (main and the stuff in gluon) is
your
long-running process (er, thread).   To restart web2py, with wsgi,
you
would do what is normal (touch a file) to cause apache to re-start
that wsgi thread.

Within web2py, you have a number of threads:  db connection pools,
and
application threads;   again, these respond to requests, and are
spawned off by web2py (not you)
"""

When run under Apache/mod_wsgi there is not a thread that is dedicated
to web2py and web2py doesn't have its own threads to respond to
requests.

In each Apache or mod_wsgi daemon process, depending on whether you
are using embedded mode or daemon mode, there is a pool of threads.
These are C threads, not Python threads and the thread pool is managed
by Apache or mod_wsgi as appropriate.

How a connection is accepted depends on Apache MPM or mod_wsgi mode
being used, but ultimately one of the threads in the thread pool
processes the request, all still in C code. For embedded mode the
request may not even be for the WSGI application but be for a static
file or other dynamic application such as PHP. If daemon mode, or if
target of request was the WSGI application, only then does Python GIL
get acquired and the thread tries to call into the WSGI application as
an external thread calling into the embedded Python interpreter.

At this point the WSGI application may not have even been loaded, so
the first request to find that has to load the WSGI script file which
may in turn load web2py. In this case web2py doesn't do anything
special. That is, it doesn't go creating its own thread pool and it
actually must return immediately once it is loaded and initialised.
Once it returns, the thread calls into the WSGI application entry
point and web2py handles the request. Any response is thence passed
back through Apache with the GIL being released at each point where
this occurs. When complete request is done, the GIL is completely
released and thread becomes inactive again pending a further request.

If other requests occur at the same time, they could also call into
web2py. The only choke point is the initial loading of the WSGI script
as obviously only want to allow one thread to do that.

So, web2py doesn't have its own request threads and all calls come in
from a external threads managed by Apache or mod_wsgi.

Graham

> - Yarko
>
>
>
>
>
> > On May 20, 2:12 pm, Yarko Tymciurak 
> > wrote:
>
> > > On May 19, 6

[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Magnitus
Now that you mention it, I recall reading in the Python/C API that
Python wasn't really thread-safe and that Python objects shouldn't be
accessed from multiple C threads (they recommended using the Python
threading API which was exposed in the Python/C API instead, but that
didn't interest me as its not true multi-threading).

My solution to this was make my C++ code C++ only and then glue parts
that I wanted to expose to Python so that Python calls on the C++
compiled code, but not the reverse.

Hence, I probably bypassed a large part of the problematic discussed
above by not delving deeply into Python's threading API.

On May 21, 5:00 am, Yarko Tymciurak 
wrote:
> On May 21, 3:33 am, Magnitus  wrote:
>
> > But if you create "tasks" without doing it at the OS level, doesn't
> > that means that you won't really be able to take full advantage of
> > multi-processor hardware (since the OS handles the hardware and if the
> > OS doesn't know about it, it won't be able to do the required
> > optimizations with the hardware)?
>
> With the GIL, python itself does not utilize multiple processors, so
> web2py is processor-bound (the only
> effect of multi-core is that the o/s itself can "leave" a core to the
> main python task, e.g.
> it can grab an alternate core... other than that, you're running on
> one core regardless -
> unless you fire multiple instances of python interpreters, in which
> case you are really only
> going to communicate thru services anyway
>
> See some of the discussion 
> athttp://bugs.python.org/issue7946,http://stackoverflow.com/questions/990102/python-global-interpreter-l...
>
> ... and so forth...
>
>
>
> > Maybe I've done C/C++ for too long and am trying to micro-manage too
> > much, but a solution to I like to use for the problem of creating/
> > tearing down process threads is just to pre-create a limited number of
> > them (optimised for the number of CPUs you have) and recycle them to
> > do various tasks as needed.
>
> Well - since you don't have that with python, you run the risk of I/O
> blocking  which is why really lightweight
> tasklets are so desireable (CCP Games 
> runshttp://en.wikipedia.org/wiki/Eve_Online
> with many tens of thousands of simultaneous users, if I recall
> correctly, and maintain stackless for this purpose).
>
>
>
> > Of course, that works best when you give your threads/processes longer
> > tasks to perform in parallel (else, the extra cost of managing it will
> > probably outweight the benefits of running it in parallel).
>
> There is much to cover in this - and I suppose reason to be happy that
> python traditionally hasn't run multi-core.
> See, for example, the discussions 
> at:http://stackoverflow.com/questions/203912/does-python-support-multipr...
>
> andhttp://docs.python.org/library/multiprocessing.html
>
> Lots to read! ;-)
>
> - Yarko
>
>
>
>
>
> > On May 20, 2:12 pm, Yarko Tymciurak 
> > wrote:
>
> > > On May 19, 6:18 pm, Yarko Tymciurak 
> > > wrote:
>
> > > > On May 19, 5:41 pm, amoygard  wrote:
>
> > > 
>
> > > > So - in general, you do not start subprocesses - with the exception of
> > > > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> > > I might better have said you do not _want_ to be starting subprocesses
> > > - besides the cost (compute time, memory, etc.), if you generally did
> > > this.   This (the inneficiency of spawning subrocesses) is why
> > > stackless  was created - and (among other things) used in a a very
> > > busy online game.  A lot of thought went into avoiding the costs of
> > > spawning subprocesses.
>
> > > If you haven't heard of it, stackless is an implementation of python
> > > that does not use the traditional "C" stack for local variables,
> > > etc.   Among other things, it has added "tasklets" to the language, so
> > > you can create and schedule tasks - without the overhead of doing so
> > > in your operating system.   There is a lot of discussion of benefit,
> > > efficiency.   Although there might be some discussion questioning the
> > > approach, other alternative approaches, one thing is clear:  the
> > > motivation to stay away from creating threads / subprocesses, and the
> > > costs involved.  it might be interesting to read up on it.
>
> > > - Yarko
>
> > > > - Yarko- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Graham Dumpleton


On May 21, 8:14 pm, Magnitus  wrote:
> Now that you mention it, I recall reading in the Python/C API that
> Python wasn't really thread-safe and that Python objects shouldn't be
> accessed from multiple C threads (they recommended using the Python
> threading API which was exposed in the Python/C API instead, but that
> didn't interest me as its not true multi-threading).

Python is thread safe so long as you abide by the contract of
acquiring the Python GIL. If you are going to ignore that required
contract, then obviously it will break.

This is the norm for any Python system in as much as you need to
acquire a lock when accessing a shared resource. In the Python case
there so happens to be one single global lock around any C API
accesses where as in a custom C/C++ application which is
multithreaded, you might have more fine grained locking around
specific data structures of parts of the API.

> My solution to this was make my C++ code C++ only and then glue parts
> that I wanted to expose to Python so that Python calls on the C++
> compiled code, but not the reverse.

Which is exactly what many C extension modules do. That is, they move
data between Python and C worlds so that they can then release the GIL
and process the data. That why it can still make use of multi core/
processor systems. This is why Apache/mod_wsgi isn't constrained by
the Python GIL because everything Apache itself does doesn't use the
Python GIL and can be properly parallelised.

Graham

> Hence, I probably bypassed a large part of the problematic discussed
> above by not delving deeply into Python's threading API.
>
> On May 21, 5:00 am, Yarko Tymciurak 
> wrote:
>
>
>
> > On May 21, 3:33 am, Magnitus  wrote:
>
> > > But if you create "tasks" without doing it at the OS level, doesn't
> > > that means that you won't really be able to take full advantage of
> > > multi-processor hardware (since the OS handles the hardware and if the
> > > OS doesn't know about it, it won't be able to do the required
> > > optimizations with the hardware)?
>
> > With the GIL, python itself does not utilize multiple processors, so
> > web2py is processor-bound (the only
> > effect of multi-core is that the o/s itself can "leave" a core to the
> > main python task, e.g.
> > it can grab an alternate core... other than that, you're running on
> > one core regardless -
> > unless you fire multiple instances of python interpreters, in which
> > case you are really only
> > going to communicate thru services anyway
>
> > See some of the discussion 
> > athttp://bugs.python.org/issue7946,http://stackoverflow.com/questions/9..
>
> > ... and so forth...
>
> > > Maybe I've done C/C++ for too long and am trying to micro-manage too
> > > much, but a solution to I like to use for the problem of creating/
> > > tearing down process threads is just to pre-create a limited number of
> > > them (optimised for the number of CPUs you have) and recycle them to
> > > do various tasks as needed.
>
> > Well - since you don't have that with python, you run the risk of I/O
> > blocking  which is why really lightweight
> > tasklets are so desireable (CCP Games 
> > runshttp://en.wikipedia.org/wiki/Eve_Online
> > with many tens of thousands of simultaneous users, if I recall
> > correctly, and maintain stackless for this purpose).
>
> > > Of course, that works best when you give your threads/processes longer
> > > tasks to perform in parallel (else, the extra cost of managing it will
> > > probably outweight the benefits of running it in parallel).
>
> > There is much to cover in this - and I suppose reason to be happy that
> > python traditionally hasn't run multi-core.
> > See, for example, the discussions 
> > at:http://stackoverflow.com/questions/203912/does-python-support-multipr...
>
> > andhttp://docs.python.org/library/multiprocessing.html
>
> > Lots to read! ;-)
>
> > - Yarko
>
> > > On May 20, 2:12 pm, Yarko Tymciurak 
> > > wrote:
>
> > > > On May 19, 6:18 pm, Yarko Tymciurak 
> > > > wrote:
>
> > > > > On May 19, 5:41 pm, amoygard  wrote:
>
> > > > 
>
> > > > > So - in general, you do not start subprocesses - with the exception of
> > > > > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> > > > I might better have said you do not _want_ to be starting subprocesses
> > > > - besides the cost (compute time, memory, etc.), if you generally did
> > > > this.   This (the inneficiency of spawning subrocesses) is why
> > > > stackless  was created - and (among other things) used in a a very
> > > > busy online game.  A lot of thought went into avoiding the costs of
> > > > spawning subprocesses.
>
> > > > If you haven't heard of it, stackless is an implementation of python
> > > > that does not use the traditional "C" stack for local variables,
> > > > etc.   Among other things, it has added "tasklets" to the language, so
> > > > you can create and schedule tasks - without the overhead of doing so
> > > > in your operating system.   There i

[web2py] Re: Catch auto-login event

2010-05-21 Thread weheh
Why don't you just keep a last_activity date? Also, the auth event log
keeps track of the last login automatically. Why not check it to see
what it's doing regarding last login when user has the "remember"
checkbox checked? Technically, if it's checked, they're not logging
in, right? Can you better articulate what you are really trying to
measure?

On May 21, 2:18 am, Adi  wrote:
> Sure. Thanks for the update.
>
> On May 21, 9:34 am, mdipierro  wrote:
>
>
>
> > need to work on this. On the case but being distracted sorry.
>
> > On May 20, 10:50 pm, Adi  wrote:
>
> > > Any help on this?
>
> > > On May 20, 3:45 pm, Adi  wrote:
>
> > > > Hi,
>
> > > > I use the "Remember me for 30 days" feature in our app. I used a
> > > > custom auth_table with a column "last_login" to update every time a
> > > > user logs into the application.
>
> > > > Currently I update it in a function call like this:
> > > > ---
> > > > def updateLastLogin(form):
>
> > > > db(db.auth_user.id==auth.user.id).update(last_login=datetime.datetime.now()
> > > >  )
>
> > > > auth.settings.login_onaccept = updateLastLogin
>
> > > > --
>
> > > > However if a user chooses to "remember me for 30 days" then there's no
> > > > actual login action. What is the way to track last_login for such
> > > > users who visit the app but don't actually login? I basically need it
> > > > for analytics.
>
> > > > Thanks,
> > > > Aditya- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: Drop Down alternative

2010-05-21 Thread weheh
LOL ... holy cr-p! That's great MDP! There is so much new stuff, I
can't keep up.

On May 21, 12:32 am, mdipierro  wrote:
> yes.
>
> from gluon.sqlhtml import AutocompleteWidget
>
> db.define_table('mytable',
>    Field('person',db.person,requires=IS_IN_DB(db,db.person.id,'%
> (name)s')),
>    ...)
>
> db.mytable.person.widget=AutocompleteWidget(request,db.person.name,db.perso­n.id,orderby=db.person.name)
>
> On May 20, 9:16 pm, greenpoise  wrote:
>
>
>
> > Is there an alternative to drop down? a type ahead type of widget?- Hide 
> > quoted text -
>
> - Show quoted text -


[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread mdipierro
T3 was a proof of concept. It works but it was written very long ago.
A lot of the T3 functionality is now in web2py. there is very little
reason for using T3.

cube9 does not exist. It is just a temp name for a project. I.e. write
an abstraction layer on top of web2py that would allow to program
without coding, by moving widgets around via drug and stop and filling
forms like in VB. It will incorporate some ideas from T3 (particularly
about menu and meta-models). Once done it will also be usable as a
CMS. It will take a while, I am sorry.

Massimo

On May 21, 3:48 am, GoldenTiger  wrote:
> Hi Massimo,
>
> I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
> attempt to rewrite T3. I love T3 !
>
> Correct me if I am wrong about this:
>
> The only way to check 'is_admin'  at T3 in models/db.py, is:
>
> is_admin=(t2.logged_in and (not settings.administrator_emails or
> t2.person_email in settings.administrator_emails))
>
> All emails in settings.administratos_emails has 'is_admin' privileges,
> hasn`t it?
> And I have to set administrator_emails manually, is this correct?
> Then if i am the only administrador and delete it by mistake,
> 'is_admin' will be always True, and all logged users will have
> 'is_admin' privileges
> Am I missing something in current T3 about this?
>
> Or is that the reason to rewrite cube9?
> I am about to use T3 on production this week, but now i am confused.
>
> T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
> field=True by default  (I change to False, ok
> )
>
> cube9 checks variable 'is_admin' which depends on two records of
> auth_user:
>
> is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de
>
> My dude is, if the first user (admin) is deleted by any reason, will
> user_id be ==1 again in future registrations?
>
> Anyway, which one to choose for production?  T3 or cube9? or web2py by
> now?
>
> Thanks alot, i hope i 'll contribute with web2py project some day :D
>
> PD: sorry my poor english


Re: [web2py] Re: "SSL is OFF" error message when starting the server

2010-05-21 Thread Timothy Farrell

So did that take care of it??

On 5/20/2010 4:15 PM, OMAR wrote:

Tim, you were very close.

libssl-dev

-

Massimo,

I went the route of installing distutils so I could easy_install, but
once again was met with an error:

sudo easy_install ssl
Processing ssl
error: Couldn't find a setup script in ssl

Thank you for the suggestions.
I see where plenty of other people had the same problem getting SSL
support in python.
Should I opt to compile python with SSL support to begin with, as this
page suggests? http://paltman.com/2007/nov/15/getting-ssl-support-in-python-251/

Perhaps a distro other than Debian?

Perhaps I should give up trying to use the included CherryPy server,
and use Cherokee or another web server instead?

This is very frustrating, and for the most part has nothing to do with
web2py.
Sorry to clutter the board.



   




[web2py] Re: Drop Down alternative

2010-05-21 Thread annet
Massimo,

I gave this a try:

from gluon.sqlhtml import AutocompleteWidget

db.define_table('address',
   Field('city',length=42,default='',notnull=True)),
   ...)

db.address.city.widget=AutocompleteWidget(request,db.city.name,db.city.name,orderby=db.city.name)


but that doesn't work, why not?


Kind regards,

Annet.


Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Timothy Farrell

Developers running with scissors!! LOL!!!

On 5/20/2010 2:12 PM, szimszon wrote:

Nice

On máj. 20, 19:52, mdipierro  wrote:
   

http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL
 




Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Albert Abril
Haha! I enjoy with this jokes in tech slides, they're amusing!

On Fri, May 21, 2010 at 3:02 PM, Timothy Farrell  wrote:

> Developers running with scissors!! LOL!!!
>
>
> On 5/20/2010 2:12 PM, szimszon wrote:
>
>> Nice
>>
>> On máj. 20, 19:52, mdipierro  wrote:
>>
>>
>>> http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL
>>>
>>>
>>
>


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Nicol van der Merwe
Nice! This is super excellent.

Just a simple question : will this work on SQL Server?

On Fri, May 21, 2010 at 1:37 AM, Alexandre Andrade  wrote:

> Some time ago I talk about to do it.
>
> Finally I have to do it.
>
> It can be improved to a form in appadmin, use the model to another db
> (postgresql, etc), and generate the file in /models.
>
> You can see the code below:
>
> --
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> #script to generate schemas from dbs
> #by Alexandre Andrade alexandrema...@gmail.com
> #www.hipercenter.com
>
> #config it here
> passwd="mypass"
> user="myuser"
> host="localhost"
> db = 'mydb'
> port='3306'
>
>
> def query(bd,sql):
> bd.query(sql)
> r = bd.store_result()
> rows = r.fetch_row(maxrows=0,how=1)
> return rows
>
> def get_tables():
> rows = query(bd,'show tables')
> tables=[]
> for row in rows:
> tables.append(row['Tables_in_'+db])
> return tables
>
> #tables()
>
> def get_fields(table):
> print table
> rows = query(bd,'show fields from '+ table)
> fields=[]
> for row in rows:
> #print row
> fields.append(row)
> return fields
>
> def field_type(field):
> if field['Type'][0:7]=='varchar':
> tipo = ",'string'"
> elif field['Type'][:8]=='longtext':
> tipo = ",'text'"
> elif field['Type'][:3]=='int':
> tipo = ",'integer'"
> elif field['Type'][:4]=='date':
> tipo = ",'date'"
> elif field['Type'][:7]=='tinyint':
> tipo = ",'int'"
> elif field['Type'][:11]=='mediumtext':
> tipo = ",'text'"
> elif field['Type'][:4]=='char':
> tipo = ",'text'"
> else:
> print  field['Type'][0:10]
> return tipo
>
> def primarykey(field):
> if field['Extra']=='auto_increment':
> pk = True
> else:
> pk = False
> return pk
>
> def define_table(table):
> fields =  get_fields(table)
> result = []
> head = 'db = DAL("mysql://'+ user+ ':'+passwd+'@'+host+':'+port+'/'+db+'",
> pool_size=10)\r\r'
>
> line = "db.define_table('"+table+"'"
> result.append(line)
> for field in fields:
> if primarykey(field) == True:
> pk =field['Field']
> #print pk
> tipo = field_type(field)
> line = "Field('"+field['Field']+"'"+tipo+")"
> result.append(line)
> line
> try:
> line = "primarykey=['"+pk+"']"
> result.append(line)
> except:
> pass
> out = ',\r'.join(result)
> output = head + out + '\r)'
> print output
> return output
>
> def define_db():
> tables = get_tables()
> r = []
> for table in tables:
> r.append(define_table(table))
> result = '\r \r'.join(r)
> return result
>
> r = define_db()
> f = open('db_'+db+'.py', 'w')
> f.write(r)
> f.close()
>
> ---
>
> --
> Atenciosamente
>
> --
> =
> Alexandre Andrade
> Hipercenter.com
>



-- 
Old Gregg: Ever drink baileys from a shoe? Wanna go to a club where people
wee on each other? I'm gonna hurt you. I like you. What do ya think of me?
Howard:I think your a nice..modern gentleman


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Jean Guy
Hi,

Really nice!

I haven't try it, but I have to do the importation of postgresql database
into a web2py model. I was just wondering if you can pointed the place that
should be adapt for postgresql, I will change it and return the running
code  for postgresql.

Thanks.

Jonhy

2010/5/20 Alexandre Andrade 

> Some time ago I talk about to do it.
>
> Finally I have to do it.
>
> It can be improved to a form in appadmin, use the model to another db
> (postgresql, etc), and generate the file in /models.
>
> You can see the code below:
>
> --
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> #script to generate schemas from dbs
> #by Alexandre Andrade alexandrema...@gmail.com
> #www.hipercenter.com
>
> #config it here
> passwd="mypass"
> user="myuser"
> host="localhost"
> db = 'mydb'
> port='3306'
>
>
> def query(bd,sql):
> bd.query(sql)
> r = bd.store_result()
> rows = r.fetch_row(maxrows=0,how=1)
> return rows
>
> def get_tables():
> rows = query(bd,'show tables')
> tables=[]
> for row in rows:
> tables.append(row['Tables_in_'+db])
> return tables
>
> #tables()
>
> def get_fields(table):
> print table
> rows = query(bd,'show fields from '+ table)
> fields=[]
> for row in rows:
> #print row
> fields.append(row)
> return fields
>
> def field_type(field):
> if field['Type'][0:7]=='varchar':
> tipo = ",'string'"
> elif field['Type'][:8]=='longtext':
> tipo = ",'text'"
> elif field['Type'][:3]=='int':
> tipo = ",'integer'"
> elif field['Type'][:4]=='date':
> tipo = ",'date'"
> elif field['Type'][:7]=='tinyint':
> tipo = ",'int'"
> elif field['Type'][:11]=='mediumtext':
> tipo = ",'text'"
> elif field['Type'][:4]=='char':
> tipo = ",'text'"
> else:
> print  field['Type'][0:10]
> return tipo
>
> def primarykey(field):
> if field['Extra']=='auto_increment':
> pk = True
> else:
> pk = False
> return pk
>
> def define_table(table):
> fields =  get_fields(table)
> result = []
> head = 'db = DAL("mysql://'+ user+ ':'+passwd+'@'+host+':'+port+'/'+db+'",
> pool_size=10)\r\r'
>
> line = "db.define_table('"+table+"'"
> result.append(line)
> for field in fields:
> if primarykey(field) == True:
> pk =field['Field']
> #print pk
> tipo = field_type(field)
> line = "Field('"+field['Field']+"'"+tipo+")"
> result.append(line)
> line
> try:
> line = "primarykey=['"+pk+"']"
> result.append(line)
> except:
> pass
> out = ',\r'.join(result)
> output = head + out + '\r)'
> print output
> return output
>
> def define_db():
> tables = get_tables()
> r = []
> for table in tables:
> r.append(define_table(table))
> result = '\r \r'.join(r)
> return result
>
> r = define_db()
> f = open('db_'+db+'.py', 'w')
> f.write(r)
> f.close()
>
> ---
>
> --
> Atenciosamente
>
> --
> =
> Alexandre Andrade
> Hipercenter.com
>


[web2py] Re: Drop Down alternative

2010-05-21 Thread mdipierro
Do you have a table db.city with a field db.city.name? If so, because
db.address.city is not a reference, it should just be

db.address.city.widget=AutocompleteWidget(request,db.city.name)



On May 21, 7:55 am, annet  wrote:
> Massimo,
>
> I gave this a try:
>
> from gluon.sqlhtml import AutocompleteWidget
>
> db.define_table('address',
>    Field('city',length=42,default='',notnull=True)),
>    ...)
>
> db.address.city.widget=AutocompleteWidget(request,db.city.name,db.city.name,orderby=db.city.name)
>
> but that doesn't work, why not?
>
> Kind regards,
>
> Annet.


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Nicol van der Merwe
Oops! Stupid me. :) Just read the *entire* subject now "Script to generate
schema (models) from *mysql*". So obviously - not for SQL Server.

*sigh* it's been a long day.

On Fri, May 21, 2010 at 3:59 PM, Nicol van der Merwe
wrote:

> Nice! This is super excellent.
>
> Just a simple question : will this work on SQL Server?
>
>
> On Fri, May 21, 2010 at 1:37 AM, Alexandre Andrade <
> alexandrema...@gmail.com> wrote:
>
>> Some time ago I talk about to do it.
>>
>> Finally I have to do it.
>>
>> It can be improved to a form in appadmin, use the model to another db
>> (postgresql, etc), and generate the file in /models.
>>
>> You can see the code below:
>>
>> --
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> #script to generate schemas from dbs
>> #by Alexandre Andrade alexandrema...@gmail.com
>> #www.hipercenter.com
>>
>> #config it here
>> passwd="mypass"
>> user="myuser"
>> host="localhost"
>> db = 'mydb'
>> port='3306'
>>
>>
>> def query(bd,sql):
>> bd.query(sql)
>> r = bd.store_result()
>> rows = r.fetch_row(maxrows=0,how=1)
>> return rows
>>
>> def get_tables():
>> rows = query(bd,'show tables')
>> tables=[]
>> for row in rows:
>> tables.append(row['Tables_in_'+db])
>> return tables
>>
>> #tables()
>>
>> def get_fields(table):
>> print table
>> rows = query(bd,'show fields from '+ table)
>> fields=[]
>> for row in rows:
>> #print row
>> fields.append(row)
>> return fields
>>
>> def field_type(field):
>> if field['Type'][0:7]=='varchar':
>> tipo = ",'string'"
>> elif field['Type'][:8]=='longtext':
>> tipo = ",'text'"
>> elif field['Type'][:3]=='int':
>> tipo = ",'integer'"
>> elif field['Type'][:4]=='date':
>> tipo = ",'date'"
>> elif field['Type'][:7]=='tinyint':
>> tipo = ",'int'"
>> elif field['Type'][:11]=='mediumtext':
>> tipo = ",'text'"
>> elif field['Type'][:4]=='char':
>> tipo = ",'text'"
>> else:
>> print  field['Type'][0:10]
>> return tipo
>>
>> def primarykey(field):
>> if field['Extra']=='auto_increment':
>> pk = True
>> else:
>> pk = False
>> return pk
>>
>> def define_table(table):
>> fields =  get_fields(table)
>> result = []
>> head = 'db = DAL("mysql://'+ user+ 
>> ':'+passwd+'@'+host+':'+port+'/'+db+'",
>> pool_size=10)\r\r'
>>
>> line = "db.define_table('"+table+"'"
>> result.append(line)
>> for field in fields:
>> if primarykey(field) == True:
>> pk =field['Field']
>> #print pk
>> tipo = field_type(field)
>> line = "Field('"+field['Field']+"'"+tipo+")"
>> result.append(line)
>> line
>> try:
>> line = "primarykey=['"+pk+"']"
>> result.append(line)
>> except:
>> pass
>> out = ',\r'.join(result)
>> output = head + out + '\r)'
>> print output
>> return output
>>
>> def define_db():
>> tables = get_tables()
>> r = []
>> for table in tables:
>> r.append(define_table(table))
>> result = '\r \r'.join(r)
>> return result
>>
>> r = define_db()
>> f = open('db_'+db+'.py', 'w')
>> f.write(r)
>> f.close()
>>
>> ---
>>
>> --
>> Atenciosamente
>>
>> --
>> =
>> Alexandre Andrade
>> Hipercenter.com
>>
>
>
>
> --
> Old Gregg: Ever drink baileys from a shoe? Wanna go to a club where people
> wee on each other? I'm gonna hurt you. I like you. What do ya think of me?
> Howard:I think your a nice..modern gentleman
>



-- 
Old Gregg: Ever drink baileys from a shoe? Wanna go to a club where people
wee on each other? I'm gonna hurt you. I like you. What do ya think of me?
Howard:I think your a nice..modern gentleman


[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread GoldenTiger
Thanks for so fast response :D

Then I will choose T3 for my urgent web, and then i will back to
web2py

Juan Martinez


On 21 mayo, 14:49, mdipierro  wrote:
> T3 was a proof of concept. It works but it was written very long ago.
> A lot of the T3 functionality is now in web2py. there is very little
> reason for using T3.
>
> cube9 does not exist. It is just a temp name for a project. I.e. write
> an abstraction layer on top of web2py that would allow to program
> without coding, by moving widgets around via drug and stop and filling
> forms like in VB. It will incorporate some ideas from T3 (particularly
> about menu and meta-models). Once done it will also be usable as a
> CMS. It will take a while, I am sorry.
>
> Massimo
>
> On May 21, 3:48 am, GoldenTiger  wrote:
>
> > Hi Massimo,
>
> > I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
> > attempt to rewrite T3. I love T3 !
>
> > Correct me if I am wrong about this:
>
> > The only way to check 'is_admin'  at T3 in models/db.py, is:
>
> > is_admin=(t2.logged_in and (not settings.administrator_emails or
> > t2.person_email in settings.administrator_emails))
>
> > All emails in settings.administratos_emails has 'is_admin' privileges,
> > hasn`t it?
> > And I have to set administrator_emails manually, is this correct?
> > Then if i am the only administrador and delete it by mistake,
> > 'is_admin' will be always True, and all logged users will have
> > 'is_admin' privileges
> > Am I missing something in current T3 about this?
>
> > Or is that the reason to rewrite cube9?
> > I am about to use T3 on production this week, but now i am confused.
>
> > T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
> > field=True by default  (I change to False, ok
> > )
>
> > cube9 checks variable 'is_admin' which depends on two records of
> > auth_user:
>
> > is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de
>
> > My dude is, if the first user (admin) is deleted by any reason, will
> > user_id be ==1 again in future registrations?
>
> > Anyway, which one to choose for production?  T3 or cube9? or web2py by
> > now?
>
> > Thanks alot, i hope i 'll contribute with web2py project some day :D
>
> > PD: sorry my poor english


[web2py] Re: Catch auto-login event

2010-05-21 Thread mdipierro
Does this mean that the "remember me for 30 days" feature works well
for you?
I have been having some problems with it.

On May 20, 5:45 am, Adi  wrote:
> Hi,
>
> I use the "Remember me for 30 days" feature in our app. I used a
> custom auth_table with a column "last_login" to update every time a
> user logs into the application.
>
> Currently I update it in a function call like this:
> ---
> def updateLastLogin(form):
>
> db(db.auth_user.id==auth.user.id).update(last_login=datetime.datetime.now())
>
> auth.settings.login_onaccept = updateLastLogin
>
> --
>
> However if a user chooses to "remember me for 30 days" then there's no
> actual login action. What is the way to track last_login for such
> users who visit the app but don't actually login? I basically need it
> for analytics.
>
> Thanks,
> Aditya


[web2py] Authentication

2010-05-21 Thread annet
I read chapter 8 of the web2py manual and some post on authentication
to get started (again) implementing a cms.

I read about MD5 and SHA-512, and understand I have to provide a
secret key for this setting: auth.settings.hmac_key='' Does this key have a specific format, e.g. 448a98e0-00fd-46b2-
ac4f-a14d2315b189? Or can I use any key? At the moment I am working in
web2py 1.76.5 does this version already use hmac + sha-512?

Furthermore I would like to customize the auth_user table. In the
manual the proper way to define a user table is:

auth_table = db.define_table(auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('email', length=128, default='', unique=True),
Field('password', 'password', length=256, readable=False,
label='Password'),
Field('registration_key', length=128, default= '', writable=False,
readable=False))

auth_table.first_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [IS_STRONG(), CRYPT()]
auth_table.email.requires =
[IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db,
auth_table.email)]
auth.settings.table_user = auth_table


In a workgroup post of 8 February I read this definition:

auth.settings.table_user = db.define_table('auth_user',
Field('first_name', length=512,default=''),
Field('last_name', length=512,default=''),
Field('email', length=512,default='', requires =
[IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email')]),
Field('password', 'password', readable=False, label='Password',
requires=CRYPT(auth.settings.hmac_key)),
Field('registration_key', length=512, writable=False,
readable=False,default=''),
Field('reset_password_key', length=512, writable=False,
readable=False, default=''))


What is the reset_password_key for? I guess I'd better use the latter
table definition, don't I need any validators?


Kind regards,

Annet.


[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread mdipierro
A friend pointed me to this: http://wavemaker.com
It is really nice and very close to what I would like the future of t3
to be.

On May 21, 9:37 am, GoldenTiger  wrote:
> Thanks for so fast response :D
>
> Then I will choose T3 for my urgent web, and then i will back to
> web2py
>
> Juan Martinez
>
> On 21 mayo, 14:49, mdipierro  wrote:
>
> > T3 was a proof of concept. It works but it was written very long ago.
> > A lot of the T3 functionality is now in web2py. there is very little
> > reason for using T3.
>
> > cube9 does not exist. It is just a temp name for a project. I.e. write
> > an abstraction layer on top of web2py that would allow to program
> > without coding, by moving widgets around via drug and stop and filling
> > forms like in VB. It will incorporate some ideas from T3 (particularly
> > about menu and meta-models). Once done it will also be usable as a
> > CMS. It will take a while, I am sorry.
>
> > Massimo
>
> > On May 21, 3:48 am, GoldenTiger  wrote:
>
> > > Hi Massimo,
>
> > > I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
> > > attempt to rewrite T3. I love T3 !
>
> > > Correct me if I am wrong about this:
>
> > > The only way to check 'is_admin'  at T3 in models/db.py, is:
>
> > > is_admin=(t2.logged_in and (not settings.administrator_emails or
> > > t2.person_email in settings.administrator_emails))
>
> > > All emails in settings.administratos_emails has 'is_admin' privileges,
> > > hasn`t it?
> > > And I have to set administrator_emails manually, is this correct?
> > > Then if i am the only administrador and delete it by mistake,
> > > 'is_admin' will be always True, and all logged users will have
> > > 'is_admin' privileges
> > > Am I missing something in current T3 about this?
>
> > > Or is that the reason to rewrite cube9?
> > > I am about to use T3 on production this week, but now i am confused.
>
> > > T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
> > > field=True by default  (I change to False, ok
> > > )
>
> > > cube9 checks variable 'is_admin' which depends on two records of
> > > auth_user:
>
> > > is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de
>
> > > My dude is, if the first user (admin) is deleted by any reason, will
> > > user_id be ==1 again in future registrations?
>
> > > Anyway, which one to choose for production?  T3 or cube9? or web2py by
> > > now?
>
> > > Thanks alot, i hope i 'll contribute with web2py project some day :D
>
> > > PD: sorry my poor english


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Jean Guy
Hi,

Could it be port to all database this way :
http://blog.gmane.org/gmane.comp.python.sqlobject/month=20100101

SQLObject

??

Jonhy



2010/5/20 Alexandre Andrade 

> Some time ago I talk about to do it.
>
> Finally I have to do it.
>
> It can be improved to a form in appadmin, use the model to another db
> (postgresql, etc), and generate the file in /models.
>
> You can see the code below:
>
> --
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> #script to generate schemas from dbs
> #by Alexandre Andrade alexandrema...@gmail.com
> #www.hipercenter.com
>
> #config it here
> passwd="mypass"
> user="myuser"
> host="localhost"
> db = 'mydb'
> port='3306'
>
>
> def query(bd,sql):
> bd.query(sql)
> r = bd.store_result()
> rows = r.fetch_row(maxrows=0,how=1)
> return rows
>
> def get_tables():
> rows = query(bd,'show tables')
> tables=[]
> for row in rows:
> tables.append(row['Tables_in_'+db])
> return tables
>
> #tables()
>
> def get_fields(table):
> print table
> rows = query(bd,'show fields from '+ table)
> fields=[]
> for row in rows:
> #print row
> fields.append(row)
> return fields
>
> def field_type(field):
> if field['Type'][0:7]=='varchar':
> tipo = ",'string'"
> elif field['Type'][:8]=='longtext':
> tipo = ",'text'"
> elif field['Type'][:3]=='int':
> tipo = ",'integer'"
> elif field['Type'][:4]=='date':
> tipo = ",'date'"
> elif field['Type'][:7]=='tinyint':
> tipo = ",'int'"
> elif field['Type'][:11]=='mediumtext':
> tipo = ",'text'"
> elif field['Type'][:4]=='char':
> tipo = ",'text'"
> else:
> print  field['Type'][0:10]
> return tipo
>
> def primarykey(field):
> if field['Extra']=='auto_increment':
> pk = True
> else:
> pk = False
> return pk
>
> def define_table(table):
> fields =  get_fields(table)
> result = []
> head = 'db = DAL("mysql://'+ user+ ':'+passwd+'@'+host+':'+port+'/'+db+'",
> pool_size=10)\r\r'
>
> line = "db.define_table('"+table+"'"
> result.append(line)
> for field in fields:
> if primarykey(field) == True:
> pk =field['Field']
> #print pk
> tipo = field_type(field)
> line = "Field('"+field['Field']+"'"+tipo+")"
> result.append(line)
> line
> try:
> line = "primarykey=['"+pk+"']"
> result.append(line)
> except:
> pass
> out = ',\r'.join(result)
> output = head + out + '\r)'
> print output
> return output
>
> def define_db():
> tables = get_tables()
> r = []
> for table in tables:
> r.append(define_table(table))
> result = '\r \r'.join(r)
> return result
>
> r = define_db()
> f = open('db_'+db+'.py', 'w')
> f.write(r)
> f.close()
>
> ---
>
> --
> Atenciosamente
>
> --
> =
> Alexandre Andrade
> Hipercenter.com
>


[web2py] Re: "SSL is OFF" error message when starting the server

2010-05-21 Thread OMAR
No, I'm still stuck.

Not sure where to go from here, so I'm starting over with a fresh
install of the OS.
Perhaps I'll pick something with python 2.6 ?
Obviously I don't have to implement the ssl through python, I can make
the connection through another web server, but I hate to give up after
investing this much time.

I'm still going to try and use the included CherryPy server for my
testing because I'm stubborn.

I just can't get the python 2.5 with ssl to work under Debian without
compiling it myself. I wanted to keep stability on the server and use
the package manager to add programs. Perhaps something like CentOS
would be a better choice.

Once again, thanks for your help with the problem.





[web2py] Re: Drop Down alternative

2010-05-21 Thread annet
Massimo,

> Do you have a table db.city with a field db.city.name?

Yes I do.

> If so, because db.address.city is not a reference, it should just be
> db.address.city.widget=AutocompleteWidget(request,db.city.name)

Yes, now it works. This saves me a lot of work, implementing the
pengoworks autocomplete every time I need an autocomplete field isn't
this simple. However, the drop box displaying the options doesn't
disappear after selecting a city name or typing the full name. Could
that be fixed, it covers some other form fields.


Kind regards,

Annet.


[web2py] Re: Drop Down alternative

2010-05-21 Thread mr.freeze
Here is another option:
http://www.web2pyslices.com/main/slices/take_slice/66


On May 20, 9:16 pm, greenpoise  wrote:
> Is there an alternative to drop down? a type ahead type of widget?


[web2py] Re: Drop Down alternative

2010-05-21 Thread annet
I had a quick look at the slice, am I right to conclude that contrary
to the pengoworks autocomplete this one is more generic. When I use
the Pengoworks autocomplete in my model I have to define:

db.address.city.widget=lambda
self,value:INPUT(_type='text',_id='city',_class='ac_input',_name='city',requires=self.requires)

... in web2py_ajax.html:

jQuery('#city').autocomplete('/init/handlers/cityAC',{maxItemsToShow:
12});

... in a controller called handlers:

def cityAC():
q=''
if request.vars:
q=request.vars.q
if not q:
return q
rows=db(db.city.name.like('%s%
%'%q.capitalize())).select(db.city.name,orderby=db.city.name)
r=''
for row in rows:
r='%s%s\n'%(r,row.name)
return r

... and I have to repeat this for every field I need autocomplete
functionality for.


When I use the one described in the slice, I would put this in db.py:

def autocomplete_widget(f,v):
import uuid
d_id = "autocomplete-" + str(uuid.uuid4())[:8]
wrapper = DIV(_id=d_id)
inp = SQLFORM.widgets.string.widget(f,v)
rows = f._db(f._table['id']>0).select(f,distinct=True)
itms = [str(t[f.name]) for t in rows]
scr = SCRIPT('var data= "%s".split("|");jQuery("#%s
input").autocomplete(data);' % \
  ("|".join(itms),d_id))
wrapper.append(inp)
wrapper.append(scr)
return wrapper

... which would work both on my laptop and on the webfaction servers!?

... put this in the handlers controller:

def get_items():
itms = []
if request.vars.q and \
   request.vars.table and \
   request.vars.field:
q = request.vars.q
f = request.vars.field
t = request.vars.table
fld = db[t][f]
rows = db(fld.upper().like(q.upper()
+"%")).select(fld,distinct=True)
itms = [str(t[f]) for t in rows]
return '\n'.join(itms)


... and put this in the table definition:

db.address.city.widget=autocomplete_widget


Is that right?


Kind regards,

Annet.


[web2py] Re: Drop Down alternative

2010-05-21 Thread mr.freeze
That's correct. Once you apply the widget to the field it will be used
on all corresponding forms.

On May 21, 11:12 am, annet  wrote:
> I had a quick look at the slice, am I right to conclude that contrary
> to the pengoworks autocomplete this one is more generic. When I use
> the Pengoworks autocomplete in my model I have to define:
>
> db.address.city.widget=lambda
> self,value:INPUT(_type='text',_id='city',_class='ac_input',_name='city',requires=self.requires)
>
> ... in web2py_ajax.html:
>
> jQuery('#city').autocomplete('/init/handlers/cityAC',{maxItemsToShow:
> 12});
>
> ... in a controller called handlers:
>
> def cityAC():
>     q=''
>     if request.vars:
>         q=request.vars.q
>     if not q:
>         return q
>     rows=db(db.city.name.like('%s%
> %'%q.capitalize())).select(db.city.name,orderby=db.city.name)
>     r=''
>     for row in rows:
>         r='%s%s\n'%(r,row.name)
>     return r
>
> ... and I have to repeat this for every field I need autocomplete
> functionality for.
>
> When I use the one described in the slice, I would put this in db.py:
>
> def autocomplete_widget(f,v):
>     import uuid
>     d_id = "autocomplete-" + str(uuid.uuid4())[:8]
>     wrapper = DIV(_id=d_id)
>     inp = SQLFORM.widgets.string.widget(f,v)
>     rows = f._db(f._table['id']>0).select(f,distinct=True)
>     itms = [str(t[f.name]) for t in rows]
>     scr = SCRIPT('var data= "%s".split("|");jQuery("#%s
> input").autocomplete(data);' % \
>                   ("|".join(itms),d_id))
>     wrapper.append(inp)
>     wrapper.append(scr)
>     return wrapper
>
> ... which would work both on my laptop and on the webfaction servers!?
>
> ... put this in the handlers controller:
>
> def get_items():
>     itms = []
>     if request.vars.q and \
>        request.vars.table and \
>        request.vars.field:
>         q = request.vars.q
>         f = request.vars.field
>         t = request.vars.table
>         fld = db[t][f]
>         rows = db(fld.upper().like(q.upper()
> +"%")).select(fld,distinct=True)
>         itms = [str(t[f]) for t in rows]
>     return '\n'.join(itms)
>
> ... and put this in the table definition:
>
> db.address.city.widget=autocomplete_widget
>
> Is that right?
>
> Kind regards,
>
> Annet.


Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Thadeus Burgess
I also see really no reason to use NoSQL unless you really just don't
like writing SQL... thats why we have ORMs and DALs anyways.

You still have to use FK relationships with document based sets... ie:
with a 4MB document limit, they suggest you split comments for a post
into its own document and link them to a post via _id.

If I am going to mess with relationships such as this I might as well
use a umm... relational database system ?

--
Thadeus





On Fri, May 21, 2010 at 8:23 AM, Albert Abril  wrote:
> Haha! I enjoy with this jokes in tech slides, they're amusing!
>
> On Fri, May 21, 2010 at 3:02 PM, Timothy Farrell  wrote:
>>
>> Developers running with scissors!! LOL!!!
>>
>> On 5/20/2010 2:12 PM, szimszon wrote:
>>>
>>> Nice
>>>
>>> On máj. 20, 19:52, mdipierro  wrote:
>>>

 http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL

>>
>
>


Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Russ Ferriday
But Thadeus, NoSQL is much more than moving away from SQL.
It's not that we *want* joins to become an application's task, or that we want 
to remove consistency within requests.
The driving forces are in general scalability, availability, & robustness with 
enormous amounts of traffic.
For most sites good old SQL is pretty good. And there are some great ORMs to 
run on top of them.
There will be many who follow the siren call of NoSQL who in retrospect could 
have done fine with MySQL/PostgresQL/ZODB. That will be next year's story.
--r.

On May 21, 2010, at 9:31 AM, Thadeus Burgess wrote:

> 
> If I am going to mess with relationships such as this I might as well
> use a umm... relational database system ?
> 
> --
> Thadeus
> 
> 
> 
> 
> 
> On Fri, May 21, 2010 at 8:23 AM, Albert Abril  wrote:
>> Haha! I enjoy with this jokes in tech slides, they're amusing!
>> 
>> On Fri, May 21, 2010 at 3:02 PM, Timothy Farrell  wrote:
>>> 
>>> Developers running with scissors!! LOL!!!
>>> 
>>> On 5/20/2010 2:12 PM, szimszon wrote:
 
 Nice
 
 On máj. 20, 19:52, mdipierro  wrote:
 
> 
> http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL
> 
>>> 
>> 
>> 

Russ Ferriday - Topia Systems - Open Source content management with Plone and 
Zope
ru...@topia.com - mobile: +1 805 234 6915 - skype: ferriday



Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Alexandre Andrade
To each new database, need to be adusted ( in a new script):

1 - the database driver (mysqlb is for mysql)
2 - maybe the sql sintax to select table and fields
3 - the treatment of result of select tables and field can need adjustments
4 - the field_type function have to be adjusted.

My first option to do it was postgresql, but I have to do for mysql first

2010/5/21 Jean Guy 

> Hi,
>
> Really nice!
>
> I haven't try it, but I have to do the importation of postgresql database
> into a web2py model. I was just wondering if you can pointed the place that
> should be adapt for postgresql, I will change it and return the running
> code  for postgresql.
>
> Thanks.
>
> Jonhy
>
> 2010/5/20 Alexandre Andrade 
>
> Some time ago I talk about to do it.
>>
>> Finally I have to do it.
>>
>> It can be improved to a form in appadmin, use the model to another db
>> (postgresql, etc), and generate the file in /models.
>>
>> You can see the code below:
>>
>> --
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> #script to generate schemas from dbs
>> #by Alexandre Andrade alexandrema...@gmail.com
>> #www.hipercenter.com
>>
>> #config it here
>> passwd="mypass"
>> user="myuser"
>> host="localhost"
>> db = 'mydb'
>> port='3306'
>>
>>
>> def query(bd,sql):
>> bd.query(sql)
>> r = bd.store_result()
>> rows = r.fetch_row(maxrows=0,how=1)
>> return rows
>>
>> def get_tables():
>> rows = query(bd,'show tables')
>> tables=[]
>> for row in rows:
>> tables.append(row['Tables_in_'+db])
>> return tables
>>
>> #tables()
>>
>> def get_fields(table):
>> print table
>> rows = query(bd,'show fields from '+ table)
>> fields=[]
>> for row in rows:
>> #print row
>> fields.append(row)
>> return fields
>>
>> def field_type(field):
>> if field['Type'][0:7]=='varchar':
>> tipo = ",'string'"
>> elif field['Type'][:8]=='longtext':
>> tipo = ",'text'"
>> elif field['Type'][:3]=='int':
>> tipo = ",'integer'"
>> elif field['Type'][:4]=='date':
>> tipo = ",'date'"
>> elif field['Type'][:7]=='tinyint':
>> tipo = ",'int'"
>> elif field['Type'][:11]=='mediumtext':
>> tipo = ",'text'"
>> elif field['Type'][:4]=='char':
>> tipo = ",'text'"
>> else:
>> print  field['Type'][0:10]
>> return tipo
>>
>> def primarykey(field):
>> if field['Extra']=='auto_increment':
>> pk = True
>> else:
>> pk = False
>> return pk
>>
>> def define_table(table):
>> fields =  get_fields(table)
>> result = []
>> head = 'db = DAL("mysql://'+ user+ 
>> ':'+passwd+'@'+host+':'+port+'/'+db+'",
>> pool_size=10)\r\r'
>>
>> line = "db.define_table('"+table+"'"
>> result.append(line)
>> for field in fields:
>> if primarykey(field) == True:
>> pk =field['Field']
>> #print pk
>> tipo = field_type(field)
>> line = "Field('"+field['Field']+"'"+tipo+")"
>> result.append(line)
>> line
>> try:
>> line = "primarykey=['"+pk+"']"
>> result.append(line)
>> except:
>> pass
>> out = ',\r'.join(result)
>> output = head + out + '\r)'
>> print output
>> return output
>>
>> def define_db():
>> tables = get_tables()
>> r = []
>> for table in tables:
>> r.append(define_table(table))
>> result = '\r \r'.join(r)
>> return result
>>
>> r = define_db()
>> f = open('db_'+db+'.py', 'w')
>> f.write(r)
>> f.close()
>>
>> ---
>>
>> --
>> Atenciosamente
>>
>> --
>> =
>> Alexandre Andrade
>> Hipercenter.com
>>
>
>


-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Alexandre Andrade
I will need to be adapted.

look my answer to Jonhy email.



2010/5/21 Nicol van der Merwe 

> Nice! This is super excellent.
>
> Just a simple question : will this work on SQL Server?
>
>
> On Fri, May 21, 2010 at 1:37 AM, Alexandre Andrade <
> alexandrema...@gmail.com> wrote:
>
>> Some time ago I talk about to do it.
>>
>> Finally I have to do it.
>>
>> It can be improved to a form in appadmin, use the model to another db
>> (postgresql, etc), and generate the file in /models.
>>
>> You can see the code below:
>>
>> --
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> #script to generate schemas from dbs
>> #by Alexandre Andrade alexandrema...@gmail.com
>> #www.hipercenter.com
>>
>> #config it here
>> passwd="mypass"
>> user="myuser"
>> host="localhost"
>> db = 'mydb'
>> port='3306'
>>
>>
>> def query(bd,sql):
>> bd.query(sql)
>> r = bd.store_result()
>> rows = r.fetch_row(maxrows=0,how=1)
>> return rows
>>
>> def get_tables():
>> rows = query(bd,'show tables')
>> tables=[]
>> for row in rows:
>> tables.append(row['Tables_in_'+db])
>> return tables
>>
>> #tables()
>>
>> def get_fields(table):
>> print table
>> rows = query(bd,'show fields from '+ table)
>> fields=[]
>> for row in rows:
>> #print row
>> fields.append(row)
>> return fields
>>
>> def field_type(field):
>> if field['Type'][0:7]=='varchar':
>> tipo = ",'string'"
>> elif field['Type'][:8]=='longtext':
>> tipo = ",'text'"
>> elif field['Type'][:3]=='int':
>> tipo = ",'integer'"
>> elif field['Type'][:4]=='date':
>> tipo = ",'date'"
>> elif field['Type'][:7]=='tinyint':
>> tipo = ",'int'"
>> elif field['Type'][:11]=='mediumtext':
>> tipo = ",'text'"
>> elif field['Type'][:4]=='char':
>> tipo = ",'text'"
>> else:
>> print  field['Type'][0:10]
>> return tipo
>>
>> def primarykey(field):
>> if field['Extra']=='auto_increment':
>> pk = True
>> else:
>> pk = False
>> return pk
>>
>> def define_table(table):
>> fields =  get_fields(table)
>> result = []
>> head = 'db = DAL("mysql://'+ user+ 
>> ':'+passwd+'@'+host+':'+port+'/'+db+'",
>> pool_size=10)\r\r'
>>
>> line = "db.define_table('"+table+"'"
>> result.append(line)
>> for field in fields:
>> if primarykey(field) == True:
>> pk =field['Field']
>> #print pk
>> tipo = field_type(field)
>> line = "Field('"+field['Field']+"'"+tipo+")"
>> result.append(line)
>> line
>> try:
>> line = "primarykey=['"+pk+"']"
>> result.append(line)
>> except:
>> pass
>> out = ',\r'.join(result)
>> output = head + out + '\r)'
>> print output
>> return output
>>
>> def define_db():
>> tables = get_tables()
>> r = []
>> for table in tables:
>> r.append(define_table(table))
>> result = '\r \r'.join(r)
>> return result
>>
>> r = define_db()
>> f = open('db_'+db+'.py', 'w')
>> f.write(r)
>> f.close()
>>
>> ---
>>
>> --
>> Atenciosamente
>>
>> --
>> =
>> Alexandre Andrade
>> Hipercenter.com
>>
>
>
>
> --
> Old Gregg: Ever drink baileys from a shoe? Wanna go to a club where people
> wee on each other? I'm gonna hurt you. I like you. What do ya think of me?
> Howard:I think your a nice..modern gentleman
>



-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com


Re: [web2py] Script to generate schema (models) from mysql

2010-05-21 Thread Alexandre Andrade
To each new database, need to be adusted ( in a new script):

1 - the database driver (mysqlb is for mysql)
2 - maybe the sql sintax to select table and fields
3 - the treatment of result of select tables and field can need adjustments
4 - the field_type function have to be adjusted.

My first option to do it was postgresql, but I have to do for mysql first.

Its possible because each database server has sql comands to describe their
structure (databases, tables and fields).
So, its only a matter of study the result of this queries and treat them and
generate the web2py schemas.

My script is like a logical model, to be adapted.



2010/5/21 Jean Guy 

> Hi,
>
> Could it be port to all database this way :
> http://blog.gmane.org/gmane.comp.python.sqlobject/month=20100101
>
> SQLObject
>
> ??
>
> Jonhy
>
>
>
> 2010/5/20 Alexandre Andrade 
>
> Some time ago I talk about to do it.
>>
>> Finally I have to do it.
>>
>> It can be improved to a form in appadmin, use the model to another db
>> (postgresql, etc), and generate the file in /models.
>>
>> You can see the code below:
>>
>> --
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> #script to generate schemas from dbs
>> #by Alexandre Andrade alexandrema...@gmail.com
>> #www.hipercenter.com
>>
>> #config it here
>> passwd="mypass"
>> user="myuser"
>> host="localhost"
>> db = 'mydb'
>> port='3306'
>>
>>
>> def query(bd,sql):
>> bd.query(sql)
>> r = bd.store_result()
>> rows = r.fetch_row(maxrows=0,how=1)
>> return rows
>>
>> def get_tables():
>> rows = query(bd,'show tables')
>> tables=[]
>> for row in rows:
>> tables.append(row['Tables_in_'+db])
>> return tables
>>
>> #tables()
>>
>> def get_fields(table):
>> print table
>> rows = query(bd,'show fields from '+ table)
>> fields=[]
>> for row in rows:
>> #print row
>> fields.append(row)
>> return fields
>>
>> def field_type(field):
>> if field['Type'][0:7]=='varchar':
>> tipo = ",'string'"
>> elif field['Type'][:8]=='longtext':
>> tipo = ",'text'"
>> elif field['Type'][:3]=='int':
>> tipo = ",'integer'"
>> elif field['Type'][:4]=='date':
>> tipo = ",'date'"
>> elif field['Type'][:7]=='tinyint':
>> tipo = ",'int'"
>> elif field['Type'][:11]=='mediumtext':
>> tipo = ",'text'"
>> elif field['Type'][:4]=='char':
>> tipo = ",'text'"
>> else:
>> print  field['Type'][0:10]
>> return tipo
>>
>> def primarykey(field):
>> if field['Extra']=='auto_increment':
>> pk = True
>> else:
>> pk = False
>> return pk
>>
>> def define_table(table):
>> fields =  get_fields(table)
>> result = []
>> head = 'db = DAL("mysql://'+ user+ 
>> ':'+passwd+'@'+host+':'+port+'/'+db+'",
>> pool_size=10)\r\r'
>>
>> line = "db.define_table('"+table+"'"
>> result.append(line)
>> for field in fields:
>> if primarykey(field) == True:
>> pk =field['Field']
>> #print pk
>> tipo = field_type(field)
>> line = "Field('"+field['Field']+"'"+tipo+")"
>> result.append(line)
>> line
>> try:
>> line = "primarykey=['"+pk+"']"
>> result.append(line)
>> except:
>> pass
>> out = ',\r'.join(result)
>> output = head + out + '\r)'
>> print output
>> return output
>>
>> def define_db():
>> tables = get_tables()
>> r = []
>> for table in tables:
>> r.append(define_table(table))
>> result = '\r \r'.join(r)
>> return result
>>
>> r = define_db()
>> f = open('db_'+db+'.py', 'w')
>> f.write(r)
>> f.close()
>>
>> ---
>>
>> --
>> Atenciosamente
>>
>> --
>> =
>> Alexandre Andrade
>> Hipercenter.com
>>
>
>


-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com


Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Russ Ferriday
Final thought...

I think if NoSQL were indicated for use with a web2Py app,  it might be most 
appropriate to replace some, but not all SQL-based tables.

--r.

On May 21, 2010, at 9:31 AM, Thadeus Burgess wrote:

> I also see really no reason to use NoSQL unless you really just don't
> like writing SQL... thats why we have ORMs and DALs anyways.
> 
> You still have to use FK relationships with document based sets... ie:
> with a 4MB document limit, they suggest you split comments for a post
> into its own document and link them to a post via _id.
> 
> If I am going to mess with relationships such as this I might as well
> use a umm... relational database system ?
> 
> --
> Thadeus
> 
> 
> 
> 
> 
> On Fri, May 21, 2010 at 8:23 AM, Albert Abril  wrote:
>> Haha! I enjoy with this jokes in tech slides, they're amusing!
>> 
>> On Fri, May 21, 2010 at 3:02 PM, Timothy Farrell  wrote:
>>> 
>>> Developers running with scissors!! LOL!!!
>>> 
>>> On 5/20/2010 2:12 PM, szimszon wrote:
 
 Nice
 
 On máj. 20, 19:52, mdipierro  wrote:
 
> 
> http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL
> 
>>> 
>> 
>> 

Russ Ferriday - Topia Systems - Open Source content management with Plone and 
Zope
ru...@topia.com - mobile: +1 805 234 6915 - skype: ferriday



[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread GoldenTiger
Yes, I know WaveMaker, It's one of my favourite ajax studio out there,
runs locally on a small java server with very simple API

If you like Wavemaker then you will like SmartClient   
http://www.smartclient.com

They both are powerfull and nice, but since runs on java servers I
prefer web2py, maybe a port of their API to web2py wouldn't be very
difficult


On 21 mayo, 16:50, mdipierro  wrote:
> A friend pointed me to this:http://wavemaker.com
> It is really nice and very close to what I would like the future of t3
> to be.
>
> On May 21, 9:37 am, GoldenTiger  wrote:
>
> > Thanks for so fast response :D
>
> > Then I will choose T3 for my urgent web, and then i will back to
> > web2py
>
> > Juan Martinez
>
> > On 21 mayo, 14:49, mdipierro  wrote:
>
> > > T3 was a proof of concept. It works but it was written very long ago.
> > > A lot of the T3 functionality is now in web2py. there is very little
> > > reason for using T3.
>
> > > cube9 does not exist. It is just a temp name for a project. I.e. write
> > > an abstraction layer on top of web2py that would allow to program
> > > without coding, by moving widgets around via drug and stop and filling
> > > forms like in VB. It will incorporate some ideas from T3 (particularly
> > > about menu and meta-models). Once done it will also be usable as a
> > > CMS. It will take a while, I am sorry.
>
> > > Massimo
>
> > > On May 21, 3:48 am, GoldenTiger  wrote:
>
> > > > Hi Massimo,
>
> > > > I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
> > > > attempt to rewrite T3. I love T3 !
>
> > > > Correct me if I am wrong about this:
>
> > > > The only way to check 'is_admin'  at T3 in models/db.py, is:
>
> > > > is_admin=(t2.logged_in and (not settings.administrator_emails or
> > > > t2.person_email in settings.administrator_emails))
>
> > > > All emails in settings.administratos_emails has 'is_admin' privileges,
> > > > hasn`t it?
> > > > And I have to set administrator_emails manually, is this correct?
> > > > Then if i am the only administrador and delete it by mistake,
> > > > 'is_admin' will be always True, and all logged users will have
> > > > 'is_admin' privileges
> > > > Am I missing something in current T3 about this?
>
> > > > Or is that the reason to rewrite cube9?
> > > > I am about to use T3 on production this week, but now i am confused.
>
> > > > T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
> > > > field=True by default  (I change to False, ok
> > > > )
>
> > > > cube9 checks variable 'is_admin' which depends on two records of
> > > > auth_user:
>
> > > > is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de
>
> > > > My dude is, if the first user (admin) is deleted by any reason, will
> > > > user_id be ==1 again in future registrations?
>
> > > > Anyway, which one to choose for production?  T3 or cube9? or web2py by
> > > > now?
>
> > > > Thanks alot, i hope i 'll contribute with web2py project some day :D
>
> > > > PD: sorry my poor english


[web2py] Re: Authentication

2010-05-21 Thread GoldenTiger
I think the first table definition is more actual and cleaner than
second and it's how I am actually doing it

On 21 mayo, 16:49, annet  wrote:
> I read chapter 8 of the web2py manual and some post on authentication
> to get started (again) implementing a cms.
>
> I read about MD5 and SHA-512, and understand I have to provide a
> secret key for this setting: auth.settings.hmac_key=' key>' Does this key have a specific format, e.g. 448a98e0-00fd-46b2-
> ac4f-a14d2315b189? Or can I use any key? At the moment I am working in
> web2py 1.76.5 does this version already use hmac + sha-512?
>
> Furthermore I would like to customize the auth_user table. In the
> manual the proper way to define a user table is:
>
> auth_table = db.define_table(auth.settings.table_user_name,
>     Field('first_name', length=128, default=''),
>     Field('last_name', length=128, default=''),
>     Field('email', length=128, default='', unique=True),
>     Field('password', 'password', length=256, readable=False,
> label='Password'),
>     Field('registration_key', length=128, default= '', writable=False,
> readable=False))
>
> auth_table.first_name.requires =
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> auth_table.last_name.requires =
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> auth_table.password.requires = [IS_STRONG(), CRYPT()]
> auth_table.email.requires =
> [IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db,
> auth_table.email)]
> auth.settings.table_user = auth_table
>
> In a workgroup post of 8 February I read this definition:
>
> auth.settings.table_user = db.define_table('auth_user',
>     Field('first_name', length=512,default=''),
>     Field('last_name', length=512,default=''),
>     Field('email', length=512,default='', requires =
> [IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email')]),
>     Field('password', 'password', readable=False, label='Password',
> requires=CRYPT(auth.settings.hmac_key)),
>     Field('registration_key', length=512, writable=False,
> readable=False,default=''),
>     Field('reset_password_key', length=512, writable=False,
> readable=False, default=''))
>
> What is the reset_password_key for? I guess I'd better use the latter
> table definition, don't I need any validators?
>
> Kind regards,
>
> Annet.


[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread GoldenTiger
I have just remembered why I left using smartclient and wavemaker, on
production server they were too slow


Re: [web2py] Re: "SSL is OFF" error message when starting the server

2010-05-21 Thread Timothy Farrell
Yah I hear ya.  I love Debian for being rock-solid stable (not to 
mention that I cut my Linux teeth on it) but man is it OLD!


I've had good luck with Ubuntu.  I try to stick with Linux systems that 
use DEBs.  I've been burned too many times by RPM-dependency hell!


There's always Gentoo!  No such thing as a clean installation...you just 
get used to it. =)


Good Luck
-tim

On 5/21/2010 10:25 AM, OMAR wrote:

No, I'm still stuck.

Not sure where to go from here, so I'm starting over with a fresh
install of the OS.
Perhaps I'll pick something with python 2.6 ?
Obviously I don't have to implement the ssl through python, I can make
the connection through another web server, but I hate to give up after
investing this much time.

I'm still going to try and use the included CherryPy server for my
testing because I'm stubborn.

I just can't get the python 2.5 with ssl to work under Debian without
compiling it myself. I wanted to keep stability on the server and use
the package manager to add programs. Perhaps something like CentOS
would be a better choice.

Once again, thanks for your help with the problem.



   




[web2py] Re: About differences bettwen T3 and cube9

2010-05-21 Thread mdipierro
Thanks for your feedback on this.

On May 21, 12:59 pm, GoldenTiger  wrote:
> Yes, I know WaveMaker, It's one of my favourite ajax studio out there,
> runs locally on a small java server with very simple API
>
> If you like Wavemaker then you will like SmartClient  
> http://www.smartclient.com
>
> They both are powerfull and nice, but since runs on java servers I
> prefer web2py, maybe a port of their API to web2py wouldn't be very
> difficult
>
> On 21 mayo, 16:50, mdipierro  wrote:
>
> > A friend pointed me to this:http://wavemaker.com
> > It is really nice and very close to what I would like the future of t3
> > to be.
>
> > On May 21, 9:37 am, GoldenTiger  wrote:
>
> > > Thanks for so fast response :D
>
> > > Then I will choose T3 for my urgent web, and then i will back to
> > > web2py
>
> > > Juan Martinez
>
> > > On 21 mayo, 14:49, mdipierro  wrote:
>
> > > > T3 was a proof of concept. It works but it was written very long ago.
> > > > A lot of the T3 functionality is now in web2py. there is very little
> > > > reason for using T3.
>
> > > > cube9 does not exist. It is just a temp name for a project. I.e. write
> > > > an abstraction layer on top of web2py that would allow to program
> > > > without coding, by moving widgets around via drug and stop and filling
> > > > forms like in VB. It will incorporate some ideas from T3 (particularly
> > > > about menu and meta-models). Once done it will also be usable as a
> > > > CMS. It will take a while, I am sorry.
>
> > > > Massimo
>
> > > > On May 21, 3:48 am, GoldenTiger  wrote:
>
> > > > > Hi Massimo,
>
> > > > > I'm trying T3 and cube9 (http://code.google.com/p/cube9/)  your new
> > > > > attempt to rewrite T3. I love T3 !
>
> > > > > Correct me if I am wrong about this:
>
> > > > > The only way to check 'is_admin'  at T3 in models/db.py, is:
>
> > > > > is_admin=(t2.logged_in and (not settings.administrator_emails or
> > > > > t2.person_email in settings.administrator_emails))
>
> > > > > All emails in settings.administratos_emails has 'is_admin' privileges,
> > > > > hasn`t it?
> > > > > And I have to set administrator_emails manually, is this correct?
> > > > > Then if i am the only administrador and delete it by mistake,
> > > > > 'is_admin' will be always True, and all logged users will have
> > > > > 'is_admin' privileges
> > > > > Am I missing something in current T3 about this?
>
> > > > > Or is that the reason to rewrite cube9?
> > > > > I am about to use T3 on production this week, but now i am confused.
>
> > > > > T3 doesn´t redefine auth_user, but cube9 does, adding an 'is_admin'
> > > > > field=True by default  (I change to False, ok
> > > > > )
>
> > > > > cube9 checks variable 'is_admin' which depends on two records of
> > > > > auth_user:
>
> > > > > is_admin = auth.user_id and auth.user.is_admin or auth.user_id==1 de
>
> > > > > My dude is, if the first user (admin) is deleted by any reason, will
> > > > > user_id be ==1 again in future registrations?
>
> > > > > Anyway, which one to choose for production?  T3 or cube9? or web2py by
> > > > > now?
>
> > > > > Thanks alot, i hope i 'll contribute with web2py project some day :D
>
> > > > > PD: sorry my poor english


[web2py] Maybe Off-Topic: I am very happy thanks to web2py :)

2010-05-21 Thread glsdesign
Hi all, I just can't resist to not tell to you how I love web2py. I've
used for some time CherryPy and Django, they are good products, but
Web2Py simplicity and productivity is marvelous. I don't talk english
very well, but even in my native language I can't say how I am
enthusiastic, I feel "empowered" and I think i can work now on very
complex project I have for a long time dreamed. If this my entrance is
not a disaster (maybe this type of discussions are not appreciated as
more techical inclined are) I hope I can get some help when needed.
Surely I will help when I can and I want to write an appliance as my
little contribute. You people are fantastic, I love you all!


[web2py] Re: new in Django

2010-05-21 Thread Pepe
Hi,

well, I see we both agree in two points:

a) we don't like use django :)
b) and we respect each other (this is more cool :P )

i'm sorry if I get off-topic of this group, really, but I don't like
the generalizations :) that's all...

if I can help you both, please tell me, I will gladly!

best regards!

Pepe.

On May 20, 10:10 am, Thadeus Burgess  wrote:
> Hi Pepe,
>
> I did not mean that in a negative tone, I do respect designers a great
> deal, they have a gift that seems to allude me =)
>
> I have strong feelings towards my < > <= signs... its just a part of
> programming, why change the standard? I won't use MongoDB either
> because they use the same $lt $gte syntax.
>
> Then again, I miss c-style pointers with asterisks... so maybe I'm
> just an odd ball for liking symbolic languages.
>
> When I said django is not catching up, to compete with web2py they
> need to satisfy the part of me that likes using symbols instead of
> text to represent something.
>
> You said your a designer, I might need you for some projects! =)
>
> --
> Thadeus
>
>
>
> On Thu, May 20, 2010 at 12:43 AM, Pepe  wrote:
> > Thadeus, What is your problem with designers, men?
>
> > I'm designer and use web2py because i don't like django... I've learnt
> > to programming in my school and my partners (today doctors, lawyers,
> > biochemicals) know to programming too (the logic, obviously, I'm sure
> > they forget all the rest, haha!), and I'm sure that they love to read
> > a really good syntax-code and not an aberration like "__lte=5" .
>
> > Obviously, I don't know and i don't have all the knowledge that a
> > developer have, and I respect them all.
>
> > Please, don't generalize. I respect you and I greatly appreciate your
> > contributions, really!
>
> > Best regards,
>
> > Pepe.
>
> > On May 18, 5:19 pm, Thadeus Burgess  wrote:
> >> Polls.objects.get(order__lte=5)
>
> >> No... no their not.
>
> >> Still a designer based framework, and developer limiting.
>
> >> --
> >> Thadeus
>
> >> On Tue, May 18, 2010 at 4:11 PM, Kuba Kucharski
>
> >>  wrote:
> >> >http://docs.djangoproject.com/en/dev/releases/1.2/
>
> >> > "Support for multiple database connections in a single Django instance."
>
> >> > django is catching up ;)
>
> >> > --
> >> > Kuba


[web2py] auth problem

2010-05-21 Thread annet
I enabled authentication and have the following entries in the
auth_user, auth_group and auth_membership tables:

user.iduser.first_name  ...
1 Ann
2 Jan


group.idgroup.role
1   user_1
2   user_2


membership.idmembership.user_idmembership.group.id
1  1
user_1(1)
2  2
user_2(2)


Now, I would like to add permissions, the problem is that
auth.add_persmission() takes the following arguments: group_id,
'name', 'object', record_id whereas I need to set permissions related
to a tables company_id field. I have tables that have the following
structure:

db.define_table('tagline',
 
Field('company_id',db.bedrijf,default='',notnull=True,ondelete='CASCADE'),
Field('line',length=84,default='',notnull=True),
migrate=’tagline.table’)


Now user with user_id 1 and group_id user_1(1) should get the
permission to create, update and delete all records in the tagline
table that have company_id 443. Is that possible in web2py's, or do I
have to customize one of the auth tables to make this possible?


Kind regards,

Annet.


[web2py] Re: auth problem

2010-05-21 Thread mdipierro
You have to add some logic to do that.



On May 21, 3:26 pm, annet  wrote:
> I enabled authentication and have the following entries in the
> auth_user, auth_group and auth_membership tables:
>
> user.id    user.first_name      ...
> 1             Ann
> 2             Jan
>
> group.id    group.role
> 1               user_1
> 2               user_2
>
> membership.id    membership.user_id    membership.group.id
> 1                          1
> user_1(1)
> 2                          2
> user_2(2)
>
> Now, I would like to add permissions, the problem is that
> auth.add_persmission() takes the following arguments: group_id,
> 'name', 'object', record_id whereas I need to set permissions related
> to a tables company_id field. I have tables that have the following
> structure:
>
> db.define_table('tagline',
>
> Field('company_id',db.bedrijf,default='',notnull=True,ondelete='CASCADE'),
>     Field('line',length=84,default='',notnull=True),
>     migrate=’tagline.table’)
>
> Now user with user_id 1 and group_id user_1(1) should get the
> permission to create, update and delete all records in the tagline
> table that have company_id 443. Is that possible in web2py's, or do I
> have to customize one of the auth tables to make this possible?
>
> Kind regards,
>
> Annet.


[web2py] bug2py

2010-05-21 Thread mdipierro
I found this
http://github.com/ideamonk/Bug2Py
seems interesting. Anybody has any info?

Massimo


[web2py] Re: bug2py

2010-05-21 Thread Abhishek Mishra
Hi Massimo,

I was thinking of porting BugBase (a base bug tracker written in php
as a college project) to web2py to learn and speed up with it. The
original PHP code is here - http://github.com/ideamonk/bugbase with
demo available at http://bugs.madetokill.com

Its a bit buggy and insecure (assumed not tested or found yet), but I
think a web2py version would solve any lacking security issues by
taking care of many things in the back.

Couldn't do much today, would love to finish a php-to-web2py port
within short time of a day / two...
Let me know if this project comes of any fruitful use.
Thanks,

Abhishek

On May 22, 1:34 am, mdipierro  wrote:
> I found thishttp://github.com/ideamonk/Bug2Py
> seems interesting. Anybody has any info?
>
> Massimo


[web2py] Re: bug2py

2010-05-21 Thread mdipierro
I think it will be very useful. Keep up posted. :-)

On May 21, 4:34 pm, Abhishek Mishra  wrote:
> Hi Massimo,
>
> I was thinking of porting BugBase (a base bug tracker written in php
> as a college project) to web2py to learn and speed up with it. The
> original PHP code is here -http://github.com/ideamonk/bugbasewith
> demo available athttp://bugs.madetokill.com
>
> Its a bit buggy and insecure (assumed not tested or found yet), but I
> think a web2py version would solve any lacking security issues by
> taking care of many things in the back.
>
> Couldn't do much today, would love to finish a php-to-web2py port
> within short time of a day / two...
> Let me know if this project comes of any fruitful use.
> Thanks,
>
> Abhishek
>
> On May 22, 1:34 am, mdipierro  wrote:
>
> > I found thishttp://github.com/ideamonk/Bug2Py
> > seems interesting. Anybody has any info?
>
> > Massimo


[web2py] Re: new in Django

2010-05-21 Thread Magnitus
> I did not mean that in a negative tone, I do respect designers a great
> deal, they have a gift that seems to allude me =)

>I am sure Thadeus did not mean it is a negative sense. I am personally
>envious of designer given my total lack of artistic skills.

That makes 3 of us.

My experience with the arts is limited to an interest in drawing I had
as a teenager and a work term spent adding complexity to simple art
using photoshop to satisfy my bosses need to have come up with the
company's need look for their website (paying me 18$ an hour to do
something that was blatantly outside both my areas of expertize...
they ended up hiring a professional web artist that came up with the
final look, it was both sad and hilarious).

Now, I really wish I had pursued my artistic interests as a teenager
in my adult years as it would have come in handy right about now.


[web2py] Re: Maybe Off-Topic: I am very happy thanks to web2py :)

2010-05-21 Thread weheh
You will find you are in good company, here. Many of us feel the same
way you do. It's perhaps not fitting to gush ... web2py isn't perfect.
But it's the best I've found at what it does, and by a large margin.


[web2py] A mistake and crashed T3 appadmin from default/configure/models - No solution by now

2010-05-21 Thread GoldenTiger
I copy-pasted some models that I previosuly defined in another web2py
app, to configure models for an T3 new page.

By mistake, I copied all content from db.py ,and pasted in configure
models, and i submitted.

This provoked duplicated tables and variables, and an already defined
error in default controller, and in appdmin controller.

So i don`t know how to roll back from web2py interface.  I tried to
delete sqlite files created, leaving only the storage.db of T3 , with
no success. I think I did this well, maybe I am wrong.

Editing sqlite file with external app is too tedious, so I start again
to coding, because i had only a few of data, and also it is more
funny,

I f I were in a production environment, what should I do?
Any solution for future mistakes like this?

How could I add code to T3 to protect me from myself? ^^

Thanks




[web2py] Re: bug2py

2010-05-21 Thread GoldenTiger
Great, now I am learning web2py I have a few of them noted at my Mac
desktop.

There is a little bug at http://bugs.madetokill.com
Register button redirect to javascript code instead of /index.php?
page=regUser

Juan Martinez


[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Yarko Tymciurak
On May 21, 5:06 am, Graham Dumpleton 
wrote:
> On May 21, 7:00 pm, Yarko Tymciurak 
> wrote:

...
> > There is much to cover in this - and I suppose reason to be happy that
> > python traditionally hasn't run multi-core.
> > See, for example, the discussions 
> > at:http://stackoverflow.com/questions/203912/does-python-support-multipr...
>
> > andhttp://docs.python.org/library/multiprocessing.html
>
> > Lots to read! ;-)
>
> Also read:
>
>  http://blog.dscpl.com.au/2007/07/web-hosting-landscape-and-modwsgi.html
>  http://blog.dscpl.com.au/2007/09/parallel-python-discussion-and-modws...
>
> BTW, your prior descriptions about how web2py works under mod_wsgi
> aren't overly accurate. You said:
>
> """
> In a hosting environment, you have apache/wsgi (for example) running
> a
> wsgi-thred that is web2py - that (main and the stuff in gluon) is
> your
> long-running process (er, thread).   To restart web2py, with wsgi,
> you
> would do what is normal (touch a file) to cause apache to re-start
> that wsgi thread.
>
> Within web2py, you have a number of threads:  db connection pools,
> and
> application threads;   again, these respond to requests, and are
> spawned off by web2py (not you)
> """
>
> When run under Apache/mod_wsgi there is not a thread that is dedicated
> to web2py and web2py doesn't have its own threads to respond to
> requests.
>
> In each Apache or mod_wsgi daemon process, depending on whether you
> are using embedded mode or daemon mode, there is a pool of threads.
> These are C threads, not Python threads and the thread pool is managed
> by Apache or mod_wsgi as appropriate.
>
> How a connection is accepted depends on Apache MPM or mod_wsgi mode
> being used, but ultimately one of the threads in the thread pool
> processes the request, all still in C code. For embedded mode the
> request may not even be for the WSGI application but be for a static
> file or other dynamic application such as PHP. If daemon mode, or if
> target of request was the WSGI application, only then does Python GIL
> get acquired and the thread tries to call into the WSGI application as
> an external thread calling into the embedded Python interpreter.
>
> At this point the WSGI application may not have even been loaded, so
> the first request to find that has to load the WSGI script file which
> may in turn load web2py. In this case web2py doesn't do anything
> special. That is, it doesn't go creating its own thread pool and it
> actually must return immediately once it is loaded and initialised.
> Once it returns, the thread calls into the WSGI application entry
> point and web2py handles the request. Any response is thence passed
> back through Apache with the GIL being released at each point where
> this occurs. When complete request is done, the GIL is completely
> released and thread becomes inactive again pending a further request.
>
> If other requests occur at the same time, they could also call into
> web2py. The only choke point is the initial loading of the WSGI script
> as obviously only want to allow one thread to do that.
>
> So, web2py doesn't have its own request threads and all calls come in
> from a external threads managed by Apache or mod_wsgi.
>
> Graham

Thank you, Graham -

Your clarification is clear, and much appreciated!

Regards,
- Yarko

>
> > - Yarko
>
> > > On May 20, 2:12 pm, Yarko Tymciurak 
> > > wrote:
>
> > > > On May 19, 6:18 pm, Yarko Tymciurak 
> > > > wrote:
>
> > > > > On May 19, 5:41 pm, amoygard  wrote:
>
> > > > 
>
> > > > > So - in general, you do not start subprocesses - with the exception of
> > > > > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> > > > I might better have said you do not _want_ to be starting subprocesses
> > > > - besides the cost (compute time, memory, etc.), if you generally did
> > > > this.   This (the inneficiency of spawning subrocesses) is why
> > > > stackless  was created - and (among other things) used in a a very
> > > > busy online game.  A lot of thought went into avoiding the costs of
> > > > spawning subprocesses.
>
> > > > If you haven't heard of it, stackless is an implementation of python
> > > > that does not use the traditional "C" stack for local variables,
> > > > etc.   Among other things, it has added "tasklets" to the language, so
> > > > you can create and schedule tasks - without the overhead of doing so
> > > > in your operating system.   There is a lot of discussion of benefit,
> > > > efficiency.   Although there might be some discussion questioning the
> > > > approach, other alternative approaches, one thing is clear:  the
> > > > motivation to stay away from creating threads / subprocesses, and the
> > > > costs involved.  it might be interesting to read up on it.
>
> > > > - Yarko
>
> > > > > - Yarko


[web2py] Re: A mistake and crashed T3 appadmin from default/configure/models - No solution by now

2010-05-21 Thread mdipierro
Everything can be recovered but the details of how to do it depend on
an exact diagnosis of what happened.

I will try draft some guildelines for recovery.

On May 21, 6:43 pm, GoldenTiger  wrote:
> I copy-pasted some models that I previosuly defined in another web2py
> app, to configure models for an T3 new page.
>
> By mistake, I copied all content from db.py ,and pasted in configure
> models, and i submitted.
>
> This provoked duplicated tables and variables, and an already defined
> error in default controller, and in appdmin controller.
>
> So i don`t know how to roll back from web2py interface.  I tried to
> delete sqlite files created, leaving only the storage.db of T3 , with
> no success. I think I did this well, maybe I am wrong.
>
> Editing sqlite file with external app is too tedious, so I start again
> to coding, because i had only a few of data, and also it is more
> funny,
>
> I f I were in a production environment, what should I do?
> Any solution for future mistakes like this?
>
> How could I add code to T3 to protect me from myself? ^^
>
> Thanks


[web2py] Re: creating background process with multiprocessing spawns new instance of web2py

2010-05-21 Thread Magnitus
Yeah, thanks for the clarification about GIL, that was awesome (I read
many a textbook that was not as well written).

Made me realise that you can do some calls to the Python's C APY from
multiple C threads, but you should do so seldomly as its more
expensive in terms of interruptions in the parallelism (given that
there is a single lock on the entire API).

On May 21, 6:32 am, Graham Dumpleton 
wrote:
> On May 21, 8:14 pm, Magnitus  wrote:
>
> > Now that you mention it, I recall reading in the Python/C API that
> > Python wasn't really thread-safe and that Python objects shouldn't be
> > accessed from multiple C threads (they recommended using the Python
> > threading API which was exposed in the Python/C API instead, but that
> > didn't interest me as its not true multi-threading).
>
> Python is thread safe so long as you abide by the contract of
> acquiring the Python GIL. If you are going to ignore that required
> contract, then obviously it will break.
>
> This is the norm for any Python system in as much as you need to
> acquire a lock when accessing a shared resource. In the Python case
> there so happens to be one single global lock around any C API
> accesses where as in a custom C/C++ application which is
> multithreaded, you might have more fine grained locking around
> specific data structures of parts of the API.
>
> > My solution to this was make my C++ code C++ only and then glue parts
> > that I wanted to expose to Python so that Python calls on the C++
> > compiled code, but not the reverse.
>
> Which is exactly what many C extension modules do. That is, they move
> data between Python and C worlds so that they can then release the GIL
> and process the data. That why it can still make use of multi core/
> processor systems. This is why Apache/mod_wsgi isn't constrained by
> the Python GIL because everything Apache itself does doesn't use the
> Python GIL and can be properly parallelised.
>
> Graham
>
>
>
> > Hence, I probably bypassed a large part of the problematic discussed
> > above by not delving deeply into Python's threading API.
>
> > On May 21, 5:00 am, Yarko Tymciurak 
> > wrote:
>
> > > On May 21, 3:33 am, Magnitus  wrote:
>
> > > > But if you create "tasks" without doing it at the OS level, doesn't
> > > > that means that you won't really be able to take full advantage of
> > > > multi-processor hardware (since the OS handles the hardware and if the
> > > > OS doesn't know about it, it won't be able to do the required
> > > > optimizations with the hardware)?
>
> > > With the GIL, python itself does not utilize multiple processors, so
> > > web2py is processor-bound (the only
> > > effect of multi-core is that the o/s itself can "leave" a core to the
> > > main python task, e.g.
> > > it can grab an alternate core... other than that, you're running on
> > > one core regardless -
> > > unless you fire multiple instances of python interpreters, in which
> > > case you are really only
> > > going to communicate thru services anyway
>
> > > See some of the discussion 
> > > athttp://bugs.python.org/issue7946,http://stackoverflow.com/questions/9..
>
> > > ... and so forth...
>
> > > > Maybe I've done C/C++ for too long and am trying to micro-manage too
> > > > much, but a solution to I like to use for the problem of creating/
> > > > tearing down process threads is just to pre-create a limited number of
> > > > them (optimised for the number of CPUs you have) and recycle them to
> > > > do various tasks as needed.
>
> > > Well - since you don't have that with python, you run the risk of I/O
> > > blocking  which is why really lightweight
> > > tasklets are so desireable (CCP Games 
> > > runshttp://en.wikipedia.org/wiki/Eve_Online
> > > with many tens of thousands of simultaneous users, if I recall
> > > correctly, and maintain stackless for this purpose).
>
> > > > Of course, that works best when you give your threads/processes longer
> > > > tasks to perform in parallel (else, the extra cost of managing it will
> > > > probably outweight the benefits of running it in parallel).
>
> > > There is much to cover in this - and I suppose reason to be happy that
> > > python traditionally hasn't run multi-core.
> > > See, for example, the discussions 
> > > at:http://stackoverflow.com/questions/203912/does-python-support-multipr...
>
> > > andhttp://docs.python.org/library/multiprocessing.html
>
> > > Lots to read! ;-)
>
> > > - Yarko
>
> > > > On May 20, 2:12 pm, Yarko Tymciurak 
> > > > wrote:
>
> > > > > On May 19, 6:18 pm, Yarko Tymciurak 
> > > > > wrote:
>
> > > > > > On May 19, 5:41 pm, amoygard  wrote:
>
> > > > > 
>
> > > > > > So - in general, you do not start subprocesses - with the exception 
> > > > > > of
> > > > > > cron.   Seehttp://www.web2py.com/book/default/section/4/17
>
> > > > > I might better have said you do not _want_ to be starting subprocesses
> > > > > - besides the cost (compute time, memory, etc.), if you generally did
> > > > > this.   This

[web2py] Re: A mistake and crashed T3 appadmin from default/configure/models - No solution by now

2010-05-21 Thread GoldenTiger
really? that would be a very usefull information!  I feel more secure
now thank you alot professor Massimo :DD

 is via shell or via web?

On 22 mayo, 03:31, mdipierro  wrote:
> Everything can be recovered but the details of how to do it depend on
> an exact diagnosis of what happened.
>
> I will try draft some guildelines for recovery.
>
> On May 21, 6:43 pm, GoldenTiger  wrote:
>
> > I copy-pasted some models that I previosuly defined in another web2py
> > app, to configure models for an T3 new page.
>
> > By mistake, I copied all content from db.py ,and pasted in configure
> > models, and i submitted.
>
> > This provoked duplicated tables and variables, and an already defined
> > error in default controller, and in appdmin controller.
>
> > So i don`t know how to roll back from web2py interface.  I tried to
> > delete sqlite files created, leaving only the storage.db of T3 , with
> > no success. I think I did this well, maybe I am wrong.
>
> > Editing sqlite file with external app is too tedious, so I start again
> > to coding, because i had only a few of data, and also it is more
> > funny,
>
> > I f I were in a production environment, what should I do?
> > Any solution for future mistakes like this?
>
> > How could I add code to T3 to protect me from myself? ^^
>
> > Thanks


Re: [web2py] Re: bug2py

2010-05-21 Thread Alexandre Andrade
Let me know if you advance in something.
This project interest me.

Alexandre Andrade

2010/5/21 Abhishek Mishra 

> Hi Massimo,
>
> I was thinking of porting BugBase (a base bug tracker written in php
> as a college project) to web2py to learn and speed up with it. The
> original PHP code is here - http://github.com/ideamonk/bugbase with
> demo available at http://bugs.madetokill.com
>
> Its a bit buggy and insecure (assumed not tested or found yet), but I
> think a web2py version would solve any lacking security issues by
> taking care of many things in the back.
>
> Couldn't do much today, would love to finish a php-to-web2py port
> within short time of a day / two...
> Let me know if this project comes of any fruitful use.
> Thanks,
>
> Abhishek
>
> On May 22, 1:34 am, mdipierro  wrote:
> > I found thishttp://github.com/ideamonk/Bug2Py
> > seems interesting. Anybody has any info?
> >
> > Massimo
>



-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com


Re: [web2py] Re: nice slides on postgresql vs nodb

2010-05-21 Thread Thadeus Burgess
Here is my comparison between the two

PostgreSQL
Tables
DAL
ACID
vertically scales
set-schema

Both
no built-in object model
requires foreign key lookups
requires migrations if schema DOES change

MongoDB
documents
NoSQL
quick reads
horizontally scales
changing-schema


The advantages I see with NoSQL is that you don't need bloated ORMs
and complicated DALs. Most of the NoSQL libraries in python are very
small, don't require special drivers, and are small enough to go with
your application. As with alot of things, it really depends on exactly
what you are doing, if you need ACID (ie: your using this for *real*
work, like a research firm or a bank) use RDBS, if your just a
personal blog, small project, or anything other than a mission
critical application, you probably could use NoSQL since its API is
typically simpler and easier to use.

For web2py, you don't have to do ``db = DAL()`` you can just as easily
do ``db = MongoDB()`` and use it like with any other system. Looking
at NoSQL APIs I do not see how they can integrate with the web2py DAL
just because there is nothing for the DAL to do but provide a syntax.

--
Thadeus





On Fri, May 21, 2010 at 12:01 PM, Russ Ferriday  wrote:
> Final thought...
> I think if NoSQL were indicated for use with a web2Py app,  it might be most
> appropriate to replace some, but not all SQL-based tables.
> --r.
> On May 21, 2010, at 9:31 AM, Thadeus Burgess wrote:
>
> I also see really no reason to use NoSQL unless you really just don't
> like writing SQL... thats why we have ORMs and DALs anyways.
>
> You still have to use FK relationships with document based sets... ie:
> with a 4MB document limit, they suggest you split comments for a post
> into its own document and link them to a post via _id.
>
> If I am going to mess with relationships such as this I might as well
> use a umm... relational database system ?
>
> --
> Thadeus
>
>
>
>
>
> On Fri, May 21, 2010 at 8:23 AM, Albert Abril 
> wrote:
>
> Haha! I enjoy with this jokes in tech slides, they're amusing!
>
> On Fri, May 21, 2010 at 3:02 PM, Timothy Farrell  wrote:
>
> Developers running with scissors!! LOL!!!
>
> On 5/20/2010 2:12 PM, szimszon wrote:
>
> Nice
>
> On máj. 20, 19:52, mdipierro  wrote:
>
>
> http://www.scribd.com/doc/31669670/PostgreSQL-and-NoSQL
>
>
>
>
>
> Russ Ferriday - Topia Systems - Open Source content management with Plone
> and Zope
> ru...@topia.com - mobile: +1 805 234 6915 - skype: ferriday
>


[web2py] Re: A mistake and crashed T3 appadmin from default/configure/models - No solution by now

2010-05-21 Thread mdipierro
The problem is figure out what when wrong. Not so much fixing it.

For normal web2py apps (except T3) the fix is always the following:
1) edit the table to match what is in the database
2) delete all databales/*.table files
3) set migrate=False, fake_migrate=True

for T3 things may be more complex because the models themselves are
stored in the database. ca you tell us more about what you did and
problems you experienced?

On May 21, 9:41 pm, GoldenTiger  wrote:
> really? that would be a very usefull information!  I feel more secure
> now thank you alot professor Massimo :DD
>
>  is via shell or via web?
>
> On 22 mayo, 03:31, mdipierro  wrote:
>
> > Everything can be recovered but the details of how to do it depend on
> > an exact diagnosis of what happened.
>
> > I will try draft some guildelines for recovery.
>
> > On May 21, 6:43 pm, GoldenTiger  wrote:
>
> > > I copy-pasted some models that I previosuly defined in another web2py
> > > app, to configure models for an T3 new page.
>
> > > By mistake, I copied all content from db.py ,and pasted in configure
> > > models, and i submitted.
>
> > > This provoked duplicated tables and variables, and an already defined
> > > error in default controller, and in appdmin controller.
>
> > > So i don`t know how to roll back from web2py interface.  I tried to
> > > delete sqlite files created, leaving only the storage.db of T3 , with
> > > no success. I think I did this well, maybe I am wrong.
>
> > > Editing sqlite file with external app is too tedious, so I start again
> > > to coding, because i had only a few of data, and also it is more
> > > funny,
>
> > > I f I were in a production environment, what should I do?
> > > Any solution for future mistakes like this?
>
> > > How could I add code to T3 to protect me from myself? ^^
>
> > > Thanks


[web2py] Re: expire_sessions.py and cron

2010-05-21 Thread Iceberg
I think there is a cleaner way. No need to modify the applications/
admin/cron/expire_sessions.py whenever you add or remove your apps.
You just put this line into each of applications/your_app/cron/crontab

10  2   *   *   *   root 
**applications/admin/cron/expire_sessions.py

The point here is that, you only need to invoke the built-in admin/
cron/expire_sessions.py, because it can already work on caller-app's
folder.

@Massimo:
And I just don't see any reason why this line does not go into
scaffold app.

@Annet:
Sorry, but what do you mean "emil"?


On May19, 6:39pm, mdipierro  wrote:
> You can but you can also modify expire_sessions.py
>
> EXPIRATION_MINUTES=60
> import os, time, stat
> for app in ['admin','init','examples','welcome']: # add yours
>     path=os.path.join(request.folder,'..',app,'sessions')
>     if not os.path.exists(path):
>        os.mkdir(path)
>     now=time.time()
>     for file in os.listdir(path):
>         filename=os.path.join(path,file)
>         t=os.stat(filename)[stat.ST_MTIME]
>         if os.path.isfile(filename) and now-t>EXPIRATION_MINUTES*60 \
>           and file.startswith(('1','2','3','4','5','6','7','8','9')):
>           os.unlink(filename)
>
> so that one expire_sessions.py does it for all your apps.
> On May 19, 5:21 am, annet  wrote:
>
>
>
> > Massimo,
>
> > Emil just tried running the following command on my account:
>
> > python2.5 /home/fitwise/webapps/customweb2py/web2py/web2py.py  -S
> > admin -R applications/admin/cron/expire_sessions.py
>
> > This was successfully executed, and the output was:
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.76.5 (2010-03-11 15:19:08)
> > Database drivers available: SQLite3, MySQL, PostgreSQL
>
> > I verified that this actually cleaned up my sessions. It did in admin,
> > not in init, b2b etc. Would it be possible to copy the
> > expire_sessions.py to every single application's cron directory and
> > set this command as a cron by editing my crontab (crontab -e):
>
> > 10 * * * * /usr/local/bin/python2.5 /home/fitwise/webapps/customweb2py/
> > web2py/web2py.py  -S init -R applications/init/cron/expire_sessions.py
>
> > According to Emil:
>
> > Applications do not really have crontabs. They may have some built-in
> > feature which makes them work similar to crontab, but it is a
> > completely separate system than your "real" crontab (the one you see
> > when you runt 'crontab -l').
>
> > By the way, the Web2py installation that I have is running behind
> > Apache + mod_wsgi.
>
> > Kind regards,
>
> > Annet.


[web2py] Re: Catch auto-login event

2010-05-21 Thread Adi
On May 21, 7:44 pm, mdipierro  wrote:
> Does this mean that the "remember me for 30 days" feature works well
> for you?
> I have been having some problems with it.
>

Good question :)

Actually without this option I've experienced that my session expires
after a while (I think 10 minutes?), while with this option the
session remains active for a long time (at least one day). But now
that you mention this, I should check this behaviour thoroughly.

On May 21, 5:13 pm, weheh  wrote:
> Why don't you just keep a last_activity date? Also, the auth event log
> keeps track of the last login automatically. Why not check it to see
> what it's doing regarding last login when user has the "remember"
> checkbox checked? Technically, if it's checked, they're not logging
> in, right? Can you better articulate what you are really trying to
> measure?

I'm trying to measure user activity on the application - like sign-
ups, sign-ins and sign-outs, etc. Introducing last_login was a way to
internally track "active" users (for example, anyone with last_login
in past one week is active, and anyone who has not logged in for a
long time is an "inactive" user). I'm actually trying to mash-up my
site activities with google analytics to come up with a variety of
analytics of user behaviour that google analytics can't track alone.

auth_event should do it. I'm checking its behaviour (checking
"Remember me for 30 days" needs some time. :) ) Thanks a lot. I forgot
all about auth_event. I should be using it to track my custom events
as well.


[web2py] Re: Maybe Off-Topic: I am very happy thanks to web2py :)

2010-05-21 Thread Adi
+1 to both posts. :)

On May 22, 4:25 am, weheh  wrote:
> You will find you are in good company, here. Many of us feel the same
> way you do. It's perhaps not fitting to gush ... web2py isn't perfect.
> But it's the best I've found at what it does, and by a large margin.


[web2py] Re: expire_sessions.py and cron

2010-05-21 Thread annet
Hi,

> @Annet:
> Sorry, but what do you mean "emil"?

Emil works at WebFaction, where I host my application in a Shared 1
plan. Using web2py's crontab doesn't work at WebFaction, I have to use
my 'real' crontab to clean up sessions in my web2py applications.
Hence Massimo's re-write of the expire_session.py file, and this line
in my 'real' crontab:

10 * * * * /usr/local/bin/python2.5 /home/fitwise/webapps/
customweb2py/
web2py/web2py.py  -S init -R applications/init/cron/
expire_sessions.py


Kind regards,

Annet.