Please email it to me. If I cut and paste I lose indentation.

Massimo

On May 21, 2:04 am, HansD <[email protected]> wrote:
> and some additional patches (already send per email):
> - for gae it enables the gae build admin console at admin-gae (for
> admin only)
> - when accessing /admin on a gea (sdk) it gives a more descriptive
> error msg
> - gentle way of switching between gae-backend and normal backend in
> the applications db.py
> - some typos
>
> Index: app.yaml
> ===================================================================
> --- app.yaml    (revision 954)
> +++ app.yaml    (working copy)
> @@ -10,6 +10,10 @@
>    upload: applications/(.+?)/static/(.+)
>    secure: optional
>
> +- url: /admin-gae/.*
> +  script: $PYTHON_LIB/google/appengine/ext/admin
> +  login: admin
> +
>  - url: .*
>    script: gaehandler.py
>    secure: optional
> @@ -27,5 +31,5 @@
>   (\..*)|
>   ((admin|examples|welcome)\.tar)|
>   (applications/(admin|examples)/.*)|
> - (applicaitons/.*/databases/.*) |
> + (applications/.*/databases/.*) |
>   )$
> Index: applications/admin/models/access.py
> ===================================================================
> --- applications/admin/models/access.py (revision 954)
> +++ applications/admin/models/access.py (working copy)
> @@ -7,7 +7,7 @@
>      return os.path.join(opath, path).replace('\\', '/')
>
>  # ###########################################################
> -# ## make sure administrator is on localhost
> +# ## make sure administrator is on localhost or https
>  # ###########################################################
>
>  http_host = request.env.http_host.split(':')[0]
> @@ -27,7 +27,7 @@
>       in ['https', 'HTTPS']:
>      session.secure()
>  elif not remote_addr in hosts:
> -    raise HTTP(200, T('Admin is disabled because unsecure channel'))
> +    raise HTTP(200, T('Admin is disabled because insecure channel'))
>
>  try:
>      _config = {}
> @@ -37,7 +37,12 @@
>      if not 'password' in _config or not _config['password']:
>          raise HTTP(200, T('admin disabled because no admin
> password'))
>  except IOError:
> -    raise HTTP(200,
> +    from gluon.settings import settings
> +    if settings.web2py_runtime_gae:
> +        raise HTTP(200,
> +                   T('admin disabled because not supported on google
> apps engine'))
> +    else:
> +        raise HTTP(200,
>                 T('admin disabled because unable to access password
> file'))
>
>  # ###########################################################
> Index: applications/welcome/controllers/default.py
> ===================================================================
> --- applications/welcome/controllers/default.py (revision 954)
> +++ applications/welcome/controllers/default.py (working copy)
> @@ -8,7 +8,7 @@
>
>  def index():
>      """
> -    example action using the internationalizaiton operator T and
> flash
> +    example action using the internationalization operator T and
> flash
>      rendered by views/default/index.html or views/generic.html
>      """
>      response.flash = T('Welcome to web2py')
> Index: applications/welcome/models/db.py
> ===================================================================
> --- applications/welcome/models/db.py   (revision 954)
> +++ applications/welcome/models/db.py   (working copy)
> @@ -2,17 +2,24 @@
>  ## This scaffolding model makes your app work on Google App Engine
> too
>
> #########################################################################
>
> -try:
> -    from gluon.contrib.gql import *  # if running on Google App
> Engine
> -except:
> -    db = SQLDB('sqlite://storage.sqlite')  # if not, use SQLite or
> other DB
> -else:
> -    db = GQLDB()  # connect to Google BigTable
> -    session.connect(request, response, db=db)  # and store sessions
> there
> +from gluon.settings import settings
> +
> +# if running on Google App Engine
> +if settings.web2py_runtime_gae:
> +    from gluon.contrib.gql import *
> +
> +    # connect to Google BigTable
> +    db = GQLDB()
> +    # and store sessions there
> +    session.connect(request, response, db=db)
>      # or use the following lines to store sessions in Memcache
>      #from gluon.contrib.memdb import MEMDB
>      #from google.appengine.api.memcache import Client
>      #session.connect(request, response, db=MEMDB(Client()))
> +else:
> +    # if not, use SQLite or other DB
> +    db = SQLDB('sqlite://storage.sqlite')
> +
>
> #########################################################################
>  ## uncomment the following line if you do not want sessions
> Index: applications/examples/models/db.py
> ===================================================================
> --- applications/examples/models/db.py  (revision 954)
> +++ applications/examples/models/db.py  (working copy)
> @@ -1,15 +1,20 @@
> +#########################################################################
> +## This scaffolding model makes your app work on Google App Engine
> too
> +#########################################################################
>
> -#
> ########################################################################
> -# # This scaffolding model makes your app work on Google App Engine
> too
> -#
> ########################################################################
> +from gluon.settings import settings
>
> -try:
> -    from gluon.contrib.gql import *  # if running on Google App
> Engine
> -except:
> -    db = SQLDB('sqlite://storage.sqlite')  # if not, use SQLite or
> other DB
> +# if running on Google App Engine
> +if settings.web2py_runtime_gae:
> +    from gluon.contrib.gql import *
> +
> +    # connect to Google BigTable
> +    db = GQLDB()
> +    # and store sessions there
> +    session.connect(request, response, db=db)
>  else:
> -    db = GQLDB()  # connect to Google BigTable
> -    session.connect(request, response, db=db)  # and store sessions
> there
> +    # if not, use SQLite or other DB
> +    db = SQLDB('sqlite://storage.sqlite')
>
>  db.define_table(
>      'users',
> @@ -43,12 +48,14 @@
>      SQLField('quantity', 'integer')
>      )
>
> -from gluon.settings import settings
> -if not settings.web2py_runtime_gae:
> +# if running on Google App Engine
> +if settings.web2py_runtime_gae:
> +    # quick hack to skip the join
> +    purchased = None
> +else:
> +    # use a joined view
>      purchased = (db.users.id == db.purchases.buyer_id) &
> (db.products.id
>                   == db.purchases.product_id)
> -else:
> -    purchased = None
>
>  db.users.name.requires = IS_NOT_EMPTY()
>  db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db,
> 'users.email')]
> Index: gluon/restricted.py
> ===================================================================
> --- gluon/restricted.py (revision 954)
> +++ gluon/restricted.py (working copy)
> @@ -53,7 +53,7 @@
>
>      def log(self, request):
>          """
> -        logs the exeption.
> +        logs the exception.
>          """
>
>          a = request.application
> @@ -91,10 +91,10 @@
>          self.traceback = d['traceback']
>
> -def restricted(code, environment={}, layer='Unkown'):
> +def restricted(code, environment={}, layer='Unknown'):
>      """
> -    runs code in evrionment and returns the output. if an exeception
> occurs
> -    in code it raises a RestrictedError containg the traceback. layer
> is passed
> +    runs code in environment and returns the output. if an exception
> occurs
> +    in code it raises a RestrictedError containing the traceback.
> layer is passed
>      to RestrictedError to identify where the error occurred.
>      """
>
> On May 20, 4:13 am, mdipierro <[email protected]> wrote:
>
> > Can you please email this to me? thanks
>
> > On May 19, 5:13 pm, HansD <[email protected]> wrote:
>
> > > update for database_examples.py:
> > > - small bug fixed for the gae_hack
> > > - updated the form to work with dropdown boxes (also for non-gae)
>
> > > Index: applications/examples/controllers/database_examples.py
> > > ===================================================================
> > > --- applications/examples/controllers/database_examples.py      (revision
> > > 953)
> > > +++ applications/examples/controllers/database_examples.py      (working
> > > copy)
> > > @@ -52,13 +52,27 @@
> > >      """ uses a form to query who is buying what. validates form and
> > >          updates existing record or inserts new record in purchases
> > > """
>
> > > -    form = FORM(TABLE(TR('Buyer id:', INPUT(_type='text',
> > > -                _name='buyer_id', requires=IS_NOT_EMPTY())),
> > > -                TR('Product id:', INPUT(_type='text',
> > > _name='product_id'
> > > -                , requires=IS_NOT_EMPTY())), TR('Quantity:',
> > > -                INPUT(_type='text', _name='quantity',
> > > -                requires=IS_INT_IN_RANGE(1, 100))), TR('',
> > > -                INPUT(_type='submit', _value='Order'))))
> > > +    buyerRecords = db().select(db.users.ALL)
> > > +    buyerOptions = []
> > > +    for row in buyerRecords:
> > > +        buyerOptions.append(OPTION(row.name, _value=row.id))
> > > +
> > > +    productRecords = db().select(db.products.ALL)
> > > +    productOptions = []
> > > +    for row in productRecords:
> > > +        productOptions.append(OPTION(row.name, _value=row.id))
> > > +
> > > +    form = FORM(TABLE(
> > > +                TR('Buyer id:',
> > > +                    SELECT(buyerOptions,_name='buyer_id')),
> > > +                TR('Product id:',
> > > +                    SELECT(productOptions,_name='product_id')),
> > > +                TR('Quantity:',
> > > +                    INPUT(_type='text', _name='quantity',
> > > +                          requires=IS_INT_IN_RANGE(1, 100))),
> > > +                TR('',
> > > +                    INPUT(_type='submit', _value='Order'))
> > > +                ))
> > >      if form.accepts(request.vars, session, keepvalues=True):
>
> > >          # ## check if user is in the database
> > > @@ -90,7 +104,6 @@
> > >              else:
>
> > >              # ## or insert a new record in table
> > > -
> > >                
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to