|
List Info
Thread: MVC usage patterns
|
|
| MVC usage patterns |

|
2007-03-22 13:42:08 |
Hello,
I'm coming from Django full-stack background. In Django,
it's just so
damn easy to produce basic minimal site in MVC fashion.
First off all,
it is designed to be truly MVC framework (or MTV ), and it
has
everything integrated. Now, for some that's a good thing and
for some
that's a bad thing. For me, it was a good thing in beginning
because I
could quickly produce fairly good site without hardly even
touching on
programming (just slap some model, write one-line controller
(view),
and write a template). Lately, I'm beginning to like
programing more
and more, so I started to look around for options.
First I settled on programming language which dictates
everything else
(Python!!1 OMG). Then, I glanced trough many Python
frameworks
available and considered the following ones more closely:
Pylons,
Django, TurboGears, web.py and CherryPy.
I liked the idea of Pylons but I didn't like the execution,
packaging,
current state etc. Everything is quite messy at this point.
And I hate
easy_install, what's up with that? What's wrong with good
old
distutils tarballs? It just seems bloated. I understand that
most of
it has to do with WSGI, but still...
Django is really nice. I enjoyed working with it. It's
fairly large
and yet it doesn't seem bloated at all. Some people don't
like that
they wrote everything in house, and not using other
components. Well,
I don't mind. You can't have everything. All in all, it's a
quality
product.
With TurboGears I have similar issues as with Pylons. I just
didn't like it.
I got fed up and checked CherryPy today (I've seen it
before, just
ignored it because I was already working with Django).
Boy is it tasty! Sometimes,
I judge quality of the product with
quality of the code written. I was surprised when I saw how
good it
is. Everything is neat and follows PEP 8 quite closely. I
love that! I
just can't stand when some Python code is badly formatted,
lines
crammed together, very long lines etc... At least Python
enforces good
formatting of the code, and yet I'm amazed at how much
Python code is
ugly in todays popular projects like Django, SQLAlchemy and
others.
What's so hard in remembering 79 line width, two spaces for
classes
etc...
So CherryPy is small, quality piece of software, and it also
has very
nice and fast WSGI web server, great!
Now, I need some database abstraction and some templating
language.
SQLAlchemy seems the most logical choice right now and for
the
templating, I'll try Mako I guess. It is very fast according
to
rumors. I like speed.
What I would like here is that I get some recommendations
about the
MVC usage. Design patterns. Like directory structure, how to
glue
everything together, best practices etc. Because now, I'm
lost. I need
some real world code examples. Today I was going to purchase
the
upcoming CherryPy book, but I have AMEX which isn't
supported, ah
well.
The following is needed for me to embrace the CherryPy and
become a
happy camper:
* Some sort of model in SQLAlchemy. Something basic, like
news
posting, 'id', 'title' and 'body' for instance.
* Use of the templating language like Mako or any other.
* Form it in the complete package.
* Authentication and/or validation is just bonus at this
point.
The book would solve everything but I'm afraid I can't
purchase it. I
sent them a mail asking do they support any alternate
payment methods
like PayPal...
I know that the above things are really easy for some, but
they are
not so easy for me. So, if there are no existing similar
code samples,
are there any best practices to follow? It's best to know
the
conventions from the beginning and learn them right. The
most simple
blog application using SQLAlchemy and some templating
language would
solve it all.
It doesn't need to be 100% MVC. It can be close enough to be
useful
and to stay in CherryPys fashion. Thanks.
- Šime
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: MVC usage patterns |
  United States |
2007-03-22 13:55:08 |
Hi -
Regarding template packagess, both Mako and Breve are
absolute speed
demons...
Tom Fillmore
Šime Ramov wrote:
> Hello,
>
> I'm coming from Django full-stack background. In
Django, it's just so
> damn easy to produce basic minimal site in MVC fashion.
First off all,
> it is designed to be truly MVC framework (or MTV ), and it
has
> everything integrated. Now, for some that's a good
thing and for some
> that's a bad thing. For me, it was a good thing in
beginning because I
> could quickly produce fairly good site without hardly
even touching on
> programming (just slap some model, write one-line
controller (view),
> and write a template). Lately, I'm beginning to like
programing more
> and more, so I started to look around for options.
>
> First I settled on programming language which dictates
everything else
> (Python!!1 OMG). Then, I glanced trough many Python
frameworks
> available and considered the following ones more
closely: Pylons,
> Django, TurboGears, web.py and CherryPy.
>
> I liked the idea of Pylons but I didn't like the
execution, packaging,
> current state etc. Everything is quite messy at this
point. And I hate
> easy_install, what's up with that? What's wrong with
good old
> distutils tarballs? It just seems bloated. I understand
that most of
> it has to do with WSGI, but still...
>
> Django is really nice. I enjoyed working with it. It's
fairly large
> and yet it doesn't seem bloated at all. Some people
don't like that
> they wrote everything in house, and not using other
components. Well,
> I don't mind. You can't have everything. All in all,
it's a quality
> product.
>
> With TurboGears I have similar issues as with Pylons. I
just didn't like it.
>
> I got fed up and checked CherryPy today (I've seen it
before, just
> ignored it because I was already working with Django).
>
> Boy is it tasty! Sometimes,
I judge quality of the product with
> quality of the code written. I was surprised when I saw
how good it
> is. Everything is neat and follows PEP 8 quite closely.
I love that! I
> just can't stand when some Python code is badly
formatted, lines
> crammed together, very long lines etc... At least
Python enforces good
> formatting of the code, and yet I'm amazed at how much
Python code is
> ugly in todays popular projects like Django, SQLAlchemy
and others.
> What's so hard in remembering 79 line width, two spaces
for classes
> etc...
>
> So CherryPy is small, quality piece of software, and it
also has very
> nice and fast WSGI web server, great!
>
> Now, I need some database abstraction and some
templating language.
> SQLAlchemy seems the most logical choice right now and
for the
> templating, I'll try Mako I guess. It is very fast
according to
> rumors. I like speed.
>
> What I would like here is that I get some
recommendations about the
> MVC usage. Design patterns. Like directory structure,
how to glue
> everything together, best practices etc. Because now,
I'm lost. I need
> some real world code examples. Today I was going to
purchase the
> upcoming CherryPy book, but I have AMEX which isn't
supported, ah
> well.
>
> The following is needed for me to embrace the CherryPy
and become a
> happy camper:
>
> * Some sort of model in SQLAlchemy. Something basic,
like news
> posting, 'id', 'title' and 'body' for instance.
> * Use of the templating language like Mako or any
other.
> * Form it in the complete package.
> * Authentication and/or validation is just bonus at
this point.
>
> The book would solve everything but I'm afraid I can't
purchase it. I
> sent them a mail asking do they support any alternate
payment methods
> like PayPal...
>
> I know that the above things are really easy for some,
but they are
> not so easy for me. So, if there are no existing
similar code samples,
> are there any best practices to follow? It's best to
know the
> conventions from the beginning and learn them right.
The most simple
> blog application using SQLAlchemy and some templating
language would
> solve it all.
>
> It doesn't need to be 100% MVC. It can be close enough
to be useful
> and to stay in CherryPys fashion. Thanks.
>
>
> - Šime
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: MVC usage patterns |
  United States |
2007-04-10 04:42:04 |
Hi,
I guess this is the closest thread on what i was about to
ask in this
group. I too need some basic layout, or patterns on using
SQLAlchemy
with CherryPy.
When i started using CherryPy + SQLAlchemy, i had some
threading
problems when i tried to use a single session for
everything. I fixed
it by creating a new session for database accesses, but i
think i'm
still doing it wrong, as postgresql processes keep building
up, until
i run out of processes in it.
At the moment i have the following layout:
model/model.py
controllers/foo.py
start.py
start.py: imports the controllers and sets up CherryPy.
model.py: Has the SQLAlchemy table definitions etc. and
opens a
database connection at the start:
--- model.py ---
from sqlalchemy import *
from sqlalchemy.orm import *
db = create_engine(...)
metadata = BoundMetaData(db)
table = Table(....)
# Function for getting a new session
def get_db_session():
return create_session(bind_to=db)
--- end of model.py ---
Every controller imports the model, and calls
get_db_session()
whenever we are accessing the database, and then closes the
session.
I guess the problem is, that create_engine() opens a new
connection
everytime i import this module, but i'm not sure about that.
Where
should i open the connection for a proper behavior? Or is
this the
proper way? An example on how to implement this kind of
system would
be excellent, and one should be added to the CherryPy wiki
too.
Regards,
K
On Mar 22, 9:42 pm, "Šime Ramov" <s... brand84.com> wrote:
> Hello,
>
> I'm coming from Django full-stack background. In
Django, it's just so
> damn easy to produce basic minimal site in MVC fashion.
First off all,
> it is designed to be truly MVC framework (or MTV ), and it
has
> everything integrated. Now, for some that's a good
thing and for some
> that's a bad thing. For me, it was a good thing in
beginning because I
> could quickly produce fairly good site without hardly
even touching on
> programming (just slap some model, write one-line
controller (view),
> and write a template). Lately, I'm beginning to like
programing more
> and more, so I started to look around for options.
>
> First I settled on programming language which dictates
everything else
> (Python!!1 OMG). Then, I glanced trough many Python
frameworks
> available and considered the following ones more
closely: Pylons,
> Django, TurboGears, web.py and CherryPy.
>
> I liked the idea of Pylons but I didn't like the
execution, packaging,
> current state etc. Everything is quite messy at this
point. And I hate
> easy_install, what's up with that? What's wrong with
good old
> distutils tarballs? It just seems bloated. I understand
that most of
> it has to do with WSGI, but still...
>
> Django is really nice. I enjoyed working with it. It's
fairly large
> and yet it doesn't seem bloated at all. Some people
don't like that
> they wrote everything in house, and not using other
components. Well,
> I don't mind. You can't have everything. All in all,
it's a quality
> product.
>
> With TurboGears I have similar issues as with Pylons. I
just didn't like it.
>
> I got fed up and checked CherryPy today (I've seen it
before, just
> ignored it because I was already working with Django).
>
> Boy is it tasty! Sometimes,
I judge quality of the product with
> quality of the code written. I was surprised when I saw
how good it
> is. Everything is neat and follows PEP 8 quite closely.
I love that! I
> just can't stand when some Python code is badly
formatted, lines
> crammed together, very long lines etc... At least
Python enforces good
> formatting of the code, and yet I'm amazed at how much
Python code is
> ugly in todays popular projects like Django, SQLAlchemy
and others.
> What's so hard in remembering 79 line width, two spaces
for classes
> etc...
>
> So CherryPy is small, quality piece of software, and it
also has very
> nice and fast WSGI web server, great!
>
> Now, I need some database abstraction and some
templating language.
> SQLAlchemy seems the most logical choice right now and
for the
> templating, I'll try Mako I guess. It is very fast
according to
> rumors. I like speed.
>
> What I would like here is that I get some
recommendations about the
> MVC usage. Design patterns. Like directory structure,
how to glue
> everything together, best practices etc. Because now,
I'm lost. I need
> some real world code examples. Today I was going to
purchase the
> upcoming CherryPy book, but I have AMEX which isn't
supported, ah
> well.
>
> The following is needed for me to embrace the CherryPy
and become a
> happy camper:
>
> * Some sort of model in SQLAlchemy. Something basic,
like news
> posting, 'id', 'title' and 'body' for instance.
> * Use of the templating language like Mako or any
other.
> * Form it in the complete package.
> * Authentication and/or validation is just bonus at
this point.
>
> The book would solve everything but I'm afraid I can't
purchase it. I
> sent them a mail asking do they support any alternate
payment methods
> like PayPal...
>
> I know that the above things are really easy for some,
but they are
> not so easy for me. So, if there are no existing
similar code samples,
> are there any best practices to follow? It's best to
know the
> conventions from the beginning and learn them right.
The most simple
> blog application using SQLAlchemy and some templating
language would
> solve it all.
>
> It doesn't need to be 100% MVC. It can be close enough
to be useful
> and to stay in CherryPys fashion. Thanks.
>
> - Šime
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: MVC usage patterns |
  United States |
2007-04-12 03:31:27 |
Hi,
For the authorizations, Trac project elegantly delegates
authentication to Apache , see http://trac.edgewall.org/wiki/TracAuthenticationIntr
oduction
Unaware of Trac solution, I was fighting to delegate
authentication to
Apache, and finally got it working with Lighttpd , see
sampel code at
http://to
ols.cherrypy.org/wiki/ExternalAuth
Regarding threading and database access, I recommend
DBUtils. Please
see CherryPy example the end of the page http://tools
.cherrypy.org/wiki/Databases
. My problems started with loosing connectivity to database
when
running heavy SQL queries (huge SELECT SUM() ) .
DButils.PersistentDB gives a "hardened" database
connection that
automatically reconnects on failure. And then there is
DBUtils.PooledDB that will take care of not having too many
connections.
DBUtils docs are at http://www.webwareforpython.org/DBUtils/Docs/UsersGu
ide.html
Cheers, Alexandru
http://sourc
eforge.net/projects/cubulus/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|