On Fri, Mar 20, 2009 at 6:48 PM, Alex Popescu <
[email protected]> wrote:

>
> On Mar 21, 1:27 am, mdipierro <[email protected]> wrote:
> > On Mar 20, 5:16 pm, Alex Popescu <[email protected]>
> > wrote:
> >
> >
> > > 1. Routing
> >
> > > According to the documentation URLs are solved according to the
> > > following rule:
> >
> > > protocol://netloc/application/controller/function[(/arg)*][?vars]
> >
> > > My question is: how difficult would be to eliminate the function part
> > > and basically route the request to a method defined in the controller
> > > corresponding to the HTTP request method name (i.e. GET -> get, POST -
> > > post, PUT -> put, etc.)?
> >
> > You cannot acoomplish soley with routes but you can have a catch all
> > action that checks
> >
> > if request.post_vars: call_post_action()
> >
>
> I'm not sure I'm following your answer. While I haven't spent too much
> time looking at the code my impression is that it should be as simple
> as making some minor changes to the way the Request object is
> initialized in gluon.main.wsgibase.


That is, going to something like
 protocol://netloc/application/default/index

(the default/index is default for an application - let's leave routes out of
this for the moment)

    def index():
        if request.post_vars:
               action=request.post_vars
                if action == 'a':  a()

Maybe an example use case would help describe what you're looking for...


>
> Well, there might be something else needed too, but I haven't found it
> yet: generating the URLs.
>
> >
> >
> > > As far as I can tell, for a WSGI deployment the URL parsing happens in
> > > gluon.main.wsgibase, but I am wondering if there are other places I
> > > should look for.
> >
> > > Note: I am looking to build a very RESTful app and I'd like to have
> > > this clear convention in my app.
> > > 2. Models and Data Access
> >
> > > This part is a bit more complex to describe, but I hope you'll bare
> > > with me for a couple of paragraphs.
> >
> > > Currently the web2py models are very data centric (please keep in mind
> > > that I'm not saying that this is good or bad):
> >
> > > db.define_table('name', SQLField(...)
> >
> > > What I'd actually like would be to hide this part behind an object
> > > centric approach. I am aware of the fact that basically the approaches
> > > are quite different (ORM vs ActiveRecord), but I'm wondering if some
> > > metaclass magic would be able to allow me to preserve the current
> > > implementation while offering an object oriented perspective. A very
> > > basic example would be the data access layer implementation available
> > > in Google App Engine:
> >
> > > Model.gql('query')....
> >
> > > Simply put the meta-magic will just have to hide the db functions
> > > behind some static Model methods.
> >
> > > Question: do you think that this is possible? how difficult would this
> > > be?
> >
> > This has been done in order to allow web2py to import Django models:
> > You can find the code here:
> http://mdp.cti.depaul.edu/AlterEgo/default/show/189
> >
>
> This looks like an excellent start. I think I can take it from there.
>
> While waiting for your comments on my previous questions I've figured
> 2 more:
>
> 3/ Templating
>
> a/ Is template inheritance supported? (I couldn't find any reference,
> but it might be caused by being tired)


for example, see views/generic:

   {{extend 'layout.html'}}


b/ Is it possible to invoke Python functions from the template that
> are enhancing the template dictionary?


   {{import my_template_helpers}}
   {{ for i in list_to_show:}}
          {{ output=my_template_helpers.someaction(i) }}
          {{ =T(output)}}
           {{pass}}

>
>
> Imagine a homepage that has a couple of 'widget' like fragments. These
> are not really part of the controller, so I'd like to just say in the
> template: invoke a function and place add the returned value to the
> dict used for rendering the template.
>
> c/ Is it possible to include in a template an HTML fragment generated
> as a result of a function invocation?


    {{ =var }}
    {{ =function_call( x ) }}
    {{ =XML( some_otherwise_escaped_value ) }}

    {{ import random
       i = random.randint(1,6)
     }}
     <h{{ =i }}> Look!  A random header!;
       H{{ =i }}
       {{ if i%2: }} is odd {{ else: }} is even {{ pass }}
      </h{{ =i }}>


>
>
> It is a similar concept to the above one, the difference being that
> the 'widget' template is completely outside the current page (while in
> the above scenario the 'widget' template was part of the current
> template)


Oh!  I think you meant this for above:

   {{ def foo():   return a+b}}
   {{ pass }}

   {{ =foo() }}


>
>
> 4/ Request/Response cycle interceptors
>
> Basically this is a way to plug in cross-cutting functionality that
> will be automatically triggered at specific moment of the request/
> response cycle:
>

I'm not sure what we're talking about here; wsgiserver ->
gluon.main.wsgibase which sets up the context, so I think you mean this (I
could be wrong - I try not to think about this too much):

>
> - before_request


    your model files are read / run first; I think you mean there... ;
 files are executed in alphabetical order, then the requested controller
function is initiated, and a like named view.


> - before_controller


> - after_controller
> - before_view
> - after_view
> - after_request
>
> I think the Django synonym would be middleware classes.


I'm not sure - I think you want to look at "New Tools" and "T2" from here
for starters:
http://www.web2py.com/examples/default/docs

Hope some of this has been helpful...

Regards,
Yarko

>
>
> Many thanks in advance,
>
> ./alex
> --
> .w( the_mindstorm )p.
>  Alexandru Popescu
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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