mr.freeze | 1 Sep 2009 01:38

[web2py:29745] Re: Comma creates an invalid request?


It fails for me when passed as an argument even when it is URL
encoded:
http://127.0.0.1:8000/test/default/index/london%2C_ontario - Invalid
request.

Passing as a query string works even when not encoded:
http://127.0.0.1:8000/test/default/index?city=london,_ontario - Works
fine.

Massimo, can you confirm that this is the expected behavior?

On Aug 31, 7:56 am, mdipierro <mdipie...@...> wrote:
> Your url does not pass validation and it is invalid. To allow this you
> must create a routes_in for fit.
>
> On Aug 30, 9:20 pm, Derek <cunningh...@...> wrote:
>
> > Hi,
>
> > I'm doing some geocoding. I have a geocoder.py file with an index
> > function.
>
> > A url like:
>
> > /geocoder/index/london
>
> > uses the value 'london' (stored in request.args[0]) just fine. But if
> > I add acomma, as in:
>
(Continue reading)

Richard | 1 Sep 2009 01:48
Picon
Gravatar

[web2py:29746] Re: pyforum instead of google groups?


Perhaps someone can help with porting that last query. I made a start
but my DAL-fu was not quite up to the task. It works apart from the
parents/siblings:

parents_field = db.zf_topic.id.count()
siblings_field = db.zf_topic.id.count()
hits_field = db.zf_topic.hits.sum()
join = [db.zf_forum.on(db.zf_forum_category.id == db.zf_forum.cat_id),
        db.zf_topic.on((db.zf_forum.id == db.zf_topic.forum_id)  &
(db.zf_topic.disabled_flag == 0))]
groupby = db.zf_forum.id | db.zf_forum.forum_title |
db.zf_forum.forum_desc | db.zf_forum.moderation_flag |
db.zf_forum.anonymous_viewaccess |
db.zf_forum.add_postings_access_roles | db.zf_forum_category.id |
db.zf_forum_category.cat_name | db.zf_forum_category.cat_desc |
db.zf_forum_category.cat_visible_to | db.zf_forum_category.cat_sort |
db.zf_forum.reply_postings_access_roles | db.zf_forum.forum_sort
orderby = db.zf_forum_category.cat_sort | db.zf_forum.forum_sort
rows = db().select(
        db.zf_forum_category.id, db.zf_forum_category.cat_name,
db.zf_forum_category.cat_desc, db.zf_forum_category.cat_visible_to,
db.zf_forum_category.cat_sort,
        db.zf_forum.id, db.zf_forum.forum_title,
db.zf_forum.forum_desc, db.zf_forum.moderation_flag,
db.zf_forum.anonymous_viewaccess,
db.zf_forum.add_postings_access_roles,
db.zf_forum.reply_postings_access_roles, db.zf_forum.forum_sort,
        parents_field, siblings_field, hits_field,
        left=join,
(Continue reading)

Richard | 1 Sep 2009 02:26
Picon
Gravatar

[web2py:29747] Re: estore status


Hi Philip,

I'm in Australia and am involved with the manufacturing industry, but
that's an obscure case study. How about a book store?

> I suggest that we have a bit of a brainstorm and see if we can't arrive at some sort of consensus on that.
Agreed.

> - Merchandising (cross-sell, up-sell etc.)
How would this work? List related products to current one?

> - Catalogue navigation (beyond a simple category hierarchy)
Would catalogue be the default view of each category?
Also multiple level categories so you could browse the "Non-fiction"
category or a more specific sub-category such as "Politics".

> - Options (Size, colour, accessories and the cost build-up associated with them)
Definitely - something like an options table linked to product with a
description and price of each addon. And some Javascript to update the
total price dynamically.

> - Shipping (carriage calculations, tracking)
There's a few settings defined in the info table about shipping.
Tracking would require user accounts so they could login to check or
receive email updates, wouldn't it?

> - Multiple payment options.
Definitely credit card and paypal. Others?
So you think Paypal integration would be relatively easy. Working off
(Continue reading)

Richard | 1 Sep 2009 02:45
Picon
Gravatar

[web2py:29748] Re: exec_environment limitations?


I want to have a standalone script to do some operations on my
application database. And I want to use the web2py DAL so my script is
as portable as my application.

I have such a script working, which I run with:
> cd /home/web2py && python web2py.py --import_models --no-cron --shell=test --run=my_script.py
This feels awkward so I want to run my script with just:
> python my_script.py

How can I do that? It seems exec_environment is not the way.
In the previous post I was trying to import my model file.

Richard

On Aug 31, 10:54 pm, mdipierro <mdipie...@...> wrote:
> Sorry, I do not understand the context
>
> If a piece of code needs to be "imported" than it should be a module
> and go in modules.
>
> models instead should not be imported and they are always executed
> alphabetically for every app.
>
> Massimo
>
> On Aug 30, 7:08 pm, Richard <richar...@...> wrote:
>
> > hi Massimo,
>
(Continue reading)

mdipierro | 1 Sep 2009 02:55
Picon
Gravatar

[web2py:29749] Re: ProgrammingError: Cannot operate on a closed database.


Any chance you can try the current version and see if you can
reproduce this error?.

On Aug 31, 5:45 pm, MikeEllis <michael.f.el...@...> wrote:
> Hi all,
>
> I'm passing the db object into an external module that needs to insert
> some records into a table in the database.  Not sure what the
> following error means.  Looks like web2py closed the db.
>
> I'm running Version 1.64.3 (2009-06-19 07:35:40) on OS X 10.5.8
> (Leopard).  I'm using the built-in SQLite db.
>
> Thanks,
> Mike
>
> Traceback (most recent call last):
>   File "/Users/mellis/trunk/python/web2py/gluon/restricted.py", line
> 107, in restricted
>     exec ccode in environment
>   File "/Users/mellis/trunk/python/web2py/applications/init/
> controllers/default.py", line 189, in <module>
>   File "/Users/mellis/trunk/python/web2py/gluon/globals.py", line 100,
> in <lambda>
>     self._caller = lambda f: f()
>   File "/Users/mellis/trunk/python/web2py/applications/init/
> controllers/default.py", line 120, in pdainterfacehandler
>     response.page = env['STATEMACHINE'].send(env)
>   File "/Users/mellis/xlrn/lib/python2.5/site-packages/
(Continue reading)

mdipierro | 1 Sep 2009 02:58
Picon
Gravatar

[web2py:29750] Re: Comma creates an invalid request?


Yes. in web2py URL are validated and special characters are not
allowed (by default). Spaces are replaced with _.
This can be changed by mappying parts of the URL, like the part after
the comma, into a variable. Example:

http://127.0.0.1:8000/a/b/c,d

you can create a file routes.py in web2py/ and in it

routes_in=(('(?P<p>.*?),(?P<q>.*)':'\g<p>?other=\g<q>'),)

then in app a, controller b.py and function c you can access

request.vars.other

which will contain 'd'.

Massimo

On Aug 31, 6:38 pm, "mr.freeze" <nat...@...> wrote:
> It fails for me when passed as an argument even when it is URL
> encoded:http://127.0.0.1:8000/test/default/index/london%2C_ontario- Invalid
> request.
>
> Passing as a query string works even when not
encoded:http://127.0.0.1:8000/test/default/index?city=london,_ontario- Works
> fine.
>
> Massimo, can you confirm that this is the expected behavior?
(Continue reading)

mdipierro | 1 Sep 2009 03:10
Picon
Gravatar

[web2py:29751] Re: exec_environment limitations?


Now I understand. I never thought about this before.

Create your file my_script.py and in it you write:

import os
os.chdir('/path/to/web2py/')
from gluon.shell import env
globals().update(env('you_app_name', import_models=True))
# now do whatever you need you can use request, db, helpers, etc.

Massimo

On Aug 31, 7:45 pm, Richard <richar...@...> wrote:
> I want to have a standalone script to do some operations on my
> application database. And I want to use the web2py DAL so my script is
> as portable as my application.
>
> I have such a script working, which I run with:> cd /home/web2py && python web2py.py --import_models
--no-cron --shell=test --run=my_script.py
>
> This feels awkward so I want to run my script with just:
>
> > python my_script.py
>
> How can I do that? It seems exec_environment is not the way.
> In the previous post I was trying to import my model file.
>
> Richard
>
(Continue reading)

Matthew | 1 Sep 2009 03:01
Picon
Gravatar

[web2py:29752] Run doctest in the modules directory


I am relatively new Web2py and very new to doctests.  I'm attempting
to test a new Validator, but the Traceback tells me it cannot even
find the gluon.validators module.

I have the web2py folder on my PYTHONPATH.  Here is my file
"validators.py" in ~/dev/source/web2py/applications/myapp/modules/


from gluon.validators import IS_NOT_EMPTY

class IS_NOT_WHITESPACE(IS_NOT_EMPTY):
    """
    Example::
        INPUT(_type='text', _name='name', requires=IS_NOT_WHITESPACE
())

    IS_NOT_WHITESPACE inherits from the IS_NOT_EMPTY validator. It
trims the
    argument, a string, of whitespace before validating:

        >>> validators.IS_NOT_WHITESPACE(' ')
        (' ', 'cannot be empty!')

    """
    def __init__(self, error_message='cannot be empty!'):
        super(self, error_message)

if __name__=='__main__':
   import doctest
(Continue reading)

mr.freeze | 1 Sep 2009 03:33

[web2py:29753] Re: Comma creates an invalid request?


Why are special characters allowed in request.vars but not
request.args by default?

i.e. why does this work:
http://127.0.0.1:8000/test/appadmin/state?london,_ontario

But not this?:
http://127.0.0.1:8000/test/appadmin/state/london,_ontario

 Just curious.

On Aug 31, 7:58 pm, mdipierro <mdipie...@...> wrote:
> Yes. in web2py URL are validated and special characters are not
> allowed (by default). Spaces are replaced with _.
> This can be changed by mappying parts of the URL, like the part after
> the comma, into a variable. Example:
>
> http://127.0.0.1:8000/a/b/c,d
>
> you can create a file routes.py in web2py/ and in it
>
> routes_in=(('(?P<p>.*?),(?P<q>.*)':'\g<p>?other=\g<q>'),)
>
> then in app a, controller b.py and function c you can access
>
> request.vars.other
>
> which will contain 'd'.
>
(Continue reading)

mdipierro | 1 Sep 2009 03:46
Picon
Gravatar

[web2py:29754] Re: Run doctest in the modules directory


I tried adding this line to the script:

import sys; sys.path.append('./')

and running from web2py/ as

python applications/myapp/modules/script.py

It worked

On Aug 31, 8:01 pm, Matthew <matthew.g.nor...@...> wrote:
> I am relatively new Web2py and very new to doctests.  I'm attempting
> to test a new Validator, but the Traceback tells me it cannot even
> find the gluon.validators module.
>
> I have the web2py folder on my PYTHONPATH.  Here is my file
> "validators.py" in ~/dev/source/web2py/applications/myapp/modules/
>
> from gluon.validators import IS_NOT_EMPTY
>
> class IS_NOT_WHITESPACE(IS_NOT_EMPTY):
>     """
>     Example::
>         INPUT(_type='text', _name='name', requires=IS_NOT_WHITESPACE
> ())
>
>     IS_NOT_WHITESPACE inherits from the IS_NOT_EMPTY validator. It
> trims the
>     argument, a string, of whitespace before validating:
(Continue reading)


Gmane