HI BG -

Thanks for your note.   Sorry for the delay on your posting - to help
manage spam robots (some of them quite offensive), we setup the group
to moderate new users.  WIth the holidays here, the people who can
moderate are scattered accross the globe / time-zones, busy skiing and
with families (I hope! ;-).  Your questions will be posted without any
more delays now.

On Dec 19, 5:01 am, BG <ulf.bys...@gmail.com> wrote:
> I already posted this once, but it didn't seem to appear. I apologize
> if my post is just delayed and will now somehow appear twice.
>
> I intended to use Django for a project but found it too time consuming
> to learn.
> With Web2py I seem to be able to "get to the code" much faster, which
> is great.

I found something similar.  I had spent some time (in the past) with
Plone, then worked on DotNetNuke (was on that core team for a bit),
then Rails (hobo for Rails actually looked promising).   Massimo, I
think, had similar experiences, and decided to roll his own - his
motivation (and ability) coming from a few places, including using it
to teach.   I ran into Massimo at PyCon last year.    Nice fellow.

>
> I have a few questions.
>
> What is the best approach to do repetitive stuff.
> In particular I mean code you want to run no matter what controller
> have been invoked.
> I want to create my own account system and on every "page" I need to
> check:
> - Has a user has logged in?
> - What permissions does the logged in user have?
>
> Do I really have to create a module which I need to import in every
> controller
> which then creates an instance of my Account class and passes the
> session object to
> that instance?

If you look at any of Massimo's code, you'll see that t2 gets imported
in the models - that's because the model gets executed first.   You
can see the layout of this in gluon/main.py - take a look at
serve_controller() for the general sequence of running an app
(serve_controller is called from wsgi_base() - which is called for a
page request).

>
> It would be great if there was a non-controller module which would be
> automatically loaded
> when a controller is used. I know global variables should be used
> sparingly, but this approach
> would make it easier to create globals for an application if you want
> them.

You can load your modules from your models files;  note that the files
in your application's models are executed in order, alphabetically -
you can put your import / initialization statement in the "0.py"
model (which is looked at first), your default "db.py" file, or any
other model file you choose.

I hope this is helpful.

>
> Normally I write PHP code, which often has globals, so maybe I just
> have the wrong ideas of
> how to do things. So, any advice on this would be welcome.
>
> === Plugins ==
> I just discovered the T2/T3 plugins.
> Since T2 is not an application, it was a little confusing (at first)
> how to use it.
> I think it would be good if there could be a separate directory and
> importer for plugins. This
> way you could also show them in a different list than the
> applications.

This is a good idea.   This summer (I think) we had some discussions
on the difference between a module and a plugin (I argued that there
is a fundamental and important difference in concept;).

In any case, the idea of modules, plugins, and how web2py will
ultimately handle that is still in the forming stages.

As it currently is, modules (which are interchangeably called plugins
- unfortunately) are by convention imported from your application's
modules directory. This may likely change in the future, but that's
the way it is now.   I encourage you to share your ideas on this.

>
> It would also be great if a plugin could include some documentation
> that can be seen through
> its design page.

That's a really good idea.

>
> Anyways, thanks for a great framework.

I hope you find this a helpful, friendly user group (as I have).
Thanks for writing, and welcome!

Kind regards,
Yarko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to