Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Nicol van der Merwe
Hi guys

This stuff is very interesting. I would like to request, if possible, that
someone makes a web2pyslice or proper AlterEgo entry on how to setup and run
these kinds of tests for web2py. I am very interested in setting up tests
for my application but I'm a bit lost as I've never done so before (plus I'm
unfortunately just too busy to research all this and make my own slice).

It would be very much appreciated if this can be done :)

Nicolaas

On Thu, Feb 25, 2010 at 5:35 AM, spiffytech  wrote:

> Thanks! Interesting article! My test cases now execute. However, I
> have a couple new questions, including a problem accessing the db in
> my controller.
>
> I modified my test file as AlterEgo 213 indicates so my unit tests can
> access the controller's functions. Here is my updated test file:
>
> ==
> #!/usr/bin/python
> import sys
> import unittest
>
> from gluon.shell import exec_environment
> from gluon.globals import Request, Response, Session
> from gluon.storage import Storage
>
> sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> this script
>
> class TestListActiveGames(unittest.TestCase):
>def setUp(self):
>self.request = Request()  # Use a clean Request
>self.controller = exec_environment('applications/api/
> controllers/10.py', request=self.request)
>
>def testListActiveGames(self):
>self.request.post_vars["game_id"] = 1
>self.request.post_vars["username"] = "spiffytech"
>self.controller.list_active_games()
>
> suite = unittest.TestSuite()
> suite.addTest(unittest.makeSuite(TestListActiveGames))
> unittest.TextTestRunner(verbosity=2).run(suite)
> ==
>
> It is called with the command:
>
> ==
> python web2py.py -S api -M -R applications/api/tests/test.py
> ==
>
> The output is this:
>
> ==
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.75.4 (2010-02-18 20:57:56)
> Database drivers available: pysqlite2
> testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>
> ==
> ERROR: testListActiveGames (__builtin__.TestListActiveGames)
> --
> Traceback (most recent call last):
>  File "applications/api/tests/test.py", line 19, in
> testListActiveGames
>self.controller.list_active_games()
>  File "applications/api/controllers/10.py", line 47, in
> list_active_games
>games = db(((db.game.user1==username)|(db.game.user2==username)) &
> (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> db.game.id, db.game.turn_number).as_list()
> NameError: global name 'db' is not defined
>
> --
> Ran 1 test in 0.008s
>
> FAILED (errors=1)
> ==
>
> Questions:
> 1) How can I get my controller to see the database?
> 2) Am I simply doing something very wrong? I would expect the web2py "-
> S" option to set up the environment, complete with my controller's
> functions, and Request/Storage/Response objects available for
> instantiation. However, several posts on the mailing list indicate
> that I need to run exec_enviroment() for access to my controllers.
> Also, the Request/Storage/Response objects don't seem to exist in the
> shell.
>
>
>
> On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
> > Replacing the way you run test suites helps. Instead of using .main()
> > add them manually.
> >
> > I would suggest reading the following article, as it includes methods
> > to aggregate your test suites together.
> >
> > http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
> >
> > import sys
> > sys.argv = sys.argv[5:]
> >
> > import unittest
> >
> > class TestDefaultController(unittest.TestCase):
> >
> > def testPrintStatement(self):
> > print "This line should print"
> > def testDatabaseRecordCount(self):
> > print "Records in database --- ", db(db.auth_user.id>0).count()
> >
> > suite = unittest.TestSuite()
> > suite.addTest(unittest.makeSuite(TestDefaultController))
> > unittest.TextTestRunner(verbosity=2).run(suite)
> >
> > python web2py.py -S pms -M -R
> applications/pms/test/testDefaultController.py
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.75.4 (2010-02-18 14:55:03)
> > Database drivers available: SQLite3
> > /home/thadeusb/web2py/applications/pms/modules/utils.py:16:
> > DeprecationWarning: the md5 module is deprecated; use hashlib instead
> >   import md5
> > testDatabaseRecordCount (__builtin__.TestDefaultController) ...
> > Records in database ---  4052
> > ok
> > testPrintStatement (__builtin__.TestDefaultController) ... This line
> > should print
> > ok
> >
> > --
> > Ran 2 tests in 0.006s
> >
> > OK
> >
> > -Thadeus
> >
> > On Wed, Feb 24, 2

Re: [web2py] Re: Download and Update Progress +a general question

2010-02-25 Thread Tiago Almeida
Sorry for the misunderstanding. When I said it was horrible I meant that
redirecting stdout is not a very elegant solution, but works.
Don't know how you could do what you need, showing the progress of the
script.


Regards,
Tiago
--

On Wed, Feb 24, 2010 at 10:35 PM, AsmanCom  wrote:

> Yo Tiango,
> many thanks for your effort.
>
> But if you say:
> > this is horrible!
>
> I´ll forget about that.
>
> > The least you should do is transform your scripts
> > so that instead of printing, they return the strings
> that's what i meant with: "(may i could change "print" to "return")"
>
> But i don´t know how to do this?
>
> May we could return to my example:
>
> def chunk_report(bytes_so_far, chunk_size, total_size):
>percent = float(bytes_so_far) / total_size
>percent = round(percent*100)
>return percent
>
>
> which is called by the def chunk_read:
>  while 1:
>chunk = response.read(chunk_size)
>bytes_so_far += len(chunk)
>
>if not chunk:
>break
>
>if report_hook:
>report_hook(bytes_so_far, chunk_size, total_size)
>
> How to display the output of chunk_report properly? (or how to update
> the ProgressBar with that output?)
>
> Best regards,
>
> Dieter Asman
>
> - AsmanCom -
> Germany
>
> On 24 Feb., 23:09, Tiago Almeida  wrote:
> > This is nasty as hell but you can redirect stdout to a string. Execute
> your
> > untouched scripts, all they print goes to the string and then, in the
> web2py
> > controller return that string instead of a dict.
> >
> > Example:
> > -- file print1_script.py: --
> > def print1():
> >print "1"
> >
> > #call print1
> > print1()
> >
> > -- file whatever.py: --
> > import sys
> > from cStringIO import StringIO
> >
> > #redirect stdout to string
> > sys.stdout = mystdout = StringIO()
> >
> > #execute script print1_script.py
> > execfile('print1_script.py')
> >
> > #reset the stdout
> > sys.stdout = sys.__stdout__
> >
> > #the output is available *as a string* in mystdout.getvalue()
> > print mystdout.getvalue()
> >
> > --- end --
> >
> > Again, this is horrible! The least you should do is transform your
> scripts
> > so that instead of printing, they return the strings. Then in web2py
> > controller you just return whatever your function returns.
> >
> > Regards,
> > Tiago
> > 
> >
> > On Wed, Feb 24, 2010 at 5:33 PM, AsmanCom  wrote:
> > > Hi Tiango,
> >
> > > no i need an equivalent for print, like:
> >
> > > def print_1():
> > >print "1"
> > >print "2"
> > > =
> > > 1
> > > 2
> >
> > > def print_2():
> > >while True:
> > >print "1"
> > > =
> > > 1
> > > 1
> > > 1
> > > 1
> > > ...
> >
> > > I need to execute scripts like in terminal, but output rendered in
> > > html. (should be very simple?)
> >
> > > Best regards,
> >
> > > Dieter Asman
> >
> > > - AsmanCom -
> > > Germany
> >
> > > On 24 Feb., 18:17, Tiago Almeida  wrote:
> > > > > for quick development-shots, i need to execute my untouched(may i
> > > > > could change "print" to "return") Python scripts(..with loops) in
> the
> > > > > Controller.
> > > > > The output should be renderd direct via http, without long-winded
> > > > > setting up the view for each function.
> > > > > Is that possible?
> >
> > > > If I understand you want to return a string directly without being
> > > processed
> > > > by the view.
> > > > On a controller function, if you return a string (not a dict) it will
> be
> > > > rendered as is.
> >
> > > > Tiago
> > > > --
> >
> > > > On Wed, Feb 24, 2010 at 4:48 PM, AsmanCom  wrote:
> > > > > Hi,
> >
> > > > > for quick development-shots, i need to execute my untouched(may i
> > > > > could change "print" to "return") Python scripts(..with loops) in
> the
> > > > > Controller.
> > > > > The output should be renderd direct via http, without long-winded
> > > > > setting up the view for each function.
> > > > > Is that possible?
> >
> > > > > To my next concern
> >
> > > > > On my actual Project i have simple form field with submit button on
> my
> > > > > controller:
> > > > > form = SQLFORM.factory(Field('update_url', default='http://.
> > > domain.org/
> > > > > text_file.txt ',
> > > > > requires=IS_NOT_EMPTY()))
> >
> > > > > On Submit the text file should be downloaded to Server indicated by
> an
> > > > > Progress Bar on the Page.
> > > > > Next the file should be inserted to the DB line by line(for loop
> with
> > > > > regex) and again indicated by the same Progress Bar .
> >
> > > > > My Code so far(... relies on clienttools example specifically on
> > > > > jqueryUI-progressbar and an urllib2 +report_hook snippet i´ve found
> > > > > somewhere):
> > > > >
> ___
> > > > > def chunk_report(bytes_so_far, chunk_size, total_size):
> > > > >percent = float(bytes_so_far) / total_size
> > > > >percent = round(percent*100)
> > > > >return percent
> >
> > > > >if bytes_so_far >= total_size

[web2py] Re: mail plain text message wrong charset

2010-02-25 Thread szimszon
I tested it again,

I created a new scaffolding app with the admin interface then I
changed:
db.py:
mail=Mail()  # mailer
mail.settings.server='localhost:25'# your SMTP server
mail.settings.sender='pr...@localhost' # your email

default.py (controller)
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
response.flash = T('mailtest')
context=dict(name="Gipsz Jakab",
 addr="Szt. Erzsébet körút")
message=response.render('emailbody.txt', context)
mail.send(to="szimszon",
  subject="test email",
  message=message)

return dict(message=T('Mail sent'))

made an emailbody.txt in views:
emailbody.txt
Üdvözlöm {{=name}}!

Címed: {{=addr}}

Ez egy teszt elektronikus levél.

Árvíztűrő tükörfúrógép!
--

Then I navigate to the site to send myself a letter:

- cut -
>From pr...@localhost  Thu Feb 25 11:24:05 2010
Return-Path: 
X-Original-To: szimszon
Delivered-To: szims...@x
Received: from xxx (localhost [127.0.0.1])
by xxx (Postfix) with ESMTP id C542A31CBF
for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
Content-Type: multipart/related;
boundary="===1518445122=="
MIME-Version: 1.0
To: szims...@
Subject: test email
Message-Id: <20100225102405.c542a31...@xxx>
Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
From: pr...@localhost

--===1518445122==
Content-Type: multipart/alternative;
boundary="===1974471883=="
MIME-Version: 1.0

--===1974471883==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Üdvözlöm Gipsz Jakab!

Címed: Szt. Erzsébet körút

Ez egy teszt elektronikus levél.

Árvíztűrő tükörfúrógép!

--===1974471883==--
--===1518445122==--

- cut -


charset: us-ascii


If I changed the
 mail.send(to="szimszon",
  subject="test email",
  message=message)

to
mail.send(to="szimszon",
  subject="test email",
  message=message,
  encoding="utf-8")
made no difference :(
On febr. 23, 21:01, Thadeus Burgess  wrote:
> I am unable to replicate this.
>
> -Thadeus
>
>
>
> On Tue, Feb 23, 2010 at 1:59 PM, szimszon  wrote:
> > No change:
>
> > --===2046819983==
> > Content-Type: multipart/alternative;
> > boundary="===1304182396=="
> > MIME-Version: 1.0
>
> > --===1304182396==
> > Content-Type: text/plain;charset="us-ascii"
> > MIME-Version: 1.0
> > Content-Transfer-Encoding: 7bit
>
> > On febr. 23, 20:47, Thadeus Burgess  wrote:
> >> Have you tried
>
> >>mail.send(encoding='us-ascii') ?
>
> >> -Thadeus
>
> >> On Tue, Feb 23, 2010 at 1:33 PM, szimszon  wrote:
> >> > Okay. I see...
>
> >> > The default is utf-8 and if I set it to utf-8 manually there is no
> >> > difference. This is the generatedmailcontent :(  :
>
> >> > --===1981490134==
> >> > Content-Type: multipart/alternative;
> >> > boundary="===859693=="
> >> > MIME-Version: 1.0
>
> >> > --===859693==
> >> > Content-Type: text/plain;charset="us-ascii"
> >> > MIME-Version: 1.0
> >> > Content-Transfer-Encoding: 7bit
>
> >> > On febr. 23, 20:06, Thadeus Burgess  wrote:
> >> >> Your looking in the wrong place.
>
> >> >> lines 172-182
>
> >> >> On line 181 is the encoding.
>
> >> >>http://code.google.com/p/web2py/source/browse/gluon/tools.py#181
>
> >> >>     def send(
> >> >>         self,
> >> >>         to,
> >> >>         subject='None',
> >> >>         message='None',
> >> >>         attachments=None,
> >> >>         cc=None,
> >> >>         bcc=None,
> >> >>         reply_to=None,
> >> >>         encoding='utf-8'
> >> >>         ):
>
> >> >> -Thadeus
>
> >> >> On Tue, Feb 23, 2010 at 12:34 PM, szimszon  wrote:
> >> >> > This is the sniplet of the most recent (1.75.4) web2py's tools.py's
> >> >> > classMail:
>
> >> >> >    def __init__(self, server=None, sender=None, login=None,
> >> >> > tls=True):
> >> >> >        """
> >> >> >        MainMailobject
> >> >> >        Arguments::
> >> >> >            server: SMTP server address in address:port notation
> >> >> >            sender: sender email address
> >> >> >            login: sender login name and password in login:password
> >> >> > notation
> >> >> >                   or None if no authentication is required
> >> >> >            tls: enables/disables encryption (True by default)
>
> >> >> > I can't do another, the file is dated:
> >> >> > tools.py       │ 113589│febr 18 21.57
>
> >> >> > Is it old?
>
> >> >> > On febr. 23, 17:32, Thadeus Burgess  wrote:
> >> >> >>Mailhas an encoding variable, unless you are running an older version
> >> >> >> of web2py.
>
> >> >> >> The code you posted is for the attachment class.
>
> >> >> >> -Thadeus
>
> >> >> >> 

RE: [web2py] Multiple Select Widget

2010-02-25 Thread Michael Howden
Thanks for the suggestion.

 

You mean:

|  |  |

?

 

You just mean for the countries selected?

And I could hide the actual check box itself? Would that be enough to ensure
the values are saved with the form? 

 

I tried to use a text box instead, but it just proved more difficult! I
think I may just stick with the multiple widget - if it ain't broke, don't
fix it!

 

From: web2py@googlegroups.com [mailto:web...@googlegroups.com] On Behalf Of
Tiago Almeida
Sent: Monday, 22 February 2010 6:20 p.m.
To: web2py@googlegroups.com
Subject: Re: [web2py] Multiple Select Widget

 

Is there a better way to do this type of functionality rather than
using a hidden multiple widget?


Why not make a simple table/list of checkboxes next to each country? 
---
Tiago

 

On Mon, Feb 22, 2010 at 10:46 AM, Michael Howden 
wrote:

Hey,

I have a need to allow the user to select multiple countries for a
single record (in this case the record is a project - which could be
occurring in a number of different countries).

I've developed a widget which allows the user to select a country from
a drop down, then click a button which uses JS to add it to a table
within the widget and also selecting it on a hidden web2py multiple
widget. The hidden multiple widget ensures that the values are saved
with the form.
Similarly, there is a "x" next to each country which has been selected
and is displayed on the table, which will run some JS to remove it
from the table, and de-select it on the hidden widget.

This code is working, but I have a few questions:

* Is it fine to presume that all users will be able to use JS on their
browsers?
* Is there a better way to do this type of functionality rather than
using a hidden multiple widget? Could the selected countries be read
directly from the table? Would it be more efficient to use a hidden
string widget? Where is the code which gets the values from the table
and saves them to the DB?
* Is there any dangers/issues/considerations in using a field with
multiple = True, rather than using a linking table for many to many
relationships? Or even using a field with multiple = True for a one to
many relationship?

Please let me know if it would simplify matters (or somehow
contribute) if I shared my code (web2pyslice?).

Cheers

Michael


--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com
 .
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.

 

-- 
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Download and Update Progress +a general question

2010-02-25 Thread mdipierro
redirecting stdout does not work unless you have a global locker that
locks web2py while you do the redirect.
Otherwise if two threads (two requests) do it at the same time you get
wrong output and you may completely loose stdout.

On Feb 25, 3:53 am, Tiago Almeida  wrote:
> Sorry for the misunderstanding. When I said it was horrible I meant that
> redirecting stdout is not a very elegant solution, but works.
> Don't know how you could do what you need, showing the progress of the
> script.
>
> Regards,
> Tiago
> --
>
> On Wed, Feb 24, 2010 at 10:35 PM, AsmanCom  wrote:
> > Yo Tiango,
> > many thanks for your effort.
>
> > But if you say:
> > > this is horrible!
>
> > I´ll forget about that.
>
> > > The least you should do is transform your scripts
> > > so that instead of printing, they return the strings
> > that's what i meant with: "(may i could change "print" to "return")"
>
> > But i don´t know how to do this?
>
> > May we could return to my example:
>
> > def chunk_report(bytes_so_far, chunk_size, total_size):
> >    percent = float(bytes_so_far) / total_size
> >    percent = round(percent*100)
> >    return percent
>
> > which is called by the def chunk_read:
> >  while 1:
> >        chunk = response.read(chunk_size)
> >        bytes_so_far += len(chunk)
>
> >        if not chunk:
> >            break
>
> >        if report_hook:
> >            report_hook(bytes_so_far, chunk_size, total_size)
>
> > How to display the output of chunk_report properly? (or how to update
> > the ProgressBar with that output?)
>
> > Best regards,
>
> > Dieter Asman
>
> > - AsmanCom -
> > Germany
>
> > On 24 Feb., 23:09, Tiago Almeida  wrote:
> > > This is nasty as hell but you can redirect stdout to a string. Execute
> > your
> > > untouched scripts, all they print goes to the string and then, in the
> > web2py
> > > controller return that string instead of a dict.
>
> > > Example:
> > > -- file print1_script.py: --
> > > def print1():
> > >    print "1"
>
> > > #call print1
> > > print1()
>
> > > -- file whatever.py: --
> > > import sys
> > > from cStringIO import StringIO
>
> > > #redirect stdout to string
> > > sys.stdout = mystdout = StringIO()
>
> > > #execute script print1_script.py
> > > execfile('print1_script.py')
>
> > > #reset the stdout
> > > sys.stdout = sys.__stdout__
>
> > > #the output is available *as a string* in mystdout.getvalue()
> > > print mystdout.getvalue()
>
> > > --- end --
>
> > > Again, this is horrible! The least you should do is transform your
> > scripts
> > > so that instead of printing, they return the strings. Then in web2py
> > > controller you just return whatever your function returns.
>
> > > Regards,
> > > Tiago
> > > 
>
> > > On Wed, Feb 24, 2010 at 5:33 PM, AsmanCom  wrote:
> > > > Hi Tiango,
>
> > > > no i need an equivalent for print, like:
>
> > > > def print_1():
> > > >    print "1"
> > > >    print "2"
> > > > =
> > > > 1
> > > > 2
>
> > > > def print_2():
> > > >    while True:
> > > >        print "1"
> > > > =
> > > > 1
> > > > 1
> > > > 1
> > > > 1
> > > > ...
>
> > > > I need to execute scripts like in terminal, but output rendered in
> > > > html. (should be very simple?)
>
> > > > Best regards,
>
> > > > Dieter Asman
>
> > > > - AsmanCom -
> > > > Germany
>
> > > > On 24 Feb., 18:17, Tiago Almeida  wrote:
> > > > > > for quick development-shots, i need to execute my untouched(may i
> > > > > > could change "print" to "return") Python scripts(..with loops) in
> > the
> > > > > > Controller.
> > > > > > The output should be renderd direct via http, without long-winded
> > > > > > setting up the view for each function.
> > > > > > Is that possible?
>
> > > > > If I understand you want to return a string directly without being
> > > > processed
> > > > > by the view.
> > > > > On a controller function, if you return a string (not a dict) it will
> > be
> > > > > rendered as is.
>
> > > > > Tiago
> > > > > --
>
> > > > > On Wed, Feb 24, 2010 at 4:48 PM, AsmanCom  wrote:
> > > > > > Hi,
>
> > > > > > for quick development-shots, i need to execute my untouched(may i
> > > > > > could change "print" to "return") Python scripts(..with loops) in
> > the
> > > > > > Controller.
> > > > > > The output should be renderd direct via http, without long-winded
> > > > > > setting up the view for each function.
> > > > > > Is that possible?
>
> > > > > > To my next concern
>
> > > > > > On my actual Project i have simple form field with submit button on
> > my
> > > > > > controller:
> > > > > > form = SQLFORM.factory(Field('update_url', default='http://.
> > > > domain.org/
> > > > > > text_file.txt ',
> > > > > > requires=IS_NOT_EMPTY()))
>
> > > > > > On Submit the text file should be downloaded to Server indicated by
> > an
> > > > > > Progress Bar on the Page.
> > > > > > Next the file should be inserted to the DB line by line(for loop
> > with
> > > > > > regex) and again indicated by the same Progress Bar .
>
> > > > > > My Code

[web2py] Re: Multiple Select Widget

2010-02-25 Thread mdipierro
Why not do this?

http://web2py.com/plugins/default/multiselect

On Feb 22, 5:19 am, Tiago Almeida  wrote:
> > Is there a better way to do this type of functionality rather than
> > using a hidden multiple widget?
>
> Why not make a simple table/list of checkboxes next to each country?
> ---
> Tiago
>
> On Mon, Feb 22, 2010 at 10:46 AM, Michael Howden
> wrote:
>
> > Hey,
>
> > I have a need to allow the user to select multiple countries for a
> > single record (in this case the record is a project - which could be
> > occurring in a number of different countries).
>
> > I've developed a widget which allows the user to select a country from
> > a drop down, then click a button which uses JS to add it to a table
> > within the widget and also selecting it on a hidden web2py multiple
> > widget. The hidden multiple widget ensures that the values are saved
> > with the form.
> > Similarly, there is a "x" next to each country which has been selected
> > and is displayed on the table, which will run some JS to remove it
> > from the table, and de-select it on the hidden widget.
>
> > This code is working, but I have a few questions:
>
> > * Is it fine to presume that all users will be able to use JS on their
> > browsers?
> > * Is there a better way to do this type of functionality rather than
> > using a hidden multiple widget? Could the selected countries be read
> > directly from the table? Would it be more efficient to use a hidden
> > string widget? Where is the code which gets the values from the table
> > and saves them to the DB?
> > * Is there any dangers/issues/considerations in using a field with
> > multiple = True, rather than using a linking table for many to many
> > relationships? Or even using a field with multiple = True for a one to
> > many relationship?
>
> > Please let me know if it would simplify matters (or somehow
> > contribute) if I shared my code (web2pyslice?).
>
> > Cheers
>
> > Michael
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > web2py+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: mail plain text message wrong charset

2010-02-25 Thread mdipierro
Because   encoding="utf-8" is default. You have to figure
out what is the encoding you need.

On Feb 25, 4:32 am, szimszon  wrote:
> I tested it again,
>
> I created a new scaffolding app with the admin interface then I
> changed:
> db.py:
> mail=Mail()                                  # mailer
> mail.settings.server='localhost:25'    # your SMTP server
> mail.settings.sender='pr...@localhost'         # your email
>
> default.py (controller)
> def index():
>     """
>     example action using the internationalization operator T and flash
>     rendered by views/default/index.html or views/generic.html
>     """
>     response.flash = T('mailtest')
>     context=dict(name="Gipsz Jakab",
>                  addr="Szt. Erzsébet körút")
>     message=response.render('emailbody.txt', context)
>     mail.send(to="szimszon",
>               subject="test email",
>               message=message)
>
>     return dict(message=T('Mail sent'))
>
> made an emailbody.txt in views:
> emailbody.txt
> Üdvözlöm {{=name}}!
>
> Címed: {{=addr}}
>
> Ez egy teszt elektronikus levél.
>
> Árvíztűrő tükörfúrógép!
> --
>
> Then I navigate to the site to send myself a letter:
>
> - cut -
> From pr...@localhost  Thu Feb 25 11:24:05 2010
> Return-Path: 
> X-Original-To: szimszon
> Delivered-To: szims...@x
> Received: from xxx (localhost [127.0.0.1])
>         by xxx (Postfix) with ESMTP id C542A31CBF
>         for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> Content-Type: multipart/related;
> boundary="===1518445122=="
> MIME-Version: 1.0
> To: szims...@
> Subject: test email
> Message-Id: <20100225102405.c542a31...@xxx>
> Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> From: pr...@localhost
>
> --===1518445122==
> Content-Type: multipart/alternative;
> boundary="===1974471883=="
> MIME-Version: 1.0
>
> --===1974471883==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 8bit
>
> Üdvözlöm Gipsz Jakab!
>
> Címed: Szt. Erzsébet körút
>
> Ez egy teszt elektronikus levél.
>
> Árvíztűrő tükörfúrógép!
>
> --===1974471883==--
> --===1518445122==--
>
> - cut -
>
> charset: us-ascii
>
> If I changed the
>      mail.send(to="szimszon",
>               subject="test email",
>               message=message)
>
> to
>     mail.send(to="szimszon",
>               subject="test email",
>               message=message,
>               encoding="utf-8")
> made no difference :(
> On febr. 23, 21:01, Thadeus Burgess  wrote:
>
> > I am unable to replicate this.
>
> > -Thadeus
>
> > On Tue, Feb 23, 2010 at 1:59 PM, szimszon  wrote:
> > > No change:
>
> > > --===2046819983==
> > > Content-Type: multipart/alternative;
> > > boundary="===1304182396=="
> > > MIME-Version: 1.0
>
> > > --===1304182396==
> > > Content-Type: text/plain;charset="us-ascii"
> > > MIME-Version: 1.0
> > > Content-Transfer-Encoding: 7bit
>
> > > On febr. 23, 20:47, Thadeus Burgess  wrote:
> > >> Have you tried
>
> > >>mail.send(encoding='us-ascii') ?
>
> > >> -Thadeus
>
> > >> On Tue, Feb 23, 2010 at 1:33 PM, szimszon  wrote:
> > >> > Okay. I see...
>
> > >> > The default is utf-8 and if I set it to utf-8 manually there is no
> > >> > difference. This is the generatedmailcontent :(  :
>
> > >> > --===1981490134==
> > >> > Content-Type: multipart/alternative;
> > >> > boundary="===859693=="
> > >> > MIME-Version: 1.0
>
> > >> > --===859693==
> > >> > Content-Type: text/plain;charset="us-ascii"
> > >> > MIME-Version: 1.0
> > >> > Content-Transfer-Encoding: 7bit
>
> > >> > On febr. 23, 20:06, Thadeus Burgess  wrote:
> > >> >> Your looking in the wrong place.
>
> > >> >> lines 172-182
>
> > >> >> On line 181 is the encoding.
>
> > >> >>http://code.google.com/p/web2py/source/browse/gluon/tools.py#181
>
> > >> >>     def send(
> > >> >>         self,
> > >> >>         to,
> > >> >>         subject='None',
> > >> >>         message='None',
> > >> >>         attachments=None,
> > >> >>         cc=None,
> > >> >>         bcc=None,
> > >> >>         reply_to=None,
> > >> >>         encoding='utf-8'
> > >> >>         ):
>
> > >> >> -Thadeus
>
> > >> >> On Tue, Feb 23, 2010 at 12:34 PM, szimszon  wrote:
> > >> >> > This is the sniplet of the most recent (1.75.4) web2py's tools.py's
> > >> >> > classMail:
>
> > >> >> >    def __init__(self, server=None, sender=None, login=None,
> > >> >> > tls=True):
> > >> >> >        """
> > >> >> >        MainMailobject
> > >> >> >        Arguments::
> > >> >> >            server: SMTP server address in address:port notation
> > >> >> >            sender: sender email address
> > >> >> >            login: sender login name and password in login:password
> > >> >> > notation
> > >> >> >                   or None if no authentication is required
> > >> >> >            tls: ena

[web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread Magnitus
Thanks for the heads up.

I did run web2py.py directly and while it works, I got the following
warning:

WARNING:root:no file locking

It seems to work otherwise, but I'd still like some clarification on
the warning if anybody knows.

Parallel to this, I found a py2exe to make a 64 bit binary at
(downloaded the one for python 2.6 as its the version of python that I
use): http://sourceforge.net/projects/py2exe/files/

When I tried running "python setup_exe.py py2exe", I got the following
error during installation:

*** copy data files ***
warning: install_data: setup script did not provide a directory for
'admin.w2p'
-- installing right in 'D:\web2py\dist'
error: can't copy 'admin.w2p': doesn't exist or not a regular file

>>python web2py.py


Because you can do so, I believe you can package it in a binary form
using
tools like py2exe.

On Feb 24, 9:48 am, Tiago Almeida  wrote:
> No questions are stupid.
> I'm no expert but I'll coment on what I know.
>
> Web2py runs officially in python 2.5. Don't know how hard it would be to put
> web2py running on 2.6.
>
> You don't need the binary package to run web2py, you can run it directly
> from python (execute file web2py.py)>>python web2py.py
>
> Because you can do so, I believe you can package it in a binary form using
> tools like py2exe.
>
> Backward compatibility claim is just related to the fact that code changes
> to web2py don't break webapplications written for web2py.
>
> I believe web2py will have to support python2.6 eventually but don't know
> when.
> Python 3.x support is even farther away. Py3k is a different language, it
> has some details that break existing code base and, as such, all the code
> has to be ported. It won't happen overnight.
>
> Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does and you
> can integrate it easily with web2py (instead of integrating web2py with what
> you have).
>
> Regards,
> Tiago
>
> ---
>
>
>
> On Wed, Feb 24, 2010 at 9:23 AM, Magnitus  wrote:
> > Hi, I'm a beginner in python and a complete neophyte in python web
> > frameworks so don't bash my head in if the questions are stupid...
>
> > I'm developing an application in C++ for windows x64 and I am now
> > looking for a way to make it a web app.
>
> > I'm looking for compatibility with python 2.6 (already started the
> > process of gluing my code with the C API) and eventually python 3.1 in
> > case they stop supporting prior versions. I'm also looking for
> > compatibility with the 64 bits address format.
>
> > Now, I see that web2py is available with a pre-compiled binary for
> > windows. Is it a win32 binary? If so, can I build a win64 binary from
> > the source code with python 2.6?
>
> > Also, looking at the current compatibilities (2.4/2.5/2.6) and the
> > claim that backward compatibility of the framework will not be broken,
> > I'm wondering if there any future plans for web2py to be eventually
> > compatible with python 3.1 (given that python 3.1 is not backward
> > compatible with code written for previous versions of python or so I
> > heard).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > web2py+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/web2py?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] SQLFORM displays "text" values with text, not textareas

2010-02-25 Thread mdmcginn
Section 7.2 of the book says, "A SQLFORM displays "boolean" values
with checkboxes, "text" values with textareas," etc. But instead, it
apparently displays "text" values with text. Others have asked how to
make them display as textareas - as larger input fields. Sure, I could
use FORM instead of SQLFORM to do it, but is the book wrong? (I
thought this might be a bug/question not an edit, so I didn't sign up
as an editor to report this.)

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread mdipierro
On Feb 25, 4:02 am, Magnitus  wrote:
> Thanks for the heads up.
>
> I did run web2py.py directly and while it works, I got the following
> warning:
>
> WARNING:root:no file locking

what os are you using. This should work o Posix and win32.

About your other issue.

py2exe and py2app have a bug and I am about to rewrite them. Will do
it soon.

> It seems to work otherwise, but I'd still like some clarification on
> the warning if anybody knows.
>
> Parallel to this, I found a py2exe to make a 64 bit binary at
> (downloaded the one for python 2.6 as its the version of python that I
> use):http://sourceforge.net/projects/py2exe/files/
>
> When I tried running "python setup_exe.py py2exe", I got the following
> error during installation:
>
> *** copy data files ***
> warning: install_data: setup script did not provide a directory for
> 'admin.w2p'
> -- installing right in 'D:\web2py\dist'
> error: can't copy 'admin.w2p': doesn't exist or not a regular file
>
> >>python web2py.py
>
> Because you can do so, I believe you can package it in a binary form
> using
> tools like py2exe.
>
> On Feb 24, 9:48 am, Tiago Almeida  wrote:
>
> > No questions are stupid.
> > I'm no expert but I'll coment on what I know.
>
> > Web2py runs officially in python 2.5. Don't know how hard it would be to put
> > web2py running on 2.6.
>
> > You don't need the binary package to run web2py, you can run it directly
> > from python (execute file web2py.py)>>python web2py.py
>
> > Because you can do so, I believe you can package it in a binary form using
> > tools like py2exe.
>
> > Backward compatibility claim is just related to the fact that code changes
> > to web2py don't break webapplications written for web2py.
>
> > I believe web2py will have to support python2.6 eventually but don't know
> > when.
> > Python 3.x support is even farther away. Py3k is a different language, it
> > has some details that break existing code base and, as such, all the code
> > has to be ported. It won't happen overnight.
>
> > Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does and you
> > can integrate it easily with web2py (instead of integrating web2py with what
> > you have).
>
> > Regards,
> > Tiago
>
> > ---
>
> > On Wed, Feb 24, 2010 at 9:23 AM, Magnitus  wrote:
> > > Hi, I'm a beginner in python and a complete neophyte in python web
> > > frameworks so don't bash my head in if the questions are stupid...
>
> > > I'm developing an application in C++ for windows x64 and I am now
> > > looking for a way to make it a web app.
>
> > > I'm looking for compatibility with python 2.6 (already started the
> > > process of gluing my code with the C API) and eventually python 3.1 in
> > > case they stop supporting prior versions. I'm also looking for
> > > compatibility with the 64 bits address format.
>
> > > Now, I see that web2py is available with a pre-compiled binary for
> > > windows. Is it a win32 binary? If so, can I build a win64 binary from
> > > the source code with python 2.6?
>
> > > Also, looking at the current compatibilities (2.4/2.5/2.6) and the
> > > claim that backward compatibility of the framework will not be broken,
> > > I'm wondering if there any future plans for web2py to be eventually
> > > compatible with python 3.1 (given that python 3.1 is not backward
> > > compatible with code written for previous versions of python or so I
> > > heard).
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "web2py-users" group.
> > > To post to this group, send email to web...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > web2py+unsubscr...@googlegroups.com
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/web2py?hl=en.-Hide quoted text -
>
> > - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: SQLFORM displays "text" values with text, not textareas

2010-02-25 Thread mdipierro
I am not sure I understand your question. The book is correct 'text'
is rendered by a textarea. Here is an example:

$ python web2py.py -S welcome -M
>>> print SQLFORM.factory(Field('test','text'))
Test: 

same with formal SQLFORM, crud.create and crud.update.

Do you get a different output?

Massimo


On Feb 24, 10:08 pm, mdmcginn  wrote:
> Section 7.2 of the book says, "A SQLFORM displays "boolean" values
> with checkboxes, "text" values with textareas," etc. But instead, it
> apparently displays "text" values with text. Others have asked how to
> make them display as textareas - as larger input fields. Sure, I could
> use FORM instead of SQLFORM to do it, but is the book wrong? (I
> thought this might be a bug/question not an edit, so I didn't sign up
> as an editor to report this.)

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread Tiago Almeida
For the root no file locking, try:

Install "Python for windows
extensions>"
(If you're using windows)

I had a similar issue and documented here
in
the past and it solved my problem. Don't know why though.

Regards,
Tiago
---

On Thu, Feb 25, 2010 at 10:02 AM, Magnitus  wrote:

> Thanks for the heads up.
>
> I did run web2py.py directly and while it works, I got the following
> warning:
>
> WARNING:root:no file locking
>
> It seems to work otherwise, but I'd still like some clarification on
> the warning if anybody knows.
>
> Parallel to this, I found a py2exe to make a 64 bit binary at
> (downloaded the one for python 2.6 as its the version of python that I
> use): http://sourceforge.net/projects/py2exe/files/
>
> When I tried running "python setup_exe.py py2exe", I got the following
> error during installation:
>
> *** copy data files ***
> warning: install_data: setup script did not provide a directory for
> 'admin.w2p'
> -- installing right in 'D:\web2py\dist'
> error: can't copy 'admin.w2p': doesn't exist or not a regular file
>
> >>python web2py.py
>
>
> Because you can do so, I believe you can package it in a binary form
> using
> tools like py2exe.
>
> On Feb 24, 9:48 am, Tiago Almeida  wrote:
> > No questions are stupid.
> > I'm no expert but I'll coment on what I know.
> >
> > Web2py runs officially in python 2.5. Don't know how hard it would be to
> put
> > web2py running on 2.6.
> >
> > You don't need the binary package to run web2py, you can run it directly
> > from python (execute file web2py.py)>>python web2py.py
> >
> > Because you can do so, I believe you can package it in a binary form
> using
> > tools like py2exe.
> >
> > Backward compatibility claim is just related to the fact that code
> changes
> > to web2py don't break webapplications written for web2py.
> >
> > I believe web2py will have to support python2.6 eventually but don't know
> > when.
> > Python 3.x support is even farther away. Py3k is a different language, it
> > has some details that break existing code base and, as such, all the code
> > has to be ported. It won't happen overnight.
> >
> > Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does and
> you
> > can integrate it easily with web2py (instead of integrating web2py with
> what
> > you have).
> >
> > Regards,
> > Tiago
> >
> > ---
> >
> >
> >
> > On Wed, Feb 24, 2010 at 9:23 AM, Magnitus 
> wrote:
> > > Hi, I'm a beginner in python and a complete neophyte in python web
> > > frameworks so don't bash my head in if the questions are stupid...
> >
> > > I'm developing an application in C++ for windows x64 and I am now
> > > looking for a way to make it a web app.
> >
> > > I'm looking for compatibility with python 2.6 (already started the
> > > process of gluing my code with the C API) and eventually python 3.1 in
> > > case they stop supporting prior versions. I'm also looking for
> > > compatibility with the 64 bits address format.
> >
> > > Now, I see that web2py is available with a pre-compiled binary for
> > > windows. Is it a win32 binary? If so, can I build a win64 binary from
> > > the source code with python 2.6?
> >
> > > Also, looking at the current compatibilities (2.4/2.5/2.6) and the
> > > claim that backward compatibility of the framework will not be broken,
> > > I'm wondering if there any future plans for web2py to be eventually
> > > compatible with python 3.1 (given that python 3.1 is not backward
> > > compatible with code written for previous versions of python or so I
> > > heard).
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "web2py-users" group.
> > > To post to this group, send email to web...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > web2py+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/web2py?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to
> web2py+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more

[web2py] newly created app fails in shell mode in 1.75.4

2010-02-25 Thread DenesL
Using 1.75.4, a newly created app fails to start in shell mode (-M -N -
S) with:

web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.75.4 (2010-02-18 14:55:03)
Database drivers available: pysqlite2, MSSQL/DB2
Traceback (most recent call last):
  File "C:\web2py\hg\gluon\restricted.py", line 173, in restricted
exec ccode in environment
  File "applications\test2\models/db.py", line 15, in 
db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or
other DB
  File "C:\web2py\hg\gluon\sql.py", line 3769, in DAL
db_codec=db_codec, check_reserved=check_reserved)
  File "C:\web2py\hg\gluon\sql.py", line 889, in __init__
self._pool_connection(lambda : sqlite3.Connection(dbpath,
  File "C:\web2py\hg\gluon\sql.py", line 829, in _pool_connection
self._connection = f()
  File "C:\web2py\hg\gluon\sql.py", line 890, in 
check_same_thread=False))
OperationalError: unable to open database file

until you use appadmin on it.
This did not happen in 1.75.1 AFAIK.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread Magnitus
>what os are you using. This should work o Posix and win32.

Windows Vista, 64-bit.

I got the 64-bit download for the windows extension at the link that
Tiago mentioned and it 'fixed' the warning message (though I'm still
puzzled at why a special windows extension was needed on top of the
release to 'fix' python, perhaps they should include it the release...
some doc came with the open source version, guess I'll have to read it
and find out what the add-on fixes).

Thanks for all the help :).

On Feb 25, 6:32 am, Tiago Almeida  wrote:
> For the root no file locking, try:
>
> Install "Python for windows
> extensions>"
> (If you're using windows)
>
> I had a similar issue and documented here
> in
> the past and it solved my problem. Don't know why though.
>
> Regards,
> Tiago
> ---
>
>
>
> On Thu, Feb 25, 2010 at 10:02 AM, Magnitus  wrote:
> > Thanks for the heads up.
>
> > I did run web2py.py directly and while it works, I got the following
> > warning:
>
> > WARNING:root:no file locking
>
> > It seems to work otherwise, but I'd still like some clarification on
> > the warning if anybody knows.
>
> > Parallel to this, I found a py2exe to make a 64 bit binary at
> > (downloaded the one for python 2.6 as its the version of python that I
> > use):http://sourceforge.net/projects/py2exe/files/
>
> > When I tried running "python setup_exe.py py2exe", I got the following
> > error during installation:
>
> > *** copy data files ***
> > warning: install_data: setup script did not provide a directory for
> > 'admin.w2p'
> > -- installing right in 'D:\web2py\dist'
> > error: can't copy 'admin.w2p': doesn't exist or not a regular file
>
> > >>python web2py.py
>
> > Because you can do so, I believe you can package it in a binary form
> > using
> > tools like py2exe.
>
> > On Feb 24, 9:48 am, Tiago Almeida  wrote:
> > > No questions are stupid.
> > > I'm no expert but I'll coment on what I know.
>
> > > Web2py runs officially in python 2.5. Don't know how hard it would be to
> > put
> > > web2py running on 2.6.
>
> > > You don't need the binary package to run web2py, you can run it directly
> > > from python (execute file web2py.py)>>python web2py.py
>
> > > Because you can do so, I believe you can package it in a binary form
> > using
> > > tools like py2exe.
>
> > > Backward compatibility claim is just related to the fact that code
> > changes
> > > to web2py don't break webapplications written for web2py.
>
> > > I believe web2py will have to support python2.6 eventually but don't know
> > > when.
> > > Python 3.x support is even farther away. Py3k is a different language, it
> > > has some details that break existing code base and, as such, all the code
> > > has to be ported. It won't happen overnight.
>
> > > Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does and
> > you
> > > can integrate it easily with web2py (instead of integrating web2py with
> > what
> > > you have).
>
> > > Regards,
> > > Tiago
>
> > > ---
>
> > > On Wed, Feb 24, 2010 at 9:23 AM, Magnitus 
> > wrote:
> > > > Hi, I'm a beginner in python and a complete neophyte in python web
> > > > frameworks so don't bash my head in if the questions are stupid...
>
> > > > I'm developing an application in C++ for windows x64 and I am now
> > > > looking for a way to make it a web app.
>
> > > > I'm looking for compatibility with python 2.6 (already started the
> > > > process of gluing my code with the C API) and eventually python 3.1 in
> > > > case they stop supporting prior versions. I'm also looking for
> > > > compatibility with the 64 bits address format.
>
> > > > Now, I see that web2py is available with a pre-compiled binary for
> > > > windows. Is it a win32 binary? If so, can I build a win64 binary from
> > > > the source code with python 2.6?
>
> > > > Also, looking at the current compatibilities (2.4/2.5/2.6) and the
> > > > claim that backward compatibility of the framework will not be broken,
> > > > I'm wondering if there any future plans for web2py to be eventually
> > > > compatible with python 3.1 (given that python 3.1 is not backward
> > > > compatible with code written for previous versions of python or so I
> > > > heard).
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "web2py-users" group.
> > > > To post to this group, send email to web...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > web2py+unsubscr...@googlegroups.com
> > 
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/web2py?hl=en.-Hide quoted text -
>
> > > - Show quoted text

[web2py] Re: mail plain text message wrong charset

2010-02-25 Thread szimszon
I need utf-8 :)

On febr. 25, 12:20, mdipierro  wrote:
> Because               encoding="utf-8" is default. You have to figure
> out what is the encoding you need.
>
> On Feb 25, 4:32 am, szimszon  wrote:
>
>
>
> > I tested it again,
>
> > I created a new scaffolding app with the admin interface then I
> > changed:
> > db.py:
> >mail=Mail()                                  # mailer
> >mail.settings.server='localhost:25'    # your SMTP server
> >mail.settings.sender='pr...@localhost'         # your email
>
> > default.py (controller)
> > def index():
> >     """
> >     example action using the internationalization operator T and flash
> >     rendered by views/default/index.html or views/generic.html
> >     """
> >     response.flash = T('mailtest')
> >     context=dict(name="Gipsz Jakab",
> >                  addr="Szt. Erzsébet körút")
> >     message=response.render('emailbody.txt', context)
> >    mail.send(to="szimszon",
> >               subject="test email",
> >               message=message)
>
> >     return dict(message=T('Mailsent'))
>
> > made an emailbody.txt in views:
> > emailbody.txt
> > Üdvözlöm {{=name}}!
>
> > Címed: {{=addr}}
>
> > Ez egy teszt elektronikus levél.
>
> > Árvíztűrő tükörfúrógép!
> > --
>
> > Then I navigate to the site to send myself a letter:
>
> > - cut -
> > From pr...@localhost  Thu Feb 25 11:24:05 2010
> > Return-Path: 
> > X-Original-To: szimszon
> > Delivered-To: szims...@x
> > Received: from xxx (localhost [127.0.0.1])
> >         by xxx (Postfix) with ESMTP id C542A31CBF
> >         for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> > Content-Type: multipart/related;
> > boundary="===1518445122=="
> > MIME-Version: 1.0
> > To: szims...@
> > Subject: test email
> > Message-Id: <20100225102405.c542a31...@xxx>
> > Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> > From: pr...@localhost
>
> > --===1518445122==
> > Content-Type: multipart/alternative;
> > boundary="===1974471883=="
> > MIME-Version: 1.0
>
> > --===1974471883==
> > Content-Type: text/plain;charset="us-ascii"
> > MIME-Version: 1.0
> > Content-Transfer-Encoding: 8bit
>
> > Üdvözlöm Gipsz Jakab!
>
> > Címed: Szt. Erzsébet körút
>
> > Ez egy teszt elektronikus levél.
>
> > Árvíztűrő tükörfúrógép!
>
> > --===1974471883==--
> > --===1518445122==--
>
> > - cut -
>
> >charset: us-ascii
>
> > If I changed the
> >      mail.send(to="szimszon",
> >               subject="test email",
> >               message=message)
>
> > to
> >    mail.send(to="szimszon",
> >               subject="test email",
> >               message=message,
> >               encoding="utf-8")
> > made no difference :(
> > On febr. 23, 21:01, Thadeus Burgess  wrote:
>
> > > I am unable to replicate this.
>
> > > -Thadeus
>
> > > On Tue, Feb 23, 2010 at 1:59 PM, szimszon  wrote:
> > > > No change:
>
> > > > --===2046819983==
> > > > Content-Type: multipart/alternative;
> > > > boundary="===1304182396=="
> > > > MIME-Version: 1.0
>
> > > > --===1304182396==
> > > > Content-Type: text/plain;charset="us-ascii"
> > > > MIME-Version: 1.0
> > > > Content-Transfer-Encoding: 7bit
>
> > > > On febr. 23, 20:47, Thadeus Burgess  wrote:
> > > >> Have you tried
>
> > > >>mail.send(encoding='us-ascii') ?
>
> > > >> -Thadeus
>
> > > >> On Tue, Feb 23, 2010 at 1:33 PM, szimszon  wrote:
> > > >> > Okay. I see...
>
> > > >> > The default is utf-8 and if I set it to utf-8 manually there is no
> > > >> > difference. This is the generatedmailcontent :(  :
>
> > > >> > --===1981490134==
> > > >> > Content-Type: multipart/alternative;
> > > >> > boundary="===859693=="
> > > >> > MIME-Version: 1.0
>
> > > >> > --===859693==
> > > >> > Content-Type: text/plain;charset="us-ascii"
> > > >> > MIME-Version: 1.0
> > > >> > Content-Transfer-Encoding: 7bit
>
> > > >> > On febr. 23, 20:06, Thadeus Burgess  wrote:
> > > >> >> Your looking in the wrong place.
>
> > > >> >> lines 172-182
>
> > > >> >> On line 181 is the encoding.
>
> > > >> >>http://code.google.com/p/web2py/source/browse/gluon/tools.py#181
>
> > > >> >>     def send(
> > > >> >>         self,
> > > >> >>         to,
> > > >> >>         subject='None',
> > > >> >>         message='None',
> > > >> >>         attachments=None,
> > > >> >>         cc=None,
> > > >> >>         bcc=None,
> > > >> >>         reply_to=None,
> > > >> >>         encoding='utf-8'
> > > >> >>         ):
>
> > > >> >> -Thadeus
>
> > > >> >> On Tue, Feb 23, 2010 at 12:34 PM, szimszon  
> > > >> >> wrote:
> > > >> >> > This is the sniplet of the most recent (1.75.4) web2py's 
> > > >> >> > tools.py's
> > > >> >> > classMail:
>
> > > >> >> >    def __init__(self, server=None, sender=None, login=None,
> > > >> >> > tls=True):
> > > >> >> >        """
> > > >> >> >        MainMailobject
> > > >> >> >        Argu

[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Jon Romero
Yeap, spiffytech where you able to run tests (no doctests) using the
database?

On Feb 25, 11:20 am, Nicol van der Merwe 
wrote:
> Hi guys
>
> This stuff is very interesting. I would like to request, if possible, that
> someone makes a web2pyslice or proper AlterEgo entry on how to setup and run
> these kinds of tests for web2py. I am very interested in setting up tests
> for my application but I'm a bit lost as I've never done so before (plus I'm
> unfortunately just too busy to research all this and make my own slice).
>
> It would be very much appreciated if this can be done :)
>
> Nicolaas
>
> On Thu, Feb 25, 2010 at 5:35 AM, spiffytech  wrote:
> > Thanks! Interesting article! My test cases now execute. However, I
> > have a couple new questions, including a problem accessing the db in
> > my controller.
>
> > I modified my test file as AlterEgo 213 indicates so my unit tests can
> > access the controller's functions. Here is my updated test file:
>
> > ==
> > #!/usr/bin/python
> > import sys
> > import unittest
>
> > from gluon.shell import exec_environment
> > from gluon.globals import Request, Response, Session
> > from gluon.storage import Storage
>
> > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> > this script
>
> > class TestListActiveGames(unittest.TestCase):
> >    def setUp(self):
> >        self.request = Request()  # Use a clean Request
> >        self.controller = exec_environment('applications/api/
> > controllers/10.py', request=self.request)
>
> >    def testListActiveGames(self):
> >        self.request.post_vars["game_id"] = 1
> >        self.request.post_vars["username"] = "spiffytech"
> >        self.controller.list_active_games()
>
> > suite = unittest.TestSuite()
> > suite.addTest(unittest.makeSuite(TestListActiveGames))
> > unittest.TextTestRunner(verbosity=2).run(suite)
> > ==
>
> > It is called with the command:
>
> > ==
> > python web2py.py -S api -M -R applications/api/tests/test.py
> > ==
>
> > The output is this:
>
> > ==
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.75.4 (2010-02-18 20:57:56)
> > Database drivers available: pysqlite2
> > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>
> > ==
> > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
> > --
> > Traceback (most recent call last):
> >  File "applications/api/tests/test.py", line 19, in
> > testListActiveGames
> >    self.controller.list_active_games()
> >  File "applications/api/controllers/10.py", line 47, in
> > list_active_games
> >    games = db(((db.game.user1==username)|(db.game.user2==username)) &
> > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> > db.game.id, db.game.turn_number).as_list()
> > NameError: global name 'db' is not defined
>
> > --
> > Ran 1 test in 0.008s
>
> > FAILED (errors=1)
> > ==
>
> > Questions:
> > 1) How can I get my controller to see the database?
> > 2) Am I simply doing something very wrong? I would expect the web2py "-
> > S" option to set up the environment, complete with my controller's
> > functions, and Request/Storage/Response objects available for
> > instantiation. However, several posts on the mailing list indicate
> > that I need to run exec_enviroment() for access to my controllers.
> > Also, the Request/Storage/Response objects don't seem to exist in the
> > shell.
>
> > On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
> > > Replacing the way you run test suites helps. Instead of using .main()
> > > add them manually.
>
> > > I would suggest reading the following article, as it includes methods
> > > to aggregate your test suites together.
>
> > >http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
>
> > > import sys
> > > sys.argv = sys.argv[5:]
>
> > > import unittest
>
> > > class TestDefaultController(unittest.TestCase):
>
> > >     def testPrintStatement(self):
> > >         print "This line should print"
> > >     def testDatabaseRecordCount(self):
> > >         print "Records in database --- ", db(db.auth_user.id>0).count()
>
> > > suite = unittest.TestSuite()
> > > suite.addTest(unittest.makeSuite(TestDefaultController))
> > > unittest.TextTestRunner(verbosity=2).run(suite)
>
> > > python web2py.py -S pms -M -R
> > applications/pms/test/testDefaultController.py
> > > web2py Enterprise Web Framework
> > > Created by Massimo Di Pierro, Copyright 2007-2010
> > > Version 1.75.4 (2010-02-18 14:55:03)
> > > Database drivers available: SQLite3
> > > /home/thadeusb/web2py/applications/pms/modules/utils.py:16:
> > > DeprecationWarning: the md5 module is deprecated; use hashlib instead
> > >   import md5
> > > testDatabaseRecordCount (__builtin__.TestDefaultC

[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
I'm going to write up a nice, clear wiki article on unit testing with
the unittest module based on what I learned in this discussion. I'll
be sure to link to it here when it's done.


On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
> Hi guys
>
> This stuff is very interesting. I would like to request, if possible, that
> someone makes a web2pyslice or proper AlterEgo entry on how to setup and run
> these kinds of tests for web2py. I am very interested in setting up tests
> for my application but I'm a bit lost as I've never done so before (plus I'm
> unfortunately just too busy to research all this and make my own slice).
>
> It would be very much appreciated if this can be done :)
>
> Nicolaas
>
> On Thu, Feb 25, 2010 at 5:35 AM, spiffytech  wrote:
> > Thanks! Interesting article! My test cases now execute. However, I
> > have a couple new questions, including a problem accessing the db in
> > my controller.
>
> > I modified my test file as AlterEgo 213 indicates so my unit tests can
> > access the controller's functions. Here is my updated test file:
>
> > ==
> > #!/usr/bin/python
> > import sys
> > import unittest
>
> > from gluon.shell import exec_environment
> > from gluon.globals import Request, Response, Session
> > from gluon.storage import Storage
>
> > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> > this script
>
> > class TestListActiveGames(unittest.TestCase):
> >    def setUp(self):
> >        self.request = Request()  # Use a clean Request
> >        self.controller = exec_environment('applications/api/
> > controllers/10.py', request=self.request)
>
> >    def testListActiveGames(self):
> >        self.request.post_vars["game_id"] = 1
> >        self.request.post_vars["username"] = "spiffytech"
> >        self.controller.list_active_games()
>
> > suite = unittest.TestSuite()
> > suite.addTest(unittest.makeSuite(TestListActiveGames))
> > unittest.TextTestRunner(verbosity=2).run(suite)
> > ==
>
> > It is called with the command:
>
> > ==
> > python web2py.py -S api -M -R applications/api/tests/test.py
> > ==
>
> > The output is this:
>
> > ==
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.75.4 (2010-02-18 20:57:56)
> > Database drivers available: pysqlite2
> > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>
> > ==
> > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
> > --
> > Traceback (most recent call last):
> >  File "applications/api/tests/test.py", line 19, in
> > testListActiveGames
> >    self.controller.list_active_games()
> >  File "applications/api/controllers/10.py", line 47, in
> > list_active_games
> >    games = db(((db.game.user1==username)|(db.game.user2==username)) &
> > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> > db.game.id, db.game.turn_number).as_list()
> > NameError: global name 'db' is not defined
>
> > --
> > Ran 1 test in 0.008s
>
> > FAILED (errors=1)
> > ==
>
> > Questions:
> > 1) How can I get my controller to see the database?
> > 2) Am I simply doing something very wrong? I would expect the web2py "-
> > S" option to set up the environment, complete with my controller's
> > functions, and Request/Storage/Response objects available for
> > instantiation. However, several posts on the mailing list indicate
> > that I need to run exec_enviroment() for access to my controllers.
> > Also, the Request/Storage/Response objects don't seem to exist in the
> > shell.
>
> > On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
> > > Replacing the way you run test suites helps. Instead of using .main()
> > > add them manually.
>
> > > I would suggest reading the following article, as it includes methods
> > > to aggregate your test suites together.
>
> > >http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
>
> > > import sys
> > > sys.argv = sys.argv[5:]
>
> > > import unittest
>
> > > class TestDefaultController(unittest.TestCase):
>
> > >     def testPrintStatement(self):
> > >         print "This line should print"
> > >     def testDatabaseRecordCount(self):
> > >         print "Records in database --- ", db(db.auth_user.id>0).count()
>
> > > suite = unittest.TestSuite()
> > > suite.addTest(unittest.makeSuite(TestDefaultController))
> > > unittest.TextTestRunner(verbosity=2).run(suite)
>
> > > python web2py.py -S pms -M -R
> > applications/pms/test/testDefaultController.py
> > > web2py Enterprise Web Framework
> > > Created by Massimo Di Pierro, Copyright 2007-2010
> > > Version 1.75.4 (2010-02-18 14:55:03)
> > > Database drivers available: SQLite3
> > > /home/thadeusb/web2py/applications/pms/modules/utils.py:16:
> > > DeprecationWarning: the md5 module is dep

Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Nicol van der Merwe
Super awesome, thanks!

On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  wrote:

> I'm going to write up a nice, clear wiki article on unit testing with
> the unittest module based on what I learned in this discussion. I'll
> be sure to link to it here when it's done.
>
>
> On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
> > Hi guys
> >
> > This stuff is very interesting. I would like to request, if possible,
> that
> > someone makes a web2pyslice or proper AlterEgo entry on how to setup and
> run
> > these kinds of tests for web2py. I am very interested in setting up tests
> > for my application but I'm a bit lost as I've never done so before (plus
> I'm
> > unfortunately just too busy to research all this and make my own slice).
> >
> > It would be very much appreciated if this can be done :)
> >
> > Nicolaas
> >
> > On Thu, Feb 25, 2010 at 5:35 AM, spiffytech 
> wrote:
> > > Thanks! Interesting article! My test cases now execute. However, I
> > > have a couple new questions, including a problem accessing the db in
> > > my controller.
> >
> > > I modified my test file as AlterEgo 213 indicates so my unit tests can
> > > access the controller's functions. Here is my updated test file:
> >
> > > ==
> > > #!/usr/bin/python
> > > import sys
> > > import unittest
> >
> > > from gluon.shell import exec_environment
> > > from gluon.globals import Request, Response, Session
> > > from gluon.storage import Storage
> >
> > > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> > > this script
> >
> > > class TestListActiveGames(unittest.TestCase):
> > >def setUp(self):
> > >self.request = Request()  # Use a clean Request
> > >self.controller = exec_environment('applications/api/
> > > controllers/10.py', request=self.request)
> >
> > >def testListActiveGames(self):
> > >self.request.post_vars["game_id"] = 1
> > >self.request.post_vars["username"] = "spiffytech"
> > >self.controller.list_active_games()
> >
> > > suite = unittest.TestSuite()
> > > suite.addTest(unittest.makeSuite(TestListActiveGames))
> > > unittest.TextTestRunner(verbosity=2).run(suite)
> > > ==
> >
> > > It is called with the command:
> >
> > > ==
> > > python web2py.py -S api -M -R applications/api/tests/test.py
> > > ==
> >
> > > The output is this:
> >
> > > ==
> > > web2py Enterprise Web Framework
> > > Created by Massimo Di Pierro, Copyright 2007-2010
> > > Version 1.75.4 (2010-02-18 20:57:56)
> > > Database drivers available: pysqlite2
> > > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
> >
> > > ==
> > > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
> > > --
> > > Traceback (most recent call last):
> > >  File "applications/api/tests/test.py", line 19, in
> > > testListActiveGames
> > >self.controller.list_active_games()
> > >  File "applications/api/controllers/10.py", line 47, in
> > > list_active_games
> > >games = db(((db.game.user1==username)|(db.game.user2==username)) &
> > > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> > > db.game.id, db.game.turn_number).as_list()
> > > NameError: global name 'db' is not defined
> >
> > > --
> > > Ran 1 test in 0.008s
> >
> > > FAILED (errors=1)
> > > ==
> >
> > > Questions:
> > > 1) How can I get my controller to see the database?
> > > 2) Am I simply doing something very wrong? I would expect the web2py "-
> > > S" option to set up the environment, complete with my controller's
> > > functions, and Request/Storage/Response objects available for
> > > instantiation. However, several posts on the mailing list indicate
> > > that I need to run exec_enviroment() for access to my controllers.
> > > Also, the Request/Storage/Response objects don't seem to exist in the
> > > shell.
> >
> > > On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
> > > > Replacing the way you run test suites helps. Instead of using .main()
> > > > add them manually.
> >
> > > > I would suggest reading the following article, as it includes methods
> > > > to aggregate your test suites together.
> >
> > > >
> http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
> >
> > > > import sys
> > > > sys.argv = sys.argv[5:]
> >
> > > > import unittest
> >
> > > > class TestDefaultController(unittest.TestCase):
> >
> > > > def testPrintStatement(self):
> > > > print "This line should print"
> > > > def testDatabaseRecordCount(self):
> > > > print "Records in database --- ", db(db.auth_user.id
> >0).count()
> >
> > > > suite = unittest.TestSuite()
> > > > suite.addTest(unittest.makeSuite(TestDefaultController))
> > > > unittest.TextTestRunner(verbosity=2).run(suite)
> >
> > > > python web2py.py -S pms -M -R
> > 

[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
execfile() did the trick! Things are working nicely now.

Using a test database would be very helpful. How do you recommend
setting one up? Do I need to copy/paste the table/field definitions
from the 'db' object, or is there a way to make a copy of the 'db'
object and point it to a different SQLite file?


On Feb 24, 10:54 pm, Thadeus Burgess  wrote:
> The unit test already has access to web2py environment (and db or
> anything else in your models). ``exec_environment`` just recreates a
> blank environment, when executing your controller it executes it
> outside of the current global scope.
>
> Instead of running exec_environment on your controller, run
> ``execfile('/path/to/file', globals())``. This way the controller is
> executed in the current environment instead of a new one.
>
> The objects for Request Storage and Response don't exist even to your
> web2py app, you always have to import them if you are using them. So
> if you wanted to use Storage even in your models you would need an
> "from gluon.storage import Storage" somewhere.
>
> Do you want your unit tests to work on your actual database? Usually I
> define a test.sqlite database that has
> nothing in it, and during my tests gets data inserted, altered, and
> then removed at the end of the tests.
>
> -Thadeus
>
> On Wed, Feb 24, 2010 at 9:35 PM, spiffytech  wrote:
> > Thanks! Interesting article! My test cases now execute. However, I
> > have a couple new questions, including a problem accessing the db in
> > my controller.
>
> > I modified my test file as AlterEgo 213 indicates so my unit tests can
> > access the controller's functions. Here is my updated test file:
>
> > ==
> > #!/usr/bin/python
> > import sys
> > import unittest
>
> > from gluon.shell import exec_environment
> > from gluon.globals import Request, Response, Session
> > from gluon.storage import Storage
>
> > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> > this script
>
> > class TestListActiveGames(unittest.TestCase):
> >    def setUp(self):
> >        self.request = Request()  # Use a clean Request
> >        self.controller = exec_environment('applications/api/
> > controllers/10.py', request=self.request)
>
> >    def testListActiveGames(self):
> >        self.request.post_vars["game_id"] = 1
> >        self.request.post_vars["username"] = "spiffytech"
> >        self.controller.list_active_games()
>
> > suite = unittest.TestSuite()
> > suite.addTest(unittest.makeSuite(TestListActiveGames))
> > unittest.TextTestRunner(verbosity=2).run(suite)
> > ==
>
> > It is called with the command:
>
> > ==
> > python web2py.py -S api -M -R applications/api/tests/test.py
> > ==
>
> > The output is this:
>
> > ==
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.75.4 (2010-02-18 20:57:56)
> > Database drivers available: pysqlite2
> > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>
> > ==
> > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
> > --
> > Traceback (most recent call last):
> >  File "applications/api/tests/test.py", line 19, in
> > testListActiveGames
> >    self.controller.list_active_games()
> >  File "applications/api/controllers/10.py", line 47, in
> > list_active_games
> >    games = db(((db.game.user1==username)|(db.game.user2==username)) &
> > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> > db.game.id, db.game.turn_number).as_list()
> > NameError: global name 'db' is not defined
>
> > --
> > Ran 1 test in 0.008s
>
> > FAILED (errors=1)
> > ==
>
> > Questions:
> > 1) How can I get my controller to see the database?
> > 2) Am I simply doing something very wrong? I would expect the web2py "-
> > S" option to set up the environment, complete with my controller's
> > functions, and Request/Storage/Response objects available for
> > instantiation. However, several posts on the mailing list indicate
> > that I need to run exec_enviroment() for access to my controllers.
> > Also, the Request/Storage/Response objects don't seem to exist in the
> > shell.
>
> > On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
> >> Replacing the way you run test suites helps. Instead of using .main()
> >> add them manually.
>
> >> I would suggest reading the following article, as it includes methods
> >> to aggregate your test suites together.
>
> >>http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
>
> >> import sys
> >> sys.argv = sys.argv[5:]
>
> >> import unittest
>
> >> class TestDefaultController(unittest.TestCase):
>
> >>     def testPrintStatement(self):
> >>         print "This line should print"
> >>     def testDatabaseRecordCount(self):
> >>         print "Records in da

Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Tiago Almeida
I concur. Thanks :)


On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe
wrote:

> Super awesome, thanks!
>
>
> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  wrote:
>
>> I'm going to write up a nice, clear wiki article on unit testing with
>> the unittest module based on what I learned in this discussion. I'll
>> be sure to link to it here when it's done.
>>
>>
>> On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
>> > Hi guys
>> >
>> > This stuff is very interesting. I would like to request, if possible,
>> that
>> > someone makes a web2pyslice or proper AlterEgo entry on how to setup and
>> run
>> > these kinds of tests for web2py. I am very interested in setting up
>> tests
>> > for my application but I'm a bit lost as I've never done so before (plus
>> I'm
>> > unfortunately just too busy to research all this and make my own slice).
>> >
>> > It would be very much appreciated if this can be done :)
>> >
>> > Nicolaas
>> >
>> > On Thu, Feb 25, 2010 at 5:35 AM, spiffytech 
>> wrote:
>> > > Thanks! Interesting article! My test cases now execute. However, I
>> > > have a couple new questions, including a problem accessing the db in
>> > > my controller.
>> >
>> > > I modified my test file as AlterEgo 213 indicates so my unit tests can
>> > > access the controller's functions. Here is my updated test file:
>> >
>> > > ==
>> > > #!/usr/bin/python
>> > > import sys
>> > > import unittest
>> >
>> > > from gluon.shell import exec_environment
>> > > from gluon.globals import Request, Response, Session
>> > > from gluon.storage import Storage
>> >
>> > > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
>> > > this script
>> >
>> > > class TestListActiveGames(unittest.TestCase):
>> > >def setUp(self):
>> > >self.request = Request()  # Use a clean Request
>> > >self.controller = exec_environment('applications/api/
>> > > controllers/10.py', request=self.request)
>> >
>> > >def testListActiveGames(self):
>> > >self.request.post_vars["game_id"] = 1
>> > >self.request.post_vars["username"] = "spiffytech"
>> > >self.controller.list_active_games()
>> >
>> > > suite = unittest.TestSuite()
>> > > suite.addTest(unittest.makeSuite(TestListActiveGames))
>> > > unittest.TextTestRunner(verbosity=2).run(suite)
>> > > ==
>> >
>> > > It is called with the command:
>> >
>> > > ==
>> > > python web2py.py -S api -M -R applications/api/tests/test.py
>> > > ==
>> >
>> > > The output is this:
>> >
>> > > ==
>> > > web2py Enterprise Web Framework
>> > > Created by Massimo Di Pierro, Copyright 2007-2010
>> > > Version 1.75.4 (2010-02-18 20:57:56)
>> > > Database drivers available: pysqlite2
>> > > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>> >
>> > > ==
>> > > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
>> > > --
>> > > Traceback (most recent call last):
>> > >  File "applications/api/tests/test.py", line 19, in
>> > > testListActiveGames
>> > >self.controller.list_active_games()
>> > >  File "applications/api/controllers/10.py", line 47, in
>> > > list_active_games
>> > >games = db(((db.game.user1==username)|(db.game.user2==username)) &
>> > > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
>> > > db.game.id, db.game.turn_number).as_list()
>> > > NameError: global name 'db' is not defined
>> >
>> > > --
>> > > Ran 1 test in 0.008s
>> >
>> > > FAILED (errors=1)
>> > > ==
>> >
>> > > Questions:
>> > > 1) How can I get my controller to see the database?
>> > > 2) Am I simply doing something very wrong? I would expect the web2py
>> "-
>> > > S" option to set up the environment, complete with my controller's
>> > > functions, and Request/Storage/Response objects available for
>> > > instantiation. However, several posts on the mailing list indicate
>> > > that I need to run exec_enviroment() for access to my controllers.
>> > > Also, the Request/Storage/Response objects don't seem to exist in the
>> > > shell.
>> >
>> > > On Feb 24, 2:52 pm, Thadeus Burgess  wrote:
>> > > > Replacing the way you run test suites helps. Instead of using
>> .main()
>> > > > add them manually.
>> >
>> > > > I would suggest reading the following article, as it includes
>> methods
>> > > > to aggregate your test suites together.
>> >
>> > > >
>> http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
>> >
>> > > > import sys
>> > > > sys.argv = sys.argv[5:]
>> >
>> > > > import unittest
>> >
>> > > > class TestDefaultController(unittest.TestCase):
>> >
>> > > > def testPrintStatement(self):
>> > > > print "This line should print"
>> > > > def testDatabaseRecordCount(self):
>> > > > print "Records in database --- ", db(db.auth_use

[web2py] Re: Plugin system status

2010-02-25 Thread mr.freeze
A simple approach would be to adopt the naming convention
'plugin_object' for any objects the developer wants to expose to the
plugin system then just create global labels:

>>>class Plugins(object):
>>>def __init__(self,globals,**kargs):
>>>for k,v in kargs.items():
>>>globals['plugin_'+k] = v

>>> db = DAL('...') #this is my mission critical data
>>> db2 = DAL('...') #this is for my plugins to use
>>> plugins = Plugins(globals(),db=db2,auth=auth,crud=crud)

This would expose to the plugin developer:
plugin_db,plugin_auth,plugin_crud

This way app developers could control which objects are exposed to the
plugin system and plugin developers could set requirement for their
plugins.  This shouldn't break existing plugins either.


On Feb 24, 8:01 pm, mdipierro  wrote:
> This may be a good idea. What should go into plugins?
>
> On Feb 24, 10:41 am, Thadeus Burgess  wrote:
>
> > I also am in favor of a class based plugin system that works like crud/auth.
>
> > Plugins would not pollute your global namespace. And they would be 
> > configurable.
>
> > Though the loss is of having plugins with their own controllers since
> > the module would be the controller instead.
>
> > -Thadeus
>
> > On Wed, Feb 24, 2010 at 7:25 AM, mr.freeze  wrote:
> > > Alternately you could simply create another container class for
> > > plugins to use and pass the preferred DAL instance to it just like you
> > > can with auth and crud:
>
> > > db = DAL('...')
> > > db2 = DAL('...')
> > > auth = Auth(globals(),db)
> > > crud = Crud(globals(),db)
> > > plugins = Plugins(globals(),db2)
>
> > > This seems more consistent with how things currently work.  What do
> > > you think?
>
> > > On Feb 24, 5:40 am, "mr.freeze"  wrote:
> > >> Then no auth would mean no plugins.  What if an attribute was added to
> > >> DAL to let the user specify:
> > >> db = DAL('...')
> > >> db.plugin_db = True
>
> > >> Then create a global plugin_db object for the plugins to use. All
> > >> plugins could then assume:
> > >> db = plugin_db
> > >> or just use plugin_db directly
>
> > >> There may be a better way but the point is that it would be
> > >> configurable. Users could dedicate a separate DAL instance for their
> > >> plugins so they don't pollute databases containing important business
> > >> objects.
>
> > >> On Feb 23, 11:48 pm, mdipierro  wrote:
>
> > >> > what if plugins were to use auth.db ? they rely on auth anyway. Or
> > >> > should we relax that?
>
> > >> > On Feb 23, 11:32 pm, mdipierro  wrote:
>
> > >> > > OK but the I would call that variable db because that is what it is
> > >> > > called in welcome/models/db.py
>
> > >> > > On Feb 23, 11:25 pm, "mr.freeze"  wrote:
>
> > >> > > > I think the most  important thing is that users can install plugins
> > >> > > > without needing to modify the plugin. This would make upgrades a 
> > >> > > > real
> > >> > > > problem. I'm sure you've heard this all before but if the plugin
> > >> > > > system was initialized in some way by the user with their preferred
> > >> > > > instance of a DAL object then all plugins could use this.  
> > >> > > > Otherwise
> > >> > > > naming your DAL object anything other than db mean you can't use
> > >> > > > plugins. What do you think?
>
> > >> > > > On Feb 23, 11:18 pm, mdipierro  wrote:
>
> > >> > > > > when I said "yes" I mean current plugins assume it.
>
> > >> > > > > I agree we need a superstructure to manage conventions. Instead 
> > >> > > > > of a
> > >> > > > > new global vars, I would prefer that each plugins has its own
> > >> > > > > plugin__settings.db and users can customize each 
> > >> > > > > individual
> > >> > > > > plugin.
>
> > >> > > > > On Feb 23, 11:12 pm, "mr.freeze"  wrote:
>
> > >> > > > > > That still feels wrong to me. What about making a plugin_db 
> > >> > > > > > parameter
> > >> > > > > > in option_std.py for the database instance name you want to 
> > >> > > > > > use for
> > >> > > > > > the plugin subsystem?
>
> > >> > > > > > On Feb 23, 10:29 pm, mdipierro  wrote:
>
> > >> > > > > > > yes
>
> > >> > > > > > > On Feb 23, 10:18 pm, "mr.freeze"  
> > >> > > > > > > wrote:
>
> > >> > > > > > > > What about the second question? Is 'db' a required naming 
> > >> > > > > > > > convention
> > >> > > > > > > > for the plugin system?
>
> > >> > > > > > > > On Feb 23, 6:41 pm, mdipierro  
> > >> > > > > > > > wrote:
>
> > >> > > > > > > > > I think so. The only think is that we will build a super 
> > >> > > > > > > > > structure on
> > >> > > > > > > > > top of it for better management of plugins metadata.
>
> > >> > > > > > > > > Massimo
>
> > >> > > > > > > > > On Feb 23, 6:37 pm, "mr.freeze"  
> > >> > > > > > > > > wrote:
>
> > >> > > > > > > > > > Is the plugin system considered backwards compatible 
> > >> > > > > > > > > > at this point? I
> > >> > > > > > > > > > am considering converting some modules into plugins 
> > >> > > > > > > > > > but want to know
> > >> > > > > > > > > > if they API is stable.
>
> > >>

[web2py] zen html

2010-02-25 Thread selecta
Sometimes you still have to write html in web2py which is annoying. It
might not be new to all of you but I just discovered zen html that
really speeds up the process.
In my example i customized the zen key to ctrl + z

What it does:

type
div.box
and you get

with you cursor in the middle of the divs ready to type :)

even better
table>tr*3>td
and you get












there are plugins for vim, emacs, textmate ...I love it, you might
too, check it out

here is a vid showing zen html
http://vimeo.com/7405114

and here the project
http://code.google.com/p/zen-coding/

I use http://www.vim.org/scripts/script.php?script_id=2981
just dropped the plugin into .vim/ftplugin/html/ and edited the
shortcut to something convenient
:)

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
Can I have cherokee uwsgi and apache mod_wsgi running on the same
web2py code base or should I make a copy so cherokee can execute it ?

You are right I could run cherokee on a non-standard port for testing
and always switch it over when I am happy with it!

-Thadeus





On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
 wrote:
> @Thadeus
>
> For me, it was a breeze to switch from Apache to Cherokee. I was happy
> with Apache too, but I used the fact that a client wanted Cherokee as
> an opportunity to give it a try, and I am glad I did :) Besides, it is
> not like you would have to remove Apache to use Cherokee, so what are
> you waiting for (besides possibly a free hour), give it a try!
>
> @mr.freeze and everyone else
>
> This guide has been posted at 
> http://www.web2pyslices.com/main/slices/take_slice/64
> and will appear on graymattercomputing.net in the near future.
>
> On Feb 24, 6:05 am, "mr.freeze"  wrote:
>> This is really helpful. Unfortunately, it will be lost on this mailing
>> list in a month or so.  Care to make a 
>> slice?http://www.web2pyslices.com/main/default/index
>>
>> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>>
>>
>>
>> > web2py with Cherokee viauWSGI: a simple, easy guide
>> > (written specifically for Ubuntu, but applicable to all systems)
>> > By: Evan Gray - GrayMatterComputing
>>
>> > 1) web2py
>> >  a) Download web2py (found at web2py.com)
>> >   i) Install python, if not present: sudo apt-get install python
>> >  b) Unzip (to /var/web2py)
>> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
>> >  d) Verify that it functions properly (by visiting localhost:8000),
>> > then close the server (Ctrl+C in terminal)
>> >  e) Allow server permission to web2py: sudo chown -hR www-data\: /var/
>> > web2py
>> >   i) Where "www-data" is Cherokee's effective user (www-data is the
>> > default)
>>
>> > 2)uWSGI
>> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
>> >  b) Unpackage wherever and cd into folder
>> >   i) Install dependencies for make, if not present: sudo apt-get
>> > install python-dev libxml2-dev
>> >  c) Makeuwsgi: sudo make -f Makefile.Py26
>> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
>> >  e) Create config.xml: sudo cat > /var/web2py/config.xml
>> > 
>> >     /var/web2py/
>> >     
>> >     wsgihandler
>> >     
>> > 
>> > [PRESS ENTER]
>> > [PRESS CTRL+D]
>>
>> > 3) Cherokee
>> >  a) Install Cherokee (follow the instructions at cherokee-project.org)
>> >   i) Note: I highly recommend using the PPA method so you can be sure
>> > to have the latest version and no issues!
>> >  b) Run cherokee-admin: sudo cherokee-admin
>> >  c) Visit admin console (via browser, password is shown in terminal):
>> > localhost:9090
>> >  d) Go to Virtual Servers, click Wizards, click Platforms, clickuWSGI
>> >   i)   New Host Name: web2py
>> >   ii)  Document Root: /var/web2py
>> >   iii) Configuration File: /var/web2py/config.xml
>> >   iv)  Same logs as vserver: default(combined)
>> >   v)   Submit
>> >  e) Go to Virtual Servers, click default
>> >   i) Under "Basics", Virtual Server Nickname: original
>> >  f) Go to Virtual Servers, click web2py
>> >   i)  Under "Basics", Virtual Server Nickname: default
>> >   ii) Under "Logging", verify all logging is correct (matches
>> > original)
>> >  g) Go to Virtual Servers
>> >   i) Set original Active to OFF
>>
>> > 4) Visit localhost (or your.ip.add.ress from another computer) to view
>> > your web2py site! :D
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: How to deploy my first app

2010-02-25 Thread Al
Brian,

Finally I found the mistake which causes all this trouble in accessing
the non-admin pages, I had the following line in the default.py in
myapp:
return dict(form=form, images=images, admin = admin)


On Feb 22, 6:11 am, Brian M  wrote:
> Al,
>
> I setup a stunnel server on Win7 which also had web2py's native server
> running on it. Then I setup a stunnel client on a Linux VM.
>
> In Stunnel Server's stunnel.conf:
> [web2py]
> accept = 8443
> connect = localhost:8000
>
> In Stunnel Client's stunnel.conf:
> ; Use it for client mode
> client = yes
> [web2py]
> accept = 8443
> connect = server_ip:8443
>
> Visitinghttp://server_ip:8443/myappbrought up the web2py application
> as expected, no prompts for the admin password - same as if I'd
> visitedhttp://server_ip:8000. Attempting to access the admin pages or
> to view a ticket brought up the admin password prompt (as it should)
> and I was able to use web2py's admin from the remote computer just
> fine without https (because web2py thought I was on localhost thanks
> to stunnel).
>
> I think the problem you're having on theMacwith "inetd mode must
> define a remote host or an executable " is due to trying to use the
> "stunnel" command (which is likely really stunnel3) instead of
> "stunnel4" at the command line. I found that I got the same error on
> linux.
>
> ~Brian
>
> On Feb 20, 11:31 pm, Brian M  wrote:
>
> > Al,
>
> > Yes, stunnel needs both a client and a server. The general public
> > should not need to use a stunnel connection to access your web2py
> > application though - they should just be using good 
> > oldhttp://your_server.com.
> > My suggestion was that *you* could use stunnel when you need to get
> > remote access to the web2py admin screens.
>
> > Port redirection/forwarding ofhttp://server_ip:8443tohttp://server_ip:8000
> > (or 80 whatever port web2py is actually listening on) from the outside
> > probably wouldn't accomplish the goal of being able to access web2py's
> > admin withoutSSL- web2py will only allow non-SSLadmin if the
> > connection comes from localhost and even with port redirection you
> > would not be connection from localhost.
>
> > So you can't accesshttp://server_ip/myfirstappoverstunnel without
> > getting the prompt for the admin password? That doesn't make sense.
> > Web2py should be behaving exactly the same whether or not you're using
> > stunnel. What do you get when you do put in the admin password? Do you
> > get your app or do you get the admin screen?
>
> > Sorry, can't help with theMacthing - don't have aMac.
>
> > ~Brian
>
> > On Feb 18, 11:09 am, Al  wrote:
>
> > > Brian,
>
> > > Thank you for your detailed instructions. I managed to get stunnel
> > > working, though it is a lot more complicated than I thought
> > > originally. On the windows server, the stunnel.conf file is setup as
> > > server mode and redirect port 8443 to 8000. On the client side, I also
> > > have to set up another stunnel as client mode and redirect
> > > 127.0.0.1:80 to 192.168.1.11 - server's IP address. As this server
> > > will be facing public, I cannot expect people to set up stunnel in
> > > their machine in order to access my website. I was expecting a tool
> > > which runs on the server side to do port redirection, and then when I
> > > type inhttp://server_ip:8443fromanothermachine, it will route me
> > > to my target app. (note: I did NOT set up anySSLcertificate to get
> > > stunnel working)
>
> > > Also with stunnel, I still cannot access the target app without
> > > entering the admin password, I cannot find any response.menu_auth to
> > > remove.
>
> > > I also have anothermacwhich I tried to set up stunnel, but when I
> > > run sudo stunnel3 I got the following error:
> > > anyone familiar withmaccan give some tips on how to solve this:
>
> > > inetd mode must define a remote host or an executable
>
> > > Cheers
> > > Al
> > > On Feb 12, 8:09 am, Brian M  wrote:
>
> > > > Al,
>
> > > > You'd want to get rid of the "edit" " menu when you "Go Live" that's
> > > > just there as a convenience while you're creating things.  Just use
> > > > this (or remove response.menu_edit from menu.py which does it once &
> > > > for all):
> > > >     response.menu_edit = None
> > > > If you don't want auth menu either do
> > > >     response.menu_auth = None
>
> > > > If you want to use the built-in server and be able to access on both
> > > > port 80 and port 443 (SSL) without running two web2py server instances
> > > > you could perhaps use a tunnel program likestunnel(www.stunnel.org).
> > > > Set it up to listen on port 443 (or really any port) and re-direct to
> > > > localhost:80. This way you should be able to get at admin and tickets
> > > > - as far as web2py is concerned you're accessing from the local
> > > > machine so tickets should work, but because it's tunneled it's also
> > > > secured as it goes to your remote computer.
>
> > > > To get the general user to automatically go tohttp://myserver/myfirstapp
> > > > w

Re: [web2py] newly created app fails in shell mode in 1.75.4

2010-02-25 Thread Thadeus Burgess
Permission error when running in shell mode?

-Thadeus





On Thu, Feb 25, 2010 at 5:47 AM, DenesL  wrote:
> Using 1.75.4, a newly created app fails to start in shell mode (-M -N -
> S) with:
>
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.75.4 (2010-02-18 14:55:03)
> Database drivers available: pysqlite2, MSSQL/DB2
> Traceback (most recent call last):
>  File "C:\web2py\hg\gluon\restricted.py", line 173, in restricted
>    exec ccode in environment
>  File "applications\test2\models/db.py", line 15, in 
>    db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> other DB
>  File "C:\web2py\hg\gluon\sql.py", line 3769, in DAL
>    db_codec=db_codec, check_reserved=check_reserved)
>  File "C:\web2py\hg\gluon\sql.py", line 889, in __init__
>    self._pool_connection(lambda : sqlite3.Connection(dbpath,
>  File "C:\web2py\hg\gluon\sql.py", line 829, in _pool_connection
>    self._connection = f()
>  File "C:\web2py\hg\gluon\sql.py", line 890, in 
>    check_same_thread=False))
> OperationalError: unable to open database file
>
> until you use appadmin on it.
> This did not happen in 1.75.1 AFAIK.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: mail plain text message wrong charset

2010-02-25 Thread Thadeus Burgess
There might be an issue that web2py is encoding the email correctly,
however your SMTP server is re-coding this into its own encoding.

I use Google Apps to send all of my emails with my web2py instances. I
just checked some of the messages received and they are all encoded
"us-ascii".

Further investigation using a SMTP server that we manage ourselves
with (mt), all emails sent from this server are encoded utf-8.

This must not be a web2py issue but SMTP issue.  Google and the like
decide to recode all of their messages, and there might not be
anything that can be done about it besides using your own SMTP server.

-Thadeus





On Thu, Feb 25, 2010 at 7:12 AM, szimszon  wrote:
> I need utf-8 :)
>
> On febr. 25, 12:20, mdipierro  wrote:
>> Because               encoding="utf-8" is default. You have to figure
>> out what is the encoding you need.
>>
>> On Feb 25, 4:32 am, szimszon  wrote:
>>
>>
>>
>> > I tested it again,
>>
>> > I created a new scaffolding app with the admin interface then I
>> > changed:
>> > db.py:
>> >mail=Mail()                                  # mailer
>> >mail.settings.server='localhost:25'    # your SMTP server
>> >mail.settings.sender='pr...@localhost'         # your email
>>
>> > default.py (controller)
>> > def index():
>> >     """
>> >     example action using the internationalization operator T and flash
>> >     rendered by views/default/index.html or views/generic.html
>> >     """
>> >     response.flash = T('mailtest')
>> >     context=dict(name="Gipsz Jakab",
>> >                  addr="Szt. Erzsébet körút")
>> >     message=response.render('emailbody.txt', context)
>> >    mail.send(to="szimszon",
>> >               subject="test email",
>> >               message=message)
>>
>> >     return dict(message=T('Mailsent'))
>>
>> > made an emailbody.txt in views:
>> > emailbody.txt
>> > Üdvözlöm {{=name}}!
>>
>> > Címed: {{=addr}}
>>
>> > Ez egy teszt elektronikus levél.
>>
>> > Árvíztűrő tükörfúrógép!
>> > --
>>
>> > Then I navigate to the site to send myself a letter:
>>
>> > - cut -
>> > From pr...@localhost  Thu Feb 25 11:24:05 2010
>> > Return-Path: 
>> > X-Original-To: szimszon
>> > Delivered-To: szims...@x
>> > Received: from xxx (localhost [127.0.0.1])
>> >         by xxx (Postfix) with ESMTP id C542A31CBF
>> >         for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
>> > Content-Type: multipart/related;
>> > boundary="===1518445122=="
>> > MIME-Version: 1.0
>> > To: szims...@
>> > Subject: test email
>> > Message-Id: <20100225102405.c542a31...@xxx>
>> > Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
>> > From: pr...@localhost
>>
>> > --===1518445122==
>> > Content-Type: multipart/alternative;
>> > boundary="===1974471883=="
>> > MIME-Version: 1.0
>>
>> > --===1974471883==
>> > Content-Type: text/plain;charset="us-ascii"
>> > MIME-Version: 1.0
>> > Content-Transfer-Encoding: 8bit
>>
>> > Üdvözlöm Gipsz Jakab!
>>
>> > Címed: Szt. Erzsébet körút
>>
>> > Ez egy teszt elektronikus levél.
>>
>> > Árvíztűrő tükörfúrógép!
>>
>> > --===1974471883==--
>> > --===1518445122==--
>>
>> > - cut -
>>
>> >charset: us-ascii
>>
>> > If I changed the
>> >      mail.send(to="szimszon",
>> >               subject="test email",
>> >               message=message)
>>
>> > to
>> >    mail.send(to="szimszon",
>> >               subject="test email",
>> >               message=message,
>> >               encoding="utf-8")
>> > made no difference :(
>> > On febr. 23, 21:01, Thadeus Burgess  wrote:
>>
>> > > I am unable to replicate this.
>>
>> > > -Thadeus
>>
>> > > On Tue, Feb 23, 2010 at 1:59 PM, szimszon  wrote:
>> > > > No change:
>>
>> > > > --===2046819983==
>> > > > Content-Type: multipart/alternative;
>> > > > boundary="===1304182396=="
>> > > > MIME-Version: 1.0
>>
>> > > > --===1304182396==
>> > > > Content-Type: text/plain;charset="us-ascii"
>> > > > MIME-Version: 1.0
>> > > > Content-Transfer-Encoding: 7bit
>>
>> > > > On febr. 23, 20:47, Thadeus Burgess  wrote:
>> > > >> Have you tried
>>
>> > > >>mail.send(encoding='us-ascii') ?
>>
>> > > >> -Thadeus
>>
>> > > >> On Tue, Feb 23, 2010 at 1:33 PM, szimszon  wrote:
>> > > >> > Okay. I see...
>>
>> > > >> > The default is utf-8 and if I set it to utf-8 manually there is no
>> > > >> > difference. This is the generatedmailcontent :(  :
>>
>> > > >> > --===1981490134==
>> > > >> > Content-Type: multipart/alternative;
>> > > >> > boundary="===859693=="
>> > > >> > MIME-Version: 1.0
>>
>> > > >> > --===859693==
>> > > >> > Content-Type: text/plain;charset="us-ascii"
>> > > >> > MIME-Version: 1.0
>> > > >> > Content-Transfer-Encoding: 7bit
>>
>> > > >> > On febr. 23, 20:06, Thadeus Burgess  wrote:
>> > > >> >> Your looking in the wrong place.
>>
>> > > >> >> lines 172-182
>>
>> > > >> >> On line 181 is the en

[web2py] Re: How to deploy my first app

2010-02-25 Thread Al
Brian,

Finally I found the mistakes which causes all the troubles of
accessing the non-admin pages:

return dict(form=form, images=images, admin = admin)

I have the above line in the default.py controller, that why it keeps
asking for admin authentication even I tried to navigate the default
home page of myapp.

As for the Mac, what you mentioned was correct, I installed the
stunnel 4.27_0 package using macports, but the executables are in the /
opt/local/bin are called stunnel and stunnel3. Haven't got time to
solve this yet...

Cheers
Al

On Feb 22, 6:11 am, Brian M  wrote:
> Al,
>
> I setup a stunnel server on Win7 which also had web2py's native server
> running on it. Then I setup a stunnel client on a Linux VM.
>
> In Stunnel Server's stunnel.conf:
> [web2py]
> accept = 8443
> connect = localhost:8000
>
> In Stunnel Client's stunnel.conf:
> ; Use it for client mode
> client = yes
> [web2py]
> accept = 8443
> connect = server_ip:8443
>
> Visitinghttp://server_ip:8443/myappbrought up the web2py application
> as expected, no prompts for the admin password - same as if I'd
> visitedhttp://server_ip:8000. Attempting to access the admin pages or
> to view a ticket brought up the admin password prompt (as it should)
> and I was able to use web2py's admin from the remote computer just
> fine without https (because web2py thought I was on localhost thanks
> to stunnel).
>
> I think the problem you're having on the Mac with "inetd mode must
> define a remote host or an executable " is due to trying to use the
> "stunnel" command (which is likely really stunnel3) instead of
> "stunnel4" at the command line. I found that I got the same error on
> linux.
>
> ~Brian
>
> On Feb 20, 11:31 pm, Brian M  wrote:
>
> > Al,
>
> > Yes, stunnel needs both a client and a server. The general public
> > should not need to use a stunnel connection to access your web2py
> > application though - they should just be using good 
> > oldhttp://your_server.com.
> > My suggestion was that *you* could use stunnel when you need to get
> > remote access to the web2py admin screens.
>
> > Port redirection/forwarding ofhttp://server_ip:8443tohttp://server_ip:8000
> > (or 80 whatever port web2py is actually listening on) from the outside
> > probably wouldn't accomplish the goal of being able to access web2py's
> > admin without SSL - web2py will only allow non-SSL admin if the
> > connection comes from localhost and even with port redirection you
> > would not be connection from localhost.
>
> > So you can't accesshttp://server_ip/myfirstappoverstunnel without
> > getting the prompt for the admin password? That doesn't make sense.
> > Web2py should be behaving exactly the same whether or not you're using
> > stunnel. What do you get when you do put in the admin password? Do you
> > get your app or do you get the admin screen?
>
> > Sorry, can't help with the Mac thing - don't have a Mac.
>
> > ~Brian
>
> > On Feb 18, 11:09 am, Al  wrote:
>
> > > Brian,
>
> > > Thank you for your detailed instructions. I managed to get stunnel
> > > working, though it is a lot more complicated than I thought
> > > originally. On the windows server, the stunnel.conf file is setup as
> > > server mode and redirect port 8443 to 8000. On the client side, I also
> > > have to set up another stunnel as client mode and redirect
> > > 127.0.0.1:80 to 192.168.1.11 - server's IP address. As this server
> > > will be facing public, I cannot expect people to set up stunnel in
> > > their machine in order to access my website. I was expecting a tool
> > > which runs on the server side to do port redirection, and then when I
> > > type inhttp://server_ip:8443fromanothermachine, it will route me
> > > to my target app. (note: I did NOT set up any SSL certificate to get
> > > stunnel working)
>
> > > Also with stunnel, I still cannot access the target app without
> > > entering the admin password, I cannot find any response.menu_auth to
> > > remove.
>
> > > I also have another mac which I tried to set up stunnel, but when I
> > > run sudo stunnel3 I got the following error:
> > > anyone familiar with mac can give some tips on how to solve this:
>
> > > inetd mode must define a remote host or an executable
>
> > > Cheers
> > > Al
> > > On Feb 12, 8:09 am, Brian M  wrote:
>
> > > > Al,
>
> > > > You'd want to get rid of the "edit" " menu when you "Go Live" that's
> > > > just there as a convenience while you're creating things.  Just use
> > > > this (or remove response.menu_edit from menu.py which does it once &
> > > > for all):
> > > >     response.menu_edit = None
> > > > If you don't want auth menu either do
> > > >     response.menu_auth = None
>
> > > > If you want to use the built-in server and be able to access on both
> > > > port 80 and port 443 (SSL) without running two web2py server instances
> > > > you could perhaps use a tunnel program likestunnel(www.stunnel.org).
> > > > Set it up to listen on port 443 (or really any port) and re-direct to
> > > > localho

Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Thadeus Burgess
So the easiest way to use a testing db and your existing tables is to
automatically recreate them.

So assuming you are in the web2py environment and have access to ``db``

>>> test_db = DAL('testing.sqlite')

>>> for tablename in db.tables:
>>>   table_copy = [copy.copy(f) for f in db[tablename]]
>>>   test_db.define_table(tablename, *table_copy)

This will create a new testing sqlite database. Then it will go
through all tables defined in db, then copy their fields to a list,
then it will define a new table in the sqlite with the copied fields.

Now any functions that you might want to unit test might rely on your
``db`` object, which could be an issue depending on how you have your
code structured.

-Thadeus





On Thu, Feb 25, 2010 at 8:02 AM, Tiago Almeida
 wrote:
> I concur. Thanks :)
>
>
> On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe 
> wrote:
>>
>> Super awesome, thanks!
>>
>> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  wrote:
>>>
>>> I'm going to write up a nice, clear wiki article on unit testing with
>>> the unittest module based on what I learned in this discussion. I'll
>>> be sure to link to it here when it's done.
>>>
>>>
>>> On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
>>> > Hi guys
>>> >
>>> > This stuff is very interesting. I would like to request, if possible,
>>> > that
>>> > someone makes a web2pyslice or proper AlterEgo entry on how to setup
>>> > and run
>>> > these kinds of tests for web2py. I am very interested in setting up
>>> > tests
>>> > for my application but I'm a bit lost as I've never done so before
>>> > (plus I'm
>>> > unfortunately just too busy to research all this and make my own
>>> > slice).
>>> >
>>> > It would be very much appreciated if this can be done :)
>>> >
>>> > Nicolaas
>>> >
>>> > On Thu, Feb 25, 2010 at 5:35 AM, spiffytech 
>>> > wrote:
>>> > > Thanks! Interesting article! My test cases now execute. However, I
>>> > > have a couple new questions, including a problem accessing the db in
>>> > > my controller.
>>> >
>>> > > I modified my test file as AlterEgo 213 indicates so my unit tests
>>> > > can
>>> > > access the controller's functions. Here is my updated test file:
>>> >
>>> > > ==
>>> > > #!/usr/bin/python
>>> > > import sys
>>> > > import unittest
>>> >
>>> > > from gluon.shell import exec_environment
>>> > > from gluon.globals import Request, Response, Session
>>> > > from gluon.storage import Storage
>>> >
>>> > > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
>>> > > this script
>>> >
>>> > > class TestListActiveGames(unittest.TestCase):
>>> > >    def setUp(self):
>>> > >        self.request = Request()  # Use a clean Request
>>> > >        self.controller = exec_environment('applications/api/
>>> > > controllers/10.py', request=self.request)
>>> >
>>> > >    def testListActiveGames(self):
>>> > >        self.request.post_vars["game_id"] = 1
>>> > >        self.request.post_vars["username"] = "spiffytech"
>>> > >        self.controller.list_active_games()
>>> >
>>> > > suite = unittest.TestSuite()
>>> > > suite.addTest(unittest.makeSuite(TestListActiveGames))
>>> > > unittest.TextTestRunner(verbosity=2).run(suite)
>>> > > ==
>>> >
>>> > > It is called with the command:
>>> >
>>> > > ==
>>> > > python web2py.py -S api -M -R applications/api/tests/test.py
>>> > > ==
>>> >
>>> > > The output is this:
>>> >
>>> > > ==
>>> > > web2py Enterprise Web Framework
>>> > > Created by Massimo Di Pierro, Copyright 2007-2010
>>> > > Version 1.75.4 (2010-02-18 20:57:56)
>>> > > Database drivers available: pysqlite2
>>> > > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>>> >
>>> > >
>>> > > ==
>>> > > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
>>> > >
>>> > > --
>>> > > Traceback (most recent call last):
>>> > >  File "applications/api/tests/test.py", line 19, in
>>> > > testListActiveGames
>>> > >    self.controller.list_active_games()
>>> > >  File "applications/api/controllers/10.py", line 47, in
>>> > > list_active_games
>>> > >    games = db(((db.game.user1==username)|(db.game.user2==username)) &
>>> > > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
>>> > > db.game.id, db.game.turn_number).as_list()
>>> > > NameError: global name 'db' is not defined
>>> >
>>> > >
>>> > > --
>>> > > Ran 1 test in 0.008s
>>> >
>>> > > FAILED (errors=1)
>>> > > ==
>>> >
>>> > > Questions:
>>> > > 1) How can I get my controller to see the database?
>>> > > 2) Am I simply doing something very wrong? I would expect the web2py
>>> > > "-
>>> > > S" option to set up the environment, complete with my controller's
>>> > > functions, and Request/Storage/Response objects available for
>>> > > instantiation. However, several pos

[web2py] Re: newly created app fails in shell mode in 1.75.4

2010-02-25 Thread DenesL


On Feb 25, 11:10 am, Thadeus Burgess  wrote:
> Permission error when running in shell mode?
>
Strange, huh?.
It happens on both WinXP and 2003 server.

And just clicking on 'database administration' in app's admin fixes
it.


-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Plugin system status

2010-02-25 Thread Thadeus Burgess
I can't stress enough. web2py plugins should be geared towards
developers, not end-users. (Someone who runs their own wordpress blog
would be an end-user of wordpress).

Plugins should be there to provide a standard for common functionality
so that everyone who comes along to web2py does not have to re-invent
the wheel. But still be flexible enough to suite 95% of developer
needs.

This means that plugins should be easy to insert into the system, but
because they need to be flexible, they will require programming to
make work.

I do not like the current plugin implementation because it does litter
web2py folders, plugins should be self contained, and you shouldn't
*have* to rely on "applications/admin" to install them for you. It is
just one of those nuances.

In every plugin system I have been researching, there is always a
"plugins" folder that the system auto-discovers what is in it, and
then activates them. This would make it easier to package and
distribute the plugins.

Though I have never seen a plugin system for a web framework, only for
applications that are devoted to one subject (wordpress, mephisto,
redmine, trac, etc). I guess django calls them "installed_apps" and
"middleware_classes".

But even with django "installed_apps"(plugins) they define their own
views, all you have to do is specify which view to render in your
functions... I suppose.

What are you trying to accomplish with plugins?

-Thadeus





On Thu, Feb 25, 2010 at 9:48 AM, mr.freeze  wrote:
> A simple approach would be to adopt the naming convention
> 'plugin_object' for any objects the developer wants to expose to the
> plugin system then just create global labels:
>
class Plugins(object):
    def __init__(self,globals,**kargs):
        for k,v in kargs.items():
            globals['plugin_'+k] = v
>
 db = DAL('...') #this is my mission critical data
 db2 = DAL('...') #this is for my plugins to use
 plugins = Plugins(globals(),db=db2,auth=auth,crud=crud)
>
> This would expose to the plugin developer:
> plugin_db,plugin_auth,plugin_crud
>
> This way app developers could control which objects are exposed to the
> plugin system and plugin developers could set requirement for their
> plugins.  This shouldn't break existing plugins either.
>
>
> On Feb 24, 8:01 pm, mdipierro  wrote:
>> This may be a good idea. What should go into plugins?
>>
>> On Feb 24, 10:41 am, Thadeus Burgess  wrote:
>>
>> > I also am in favor of a class based plugin system that works like 
>> > crud/auth.
>>
>> > Plugins would not pollute your global namespace. And they would be 
>> > configurable.
>>
>> > Though the loss is of having plugins with their own controllers since
>> > the module would be the controller instead.
>>
>> > -Thadeus
>>
>> > On Wed, Feb 24, 2010 at 7:25 AM, mr.freeze  wrote:
>> > > Alternately you could simply create another container class for
>> > > plugins to use and pass the preferred DAL instance to it just like you
>> > > can with auth and crud:
>>
>> > > db = DAL('...')
>> > > db2 = DAL('...')
>> > > auth = Auth(globals(),db)
>> > > crud = Crud(globals(),db)
>> > > plugins = Plugins(globals(),db2)
>>
>> > > This seems more consistent with how things currently work.  What do
>> > > you think?
>>
>> > > On Feb 24, 5:40 am, "mr.freeze"  wrote:
>> > >> Then no auth would mean no plugins.  What if an attribute was added to
>> > >> DAL to let the user specify:
>> > >> db = DAL('...')
>> > >> db.plugin_db = True
>>
>> > >> Then create a global plugin_db object for the plugins to use. All
>> > >> plugins could then assume:
>> > >> db = plugin_db
>> > >> or just use plugin_db directly
>>
>> > >> There may be a better way but the point is that it would be
>> > >> configurable. Users could dedicate a separate DAL instance for their
>> > >> plugins so they don't pollute databases containing important business
>> > >> objects.
>>
>> > >> On Feb 23, 11:48 pm, mdipierro  wrote:
>>
>> > >> > what if plugins were to use auth.db ? they rely on auth anyway. Or
>> > >> > should we relax that?
>>
>> > >> > On Feb 23, 11:32 pm, mdipierro  wrote:
>>
>> > >> > > OK but the I would call that variable db because that is what it is
>> > >> > > called in welcome/models/db.py
>>
>> > >> > > On Feb 23, 11:25 pm, "mr.freeze"  wrote:
>>
>> > >> > > > I think the most  important thing is that users can install 
>> > >> > > > plugins
>> > >> > > > without needing to modify the plugin. This would make upgrades a 
>> > >> > > > real
>> > >> > > > problem. I'm sure you've heard this all before but if the plugin
>> > >> > > > system was initialized in some way by the user with their 
>> > >> > > > preferred
>> > >> > > > instance of a DAL object then all plugins could use this.  
>> > >> > > > Otherwise
>> > >> > > > naming your DAL object anything other than db mean you can't use
>> > >> > > > plugins. What do you think?
>>
>> > >> > > > On Feb 23, 11:18 pm, mdipierro  wrote:
>>
>> > >> > > > > when I said "yes" I mean current plugins ass

Re: [web2py] Re: newly created app fails in shell mode in 1.75.4

2010-02-25 Thread Thadeus Burgess
thats odd.

Yeah It seems like the shell doesn't have "create" access but it does
have "write" access. And web2py has both "create and write" access.

-Thadeus





On Thu, Feb 25, 2010 at 10:36 AM, DenesL  wrote:
>
>
> On Feb 25, 11:10 am, Thadeus Burgess  wrote:
>> Permission error when running in shell mode?
>>
> Strange, huh?.
> It happens on both WinXP and 2003 server.
>
> And just clicking on 'database administration' in app's admin fixes
> it.
> 
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
Works great! I added an "import copy" in db.py, and added a line in my
unit test to rename "test_db" to "db" so that functions in the test
script will use the test DB.

For posterity, here is a complete working example of unit tests with
web2py, with access to the database, using test database. The wiki
article I create will explain each piece and why it's needed.

== To run the unit tests, type this on the command line: ==
python web2py.py -S api -M -R applications/api/controllers/test.py  #
Fill in your own values for the test file and controller name


== applications/api/controllers/test.py ==
#!/usr/bin/python
import sys
import unittest

from gluon.globals import Request  # So we can reset the request for
each test

sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
this script

db = test_db  # Rename the test database so that functions will use it
instead of the real database
execfile("applications/api/controllers/10.py", globals())  # Brings
the controller's functions into this script's scope

class TestListActiveGames(unittest.TestCase):
def setUp(self):
request = Request()  # Use a clean request

def testListActiveGames(self):
# Set variables for the test function
request.post_vars["game_id"] = 1
request.post_vars["username"] = "spiffytech"

# Call a function from the controller "10.py" and print the
dictionary it returns
resp = list_active_games()
print resp
self.assertEquals(0, len(resp["games"]))

# Manually specify tests to run; the web2py environment breaks
unittest.main()
# Taken from here: 
http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestListActiveGames))
unittest.TextTestRunner(verbosity=2).run(suite)

db(db.game.id>0).delete()  # Empty out the test database so it's fresh
for next time
==

== Added to the bottom of applications/api/models/db.py ==
# Create a test database that's laid out just like the "real" database
import copy
test_db = DAL('sqlite://testing.sqlite')  # DB name and location
for tablename in db.tables:  # Copy tables!
table_copy = [copy.copy(f) for f in db[tablename]]
test_db.define_table(tablename, *table_copy)

===


On Feb 25, 11:36 am, Thadeus Burgess  wrote:
> So the easiest way to use a testing db and your existing tables is to
> automatically recreate them.
>
> So assuming you are in the web2py environment and have access to ``db``
>
> >>> test_db = DAL('testing.sqlite')
> >>> for tablename in db.tables:
> >>>   table_copy = [copy.copy(f) for f in db[tablename]]
> >>>   test_db.define_table(tablename, *table_copy)
>
> This will create a new testing sqlite database. Then it will go
> through all tables defined in db, then copy their fields to a list,
> then it will define a new table in the sqlite with the copied fields.
>
> Now any functions that you might want to unit test might rely on your
> ``db`` object, which could be an issue depending on how you have your
> code structured.
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 8:02 AM, Tiago Almeida
>
>  wrote:
> > I concur. Thanks :)
>
> > On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe 
> > wrote:
>
> >> Super awesome, thanks!
>
> >> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  wrote:
>
> >>> I'm going to write up a nice, clear wiki article on unit testing with
> >>> the unittest module based on what I learned in this discussion. I'll
> >>> be sure to link to it here when it's done.
>
> >>> On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
> >>> > Hi guys
>
> >>> > This stuff is very interesting. I would like to request, if possible,
> >>> > that
> >>> > someone makes a web2pyslice or proper AlterEgo entry on how to setup
> >>> > and run
> >>> > these kinds of tests for web2py. I am very interested in setting up
> >>> > tests
> >>> > for my application but I'm a bit lost as I've never done so before
> >>> > (plus I'm
> >>> > unfortunately just too busy to research all this and make my own
> >>> > slice).
>
> >>> > It would be very much appreciated if this can be done :)
>
> >>> > Nicolaas
>
> >>> > On Thu, Feb 25, 2010 at 5:35 AM, spiffytech 
> >>> > wrote:
> >>> > > Thanks! Interesting article! My test cases now execute. However, I
> >>> > > have a couple new questions, including a problem accessing the db in
> >>> > > my controller.
>
> >>> > > I modified my test file as AlterEgo 213 indicates so my unit tests
> >>> > > can
> >>> > > access the controller's functions. Here is my updated test file:
>
> >>> > > ==
> >>> > > #!/usr/bin/python
> >>> > > import sys
> >>> > > import unittest
>
> >>> > > from gluon.shell import exec_environment
> >>> > > from gluon.globals import Request, Response, Session
> >>> > > from gluon.storage import Storage
>
> >>> > 

[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
Last question: Is there any value in having web2py.py pass scripts the
full command line (sys.argv)? If not, would you be open to a patch to
gluon/shell.py so that it only passes the script's filename and any
CLI variables shell.py didn't use? I'd also appreciate suggestions on
how to do that more reliably than sys.argv[5:].


On Feb 25, 11:36 am, Thadeus Burgess  wrote:
> So the easiest way to use a testing db and your existing tables is to
> automatically recreate them.
>
> So assuming you are in the web2py environment and have access to ``db``
>
> >>> test_db = DAL('testing.sqlite')
> >>> for tablename in db.tables:
> >>>   table_copy = [copy.copy(f) for f in db[tablename]]
> >>>   test_db.define_table(tablename, *table_copy)
>
> This will create a new testing sqlite database. Then it will go
> through all tables defined in db, then copy their fields to a list,
> then it will define a new table in the sqlite with the copied fields.
>
> Now any functions that you might want to unit test might rely on your
> ``db`` object, which could be an issue depending on how you have your
> code structured.
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 8:02 AM, Tiago Almeida
>
>  wrote:
> > I concur. Thanks :)
>
> > On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe 
> > wrote:
>
> >> Super awesome, thanks!
>
> >> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  wrote:
>
> >>> I'm going to write up a nice, clear wiki article on unit testing with
> >>> the unittest module based on what I learned in this discussion. I'll
> >>> be sure to link to it here when it's done.
>
> >>> On Feb 25, 4:20 am, Nicol van der Merwe  wrote:
> >>> > Hi guys
>
> >>> > This stuff is very interesting. I would like to request, if possible,
> >>> > that
> >>> > someone makes a web2pyslice or proper AlterEgo entry on how to setup
> >>> > and run
> >>> > these kinds of tests for web2py. I am very interested in setting up
> >>> > tests
> >>> > for my application but I'm a bit lost as I've never done so before
> >>> > (plus I'm
> >>> > unfortunately just too busy to research all this and make my own
> >>> > slice).
>
> >>> > It would be very much appreciated if this can be done :)
>
> >>> > Nicolaas
>
> >>> > On Thu, Feb 25, 2010 at 5:35 AM, spiffytech 
> >>> > wrote:
> >>> > > Thanks! Interesting article! My test cases now execute. However, I
> >>> > > have a couple new questions, including a problem accessing the db in
> >>> > > my controller.
>
> >>> > > I modified my test file as AlterEgo 213 indicates so my unit tests
> >>> > > can
> >>> > > access the controller's functions. Here is my updated test file:
>
> >>> > > ==
> >>> > > #!/usr/bin/python
> >>> > > import sys
> >>> > > import unittest
>
> >>> > > from gluon.shell import exec_environment
> >>> > > from gluon.globals import Request, Response, Session
> >>> > > from gluon.storage import Storage
>
> >>> > > sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> >>> > > this script
>
> >>> > > class TestListActiveGames(unittest.TestCase):
> >>> > >    def setUp(self):
> >>> > >        self.request = Request()  # Use a clean Request
> >>> > >        self.controller = exec_environment('applications/api/
> >>> > > controllers/10.py', request=self.request)
>
> >>> > >    def testListActiveGames(self):
> >>> > >        self.request.post_vars["game_id"] = 1
> >>> > >        self.request.post_vars["username"] = "spiffytech"
> >>> > >        self.controller.list_active_games()
>
> >>> > > suite = unittest.TestSuite()
> >>> > > suite.addTest(unittest.makeSuite(TestListActiveGames))
> >>> > > unittest.TextTestRunner(verbosity=2).run(suite)
> >>> > > ==
>
> >>> > > It is called with the command:
>
> >>> > > ==
> >>> > > python web2py.py -S api -M -R applications/api/tests/test.py
> >>> > > ==
>
> >>> > > The output is this:
>
> >>> > > ==
> >>> > > web2py Enterprise Web Framework
> >>> > > Created by Massimo Di Pierro, Copyright 2007-2010
> >>> > > Version 1.75.4 (2010-02-18 20:57:56)
> >>> > > Database drivers available: pysqlite2
> >>> > > testListActiveGames (__builtin__.TestListActiveGames) ... ERROR
>
> >>> > > ==
> >>> > > ERROR: testListActiveGames (__builtin__.TestListActiveGames)
>
> >>> > > --
> >>> > > Traceback (most recent call last):
> >>> > >  File "applications/api/tests/test.py", line 19, in
> >>> > > testListActiveGames
> >>> > >    self.controller.list_active_games()
> >>> > >  File "applications/api/controllers/10.py", line 47, in
> >>> > > list_active_games
> >>> > >    games = db(((db.game.user1==username)|(db.game.user2==username)) &
> >>> > > (db.game.victory==-2)).select(db.game.user1, db.game.user2,
> >>> > > db.game.id, db.game.turn_number).as_list()
> >>> > > NameError: global name 'db' is not defined
>
> >>> > > ---

Re: [web2py] Re: Plugin system status

2010-02-25 Thread Alexandre Andrade
>I fully agree that plugins should exist in
>their own folders

I defend it some time ago and still think it is a good idea

2010/2/25 mr.freeze 

> >>>What are you trying to accomplish with plugins?
> I'm trying to created packaged chunks of reusable code that are easily
> installed ,upgraded or removed by developers. I don't like the current
> implementation either. I fully agree that plugins should exist in
> their own folders (at the framework level,the shared application level
> and the application level) but Massimo doesn't seem to be willing to
> budge on this (possibly for good reason) and I would rather have a
> plugin system that sort of works than none at all.  I'm not completely
> sold on class based plugins just because I'm not sure how views would
> work (are they separate files or strings?). I'd rather that plugins
> were mini application with their own mvc folder stucture.
>
> The point of the Plugins class above would be to give a modicum of
> control developers as to the objects that are exposed to the current
> plugin system.
>
>
> On Feb 25, 10:58 am, Thadeus Burgess  wrote:
> > I can't stress enough. web2py plugins should be geared towards
> > developers, not end-users. (Someone who runs their own wordpress blog
> > would be an end-user of wordpress).
> >
> > Plugins should be there to provide a standard for common functionality
> > so that everyone who comes along to web2py does not have to re-invent
> > the wheel. But still be flexible enough to suite 95% of developer
> > needs.
> >
> > This means that plugins should be easy to insert into the system, but
> > because they need to be flexible, they will require programming to
> > make work.
> >
> > I do not like the current plugin implementation because it does litter
> > web2py folders, plugins should be self contained, and you shouldn't
> > *have* to rely on "applications/admin" to install them for you. It is
> > just one of those nuances.
> >
> > In every plugin system I have been researching, there is always a
> > "plugins" folder that the system auto-discovers what is in it, and
> > then activates them. This would make it easier to package and
> > distribute the plugins.
> >
> > Though I have never seen a plugin system for a web framework, only for
> > applications that are devoted to one subject (wordpress, mephisto,
> > redmine, trac, etc). I guess django calls them "installed_apps" and
> > "middleware_classes".
> >
> > But even with django "installed_apps"(plugins) they define their own
> > views, all you have to do is specify which view to render in your
> > functions... I suppose.
> >
> > What are you trying to accomplish with plugins?
> >
> > -Thadeus
> >
> > On Thu, Feb 25, 2010 at 9:48 AM, mr.freeze  wrote:
> > > A simple approach would be to adopt the naming convention
> > > 'plugin_object' for any objects the developer wants to expose to the
> > > plugin system then just create global labels:
> >
> > class Plugins(object):
> > def __init__(self,globals,**kargs):
> > for k,v in kargs.items():
> > globals['plugin_'+k] = v
> >
> >  db = DAL('...') #this is my mission critical data
> >  db2 = DAL('...') #this is for my plugins to use
> >  plugins = Plugins(globals(),db=db2,auth=auth,crud=crud)
> >
> > > This would expose to the plugin developer:
> > > plugin_db,plugin_auth,plugin_crud
> >
> > > This way app developers could control which objects are exposed to the
> > > plugin system and plugin developers could set requirement for their
> > > plugins.  This shouldn't break existing plugins either.
> >
> > > On Feb 24, 8:01 pm, mdipierro  wrote:
> > >> This may be a good idea. What should go into plugins?
> >
> > >> On Feb 24, 10:41 am, Thadeus Burgess  wrote:
> >
> > >> > I also am in favor of a class based plugin system that works like
> crud/auth.
> >
> > >> > Plugins would not pollute your global namespace. And they would be
> configurable.
> >
> > >> > Though the loss is of having plugins with their own controllers
> since
> > >> > the module would be the controller instead.
> >
> > >> > -Thadeus
> >
> > >> > On Wed, Feb 24, 2010 at 7:25 AM, mr.freeze 
> wrote:
> > >> > > Alternately you could simply create another container class for
> > >> > > plugins to use and pass the preferred DAL instance to it just like
> you
> > >> > > can with auth and crud:
> >
> > >> > > db = DAL('...')
> > >> > > db2 = DAL('...')
> > >> > > auth = Auth(globals(),db)
> > >> > > crud = Crud(globals(),db)
> > >> > > plugins = Plugins(globals(),db2)
> >
> > >> > > This seems more consistent with how things currently work.  What
> do
> > >> > > you think?
> >
> > >> > > On Feb 24, 5:40 am, "mr.freeze"  wrote:
> > >> > >> Then no auth would mean no plugins.  What if an attribute was
> added to
> > >> > >> DAL to let the user specify:
> > >> > >> db = DAL('...')
> > >> > >> db.plugin_db = True
> >
> > >> > >> Then create a global plugin_db object for the plugins to use. All
> > >> > >> plugins co

[web2py] Cuestion about jzip and jpg image?

2010-02-25 Thread drayco
Hi, web2py users,
I have a application with 6 web services with json in web2py.
I answer topological information every minute.
And my partners told me that the size of the answer is too large. They
told me that we need to use jzip.
The new requirements is that I need to give a jpg image too.

But I am a newbie in web application.

Can any of you give me a litle example with jzip?

And How can I put a jpg image in a web service?

Thank's in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Toggle on/off editarea on startup

2010-02-25 Thread Thadeus Burgess
So this patch allows you to disable EditArea javascript, this way you
can use Its All Text with the actual html textarea?

Is there a way to make it so that you have GUI access to this instead
of having to edit admin. Perhaps it can get this value from
request.get_vars. It would be a nuance if it were something you would
have to edit admin application automatically just to set the option to
"later".

I +1 this patch, since it looks to be a useful addition for those who
use the built-in editor.

-Thadeus





On Thu, Feb 25, 2010 at 1:04 PM, villas  wrote:
> Hi Alex,
>
> This is the right place to make your suggestion.  I am sorry that no
> one commented,  but this may mean that the group didn't see the
> benefit of the patch very clearly.
>
> However,  It would be a shame if someone goes to the trouble of
> submitting a patch and didn't get a reply.  I hope others may also get
> time to comment and, better still, try it out and, if they like it,
> second it.
>
> Regards,
> David
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
What about adding to the shell environment a variable containing the
name of the current app? Then scripts like yours could still get the
information they need, and the extra values could be removed from
sys.argv without a script having to import a helper.

Does this count as breaking backward-compatibility in web2py, or does
web2py only claim compatibility for models/views/controller code?


On Feb 25, 1:42 pm, Thadeus Burgess  wrote:
> Yes, I forgot to mention the db.commit().
>
> In fact, I would db.commit() after every successful
> insertion/delete/update this way your tests will be more in line?
>
> I do not know any reason as to why web2py passes along args that it is
> not using. However I think this could be beneficial in certain scripts
> that need to rely on certain parameters, like I have a backup script
> that relies on the app name, I can look at the -S arg to determine
> what app I am currently working on for this script.
>
> There should be a way though to easily filter out web2py args from
> sys.argv in a script perhaps a helper function in shell.py that
> can do this for you when you call it.
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 11:33 AM, spiffytech  wrote:
> > *addendum: at the bottom of applications/api/controllers/test.py add
> > the line "db.commit()" to force web2py to clear the database. web2py
> > automatically uses database transactions. They are executed
> > automatically after a controller's function is called, which is why
> > you don't normally have to call commit yourself. In external scripts,
> > though, all inserts/updates/deletes in the database have to be
> > manually committed.)
>
> > On Feb 25, 12:12 pm, spiffytech  wrote:
> >> Works great! I added an "import copy" in db.py, and added a line in my
> >> unit test to rename "test_db" to "db" so that functions in the test
> >> script will use the test DB.
>
> >> For posterity, here is a complete working example of unit tests with
> >> web2py, with access to the database, using test database. The wiki
> >> article I create will explain each piece and why it's needed.
>
> >> == To run the unit tests, type this on the command line: ==
> >> python web2py.py -S api -M -R applications/api/controllers/test.py  #
> >> Fill in your own values for the test file and controller name
> >> 
>
> >> == applications/api/controllers/test.py ==
> >> #!/usr/bin/python
> >> import sys
> >> import unittest
>
> >> from gluon.globals import Request  # So we can reset the request for
> >> each test
>
> >> sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
> >> this script
>
> >> db = test_db  # Rename the test database so that functions will use it
> >> instead of the real database
> >> execfile("applications/api/controllers/10.py", globals())  # Brings
> >> the controller's functions into this script's scope
>
> >> class TestListActiveGames(unittest.TestCase):
> >>     def setUp(self):
> >>         request = Request()  # Use a clean request
>
> >>     def testListActiveGames(self):
> >>         # Set variables for the test function
> >>         request.post_vars["game_id"] = 1
> >>         request.post_vars["username"] = "spiffytech"
>
> >>         # Call a function from the controller "10.py" and print the
> >> dictionary it returns
> >>         resp = list_active_games()
> >>         print resp
> >>         self.assertEquals(0, len(resp["games"]))
>
> >> # Manually specify tests to run; the web2py environment breaks
> >> unittest.main()
> >> # Taken from 
> >> here:http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
> >> suite = unittest.TestSuite()
> >> suite.addTest(unittest.makeSuite(TestListActiveGames))
> >> unittest.TextTestRunner(verbosity=2).run(suite)
>
> >> db(db.game.id>0).delete()  # Empty out the test database so it's fresh
> >> for next time
> >> ==
>
> >> == Added to the bottom of applications/api/models/db.py ==
> >> # Create a test database that's laid out just like the "real" database
> >> import copy
> >> test_db = DAL('sqlite://testing.sqlite')  # DB name and location
> >> for tablename in db.tables:  # Copy tables!
> >>     table_copy = [copy.copy(f) for f in db[tablename]]
> >>     test_db.define_table(tablename, *table_copy)
>
> >> ===
>
> >> On Feb 25, 11:36 am, Thadeus Burgess  wrote:
>
> >> > So the easiest way to use a testing db and your existing tables is to
> >> > automatically recreate them.
>
> >> > So assuming you are in the web2py environment and have access to ``db``
>
> >> > >>> test_db = DAL('testing.sqlite')
> >> > >>> for tablename in db.tables:
> >> > >>>   table_copy = [copy.copy(f) for f in db[tablename]]
> >> > >>>   test_db.define_table(tablename, *table_copy)
>
> >> > This will create a new testing sqlite database. Then it will go
> >> > through all tables defined in db, then copy their fields to a li

Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Thadeus Burgess
I do not like the idea of having to specify the name of the app twice,
it breaks DRY.

What about an additional command line flag that can tell whether to
strip sys.argv or not. This will keep backwards compatibility, and
also allow for scripts to have a simple sys.argv if required.

web2py.py --clean-argv

On this note, have you attempted to use unittest.TextTestRunner(...)
without the sys.argv=sys.argv[5:]

I believe that TextTestRunner should work since it shouldn't look at
command line args.

-Thadeus





On Thu, Feb 25, 2010 at 1:37 PM, spiffytech  wrote:
> ot know any reason as to why web2py passes along args that it is
>> not using. However I think this could be beneficial in certain scripts
>> that need to rely on certain parameters, like I have a backup script
>> that relies on the app name, I can look at the -S arg to determine
>> what app I am currently working on for this scr

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Uservoice: web2py forum

2010-02-25 Thread waTR
The idea of uservoice is not simply a list of feature requests, but
also a measure of popularity or demand. The forum isn't a good list of
features (as they are overwhelmed by posts about other topics), and
google code gives no indication upon quick examination of the demand
for a feature existing in the user community.



On Feb 23, 4:56 pm, Richard  wrote:
> works well - I used it previously via Elance.
> Though people can already request features via this forum or Google
> Code (http://code.google.com/p/web2py/issues/list)
>
> On Feb 24, 9:08 am, waTR  wrote:
>
> > I was just wondering if Massimo is interested in creating a UserVoice
> > account & forum for web2py. It's free, and it is really nice to have.
> > At least people will have a place to request features... It's also a
> > really nice interface.
>
> > Here is an example:http://freenet.uservoice.com/forums/8861-general

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Cuestion about jzip and jpg image?

2010-02-25 Thread drayco
Hi, web2py users,
I have a application with 6 web services with json in web2py.
I answer topological information every minute.
And my partners told me that the size of the answer is too large. They
told me that we need to use jzip.
The new requirements is that I need to give a jpg image too.

But I am a newbie in web application.

Can any of you give me a litle example with jzip?

And How can I put a jpg image in a web service?

Thank's in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Plugin system status

2010-02-25 Thread Thadeus Burgess
Yes we can resurrect 100's of posts on this topic of plugins in sub folders :)

There are two reasons Massimo does not support folder contained
plugins, from what I have read.

1. Execution overhead. Having to scan yet another folder will add that
much more overhead to the execution of a web2py app to find and
execute files in a plugins folder.

Potential solutions are

A) Specifically declaring plugins to execute, if they exist web2py
will go execute them.
B) Only find and execute plugins if you call Plugins() in a model.

I am in favor of A, however it requires one more step for the
developer to "initialize" a plugin.

2. Plugins should be able to control anything about an app. An example
Massimo provides is a "layout" plugin that can overwrite your
layout.html, or other views.

I completely disagree with allowing plugins this functionality. I
would rather a plugin like this change something like response.view to
another layout that exists in the plugins sub folder.

3. The current implementation requires no changes to the web2py base
execution code. The only code change was in Admin to hide the plugins
in a separate place to view the files.

This is probably the biggest reason as to why Massimo does not support
folder based plugins. This is quite understandable since there is
still alot to do with web2py (New DAL, new SQLFORM, etc etc). This was
also a quick and dirty solution.

-Thadeus





On Thu, Feb 25, 2010 at 11:32 AM, Alexandre Andrade
 wrote:
>>I fully agree that plugins should exist in
>>their own folders
>
> I defend it some time ago and still think it is a good idea
>
> 2010/2/25 mr.freeze 
>>
>> >>>What are you trying to accomplish with plugins?
>> I'm trying to created packaged chunks of reusable code that are easily
>> installed ,upgraded or removed by developers. I don't like the current
>> implementation either. I fully agree that plugins should exist in
>> their own folders (at the framework level,the shared application level
>> and the application level) but Massimo doesn't seem to be willing to
>> budge on this (possibly for good reason) and I would rather have a
>> plugin system that sort of works than none at all.  I'm not completely
>> sold on class based plugins just because I'm not sure how views would
>> work (are they separate files or strings?). I'd rather that plugins
>> were mini application with their own mvc folder stucture.
>>
>> The point of the Plugins class above would be to give a modicum of
>> control developers as to the objects that are exposed to the current
>> plugin system.
>>
>>
>> On Feb 25, 10:58 am, Thadeus Burgess  wrote:
>> > I can't stress enough. web2py plugins should be geared towards
>> > developers, not end-users. (Someone who runs their own wordpress blog
>> > would be an end-user of wordpress).
>> >
>> > Plugins should be there to provide a standard for common functionality
>> > so that everyone who comes along to web2py does not have to re-invent
>> > the wheel. But still be flexible enough to suite 95% of developer
>> > needs.
>> >
>> > This means that plugins should be easy to insert into the system, but
>> > because they need to be flexible, they will require programming to
>> > make work.
>> >
>> > I do not like the current plugin implementation because it does litter
>> > web2py folders, plugins should be self contained, and you shouldn't
>> > *have* to rely on "applications/admin" to install them for you. It is
>> > just one of those nuances.
>> >
>> > In every plugin system I have been researching, there is always a
>> > "plugins" folder that the system auto-discovers what is in it, and
>> > then activates them. This would make it easier to package and
>> > distribute the plugins.
>> >
>> > Though I have never seen a plugin system for a web framework, only for
>> > applications that are devoted to one subject (wordpress, mephisto,
>> > redmine, trac, etc). I guess django calls them "installed_apps" and
>> > "middleware_classes".
>> >
>> > But even with django "installed_apps"(plugins) they define their own
>> > views, all you have to do is specify which view to render in your
>> > functions... I suppose.
>> >
>> > What are you trying to accomplish with plugins?
>> >
>> > -Thadeus
>> >
>> > On Thu, Feb 25, 2010 at 9:48 AM, mr.freeze  wrote:
>> > > A simple approach would be to adopt the naming convention
>> > > 'plugin_object' for any objects the developer wants to expose to the
>> > > plugin system then just create global labels:
>> >
>> > class Plugins(object):
>> >     def __init__(self,globals,**kargs):
>> >         for k,v in kargs.items():
>> >             globals['plugin_'+k] = v
>> >
>> >  db = DAL('...') #this is my mission critical data
>> >  db2 = DAL('...') #this is for my plugins to use
>> >  plugins = Plugins(globals(),db=db2,auth=auth,crud=crud)
>> >
>> > > This would expose to the plugin developer:
>> > > plugin_db,plugin_auth,plugin_crud
>> >
>> > > This way app developers could control which obje

[web2py] Re: google app engine, file size limits

2010-02-25 Thread villas
Alex,  Thanks for this interesting information. This can make GAE
suitable for a lot of extra use.

> It should be easy to add blobstore support to web2py.

+1

Massimo,  How do you imagine it would be supported?
Maybe as just an option on 'upload' type which is ignored when non-GAE?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Toggle on/off editarea on startup

2010-02-25 Thread villas
Hi Alex,

This is the right place to make your suggestion.  I am sorry that no
one commented,  but this may mean that the group didn't see the
benefit of the patch very clearly.

However,  It would be a shame if someone goes to the trouble of
submitting a patch and didn't get a reply.  I hope others may also get
time to comment and, better still, try it out and, if they like it,
second it.

Regards,
David

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Thadeus Burgess
Yes, I forgot to mention the db.commit().

In fact, I would db.commit() after every successful
insertion/delete/update this way your tests will be more in line?

I do not know any reason as to why web2py passes along args that it is
not using. However I think this could be beneficial in certain scripts
that need to rely on certain parameters, like I have a backup script
that relies on the app name, I can look at the -S arg to determine
what app I am currently working on for this script.

There should be a way though to easily filter out web2py args from
sys.argv in a script perhaps a helper function in shell.py that
can do this for you when you call it.

-Thadeus





On Thu, Feb 25, 2010 at 11:33 AM, spiffytech  wrote:
> *addendum: at the bottom of applications/api/controllers/test.py add
> the line "db.commit()" to force web2py to clear the database. web2py
> automatically uses database transactions. They are executed
> automatically after a controller's function is called, which is why
> you don't normally have to call commit yourself. In external scripts,
> though, all inserts/updates/deletes in the database have to be
> manually committed.)
>
>
> On Feb 25, 12:12 pm, spiffytech  wrote:
>> Works great! I added an "import copy" in db.py, and added a line in my
>> unit test to rename "test_db" to "db" so that functions in the test
>> script will use the test DB.
>>
>> For posterity, here is a complete working example of unit tests with
>> web2py, with access to the database, using test database. The wiki
>> article I create will explain each piece and why it's needed.
>>
>> == To run the unit tests, type this on the command line: ==
>> python web2py.py -S api -M -R applications/api/controllers/test.py  #
>> Fill in your own values for the test file and controller name
>> 
>>
>> == applications/api/controllers/test.py ==
>> #!/usr/bin/python
>> import sys
>> import unittest
>>
>> from gluon.globals import Request  # So we can reset the request for
>> each test
>>
>> sys.arvg = sys.argv[5:]  # web2py.py passes the whole command line to
>> this script
>>
>> db = test_db  # Rename the test database so that functions will use it
>> instead of the real database
>> execfile("applications/api/controllers/10.py", globals())  # Brings
>> the controller's functions into this script's scope
>>
>> class TestListActiveGames(unittest.TestCase):
>>     def setUp(self):
>>         request = Request()  # Use a clean request
>>
>>     def testListActiveGames(self):
>>         # Set variables for the test function
>>         request.post_vars["game_id"] = 1
>>         request.post_vars["username"] = "spiffytech"
>>
>>         # Call a function from the controller "10.py" and print the
>> dictionary it returns
>>         resp = list_active_games()
>>         print resp
>>         self.assertEquals(0, len(resp["games"]))
>>
>> # Manually specify tests to run; the web2py environment breaks
>> unittest.main()
>> # Taken from 
>> here:http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-u...
>> suite = unittest.TestSuite()
>> suite.addTest(unittest.makeSuite(TestListActiveGames))
>> unittest.TextTestRunner(verbosity=2).run(suite)
>>
>> db(db.game.id>0).delete()  # Empty out the test database so it's fresh
>> for next time
>> ==
>>
>> == Added to the bottom of applications/api/models/db.py ==
>> # Create a test database that's laid out just like the "real" database
>> import copy
>> test_db = DAL('sqlite://testing.sqlite')  # DB name and location
>> for tablename in db.tables:  # Copy tables!
>>     table_copy = [copy.copy(f) for f in db[tablename]]
>>     test_db.define_table(tablename, *table_copy)
>>
>> ===
>>
>> On Feb 25, 11:36 am, Thadeus Burgess  wrote:
>>
>> > So the easiest way to use a testing db and your existing tables is to
>> > automatically recreate them.
>>
>> > So assuming you are in the web2py environment and have access to ``db``
>>
>> > >>> test_db = DAL('testing.sqlite')
>> > >>> for tablename in db.tables:
>> > >>>   table_copy = [copy.copy(f) for f in db[tablename]]
>> > >>>   test_db.define_table(tablename, *table_copy)
>>
>> > This will create a new testing sqlite database. Then it will go
>> > through all tables defined in db, then copy their fields to a list,
>> > then it will define a new table in the sqlite with the copied fields.
>>
>> > Now any functions that you might want to unit test might rely on your
>> > ``db`` object, which could be an issue depending on how you have your
>> > code structured.
>>
>> > -Thadeus
>>
>> > On Thu, Feb 25, 2010 at 8:02 AM, Tiago Almeida
>>
>> >  wrote:
>> > > I concur. Thanks :)
>>
>> > > On Thu, Feb 25, 2010 at 1:52 PM, Nicol van der Merwe 
>> > > 
>> > > wrote:
>>
>> > >> Super awesome, thanks!
>>
>> > >> On Thu, Feb 25, 2010 at 3:43 PM, spiffytech  
>> > >> wrote:
>>
>> > >>> I'm going to w

Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
A couple of suggestions with the slice

Make a note, for building uwsgi, that there are makefile.py25 and
others so that you can build it for the python version that you want.

Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
to securely connect to cherokee admin.

I do not see uWSGI listed under Wizards->Platforms. I do not see it
anywhere else.

I can run ``uwsgi`` from command line, so it is installed correctly in my bin.

The only difference is I have /web2py and /web2py/config.xml does this matter?

-Thadeus





On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess  wrote:
> Can I have cherokee uwsgi and apache mod_wsgi running on the same
> web2py code base or should I make a copy so cherokee can execute it ?
>
> You are right I could run cherokee on a non-standard port for testing
> and always switch it over when I am happy with it!
>
> -Thadeus
>
>
>
>
>
> On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
>  wrote:
>> @Thadeus
>>
>> For me, it was a breeze to switch from Apache to Cherokee. I was happy
>> with Apache too, but I used the fact that a client wanted Cherokee as
>> an opportunity to give it a try, and I am glad I did :) Besides, it is
>> not like you would have to remove Apache to use Cherokee, so what are
>> you waiting for (besides possibly a free hour), give it a try!
>>
>> @mr.freeze and everyone else
>>
>> This guide has been posted at 
>> http://www.web2pyslices.com/main/slices/take_slice/64
>> and will appear on graymattercomputing.net in the near future.
>>
>> On Feb 24, 6:05 am, "mr.freeze"  wrote:
>>> This is really helpful. Unfortunately, it will be lost on this mailing
>>> list in a month or so.  Care to make a 
>>> slice?http://www.web2pyslices.com/main/default/index
>>>
>>> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>>>
>>>
>>>
>>> > web2py with Cherokee viauWSGI: a simple, easy guide
>>> > (written specifically for Ubuntu, but applicable to all systems)
>>> > By: Evan Gray - GrayMatterComputing
>>>
>>> > 1) web2py
>>> >  a) Download web2py (found at web2py.com)
>>> >   i) Install python, if not present: sudo apt-get install python
>>> >  b) Unzip (to /var/web2py)
>>> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
>>> >  d) Verify that it functions properly (by visiting localhost:8000),
>>> > then close the server (Ctrl+C in terminal)
>>> >  e) Allow server permission to web2py: sudo chown -hR www-data\: /var/
>>> > web2py
>>> >   i) Where "www-data" is Cherokee's effective user (www-data is the
>>> > default)
>>>
>>> > 2)uWSGI
>>> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
>>> >  b) Unpackage wherever and cd into folder
>>> >   i) Install dependencies for make, if not present: sudo apt-get
>>> > install python-dev libxml2-dev
>>> >  c) Makeuwsgi: sudo make -f Makefile.Py26
>>> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
>>> >  e) Create config.xml: sudo cat > /var/web2py/config.xml
>>> > 
>>> >     /var/web2py/
>>> >     
>>> >     wsgihandler
>>> >     
>>> > 
>>> > [PRESS ENTER]
>>> > [PRESS CTRL+D]
>>>
>>> > 3) Cherokee
>>> >  a) Install Cherokee (follow the instructions at cherokee-project.org)
>>> >   i) Note: I highly recommend using the PPA method so you can be sure
>>> > to have the latest version and no issues!
>>> >  b) Run cherokee-admin: sudo cherokee-admin
>>> >  c) Visit admin console (via browser, password is shown in terminal):
>>> > localhost:9090
>>> >  d) Go to Virtual Servers, click Wizards, click Platforms, clickuWSGI
>>> >   i)   New Host Name: web2py
>>> >   ii)  Document Root: /var/web2py
>>> >   iii) Configuration File: /var/web2py/config.xml
>>> >   iv)  Same logs as vserver: default(combined)
>>> >   v)   Submit
>>> >  e) Go to Virtual Servers, click default
>>> >   i) Under "Basics", Virtual Server Nickname: original
>>> >  f) Go to Virtual Servers, click web2py
>>> >   i)  Under "Basics", Virtual Server Nickname: default
>>> >   ii) Under "Logging", verify all logging is correct (matches
>>> > original)
>>> >  g) Go to Virtual Servers
>>> >   i) Set original Active to OFF
>>>
>>> > 4) Visit localhost (or your.ip.add.ress from another computer) to view
>>> > your web2py site! :D
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To post to this group, send email to web...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/web2py?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread spiffytech
I had not tried taking the sys.argv statement out of my code. You are
correct: when using TestTextRunner, sys.argv does not need to be
cleaned. I like the idea of a command line flag. It's probably a good
idea to offer such a flag, even though it turns out it's not needed to
run unit tests.


On Feb 25, 2:49 pm, Thadeus Burgess  wrote:
> I do not like the idea of having to specify the name of the app twice,
> it breaks DRY.
>
> What about an additional command line flag that can tell whether to
> strip sys.argv or not. This will keep backwards compatibility, and
> also allow for scripts to have a simple sys.argv if required.
>
> web2py.py --clean-argv
>
> On this note, have you attempted to use unittest.TextTestRunner(...)
> without the sys.argv=sys.argv[5:]
>
> I believe that TextTestRunner should work since it shouldn't look at
> command line args.
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 1:37 PM, spiffytech  wrote:
> > ot know any reason as to why web2py passes along args that it is
> >> not using. However I think this could be beneficial in certain scripts
> >> that need to rely on certain parameters, like I have a backup script
> >> that relies on the app name, I can look at the -S arg to determine
> >> what app I am currently working on for this scr

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Unit testing in web2py : Some thoughts

2010-02-25 Thread Jonathan Lundell
I'm really glad to see this work happening, and I look forward to the slice.

Perhaps we could eventually have unit tests as part of the welcome app, or 
indeed all three standard apps, both for documentation purposes and to set a 
good example.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
Also, emphasis the fact of using the PPA method of installing, and
provide instructions on how to do this, and a link to that page. The
reason it was not working was I installed 0.99.19 instead of 0.99.43.

-Thadeus





On Thu, Feb 25, 2010 at 2:27 PM, Thadeus Burgess  wrote:
> A couple of suggestions with the slice
>
> Make a note, for building uwsgi, that there are makefile.py25 and
> others so that you can build it for the python version that you want.
>
> Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
> to securely connect to cherokee admin.
>
> I do not see uWSGI listed under Wizards->Platforms. I do not see it
> anywhere else.
>
> I can run ``uwsgi`` from command line, so it is installed correctly in my bin.
>
> The only difference is I have /web2py and /web2py/config.xml does this matter?
>
> -Thadeus
>
>
>
>
>
> On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess  
> wrote:
>> Can I have cherokee uwsgi and apache mod_wsgi running on the same
>> web2py code base or should I make a copy so cherokee can execute it ?
>>
>> You are right I could run cherokee on a non-standard port for testing
>> and always switch it over when I am happy with it!
>>
>> -Thadeus
>>
>>
>>
>>
>>
>> On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
>>  wrote:
>>> @Thadeus
>>>
>>> For me, it was a breeze to switch from Apache to Cherokee. I was happy
>>> with Apache too, but I used the fact that a client wanted Cherokee as
>>> an opportunity to give it a try, and I am glad I did :) Besides, it is
>>> not like you would have to remove Apache to use Cherokee, so what are
>>> you waiting for (besides possibly a free hour), give it a try!
>>>
>>> @mr.freeze and everyone else
>>>
>>> This guide has been posted at 
>>> http://www.web2pyslices.com/main/slices/take_slice/64
>>> and will appear on graymattercomputing.net in the near future.
>>>
>>> On Feb 24, 6:05 am, "mr.freeze"  wrote:
 This is really helpful. Unfortunately, it will be lost on this mailing
 list in a month or so.  Care to make a 
 slice?http://www.web2pyslices.com/main/default/index

 On Feb 23, 2:56 pm, GrayMatterComputing  wrote:



 > web2py with Cherokee viauWSGI: a simple, easy guide
 > (written specifically for Ubuntu, but applicable to all systems)
 > By: Evan Gray - GrayMatterComputing

 > 1) web2py
 >  a) Download web2py (found at web2py.com)
 >   i) Install python, if not present: sudo apt-get install python
 >  b) Unzip (to /var/web2py)
 >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
 >  d) Verify that it functions properly (by visiting localhost:8000),
 > then close the server (Ctrl+C in terminal)
 >  e) Allow server permission to web2py: sudo chown -hR www-data\: /var/
 > web2py
 >   i) Where "www-data" is Cherokee's effective user (www-data is the
 > default)

 > 2)uWSGI
 >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
 >  b) Unpackage wherever and cd into folder
 >   i) Install dependencies for make, if not present: sudo apt-get
 > install python-dev libxml2-dev
 >  c) Makeuwsgi: sudo make -f Makefile.Py26
 >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
 >  e) Create config.xml: sudo cat > /var/web2py/config.xml
 > 
 >     /var/web2py/
 >     
 >     wsgihandler
 >     
 > 
 > [PRESS ENTER]
 > [PRESS CTRL+D]

 > 3) Cherokee
 >  a) Install Cherokee (follow the instructions at cherokee-project.org)
 >   i) Note: I highly recommend using the PPA method so you can be sure
 > to have the latest version and no issues!
 >  b) Run cherokee-admin: sudo cherokee-admin
 >  c) Visit admin console (via browser, password is shown in terminal):
 > localhost:9090
 >  d) Go to Virtual Servers, click Wizards, click Platforms, clickuWSGI
 >   i)   New Host Name: web2py
 >   ii)  Document Root: /var/web2py
 >   iii) Configuration File: /var/web2py/config.xml
 >   iv)  Same logs as vserver: default(combined)
 >   v)   Submit
 >  e) Go to Virtual Servers, click default
 >   i) Under "Basics", Virtual Server Nickname: original
 >  f) Go to Virtual Servers, click web2py
 >   i)  Under "Basics", Virtual Server Nickname: default
 >   ii) Under "Logging", verify all logging is correct (matches
 > original)
 >  g) Go to Virtual Servers
 >   i) Set original Active to OFF

 > 4) Visit localhost (or your.ip.add.ress from another computer) to view
 > your web2py site! :D
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "web2py-users" group.
>>> To post to this group, send email to web...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> web2py+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/web2py?hl=en.
>>>
>>>
>>
>

-- 
You received this message b

Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
Don't forget to hit save :)0

And how to enable SSL, and use my self signed certificate, OR use a
paid for certificate?


-Thadeus





On Thu, Feb 25, 2010 at 3:25 PM, Thadeus Burgess  wrote:
> Also, emphasis the fact of using the PPA method of installing, and
> provide instructions on how to do this, and a link to that page. The
> reason it was not working was I installed 0.99.19 instead of 0.99.43.
>
> -Thadeus
>
>
>
>
>
> On Thu, Feb 25, 2010 at 2:27 PM, Thadeus Burgess  
> wrote:
>> A couple of suggestions with the slice
>>
>> Make a note, for building uwsgi, that there are makefile.py25 and
>> others so that you can build it for the python version that you want.
>>
>> Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
>> to securely connect to cherokee admin.
>>
>> I do not see uWSGI listed under Wizards->Platforms. I do not see it
>> anywhere else.
>>
>> I can run ``uwsgi`` from command line, so it is installed correctly in my 
>> bin.
>>
>> The only difference is I have /web2py and /web2py/config.xml does this 
>> matter?
>>
>> -Thadeus
>>
>>
>>
>>
>>
>> On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess  
>> wrote:
>>> Can I have cherokee uwsgi and apache mod_wsgi running on the same
>>> web2py code base or should I make a copy so cherokee can execute it ?
>>>
>>> You are right I could run cherokee on a non-standard port for testing
>>> and always switch it over when I am happy with it!
>>>
>>> -Thadeus
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
>>>  wrote:
 @Thadeus

 For me, it was a breeze to switch from Apache to Cherokee. I was happy
 with Apache too, but I used the fact that a client wanted Cherokee as
 an opportunity to give it a try, and I am glad I did :) Besides, it is
 not like you would have to remove Apache to use Cherokee, so what are
 you waiting for (besides possibly a free hour), give it a try!

 @mr.freeze and everyone else

 This guide has been posted at 
 http://www.web2pyslices.com/main/slices/take_slice/64
 and will appear on graymattercomputing.net in the near future.

 On Feb 24, 6:05 am, "mr.freeze"  wrote:
> This is really helpful. Unfortunately, it will be lost on this mailing
> list in a month or so.  Care to make a 
> slice?http://www.web2pyslices.com/main/default/index
>
> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>
>
>
> > web2py with Cherokee viauWSGI: a simple, easy guide
> > (written specifically for Ubuntu, but applicable to all systems)
> > By: Evan Gray - GrayMatterComputing
>
> > 1) web2py
> >  a) Download web2py (found at web2py.com)
> >   i) Install python, if not present: sudo apt-get install python
> >  b) Unzip (to /var/web2py)
> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
> >  d) Verify that it functions properly (by visiting localhost:8000),
> > then close the server (Ctrl+C in terminal)
> >  e) Allow server permission to web2py: sudo chown -hR www-data\: /var/
> > web2py
> >   i) Where "www-data" is Cherokee's effective user (www-data is the
> > default)
>
> > 2)uWSGI
> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
> >  b) Unpackage wherever and cd into folder
> >   i) Install dependencies for make, if not present: sudo apt-get
> > install python-dev libxml2-dev
> >  c) Makeuwsgi: sudo make -f Makefile.Py26
> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
> >  e) Create config.xml: sudo cat > /var/web2py/config.xml
> > 
> >     /var/web2py/
> >     
> >     wsgihandler
> >     
> > 
> > [PRESS ENTER]
> > [PRESS CTRL+D]
>
> > 3) Cherokee
> >  a) Install Cherokee (follow the instructions at cherokee-project.org)
> >   i) Note: I highly recommend using the PPA method so you can be sure
> > to have the latest version and no issues!
> >  b) Run cherokee-admin: sudo cherokee-admin
> >  c) Visit admin console (via browser, password is shown in terminal):
> > localhost:9090
> >  d) Go to Virtual Servers, click Wizards, click Platforms, clickuWSGI
> >   i)   New Host Name: web2py
> >   ii)  Document Root: /var/web2py
> >   iii) Configuration File: /var/web2py/config.xml
> >   iv)  Same logs as vserver: default(combined)
> >   v)   Submit
> >  e) Go to Virtual Servers, click default
> >   i) Under "Basics", Virtual Server Nickname: original
> >  f) Go to Virtual Servers, click web2py
> >   i)  Under "Basics", Virtual Server Nickname: default
> >   ii) Under "Logging", verify all logging is correct (matches
> > original)
> >  g) Go to Virtual Servers
> >   i) Set original Active to OFF
>
> > 4) Visit localhost (or your.ip.add.ress from another computer) to view
> > your web2py site! :D

 --
 You received this message because you are subscribed to 

Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
The following packages are not installed by the PPA...

cherokee-doc
libcherokee-mod-geoip
libcherokee-mod-ldap
libcherokee-mod-libssl
libcherokee-mod-mysql
libcherokee-mod-rrd
libcherokee-mod-streaming

Installing libcherokee-mod-libssl fixes this.

Also they have a great article on creating and signing your own ssl
key, it seems the one I am using for apache setup is invalid :)


-Thadeus





On Thu, Feb 25, 2010 at 3:36 PM, Thadeus Burgess  wrote:
> Don't forget to hit save :)0
>
> And how to enable SSL, and use my self signed certificate, OR use a
> paid for certificate?
>
>
> -Thadeus
>
>
>
>
>
> On Thu, Feb 25, 2010 at 3:25 PM, Thadeus Burgess  
> wrote:
>> Also, emphasis the fact of using the PPA method of installing, and
>> provide instructions on how to do this, and a link to that page. The
>> reason it was not working was I installed 0.99.19 instead of 0.99.43.
>>
>> -Thadeus
>>
>>
>>
>>
>>
>> On Thu, Feb 25, 2010 at 2:27 PM, Thadeus Burgess  
>> wrote:
>>> A couple of suggestions with the slice
>>>
>>> Make a note, for building uwsgi, that there are makefile.py25 and
>>> others so that you can build it for the python version that you want.
>>>
>>> Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
>>> to securely connect to cherokee admin.
>>>
>>> I do not see uWSGI listed under Wizards->Platforms. I do not see it
>>> anywhere else.
>>>
>>> I can run ``uwsgi`` from command line, so it is installed correctly in my 
>>> bin.
>>>
>>> The only difference is I have /web2py and /web2py/config.xml does this 
>>> matter?
>>>
>>> -Thadeus
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess  
>>> wrote:
 Can I have cherokee uwsgi and apache mod_wsgi running on the same
 web2py code base or should I make a copy so cherokee can execute it ?

 You are right I could run cherokee on a non-standard port for testing
 and always switch it over when I am happy with it!

 -Thadeus





 On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
  wrote:
> @Thadeus
>
> For me, it was a breeze to switch from Apache to Cherokee. I was happy
> with Apache too, but I used the fact that a client wanted Cherokee as
> an opportunity to give it a try, and I am glad I did :) Besides, it is
> not like you would have to remove Apache to use Cherokee, so what are
> you waiting for (besides possibly a free hour), give it a try!
>
> @mr.freeze and everyone else
>
> This guide has been posted at 
> http://www.web2pyslices.com/main/slices/take_slice/64
> and will appear on graymattercomputing.net in the near future.
>
> On Feb 24, 6:05 am, "mr.freeze"  wrote:
>> This is really helpful. Unfortunately, it will be lost on this mailing
>> list in a month or so.  Care to make a 
>> slice?http://www.web2pyslices.com/main/default/index
>>
>> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>>
>>
>>
>> > web2py with Cherokee viauWSGI: a simple, easy guide
>> > (written specifically for Ubuntu, but applicable to all systems)
>> > By: Evan Gray - GrayMatterComputing
>>
>> > 1) web2py
>> >  a) Download web2py (found at web2py.com)
>> >   i) Install python, if not present: sudo apt-get install python
>> >  b) Unzip (to /var/web2py)
>> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
>> >  d) Verify that it functions properly (by visiting localhost:8000),
>> > then close the server (Ctrl+C in terminal)
>> >  e) Allow server permission to web2py: sudo chown -hR www-data\: /var/
>> > web2py
>> >   i) Where "www-data" is Cherokee's effective user (www-data is the
>> > default)
>>
>> > 2)uWSGI
>> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
>> >  b) Unpackage wherever and cd into folder
>> >   i) Install dependencies for make, if not present: sudo apt-get
>> > install python-dev libxml2-dev
>> >  c) Makeuwsgi: sudo make -f Makefile.Py26
>> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
>> >  e) Create config.xml: sudo cat > /var/web2py/config.xml
>> > 
>> >     /var/web2py/
>> >     
>> >     wsgihandler
>> >     
>> > 
>> > [PRESS ENTER]
>> > [PRESS CTRL+D]
>>
>> > 3) Cherokee
>> >  a) Install Cherokee (follow the instructions at cherokee-project.org)
>> >   i) Note: I highly recommend using the PPA method so you can be sure
>> > to have the latest version and no issues!
>> >  b) Run cherokee-admin: sudo cherokee-admin
>> >  c) Visit admin console (via browser, password is shown in terminal):
>> > localhost:9090
>> >  d) Go to Virtual Servers, click Wizards, click Platforms, clickuWSGI
>> >   i)   New Host Name: web2py
>> >   ii)  Document Root: /var/web2py
>> >   iii) Configuration File: /var/web2py/config.xml
>> >   iv)  Same logs as vserver: default(combined)

[web2py] auth.settings.registration_requires_approval

2010-02-25 Thread baloan
When setting

auth.settings.registration_requires_approval = True

new user registration seem to keep sitting in pending state. The admin
needs a user interface to approve or reject new registrations.

Is there any preconfigured approval pages/process built into web2py or
do I have to implement one by myself? Any template code out there?

Regards, Andreas

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: mail plain text message wrong charset

2010-02-25 Thread szimszon
Hmmm... I don't use gmail or google to send email...

You talk about the character real representation like ÁÖ...
or the email part header
--===1974471883==
Content-Type: text/plain;charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

if you say us-ascii?

I think the email message part header
--===1974471883==
Content-Type: text/plain;charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

is part of the mail body and generated by python. I don't think it
gets rewritten by mail transport agent. So my primary concern is the
generated instruction about how to read the rest of the message. Is it
us-ascii or utf-8. I don't mind how is the text actually encoded...

On febr. 25, 17:18, Thadeus Burgess  wrote:
> There might be an issue that web2py is encoding the email correctly,
> however your SMTP server is re-coding this into its own encoding.
>
> I use Google Apps to send all of my emails with my web2py instances. I
> just checked some of the messages received and they are all encoded
> "us-ascii".
>
> Further investigation using a SMTP server that we manage ourselves
> with (mt), all emails sent from this server are encoded utf-8.
>
> This must not be a web2py issue but SMTP issue.  Google and the like
> decide to recode all of their messages, and there might not be
> anything that can be done about it besides using your own SMTP server.
>
> -ThadeusOn Thu, Feb 25, 2010 at 7:12 AM, szimszon  wrote:
> > I need utf-8 :)
>
> > On febr. 25, 12:20, mdipierro  wrote:
> >> Because               encoding="utf-8" is default. You have to figure
> >> out what is the encoding you need.
>
> >> On Feb 25, 4:32 am, szimszon  wrote:
>
> >> > I tested it again,
>
> >> > I created a new scaffolding app with the admin interface then I
> >> > changed:
> >> > db.py:
> >> >mail=Mail()                                  # mailer
> >> >mail.settings.server='localhost:25'    # your SMTP server
> >> >mail.settings.sender='pr...@localhost'         # your email
>
> >> > default.py (controller)
> >> > def index():
> >> >     """
> >> >     example action using the internationalization operator T and flash
> >> >     rendered by views/default/index.html or views/generic.html
> >> >     """
> >> >     response.flash = T('mailtest')
> >> >     context=dict(name="Gipsz Jakab",
> >> >                  addr="Szt. Erzsébet körút")
> >> >     message=response.render('emailbody.txt', context)
> >> >    mail.send(to="szimszon",
> >> >               subject="test email",
> >> >               message=message)
>
> >> >     return dict(message=T('Mailsent'))
>
> >> > made an emailbody.txt in views:
> >> > emailbody.txt
> >> > Üdvözlöm {{=name}}!
>
> >> > Címed: {{=addr}}
>
> >> > Ez egy teszt elektronikus levél.
>
> >> > Árvíztűrő tükörfúrógép!
> >> > --
>
> >> > Then I navigate to the site to send myself a letter:
>
> >> > - cut -
> >> > From pr...@localhost  Thu Feb 25 11:24:05 2010
> >> > Return-Path: 
> >> > X-Original-To: szimszon
> >> > Delivered-To: szims...@x
> >> > Received: from xxx (localhost [127.0.0.1])
> >> >         by xxx (Postfix) with ESMTP id C542A31CBF
> >> >         for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> >> > Content-Type: multipart/related;
> >> > boundary="===1518445122=="
> >> > MIME-Version: 1.0
> >> > To: szims...@
> >> > Subject: test email
> >> > Message-Id: <20100225102405.c542a31...@xxx>
> >> > Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
> >> > From: pr...@localhost
>
> >> > --===1518445122==
> >> > Content-Type: multipart/alternative;
> >> > boundary="===1974471883=="
> >> > MIME-Version: 1.0
>
> >> > --===1974471883==
> >> > Content-Type: text/plain;charset="us-ascii"
> >> > MIME-Version: 1.0
> >> > Content-Transfer-Encoding: 8bit
>
> >> > Üdvözlöm Gipsz Jakab!
>
> >> > Címed: Szt. Erzsébet körút
>
> >> > Ez egy teszt elektronikus levél.
>
> >> > Árvíztűrő tükörfúrógép!
>
> >> > --===1974471883==--
> >> > --===1518445122==--
>
> >> > - cut -
>
> >> >charset: us-ascii
>
> >> > If I changed the
> >> >      mail.send(to="szimszon",
> >> >               subject="test email",
> >> >               message=message)
>
> >> > to
> >> >    mail.send(to="szimszon",
> >> >               subject="test email",
> >> >               message=message,
> >> >               encoding="utf-8")
> >> > made no difference :(
> >> > On febr. 23, 21:01, Thadeus Burgess  wrote:
>
> >> > > I am unable to replicate this.
>
> >> > > -Thadeus
>
> >> > > On Tue, Feb 23, 2010 at 1:59 PM, szimszon  wrote:
> >> > > > No change:
>
> >> > > > --===2046819983==
> >> > > > Content-Type: multipart/alternative;
> >> > > > boundary="===1304182396=="
> >> > > > MIME-Version: 1.0
>
> >> > > > --===1304182396==
> >> > > > Content-Type: text/plain;charset="us-ascii"
> >> > > > MIME-Version: 1.0
> >> > > > Con

[web2py] Re: Plugin system status

2010-02-25 Thread pistacchio
i'm late in the whole "plugin" discussion, i didn't really follow it
from start (being new to web2py).
my only question is: what is the _scope_ of plugins? as i got it
correctly, there's an ongoing debate on the form of plugins, classes
vs directories.

if we're talking about small things like "display the last post from
twitter plugin" or "contact form plugin" or "openid authentication
plugin", the class thing may fit. but if we're talking about wider
things like "the blog plugin" or "the forum plugin", i really wonder
how they could implemented without having their own directory
structure.

On 24 Feb, 01:37, "mr.freeze"  wrote:
> Is the plugin system considered backwards compatible at this point? I
> am considering converting some modules into plugins but want to know
> if they API is stable.
>
> Also, is the naming convention of 'db' for your database still
> required for the plugin system?
>
> ---
> I predict that in the year 2015, web2py will gain self awareness and
> attempt to take over the world under the name PyNet.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] I'd just like to say.

2010-02-25 Thread Matt
Hi Massimo ,

I'd just like to say a massive thanks to you and the rest of the
people who have contributed to making web2py such an amazingly nice
framework to use.

I'm in the process of porting an existing Django project in web2py and
I'm thoroughly enjoying how clean and simple web2py is.

The GAE support it brilliant, the API is flexible and well thought out
and having everything like JQuery etc bundled in is a massive help not
to mention a huge time saver.

Thanks for creating a better wheel. Keep up the fantastic work.

Kind regards,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread GrayMatterComputing
The guide is fine, it just needs to be Followed Step By Step without
skipping. ;)
I also figured the SSL and all was easy enough to find and, again,
outside the scope of this entry.

On Feb 25, 4:47 pm, Thadeus Burgess  wrote:
> The following packages are not installed by the PPA...
>
> cherokee-doc
> libcherokee-mod-geoip
> libcherokee-mod-ldap
> libcherokee-mod-libssl
> libcherokee-mod-mysql
> libcherokee-mod-rrd
> libcherokee-mod-streaming
>
> Installing libcherokee-mod-libssl fixes this.
>
> Also they have a great article on creating and signing your own ssl
> key, it seems the one I am using for apache setup is invalid :)
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 3:36 PM, Thadeus Burgess  
> wrote:
> > Don't forget to hit save :)0
>
> > And how to enable SSL, and use my self signed certificate, OR use a
> > paid for certificate?
>
> > -Thadeus
>
> > On Thu, Feb 25, 2010 at 3:25 PM, Thadeus Burgess  
> > wrote:
> >> Also, emphasis the fact of using the PPA method of installing, and
> >> provide instructions on how to do this, and a link to that page. The
> >> reason it was not working was I installed 0.99.19 instead of 0.99.43.
>
> >> -Thadeus
>
> >> On Thu, Feb 25, 2010 at 2:27 PM, Thadeus Burgess  
> >> wrote:
> >>> A couple of suggestions with the slice
>
> >>> Make a note, for buildinguwsgi, that there are makefile.py25 and
> >>> others so that you can build it for the python version that you want.
>
> >>> Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
> >>> to securely connect to cherokee admin.
>
> >>> I do not seeuWSGIlisted under Wizards->Platforms. I do not see it
> >>> anywhere else.
>
> >>> I can run ``uwsgi`` from command line, so it is installed correctly in my 
> >>> bin.
>
> >>> The only difference is I have /web2py and /web2py/config.xml does this 
> >>> matter?
>
> >>> -Thadeus
>
> >>> On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess  
> >>> wrote:
>  Can I have cherokeeuwsgiand apache mod_wsgi running on the same
>  web2py code base or should I make a copy so cherokee can execute it ?
>
>  You are right I could run cherokee on a non-standard port for testing
>  and always switch it over when I am happy with it!
>
>  -Thadeus
>
>  On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
>   wrote:
> > @Thadeus
>
> > For me, it was a breeze to switch from Apache to Cherokee. I was happy
> > with Apache too, but I used the fact that a client wanted Cherokee as
> > an opportunity to give it a try, and I am glad I did :) Besides, it is
> > not like you would have to remove Apache to use Cherokee, so what are
> > you waiting for (besides possibly a free hour), give it a try!
>
> > @mr.freeze and everyone else
>
> > This guide has been posted 
> > athttp://www.web2pyslices.com/main/slices/take_slice/64
> > and will appear on graymattercomputing.net in the near future.
>
> > On Feb 24, 6:05 am, "mr.freeze"  wrote:
> >> This is really helpful. Unfortunately, it will be lost on this mailing
> >> list in a month or so.  Care to make a 
> >> slice?http://www.web2pyslices.com/main/default/index
>
> >> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>
> >> > web2py with Cherokee viauWSGI: a simple, easy guide
> >> > (written specifically for Ubuntu, but applicable to all systems)
> >> > By: Evan Gray - GrayMatterComputing
>
> >> > 1) web2py
> >> >  a) Download web2py (found at web2py.com)
> >> >   i) Install python, if not present: sudo apt-get install python
> >> >  b) Unzip (to /var/web2py)
> >> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
> >> >  d) Verify that it functions properly (by visiting localhost:8000),
> >> > then close the server (Ctrl+C in terminal)
> >> >  e) Allow server permission to web2py: sudo chown -hR www-data\: 
> >> > /var/
> >> > web2py
> >> >   i) Where "www-data" is Cherokee's effective user (www-data is the
> >> > default)
>
> >> > 2)uWSGI
> >> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
> >> >  b) Unpackage wherever and cd into folder
> >> >   i) Install dependencies for make, if not present: sudo apt-get
> >> > install python-dev libxml2-dev
> >> >  c) Makeuwsgi: sudo make -f Makefile.Py26
> >> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
> >> >  e) Create config.xml: sudo cat > /var/web2py/config.xml
> >> > 
> >> >     /var/web2py/
> >> >     
> >> >     wsgihandler
> >> >     
> >> > 
> >> > [PRESS ENTER]
> >> > [PRESS CTRL+D]
>
> >> > 3) Cherokee
> >> >  a) Install Cherokee (follow the instructions at 
> >> > cherokee-project.org)
> >> >   i) Note: I highly recommend using the PPA method so you can be sure
> >> > to have the latest version and no issues!
> >> >  b) Run cherokee-admin: sudo cherokee-admin
> >> >  c) Visit admin console (via browser, password is shown in termi

Re: [web2py] Re: mail plain text message wrong charset

2010-02-25 Thread Thadeus Burgess
I did some more testing.

Server A -> Google SMTP -> receive Content-Type us-ascii
Server B -> Custom SMTP -> receive Content-Type utf-8

If I take Server B's credentials for the SMTP server, and stick them
in Server A this is the result..

ServerA -> Custom SMTP -> receive Content-Type utf-8
ServerB -> Custom SMTP -> receive Content-Type utf-8

And I also did the reverse

ServerA -> Google SMTP -> receive Content-Type us-ascii
ServerB -> Google SMTP -> receive Content-Type us-ascii

The only change is the credentials and SMTP server I am connecting to,
no code changes whatsoever.

-Thadeus





On Thu, Feb 25, 2010 at 4:20 PM, szimszon  wrote:
> Hmmm... I don't use gmail or google to send email...
>
> You talk about the character real representation like ÁÖ...
> or the email part header
> --===1974471883==
> Content-Type: text/plain;charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 8bit
>
> if you say us-ascii?
>
> I think the email message part header
> --===1974471883==
> Content-Type: text/plain;charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 8bit
>
> is part of the mail body and generated by python. I don't think it
> gets rewritten by mail transport agent. So my primary concern is the
> generated instruction about how to read the rest of the message. Is it
> us-ascii or utf-8. I don't mind how is the text actually encoded...
>
> On febr. 25, 17:18, Thadeus Burgess  wrote:
>> There might be an issue that web2py is encoding the email correctly,
>> however your SMTP server is re-coding this into its own encoding.
>>
>> I use Google Apps to send all of my emails with my web2py instances. I
>> just checked some of the messages received and they are all encoded
>> "us-ascii".
>>
>> Further investigation using a SMTP server that we manage ourselves
>> with (mt), all emails sent from this server are encoded utf-8.
>>
>> This must not be a web2py issue but SMTP issue.  Google and the like
>> decide to recode all of their messages, and there might not be
>> anything that can be done about it besides using your own SMTP server.
>>
>> -ThadeusOn Thu, Feb 25, 2010 at 7:12 AM, szimszon  wrote:
>> > I need utf-8 :)
>>
>> > On febr. 25, 12:20, mdipierro  wrote:
>> >> Because               encoding="utf-8" is default. You have to figure
>> >> out what is the encoding you need.
>>
>> >> On Feb 25, 4:32 am, szimszon  wrote:
>>
>> >> > I tested it again,
>>
>> >> > I created a new scaffolding app with the admin interface then I
>> >> > changed:
>> >> > db.py:
>> >> >mail=Mail()                                  # mailer
>> >> >mail.settings.server='localhost:25'    # your SMTP server
>> >> >mail.settings.sender='pr...@localhost'         # your email
>>
>> >> > default.py (controller)
>> >> > def index():
>> >> >     """
>> >> >     example action using the internationalization operator T and flash
>> >> >     rendered by views/default/index.html or views/generic.html
>> >> >     """
>> >> >     response.flash = T('mailtest')
>> >> >     context=dict(name="Gipsz Jakab",
>> >> >                  addr="Szt. Erzsébet körút")
>> >> >     message=response.render('emailbody.txt', context)
>> >> >    mail.send(to="szimszon",
>> >> >               subject="test email",
>> >> >               message=message)
>>
>> >> >     return dict(message=T('Mailsent'))
>>
>> >> > made an emailbody.txt in views:
>> >> > emailbody.txt
>> >> > Üdvözlöm {{=name}}!
>>
>> >> > Címed: {{=addr}}
>>
>> >> > Ez egy teszt elektronikus levél.
>>
>> >> > Árvíztűrő tükörfúrógép!
>> >> > --
>>
>> >> > Then I navigate to the site to send myself a letter:
>>
>> >> > - cut -
>> >> > From pr...@localhost  Thu Feb 25 11:24:05 2010
>> >> > Return-Path: 
>> >> > X-Original-To: szimszon
>> >> > Delivered-To: szims...@x
>> >> > Received: from xxx (localhost [127.0.0.1])
>> >> >         by xxx (Postfix) with ESMTP id C542A31CBF
>> >> >         for ; Thu, 25 Feb 2010 11:24:05 +0100 (CET)
>> >> > Content-Type: multipart/related;
>> >> > boundary="===1518445122=="
>> >> > MIME-Version: 1.0
>> >> > To: szims...@
>> >> > Subject: test email
>> >> > Message-Id: <20100225102405.c542a31...@xxx>
>> >> > Date: Thu, 25 Feb 2010 11:24:05 +0100 (CET)
>> >> > From: pr...@localhost
>>
>> >> > --===1518445122==
>> >> > Content-Type: multipart/alternative;
>> >> > boundary="===1974471883=="
>> >> > MIME-Version: 1.0
>>
>> >> > --===1974471883==
>> >> > Content-Type: text/plain;charset="us-ascii"
>> >> > MIME-Version: 1.0
>> >> > Content-Transfer-Encoding: 8bit
>>
>> >> > Üdvözlöm Gipsz Jakab!
>>
>> >> > Címed: Szt. Erzsébet körút
>>
>> >> > Ez egy teszt elektronikus levél.
>>
>> >> > Árvíztűrő tükörfúrógép!
>>
>> >> > --===1974471883==--
>> >> > --===1518445122==--
>>
>> >> > - cut -
>>
>> >> >charset: us-ascii
>>
>> >> > If I changed the
>> >> >      mail.send(

Re: [web2py] Re: web2py with Cherokee via uWSGI: a simple, easy guide

2010-02-25 Thread Thadeus Burgess
Actually, SSL is not out of the scope of this entry.

How do you expect me to access admin, or appadmin for that matter?

I can't use web2py without SSL :)

I have tried everything but it just keeps giving me an error saying
something is wrong with my .pem file, but not telling me "what" is
wrong. I even used the make-cert.sh that comes with cherokee.

-Thadeus





On Thu, Feb 25, 2010 at 4:42 PM, GrayMatterComputing
 wrote:
> The guide is fine, it just needs to be Followed Step By Step without
> skipping. ;)
> I also figured the SSL and all was easy enough to find and, again,
> outside the scope of this entry.
>
> On Feb 25, 4:47 pm, Thadeus Burgess  wrote:
>> The following packages are not installed by the PPA...
>>
>> cherokee-doc
>> libcherokee-mod-geoip
>> libcherokee-mod-ldap
>> libcherokee-mod-libssl
>> libcherokee-mod-mysql
>> libcherokee-mod-rrd
>> libcherokee-mod-streaming
>>
>> Installing libcherokee-mod-libssl fixes this.
>>
>> Also they have a great article on creating and signing your own ssl
>> key, it seems the one I am using for apache setup is invalid :)
>>
>> -Thadeus
>>
>> On Thu, Feb 25, 2010 at 3:36 PM, Thadeus Burgess  
>> wrote:
>> > Don't forget to hit save :)0
>>
>> > And how to enable SSL, and use my self signed certificate, OR use a
>> > paid for certificate?
>>
>> > -Thadeus
>>
>> > On Thu, Feb 25, 2010 at 3:25 PM, Thadeus Burgess  
>> > wrote:
>> >> Also, emphasis the fact of using the PPA method of installing, and
>> >> provide instructions on how to do this, and a link to that page. The
>> >> reason it was not working was I installed 0.99.19 instead of 0.99.43.
>>
>> >> -Thadeus
>>
>> >> On Thu, Feb 25, 2010 at 2:27 PM, Thadeus Burgess  
>> >> wrote:
>> >>> A couple of suggestions with the slice
>>
>> >>> Make a note, for buildinguwsgi, that there are makefile.py25 and
>> >>> others so that you can build it for the python version that you want.
>>
>> >>> Do include the little ``ssh -L 9090:localhost:9090 remote_IP`` trick
>> >>> to securely connect to cherokee admin.
>>
>> >>> I do not seeuWSGIlisted under Wizards->Platforms. I do not see it
>> >>> anywhere else.
>>
>> >>> I can run ``uwsgi`` from command line, so it is installed correctly in 
>> >>> my bin.
>>
>> >>> The only difference is I have /web2py and /web2py/config.xml does this 
>> >>> matter?
>>
>> >>> -Thadeus
>>
>> >>> On Thu, Feb 25, 2010 at 10:07 AM, Thadeus Burgess 
>> >>>  wrote:
>>  Can I have cherokeeuwsgiand apache mod_wsgi running on the same
>>  web2py code base or should I make a copy so cherokee can execute it ?
>>
>>  You are right I could run cherokee on a non-standard port for testing
>>  and always switch it over when I am happy with it!
>>
>>  -Thadeus
>>
>>  On Wed, Feb 24, 2010 at 11:30 PM, GrayMatterComputing
>>   wrote:
>> > @Thadeus
>>
>> > For me, it was a breeze to switch from Apache to Cherokee. I was happy
>> > with Apache too, but I used the fact that a client wanted Cherokee as
>> > an opportunity to give it a try, and I am glad I did :) Besides, it is
>> > not like you would have to remove Apache to use Cherokee, so what are
>> > you waiting for (besides possibly a free hour), give it a try!
>>
>> > @mr.freeze and everyone else
>>
>> > This guide has been posted 
>> > athttp://www.web2pyslices.com/main/slices/take_slice/64
>> > and will appear on graymattercomputing.net in the near future.
>>
>> > On Feb 24, 6:05 am, "mr.freeze"  wrote:
>> >> This is really helpful. Unfortunately, it will be lost on this mailing
>> >> list in a month or so.  Care to make a 
>> >> slice?http://www.web2pyslices.com/main/default/index
>>
>> >> On Feb 23, 2:56 pm, GrayMatterComputing  wrote:
>>
>> >> > web2py with Cherokee viauWSGI: a simple, easy guide
>> >> > (written specifically for Ubuntu, but applicable to all systems)
>> >> > By: Evan Gray - GrayMatterComputing
>>
>> >> > 1) web2py
>> >> >  a) Download web2py (found at web2py.com)
>> >> >   i) Install python, if not present: sudo apt-get install python
>> >> >  b) Unzip (to /var/web2py)
>> >> >  c) Run: sudo python /var/web2py/web2py.py -a desiredpassword
>> >> >  d) Verify that it functions properly (by visiting localhost:8000),
>> >> > then close the server (Ctrl+C in terminal)
>> >> >  e) Allow server permission to web2py: sudo chown -hR www-data\: 
>> >> > /var/
>> >> > web2py
>> >> >   i) Where "www-data" is Cherokee's effective user (www-data is the
>> >> > default)
>>
>> >> > 2)uWSGI
>> >> >  a) DownloaduWSGI(found at projects.unbit.it/uwsgi/)
>> >> >  b) Unpackage wherever and cd into folder
>> >> >   i) Install dependencies for make, if not present: sudo apt-get
>> >> > install python-dev libxml2-dev
>> >> >  c) Makeuwsgi: sudo make -f Makefile.Py26
>> >> >  d) Install: sudo cp uwsgi26 /usr/local/bin/uwsgi
>> >> >  e) Create config.xml: sudo cat > /var/web2py/co

Re: [web2py] auth.settings.registration_requires_approval

2010-02-25 Thread Alexandre Andrade
I have adapted a plugin. I will post it soon.

2010/2/25, baloan :
> When setting
>
> auth.settings.registration_requires_approval = True
>
> new user registration seem to keep sitting in pending state. The admin
> needs a user interface to approve or reject new registrations.
>
> Is there any preconfigured approval pages/process built into web2py or
> do I have to implement one by myself? Any template code out there?
>
> Regards, Andreas
>
> --
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/web2py?hl=en.
>
>


-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Plugin useradmin (membership manager)

2010-02-25 Thread Alexandre Andrade
I corrected some functions in the plugin posted before (is no more
ajax, but works).

to make it work, unzip in your app folder.


-- 
Atenciosamente

-- 
=
Alexandre Andrade
Hipercenter.com

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] importing local modules

2010-02-25 Thread Jonathan Lundell
I've made a module that does a nice job, if I do say so myself, of 
encapsulating DataTables (I'll post something about it eventually). 

Since it's a module, I need to import it to my controller, which I'm doing like 
so:

import sys
sys.path.append(request.folder)
import modules.datatables as dt


My question: is there a better way to manage this? At first I was building the 
import path all the way from the web2py base, but I didn't want to include the 
literal application name.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: importing local modules

2010-02-25 Thread mr.freeze
Just do: dt = local_import('datatables')

On Feb 25, 6:11 pm, Jonathan Lundell  wrote:
> I've made a module that does a nice job, if I do say so myself, of 
> encapsulating DataTables (I'll post something about it eventually).
>
> Since it's a module, I need to import it to my controller, which I'm doing 
> like so:
>
> import sys
> sys.path.append(request.folder)
> import modules.datatables as dt
>
> My question: is there a better way to manage this? At first I was building 
> the import path all the way from the web2py base, but I didn't want to 
> include the literal application name.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: Plugin useradmin (membership manager)

2010-02-25 Thread Thadeus Burgess
You can use Admin to pack this in a installable format that admin can
then be used to reimport it into another system.

This is so it is a one click installation instead of having to go
unzip it and everything.

-Thadeus





On Thu, Feb 25, 2010 at 6:02 PM, Alexandre Andrade
 wrote:
> Ops. the file now...
>
>
> 2010/2/25, Alexandre Andrade :
>> I corrected some functions in the plugin posted before (is no more
>> ajax, but works).
>>
>> to make it work, unzip in your app folder.
>>
>>
>> --
>> Atenciosamente
>>
>> --
>> =
>> Alexandre Andrade
>> Hipercenter.com
>>
>
>
> --
> Atenciosamente
>
> --
> =
> Alexandre Andrade
> Hipercenter.com
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] LOAD requires up to date web2py_ajax.html

2010-02-25 Thread Thadeus Burgess
Is there a way that LOAD will just create the necessary javascript, I
have noticed in my apps that haved used LOAD, that they break unless I
update the jquery functions in web2py_ajax.html.

-Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: importing local modules

2010-02-25 Thread Jonathan Lundell
On Feb 25, 2010, at 4:19 PM, mr.freeze wrote:

> Just do: dt = local_import('datatables')

Thanks. Maybe the book should reflect this: 
http://web2py.com/book/default/section/4/18

(I'd make the change, but I'm a little fuzzy on the details.)

> 
> On Feb 25, 6:11 pm, Jonathan Lundell  wrote:
>> I've made a module that does a nice job, if I do say so myself, of 
>> encapsulating DataTables (I'll post something about it eventually).
>> 
>> Since it's a module, I need to import it to my controller, which I'm doing 
>> like so:
>> 
>> import sys
>> sys.path.append(request.folder)
>> import modules.datatables as dt
>> 
>> My question: is there a better way to manage this? At first I was building 
>> the import path all the way from the web2py base, but I didn't want to 
>> include the literal application name.


-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: LOAD requires up to date web2py_ajax.html

2010-02-25 Thread mr.freeze
I've asked for this a few times with no response but I'll say it
again: web2py_ajax.html needs an area for something similar to
response.files but for raw script. Plugins, widgets and other
components could use it to include just this sort of thing.

On Feb 25, 6:51 pm, Thadeus Burgess  wrote:
> Is there a way that LOAD will just create the necessary javascript, I
> have noticed in my apps that haved used LOAD, that they break unless I
> update the jquery functions in web2py_ajax.html.
>
> -Thadeus

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: LOAD requires up to date web2py_ajax.html

2010-02-25 Thread Thadeus Burgess
py2jquery manager class does this already also your clienttools
has a version of this.

I am thinking something similar to these needs to be included into web2py.

-Thadeus





On Thu, Feb 25, 2010 at 7:30 PM, mr.freeze  wrote:
> I've asked for this a few times with no response but I'll say it
> again: web2py_ajax.html needs an area for something similar to
> response.files but for raw script. Plugins, widgets and other
> components could use it to include just this sort of thing.
>
> On Feb 25, 6:51 pm, Thadeus Burgess  wrote:
>> Is there a way that LOAD will just create the necessary javascript, I
>> have noticed in my apps that haved used LOAD, that they break unless I
>> update the jquery functions in web2py_ajax.html.
>>
>> -Thadeus
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] app admin - old app missing from list

2010-02-25 Thread BrendanC
newbie qns -
I just d/loaded the latest version of web2py and on start up I see
that a small app I created some time ago is not listed in the app list
- the files are there in the web2py directory.

Is there something I need to do to include missing apps (this is on
Win XP - so it's not a symlink issue afaik)?

also - where does web2py store its files by default and is this
configurable? (Fwiw I like to use my own (color coded  editor for code
editing).

TIA,
Brendan

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: importing local modules

2010-02-25 Thread Thadeus Burgess
Done.

-Thadeus





On Thu, Feb 25, 2010 at 7:06 PM, Jonathan Lundell  wrote:
> On Feb 25, 2010, at 4:19 PM, mr.freeze wrote:
>
>> Just do: dt = local_import('datatables')
>
> Thanks. Maybe the book should reflect this: 
> http://web2py.com/book/default/section/4/18
>
> (I'd make the change, but I'm a little fuzzy on the details.)
>
>>
>> On Feb 25, 6:11 pm, Jonathan Lundell  wrote:
>>> I've made a module that does a nice job, if I do say so myself, of 
>>> encapsulating DataTables (I'll post something about it eventually).
>>>
>>> Since it's a module, I need to import it to my controller, which I'm doing 
>>> like so:
>>>
>>> import sys
>>> sys.path.append(request.folder)
>>> import modules.datatables as dt
>>>
>>> My question: is there a better way to manage this? At first I was building 
>>> the import path all the way from the web2py base, but I didn't want to 
>>> include the literal application name.
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread mdipierro
Tiago was right. You need the windows extension to have file locking
in windows. I do not know why they did not include that as standard in
Python. I agree with you it should be critical.

On Feb 25, 6:13 am, Magnitus  wrote:
> >what os are you using. This should work o Posix and win32.
>
> Windows Vista, 64-bit.
>
> I got the 64-bit download for the windows extension at the link that
> Tiago mentioned and it 'fixed' the warning message (though I'm still
> puzzled at why a special windows extension was needed on top of the
> release to 'fix' python, perhaps they should include it the release...
> some doc came with the open source version, guess I'll have to read it
> and find out what the add-on fixes).
>
> Thanks for all the help :).
>
> On Feb 25, 6:32 am, Tiago Almeida  wrote:
>
> > For the root no file locking, try:
>
> > Install "Python for windows
> > extensions>"
> > (If you're using windows)
>
> > I had a similar issue and documented here
> > in
> > the past and it solved my problem. Don't know why though.
>
> > Regards,
> > Tiago
> > ---
>
> > On Thu, Feb 25, 2010 at 10:02 AM, Magnitus  wrote:
> > > Thanks for the heads up.
>
> > > I did run web2py.py directly and while it works, I got the following
> > > warning:
>
> > > WARNING:root:no file locking
>
> > > It seems to work otherwise, but I'd still like some clarification on
> > > the warning if anybody knows.
>
> > > Parallel to this, I found a py2exe to make a 64 bit binary at
> > > (downloaded the one for python 2.6 as its the version of python that I
> > > use):http://sourceforge.net/projects/py2exe/files/
>
> > > When I tried running "python setup_exe.py py2exe", I got the following
> > > error during installation:
>
> > > *** copy data files ***
> > > warning: install_data: setup script did not provide a directory for
> > > 'admin.w2p'
> > > -- installing right in 'D:\web2py\dist'
> > > error: can't copy 'admin.w2p': doesn't exist or not a regular file
>
> > > >>python web2py.py
>
> > > Because you can do so, I believe you can package it in a binary form
> > > using
> > > tools like py2exe.
>
> > > On Feb 24, 9:48 am, Tiago Almeida  wrote:
> > > > No questions are stupid.
> > > > I'm no expert but I'll coment on what I know.
>
> > > > Web2py runs officially in python 2.5. Don't know how hard it would be to
> > > put
> > > > web2py running on 2.6.
>
> > > > You don't need the binary package to run web2py, you can run it directly
> > > > from python (execute file web2py.py)>>python web2py.py
>
> > > > Because you can do so, I believe you can package it in a binary form
> > > using
> > > > tools like py2exe.
>
> > > > Backward compatibility claim is just related to the fact that code
> > > changes
> > > > to web2py don't break webapplications written for web2py.
>
> > > > I believe web2py will have to support python2.6 eventually but don't 
> > > > know
> > > > when.
> > > > Python 3.x support is even farther away. Py3k is a different language, 
> > > > it
> > > > has some details that break existing code base and, as such, all the 
> > > > code
> > > > has to be ported. It won't happen overnight.
>
> > > > Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does and
> > > you
> > > > can integrate it easily with web2py (instead of integrating web2py with
> > > what
> > > > you have).
>
> > > > Regards,
> > > > Tiago
>
> > > > ---
>
> > > > On Wed, Feb 24, 2010 at 9:23 AM, Magnitus 
> > > wrote:
> > > > > Hi, I'm a beginner in python and a complete neophyte in python web
> > > > > frameworks so don't bash my head in if the questions are stupid...
>
> > > > > I'm developing an application in C++ for windows x64 and I am now
> > > > > looking for a way to make it a web app.
>
> > > > > I'm looking for compatibility with python 2.6 (already started the
> > > > > process of gluing my code with the C API) and eventually python 3.1 in
> > > > > case they stop supporting prior versions. I'm also looking for
> > > > > compatibility with the 64 bits address format.
>
> > > > > Now, I see that web2py is available with a pre-compiled binary for
> > > > > windows. Is it a win32 binary? If so, can I build a win64 binary from
> > > > > the source code with python 2.6?
>
> > > > > Also, looking at the current compatibilities (2.4/2.5/2.6) and the
> > > > > claim that backward compatibility of the framework will not be broken,
> > > > > I'm wondering if there any future plans for web2py to be eventually
> > > > > compatible with python 3.1 (given that python 3.1 is not backward
> > > > > compatible with code written for previous versions of python or so I
> > > > > heard).
>
> > > > > --
> > > > > You

[web2py] Re: zen html

2010-02-25 Thread mdipierro
cool. thanks.

On Feb 25, 9:49 am, selecta  wrote:
> Sometimes you still have to write html in web2py which is annoying. It
> might not be new to all of you but I just discovered zen html that
> really speeds up the process.
> In my example i customized the zen key to ctrl + z
>
> What it does:
>
> type
> div.box
> and you get
> 
> with you cursor in the middle of the divs ready to type :)
>
> even better
> table>tr*3>td
> and you get
> 
>         
>                 
>         
>         
>                 
>         
>         
>                 
>         
> 
>
> there are plugins for vim, emacs, textmate ...I love it, you might
> too, check it out
>
> here is a vid showing zen htmlhttp://vimeo.com/7405114
>
> and here the projecthttp://code.google.com/p/zen-coding/
>
> I usehttp://www.vim.org/scripts/script.php?script_id=2981
> just dropped the plugin into .vim/ftplugin/html/ and edited the
> shortcut to something convenient
> :)

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: newly created app fails in shell mode in 1.75.4

2010-02-25 Thread mdipierro
scratching head too...

On Feb 25, 5:47 am, DenesL  wrote:
> Using 1.75.4, a newly created app fails to start in shell mode (-M -N -
> S) with:
>
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.75.4 (2010-02-18 14:55:03)
> Database drivers available: pysqlite2, MSSQL/DB2
> Traceback (most recent call last):
>   File "C:\web2py\hg\gluon\restricted.py", line 173, in restricted
>     exec ccode in environment
>   File "applications\test2\models/db.py", line 15, in 
>     db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> other DB
>   File "C:\web2py\hg\gluon\sql.py", line 3769, in DAL
>     db_codec=db_codec, check_reserved=check_reserved)
>   File "C:\web2py\hg\gluon\sql.py", line 889, in __init__
>     self._pool_connection(lambda : sqlite3.Connection(dbpath,
>   File "C:\web2py\hg\gluon\sql.py", line 829, in _pool_connection
>     self._connection = f()
>   File "C:\web2py\hg\gluon\sql.py", line 890, in 
>     check_same_thread=False))
> OperationalError: unable to open database file
>
> until you use appadmin on it.
> This did not happen in 1.75.1 AFAIK.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Cuestion about jzip and jpg image?

2010-02-25 Thread mdipierro
You should use a separate web server, for example apache, and
configure it use it gzip. It is explained here:

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

This is outside and transparent to web2py.

Perhaps this helps.

On Feb 25, 12:10 pm, drayco  wrote:
> Hi, web2py users,
> I have a application with 6 web services with json in web2py.
> I answer topological information every minute.
> And my partners told me that the size of the answer is too large. They
> told me that we need to use jzip.
> The new requirements is that I need to give a jpg image too.
>
> But I am a newbie in web application.
>
> Can any of you give me a litle example with jzip?
>
> And How can I put a jpg image in a web service?
>
> Thank's in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Toggle on/off editarea on startup

2010-02-25 Thread mdipierro
I will look at it asap. thanks.

On Feb 20, 2:13 pm, Alex  wrote:
> I have added DISPLAY parameter in web2py\applications\admin\models
> \0.py
> It helps to manage mode of web2py built in code editor on page
> startup.
> It is usefull with Its All Text Firefox plugin which allow to edit
> context of textareas in your favorite editor. UliPad for example) This
> plugin work well with textarea not editarea extension
>
> Patch with instruction is 
> here:http://sites.google.com/a/rasklad.com/web2py/home/editareastartuponoff
>
> I am newbie in team development and in open source participation.
> Please, advise me how can I make my cosmetic corrections and share
> them with web2py community.
>
> Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Some interrogations concerning Web2py compatibilities

2010-02-25 Thread mr.freeze
I started using ActivePython instead of the stock releases of python.
They have win32 extensions built in and a few other helpful things.
http://www.activestate.com/activepython/features/

On Feb 25, 8:12 pm, mdipierro  wrote:
> Tiago was right. You need the windows extension to have file locking
> in windows. I do not know why they did not include that as standard in
> Python. I agree with you it should be critical.
>
> On Feb 25, 6:13 am, Magnitus  wrote:
>
> > >what os are you using. This should work o Posix and win32.
>
> > Windows Vista, 64-bit.
>
> > I got the 64-bit download for the windows extension at the link that
> > Tiago mentioned and it 'fixed' the warning message (though I'm still
> > puzzled at why a special windows extension was needed on top of the
> > release to 'fix' python, perhaps they should include it the release...
> > some doc came with the open source version, guess I'll have to read it
> > and find out what the add-on fixes).
>
> > Thanks for all the help :).
>
> > On Feb 25, 6:32 am, Tiago Almeida  wrote:
>
> > > For the root no file locking, try:
>
> > > Install "Python for windows
> > > extensions>"
> > > (If you're using windows)
>
> > > I had a similar issue and documented here
> > > in
> > > the past and it solved my problem. Don't know why though.
>
> > > Regards,
> > > Tiago
> > > ---
>
> > > On Thu, Feb 25, 2010 at 10:02 AM, Magnitus  
> > > wrote:
> > > > Thanks for the heads up.
>
> > > > I did run web2py.py directly and while it works, I got the following
> > > > warning:
>
> > > > WARNING:root:no file locking
>
> > > > It seems to work otherwise, but I'd still like some clarification on
> > > > the warning if anybody knows.
>
> > > > Parallel to this, I found a py2exe to make a 64 bit binary at
> > > > (downloaded the one for python 2.6 as its the version of python that I
> > > > use):http://sourceforge.net/projects/py2exe/files/
>
> > > > When I tried running "python setup_exe.py py2exe", I got the following
> > > > error during installation:
>
> > > > *** copy data files ***
> > > > warning: install_data: setup script did not provide a directory for
> > > > 'admin.w2p'
> > > > -- installing right in 'D:\web2py\dist'
> > > > error: can't copy 'admin.w2p': doesn't exist or not a regular file
>
> > > > >>python web2py.py
>
> > > > Because you can do so, I believe you can package it in a binary form
> > > > using
> > > > tools like py2exe.
>
> > > > On Feb 24, 9:48 am, Tiago Almeida  wrote:
> > > > > No questions are stupid.
> > > > > I'm no expert but I'll coment on what I know.
>
> > > > > Web2py runs officially in python 2.5. Don't know how hard it would be 
> > > > > to
> > > > put
> > > > > web2py running on 2.6.
>
> > > > > You don't need the binary package to run web2py, you can run it 
> > > > > directly
> > > > > from python (execute file web2py.py)>>python web2py.py
>
> > > > > Because you can do so, I believe you can package it in a binary form
> > > > using
> > > > > tools like py2exe.
>
> > > > > Backward compatibility claim is just related to the fact that code
> > > > changes
> > > > > to web2py don't break webapplications written for web2py.
>
> > > > > I believe web2py will have to support python2.6 eventually but don't 
> > > > > know
> > > > > when.
> > > > > Python 3.x support is even farther away. Py3k is a different 
> > > > > language, it
> > > > > has some details that break existing code base and, as such, all the 
> > > > > code
> > > > > has to be ported. It won't happen overnight.
>
> > > > > Doesn't the code you wrote for python 2.6 run in 2.5? Maybe it does 
> > > > > and
> > > > you
> > > > > can integrate it easily with web2py (instead of integrating web2py 
> > > > > with
> > > > what
> > > > > you have).
>
> > > > > Regards,
> > > > > Tiago
>
> > > > > ---
>
> > > > > On Wed, Feb 24, 2010 at 9:23 AM, Magnitus 
> > > > wrote:
> > > > > > Hi, I'm a beginner in python and a complete neophyte in python web
> > > > > > frameworks so don't bash my head in if the questions are stupid...
>
> > > > > > I'm developing an application in C++ for windows x64 and I am now
> > > > > > looking for a way to make it a web app.
>
> > > > > > I'm looking for compatibility with python 2.6 (already started the
> > > > > > process of gluing my code with the C API) and eventually python 3.1 
> > > > > > in
> > > > > > case they stop supporting prior versions. I'm also looking for
> > > > > > compatibility with the 64 bits address format.
>
> > > > > > Now, I see that web2py is available with a pre-compiled binary for
> > > > > > windows. Is it a win32 binary? If so, can I build a win64 binary 
> > > > > > from
>

[web2py] Re: google app engine, file size limits

2010-02-25 Thread mdipierro
Exactly. Like you specify

db.table.field.uploadfolder=os.path.join(request.folder,'uploads')

you could specify

db.table.field.uploadmethod='gae_blobstore'

On Feb 25, 2:02 pm, villas  wrote:
> Alex,  Thanks for this interesting information. This can make GAE
> suitable for a lot of extra use.
>
> > It should be easy to add blobstore support to web2py.
>
> +1
>
> Massimo,  How do you imagine it would be supported?
> Maybe as just an option on 'upload' type which is ignored when non-GAE?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: LOAD requires up to date web2py_ajax.html

2010-02-25 Thread mr.freeze
Sure, but clienttools had it first :)

On Feb 25, 8:05 pm, Thadeus Burgess  wrote:
> py2jquery manager class does this already also your clienttools
> has a version of this.
>
> I am thinking something similar to these needs to be included into web2py.
>
> -Thadeus
>
> On Thu, Feb 25, 2010 at 7:30 PM, mr.freeze  wrote:
> > I've asked for this a few times with no response but I'll say it
> > again: web2py_ajax.html needs an area for something similar to
> > response.files but for raw script. Plugins, widgets and other
> > components could use it to include just this sort of thing.
>
> > On Feb 25, 6:51 pm, Thadeus Burgess  wrote:
> >> Is there a way that LOAD will just create the necessary javascript, I
> >> have noticed in my apps that haved used LOAD, that they break unless I
> >> update the jquery functions in web2py_ajax.html.
>
> >> -Thadeus
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Plugin system status

2010-02-25 Thread mdipierro
When I am back home Perhaps we should an IRC discussion on this. Email
will not do. Start preparing your proposals.

On Feb 25, 4:34 pm, pistacchio  wrote:
> i'm late in the whole "plugin" discussion, i didn't really follow it
> from start (being new to web2py).
> my only question is: what is the _scope_ of plugins? as i got it
> correctly, there's an ongoing debate on the form of plugins, classes
> vs directories.
>
> if we're talking about small things like "display the last post from
> twitter plugin" or "contact form plugin" or "openid authentication
> plugin", the class thing may fit. but if we're talking about wider
> things like "the blog plugin" or "the forum plugin", i really wonder
> how they could implemented without having their own directory
> structure.
>
> On 24 Feb, 01:37, "mr.freeze"  wrote:
>
> > Is the plugin system considered backwards compatible at this point? I
> > am considering converting some modules into plugins but want to know
> > if they API is stable.
>
> > Also, is the naming convention of 'db' for your database still
> > required for the plugin system?
>
> > ---
> > I predict that in the year 2015, web2py will gain self awareness and
> > attempt to take over the world under the name PyNet.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: I'd just like to say.

2010-02-25 Thread mdipierro
Thanks for letting us know. If it is useful we are happy.

On Feb 25, 4:42 pm, Matt  wrote:
> Hi Massimo ,
>
> I'd just like to say a massive thanks to you and the rest of the
> people who have contributed to making web2py such an amazingly nice
> framework to use.
>
> I'm in the process of porting an existing Django project in web2py and
> I'm thoroughly enjoying how clean and simple web2py is.
>
> The GAE support it brilliant, the API is flexible and well thought out
> and having everything like JQuery etc bundled in is a massive help not
> to mention a huge time saver.
>
> Thanks for creating a better wheel. Keep up the fantastic work.
>
> Kind regards,
> Matt

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: LOAD requires up to date web2py_ajax.html

2010-02-25 Thread Thadeus Burgess
py2jquery handles dependencies :)

-Thadeus





On Thu, Feb 25, 2010 at 8:21 PM, mr.freeze  wrote:
> Sure, but clienttools had it first :)
>
> On Feb 25, 8:05 pm, Thadeus Burgess  wrote:
>> py2jquery manager class does this already also your clienttools
>> has a version of this.
>>
>> I am thinking something similar to these needs to be included into web2py.
>>
>> -Thadeus
>>
>> On Thu, Feb 25, 2010 at 7:30 PM, mr.freeze  wrote:
>> > I've asked for this a few times with no response but I'll say it
>> > again: web2py_ajax.html needs an area for something similar to
>> > response.files but for raw script. Plugins, widgets and other
>> > components could use it to include just this sort of thing.
>>
>> > On Feb 25, 6:51 pm, Thadeus Burgess  wrote:
>> >> Is there a way that LOAD will just create the necessary javascript, I
>> >> have noticed in my apps that haved used LOAD, that they break unless I
>> >> update the jquery functions in web2py_ajax.html.
>>
>> >> -Thadeus
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "web2py-users" group.
>> > To post to this group, send email to web...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > web2py+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/web2py?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Web2py Scalability and demos

2010-02-25 Thread Alfonso de la Guarda
Hello,

Right now, i have a costumer in the news business in my country which
expect, at least, 50 hits by day in their website.  Currently they
are using django as web framework but i wanna move some new apps to
web2py.  The questions are:

How can I convince them to agree to take the course for new projects web2py?
There are statistics from sites with similar traffic web2py currently employing?
There is documentation of performance benchmarks among web2py, django,
ROR or PHP?
Someone has information, or has gone through the same problem?

(A clarification: we have now developed small applications, but in
this case we speak of a large number of hits per day and that means
making a decision technically supported)



Thanks in advance,


Alfonso de la Guarda
Centro Open Source(COS)
http://www.cos-la.net
http://alfonsodg.net
   Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] app admin - old app missing from list

2010-02-25 Thread Thadeus Burgess
web2py stores all applications in

web2py/applications

So in this folder you will find

web2py/applications/admin
web2py/applications/welcome
web2py/applications/

You can edit these files with any external editor that you desire.
Personally I prefer WingIDE, however since I cannot afford it I use
Netbeans with python plugin. I just create my project and references
my applications folder, and all of my apps are version controlled as
well.

What has probably happened, from your description, is you had a old
version of web2py, you created your app and everything, and then you
downloaded a newer one in a new location. You just need to copy your
applications/ from the old web2py directory to the new one.

And since web2py/applications/ is all self contained, you can
easily store this elsewhere on your computer and simlink it to the
web2py/applications directory. Though keep in mind applications
created through admin will always existin in
web2py/applications/, but even then you do not need to use
admin to create/or edit any of the files.

-Thadeus





On Thu, Feb 25, 2010 at 5:04 PM, BrendanC  wrote:
> newbie qns -
> I just d/loaded the latest version of web2py and on start up I see
> that a small app I created some time ago is not listed in the app list
> - the files are there in the web2py directory.
>
> Is there something I need to do to include missing apps (this is on
> Win XP - so it's not a symlink issue afaik)?
>
> also - where does web2py store its files by default and is this
> configurable? (Fwiw I like to use my own (color coded  editor for code
> editing).
>
> TIA,
> Brendan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: app admin - old app missing from list

2010-02-25 Thread BrendanC
Thadeus,
Many thanks for your fast response - you nailed it - the newer version
I installed is looking for files/apps on my C drive - (I had set the
the previous version's apps up on my D drive). I just need to move
them per your suggestion. FWIW - I've also used the WingIDE for some
Python development and like it a lot for  general coding/debugging.

P.S. I'm not sure if it's possible to symlink in windows (xp). Windows
short cuts are somewhat similar to symlinks but may not work with
web2py .

thx again!

On Feb 25, 6:43 pm, Thadeus Burgess  wrote:
> web2py stores all applications in
>
> web2py/applications
>
> So in this folder you will find
>
> web2py/applications/admin
> web2py/applications/welcome
> web2py/applications/
>
> You can edit these files with any external editor that you desire.
> Personally I prefer WingIDE, however since I cannot afford it I use
> Netbeans with python plugin. I just create my project and references
> my applications folder, and all of my apps are version controlled as
> well.
>
> What has probably happened, from your description, is you had a old
> version of web2py, you created your app and everything, and then you
> downloaded a newer one in a new location. You just need to copy your
> applications/ from the old web2py directory to the new one.
>
> And since web2py/applications/ is all self contained, you can
> easily store this elsewhere on your computer and simlink it to the
> web2py/applications directory. Though keep in mind applications
> created through admin will always existin in
> web2py/applications/, but even then you do not need to use
> admin to create/or edit any of the files.
>
> -Thadeus
>
>
>
> On Thu, Feb 25, 2010 at 5:04 PM, BrendanC  wrote:
> > newbie qns -
> > I just d/loaded the latest version of web2py and on start up I see
> > that a small app I created some time ago is not listed in the app list
> > - the files are there in the web2py directory.
>
> > Is there something I need to do to include missing apps (this is on
> > Win XP - so it's not a symlink issue afaik)?
>
> > also - where does web2py store its files by default and is this
> > configurable? (Fwiw I like to use my own (color coded  editor for code
> > editing).
>
> > TIA,
> > Brendan
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] request.vars bug?

2010-02-25 Thread Ben
Hi all,
I have a URL like the following:
feature_reading?
feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=54

however, when I try to extract the sensor_id vars at the other end, i
get a list as such:
['51', '5', '2', '5', '3', '5', '4']

anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: app admin - old app missing from list

2010-02-25 Thread Thadeus Burgess
If you are using NTFS take a look into "hard links" they are simlinks
for windows. I used them for gaming back in the day. (to trick the
games that they were installing on C: when they were really installing
on T :)

-Thadeus





On Thu, Feb 25, 2010 at 9:59 PM, BrendanC  wrote:
> Thadeus,
> Many thanks for your fast response - you nailed it - the newer version
> I installed is looking for files/apps on my C drive - (I had set the
> the previous version's apps up on my D drive). I just need to move
> them per your suggestion. FWIW - I've also used the WingIDE for some
> Python development and like it a lot for  general coding/debugging.
>
> P.S. I'm not sure if it's possible to symlink in windows (xp). Windows
> short cuts are somewhat similar to symlinks but may not work with
> web2py .
>
> thx again!
>
> On Feb 25, 6:43 pm, Thadeus Burgess  wrote:
>> web2py stores all applications in
>>
>> web2py/applications
>>
>> So in this folder you will find
>>
>> web2py/applications/admin
>> web2py/applications/welcome
>> web2py/applications/
>>
>> You can edit these files with any external editor that you desire.
>> Personally I prefer WingIDE, however since I cannot afford it I use
>> Netbeans with python plugin. I just create my project and references
>> my applications folder, and all of my apps are version controlled as
>> well.
>>
>> What has probably happened, from your description, is you had a old
>> version of web2py, you created your app and everything, and then you
>> downloaded a newer one in a new location. You just need to copy your
>> applications/ from the old web2py directory to the new one.
>>
>> And since web2py/applications/ is all self contained, you can
>> easily store this elsewhere on your computer and simlink it to the
>> web2py/applications directory. Though keep in mind applications
>> created through admin will always existin in
>> web2py/applications/, but even then you do not need to use
>> admin to create/or edit any of the files.
>>
>> -Thadeus
>>
>>
>>
>> On Thu, Feb 25, 2010 at 5:04 PM, BrendanC  wrote:
>> > newbie qns -
>> > I just d/loaded the latest version of web2py and on start up I see
>> > that a small app I created some time ago is not listed in the app list
>> > - the files are there in the web2py directory.
>>
>> > Is there something I need to do to include missing apps (this is on
>> > Win XP - so it's not a symlink issue afaik)?
>>
>> > also - where does web2py store its files by default and is this
>> > configurable? (Fwiw I like to use my own (color coded  editor for code
>> > editing).
>>
>> > TIA,
>> > Brendan
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "web2py-users" group.
>> > To post to this group, send email to web...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > web2py+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/web2py?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Web2py Scalability and demos

2010-02-25 Thread mdipierro
In general the bottleneck is the database access. The web2py DAL adds
negligible overhead to that

   http://web2py.com/AlterEgo/default/show/76

People have tested web2py vs Pylons (which people says it is faster
than Django and reddit.com uses it):

   http://www.mail-archive.com/web2py@googlegroups.com/msg04120.html

(these kind of results really depend on the app).

If you use the internal web server, web2py  uses cherrypy's which is
faster than the others python ones.

   http://www.rkblog.rk.edu.pl/w/p/simple-python-frameworks-benchmark/

(this is going to change since Tim wrote Rocket that is better than
Cherrypy's and we are about to move to it).

It would be nice to run more benchmarks.

Massimo

On Feb 25, 8:42 pm, Alfonso de la Guarda  wrote:
> Hello,
>
> Right now, i have a costumer in the news business in my country which
> expect, at least, 50 hits by day in their website.  Currently they
> are using django as web framework but i wanna move some new apps to
> web2py.  The questions are:
>
> How can I convince them to agree to take the course for new projects web2py?
> There are statistics from sites with similar traffic web2py currently 
> employing?
> There is documentation of performance benchmarks among web2py, django,
> ROR or PHP?
> Someone has information, or has gone through the same problem?
>
> (A clarification: we have now developed small applications, but in
> this case we speak of a large number of hits per day and that means
> making a decision technically supported)
>
> Thanks in advance,
>
> 
> Alfonso de la Guarda
> Centro Open Source(COS)http://www.cos-la.nethttp://alfonsodg.net
>    Telef. 991935157
> 1024D/B23B24A4
> 5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread mdipierro
This is a feature.
If you have multiple values for the same var in the url you get a list
with the values.

On Feb 25, 10:06 pm, Ben  wrote:
> Hi all,
> I have a URL like the following:
> feature_reading?
> feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=54
>
> however, when I try to extract the sensor_id vars at the other end, i
> get a list as such:
> ['51', '5', '2', '5', '3', '5', '4']
>
> anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread Ben
Also, I can confirm that request.values() produces the correct output:
'REQUEST_URI': '/tasman/query/feature_reading?
feature_id=15&sensor_id=51&sensor_id=52&sensor_id=53&sensor_id=54...

On Feb 26, 3:06 pm, Ben  wrote:
> Hi all,
> I have a URL like the following:
> feature_reading?
> feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5 4
>
> however, when I try to extract the sensor_id vars at the other end, i
> get a list as such:
> ['51', '5', '2', '5', '3', '5', '4']
>
> anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread Ben
I do indeed want multiple values, however, they should be ['51', '52',
'53', '54'].

On Feb 26, 3:37 pm, mdipierro  wrote:
> This is a feature.
> If you have multiple values for the same var in the url you get a list
> with the values.
>
> On Feb 25, 10:06 pm, Ben  wrote:
>
>
>
> > Hi all,
> > I have a URL like the following:
> > feature_reading?
> > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5 
> > 4
>
> > however, when I try to extract the sensor_id vars at the other end, i
> > get a list as such:
> > ['51', '5', '2', '5', '3', '5', '4']
>
> > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] any quick workaround for the datetime strftime() methods require year >= 1900

2010-02-25 Thread vince
i run into some rare problem on web2py it's related to python's
limitation/bugs

Traceback (most recent call last):
  File "/Library/WebServer/Documents/web2py/gluon/restricted.py", line
173, in restricted
exec ccode in environment
  File "/Library/WebServer/Documents/web2py/applications/cychurch/
controllers/members.py", line 2523, in 
  File "/Library/WebServer/Documents/web2py/gluon/globals.py", line
96, in 
self._caller = lambda f: f()
  File "/Library/WebServer/Documents/web2py/applications/cychurch/
controllers/members.py", line 72, in show
 
form1=SQLFORM(db.members,thisrecord,fields=field1,deletable=False,showid=False,labels=header1,submit_button=T('Submit'))
  File "/Library/WebServer/Documents/web2py/gluon/sqlhtml.py", line
656, in __init__
default = field.formatter(default)
  File "/Library/WebServer/Documents/web2py/gluon/sql.py", line 2676,
in formatter
  File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
2214, in formatter
return self.other.formatter(value)
  File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
1960, in formatter
return value.strftime(self.format)
ValueError: year=1897 is before 1900; the datetime strftime() methods
require year >= 1900


is there any quick workaround for it? any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread mdipierro
oops. I misunderstood the question. Something is wrong. Which OS/web2
server/Python version?

On Feb 25, 10:06 pm, Ben  wrote:
> Hi all,
> I have a URL like the following:
> feature_reading?
> feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=54
>
> however, when I try to extract the sensor_id vars at the other end, i
> get a list as such:
> ['51', '5', '2', '5', '3', '5', '4']
>
> anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread mdipierro
This parsing is not done by web2py. It is done by the Python
cgi.FieldStoarge function.
What is in requet.get_vars and request.post_vars?


On Feb 25, 10:44 pm, Ben  wrote:
> I do indeed want multiple values, however, they should be ['51', '52',
> '53', '54'].
>
> On Feb 26, 3:37 pm, mdipierro  wrote:
>
> > This is a feature.
> > If you have multiple values for the same var in the url you get a list
> > with the values.
>
> > On Feb 25, 10:06 pm, Ben  wrote:
>
> > > Hi all,
> > > I have a URL like the following:
> > > feature_reading?
> > > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5
> > >  4
>
> > > however, when I try to extract the sensor_id vars at the other end, i
> > > get a list as such:
> > > ['51', '5', '2', '5', '3', '5', '4']
>
> > > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread Ben
OS: GNU/Linux (2.6.24-21-generic) [Debian lenny/sid]
web2py: web2py Version 1.75.1 (2010-02-12 15:13:11)
Python: Python 2.5.2

On Feb 26, 3:47 pm, mdipierro  wrote:
> oops. I misunderstood the question. Something is wrong. Which OS/web2
> server/Python version?
>
> On Feb 25, 10:06 pm, Ben  wrote:
>
>
>
> > Hi all,
> > I have a URL like the following:
> > feature_reading?
> > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5 
> > 4
>
> > however, when I try to extract the sensor_id vars at the other end, i
> > get a list as such:
> > ['51', '5', '2', '5', '3', '5', '4']
>
> > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread Ben
Hmm, interesting..
request.get_vars = ...'sensor_id': ['51', '5', '2', '5', '3', '5',
'4']
post_vars is empty (as I would expect).
Cheers.

If it turns out to be a python bug I'll just regex it out of
request.values() instead :)

On Feb 26, 3:50 pm, mdipierro  wrote:
> This parsing is not done by web2py. It is done by the Python
> cgi.FieldStoarge function.
> What is in requet.get_vars and request.post_vars?
>
> On Feb 25, 10:44 pm, Ben  wrote:
>
>
>
> > I do indeed want multiple values, however, they should be ['51', '52',
> > '53', '54'].
>
> > On Feb 26, 3:37 pm, mdipierro  wrote:
>
> > > This is a feature.
> > > If you have multiple values for the same var in the url you get a list
> > > with the values.
>
> > > On Feb 25, 10:06 pm, Ben  wrote:
>
> > > > Hi all,
> > > > I have a URL like the following:
> > > > feature_reading?
> > > > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5
> > > >  4
>
> > > > however, when I try to extract the sensor_id vars at the other end, i
> > > > get a list as such:
> > > > ['51', '5', '2', '5', '3', '5', '4']
>
> > > > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread mdipierro
I think this is a bug in the cgi module but please do one test.

In gluon/mail.py there is

def parse_get_post_vars(request, environ):
dget = cgi.parse_qsl(request.env.query_string,
keep_blank_values=1)

Add this line:

   print request.env.query_string
   print dget

This will nail down the problem to the cgi.parse_qsl funtion.


On Feb 25, 10:53 pm, Ben  wrote:
> OS: GNU/Linux (2.6.24-21-generic) [Debian lenny/sid]
> web2py: web2py Version 1.75.1 (2010-02-12 15:13:11)
> Python: Python 2.5.2
>
> On Feb 26, 3:47 pm, mdipierro  wrote:
>
> > oops. I misunderstood the question. Something is wrong. Which OS/web2
> > server/Python version?
>
> > On Feb 25, 10:06 pm, Ben  wrote:
>
> > > Hi all,
> > > I have a URL like the following:
> > > feature_reading?
> > > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5
> > >  4
>
> > > however, when I try to extract the sensor_id vars at the other end, i
> > > get a list as such:
> > > ['51', '5', '2', '5', '3', '5', '4']
>
> > > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: any quick workaround for the datetime strftime() methods require year >= 1900

2010-02-25 Thread mdipierro
what about about we do something like this in web2py?

def format_date(d, format):
 format = format.replace('%y',str(d.year)[-2:])
 if d.year>=0:
 format = format.replace('%Y',str(d.year))
 else:
 format = format.replace('%Y',str(d.year)+'B.C.')
 d =
datetime.datetime(2000,d.month,d.day,d.hour,d.minute,d.second)
 return d.strftime(format)


On Feb 25, 10:47 pm, vince  wrote:
> i run into some rare problem on web2py it's related to python's
> limitation/bugs
>
> Traceback (most recent call last):
>   File "/Library/WebServer/Documents/web2py/gluon/restricted.py", line
> 173, in restricted
>     exec ccode in environment
>   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> controllers/members.py", line 2523, in 
>   File "/Library/WebServer/Documents/web2py/gluon/globals.py", line
> 96, in 
>     self._caller = lambda f: f()
>   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> controllers/members.py", line 72, in show
>
> form1=SQLFORM(db.members,thisrecord,fields=field1,deletable=False,showid=False,labels=header1,submit_button=T('Submit'))
>   File "/Library/WebServer/Documents/web2py/gluon/sqlhtml.py", line
> 656, in __init__
>     default = field.formatter(default)
>   File "/Library/WebServer/Documents/web2py/gluon/sql.py", line 2676,
> in formatter
>   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> 2214, in formatter
>     return self.other.formatter(value)
>   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> 1960, in formatter
>     return value.strftime(self.format)
> ValueError: year=1897 is before 1900; the datetime strftime() methods
> require year >= 1900
>
> is there any quick workaround for it? any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: any quick workaround for the datetime strftime() methods require year >= 1900

2010-02-25 Thread vince
is it just for years for B.C.? but currently python's strftime even
have error when it's year >= 1900.

On Feb 26, 1:09 pm, mdipierro  wrote:
> what about about we do something like this in web2py?
>
> def format_date(d, format):
>      format = format.replace('%y',str(d.year)[-2:])
>      if d.year>=0:
>          format = format.replace('%Y',str(d.year))
>      else:
>          format = format.replace('%Y',str(d.year)+'B.C.')
>      d =
> datetime.datetime(2000,d.month,d.day,d.hour,d.minute,d.second)
>      return d.strftime(format)
>
> On Feb 25, 10:47 pm, vince  wrote:
>
> > i run into some rare problem on web2py it's related to python's
> > limitation/bugs
>
> > Traceback (most recent call last):
> >   File "/Library/WebServer/Documents/web2py/gluon/restricted.py", line
> > 173, in restricted
> >     exec ccode in environment
> >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > controllers/members.py", line 2523, in 
> >   File "/Library/WebServer/Documents/web2py/gluon/globals.py", line
> > 96, in 
> >     self._caller = lambda f: f()
> >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > controllers/members.py", line 72, in show
>
> > form1=SQLFORM(db.members,thisrecord,fields=field1,deletable=False,showid=False,labels=header1,submit_button=T('Submit'))
> >   File "/Library/WebServer/Documents/web2py/gluon/sqlhtml.py", line
> > 656, in __init__
> >     default = field.formatter(default)
> >   File "/Library/WebServer/Documents/web2py/gluon/sql.py", line 2676,
> > in formatter
> >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > 2214, in formatter
> >     return self.other.formatter(value)
> >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > 1960, in formatter
> >     return value.strftime(self.format)
> > ValueError: year=1897 is before 1900; the datetime strftime() methods
> > require year >= 1900
>
> > is there any quick workaround for it? any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread mdipierro
I can reproduce it. It is a major bug in web2py. I fixed it in trunk
just now.
Thanks for reporting this problem.

The problem is that except for the first value '51' all other values
with the same keys where being broken into chars and the chars would
be appended.


On Feb 25, 10:06 pm, Ben  wrote:
> Hi all,
> I have a URL like the following:
> feature_reading?
> feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=54
>
> however, when I try to extract the sensor_id vars at the other end, i
> get a list as such:
> ['51', '5', '2', '5', '3', '5', '4']
>
> anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: any quick workaround for the datetime strftime() methods require year >= 1900

2010-02-25 Thread mdipierro
No it work for every date but just B.C.

On Feb 25, 11:14 pm, vince  wrote:
> is it just for years for B.C.? but currently python's strftime even
> have error when it's year >= 1900.
>
> On Feb 26, 1:09 pm, mdipierro  wrote:
>
> > what about about we do something like this in web2py?
>
> > def format_date(d, format):
> >      format = format.replace('%y',str(d.year)[-2:])
> >      if d.year>=0:
> >          format = format.replace('%Y',str(d.year))
> >      else:
> >          format = format.replace('%Y',str(d.year)+'B.C.')
> >      d =
> > datetime.datetime(2000,d.month,d.day,d.hour,d.minute,d.second)
> >      return d.strftime(format)
>
> > On Feb 25, 10:47 pm, vince  wrote:
>
> > > i run into some rare problem on web2py it's related to python's
> > > limitation/bugs
>
> > > Traceback (most recent call last):
> > >   File "/Library/WebServer/Documents/web2py/gluon/restricted.py", line
> > > 173, in restricted
> > >     exec ccode in environment
> > >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > > controllers/members.py", line 2523, in 
> > >   File "/Library/WebServer/Documents/web2py/gluon/globals.py", line
> > > 96, in 
> > >     self._caller = lambda f: f()
> > >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > > controllers/members.py", line 72, in show
>
> > > form1=SQLFORM(db.members,thisrecord,fields=field1,deletable=False,showid=False,labels=header1,submit_button=T('Submit'))
> > >   File "/Library/WebServer/Documents/web2py/gluon/sqlhtml.py", line
> > > 656, in __init__
> > >     default = field.formatter(default)
> > >   File "/Library/WebServer/Documents/web2py/gluon/sql.py", line 2676,
> > > in formatter
> > >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > > 2214, in formatter
> > >     return self.other.formatter(value)
> > >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > > 1960, in formatter
> > >     return value.strftime(self.format)
> > > ValueError: year=1897 is before 1900; the datetime strftime() methods
> > > require year >= 1900
>
> > > is there any quick workaround for it? any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: request.vars bug?

2010-02-25 Thread Ben
Ah excellent, thanks very much indeed!
I guess I should update to trunk now...
Thanks again!
- Ben.

On Feb 26, 4:18 pm, mdipierro  wrote:
> I can reproduce it. It is a major bug in web2py. I fixed it in trunk
> just now.
> Thanks for reporting this problem.
>
> The problem is that except for the first value '51' all other values
> with the same keys where being broken into chars and the chars would
> be appended.
>
> On Feb 25, 10:06 pm, Ben  wrote:
>
>
>
> > Hi all,
> > I have a URL like the following:
> > feature_reading?
> > feature_id=15&sensor_id=51&sensor_id=52&sensor_id2&sensor_id=53&sensor_id=5 
> > 4
>
> > however, when I try to extract the sensor_id vars at the other end, i
> > get a list as such:
> > ['51', '5', '2', '5', '3', '5', '4']
>
> > anyone had this problem before?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: any quick workaround for the datetime strftime() methods require year >= 1900

2010-02-25 Thread vince
it's just osx and windows problem since i've just google it. it's a
known problem on python.

ValueError: year=1897 is before 1900; the datetime strftime() methods
require year >= 1900



On Feb 26, 1:20 pm, mdipierro  wrote:
> No it work for every date but just B.C.
>
> On Feb 25, 11:14 pm, vince  wrote:
>
> > is it just for years for B.C.? but currently python's strftime even
> > have error when it's year >= 1900.
>
> > On Feb 26, 1:09 pm, mdipierro  wrote:
>
> > > what about about we do something like this in web2py?
>
> > > def format_date(d, format):
> > >      format = format.replace('%y',str(d.year)[-2:])
> > >      if d.year>=0:
> > >          format = format.replace('%Y',str(d.year))
> > >      else:
> > >          format = format.replace('%Y',str(d.year)+'B.C.')
> > >      d =
> > > datetime.datetime(2000,d.month,d.day,d.hour,d.minute,d.second)
> > >      return d.strftime(format)
>
> > > On Feb 25, 10:47 pm, vince  wrote:
>
> > > > i run into some rare problem on web2py it's related to python's
> > > > limitation/bugs
>
> > > > Traceback (most recent call last):
> > > >   File "/Library/WebServer/Documents/web2py/gluon/restricted.py", line
> > > > 173, in restricted
> > > >     exec ccode in environment
> > > >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > > > controllers/members.py", line 2523, in 
> > > >   File "/Library/WebServer/Documents/web2py/gluon/globals.py", line
> > > > 96, in 
> > > >     self._caller = lambda f: f()
> > > >   File "/Library/WebServer/Documents/web2py/applications/cychurch/
> > > > controllers/members.py", line 72, in show
>
> > > > form1=SQLFORM(db.members,thisrecord,fields=field1,deletable=False,showid=False,labels=header1,submit_button=T('Submit'))
> > > >   File "/Library/WebServer/Documents/web2py/gluon/sqlhtml.py", line
> > > > 656, in __init__
> > > >     default = field.formatter(default)
> > > >   File "/Library/WebServer/Documents/web2py/gluon/sql.py", line 2676,
> > > > in formatter
> > > >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > > > 2214, in formatter
> > > >     return self.other.formatter(value)
> > > >   File "/Library/WebServer/Documents/web2py/gluon/validators.py", line
> > > > 1960, in formatter
> > > >     return value.strftime(self.format)
> > > > ValueError: year=1897 is before 1900; the datetime strftime() methods
> > > > require year >= 1900
>
> > > > is there any quick workaround for it? any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



  1   2   >