Using SQLAlchemy's declarative by default

2 views
Skip to first unread message

Gustavo Narea

unread,
Aug 2, 2008, 3:24:09 PM8/2/08
to turbogea...@googlegroups.com
Hello, everyone.

What do you think about defining the model in the default TG2 template using
SQLAlchemy's declarative extension instead of using it the traditional way?

I think it would make the model look more natural and easier to get started.

I can implement it if you agree.

Cheers.
--
Gustavo Narea.
General Secretary. GNU/Linux Matters.
http://www.gnulinuxmatters.org/

signature.asc

Lee McFadden

unread,
Aug 2, 2008, 6:35:14 PM8/2/08
to turbogea...@googlegroups.com
On Sat, Aug 2, 2008 at 8:24 PM, Gustavo Narea
<gus...@gnulinuxmatters.org> wrote:
> Hello, everyone.
>
> What do you think about defining the model in the default TG2 template using
> SQLAlchemy's declarative extension instead of using it the traditional way?
>
> I think it would make the model look more natural and easier to get started.
>

-1

The SQLAlchemy documentation (which we will be referring people to on
a regular basis) uses the standard method of declaring tables/classes.
Personally I would prefer to allow people to use the documentation
available and not have to "translate" into the declarative mode.

Purely from a support standpoint I don't think changing this is the best idea.

--
Lee McFadden

blog: http://www.splee.co.uk
twitter: http://twitter.com/splee

Jorge Vargas

unread,
Aug 3, 2008, 12:55:24 AM8/3/08
to turbogea...@googlegroups.com
On Sat, Aug 2, 2008 at 4:35 PM, Lee McFadden <sple...@gmail.com> wrote:
>
> On Sat, Aug 2, 2008 at 8:24 PM, Gustavo Narea
> <gus...@gnulinuxmatters.org> wrote:
>> Hello, everyone.
>>
>> What do you think about defining the model in the default TG2 template using
>> SQLAlchemy's declarative extension instead of using it the traditional way?
>>
>> I think it would make the model look more natural and easier to get started.
>>
>
> -1
>
> The SQLAlchemy documentation (which we will be referring people to on
> a regular basis) uses the standard method of declaring tables/classes.
> Personally I would prefer to allow people to use the documentation
> available and not have to "translate" into the declarative mode.
>
actually the new docs have both methods, and it seems to be something
taking some acceptance in the community.
http://www.sqlalchemy.org/docs/05/ormtutorial.html#datamapping_declarative

> Purely from a support standpoint I don't think changing this is the best idea.
>

I'm +0 on this one. To be honest I do like declarative more, but we
shouldn't force it on people (specially new people).

Kless

unread,
Aug 3, 2008, 4:37:57 AM8/3/08
to TurboGears Trunk


On 2 ago, 20:24, Gustavo Narea <gust...@gnulinuxmatters.org> wrote:
> Hello, everyone.
>
> What do you think about defining the model in the default TG2 template using
> SQLAlchemy's declarative extension instead of using it the traditional way?
>
> I think it would make the model look more natural and easier to get started.
Yes, and it's more similar to another ORMs as SQLObject, so would be
more easy to people to make the change.

+1

Kless

unread,
Aug 3, 2008, 4:40:22 AM8/3/08
to TurboGears Trunk


On 3 ago, 05:55, "Jorge Vargas" <jorge.var...@gmail.com> wrote:
> > Purely from a support standpoint I don't think changing this is the best idea.
>
> I'm +0 on this one. To be honest I do like declarative more, but we
> shouldn't force it on people (specially new people).
Well, it would be possible that the user chooses which mode use. It
could be used any option when a new project is created.

Gustavo Narea

unread,
Aug 3, 2008, 12:11:19 PM8/3/08
to turbogea...@googlegroups.com
Hello,

On Sunday 03 August 2008 00:35:14 Lee McFadden wrote:
> The SQLAlchemy documentation (which we will be referring people to on
> a regular basis) uses the standard method of declaring tables/classes.

If you're talking about v0.4 that's right, but please check the documentation
for v0.5. The ORM tutorial itself uses the traditional way only in the
beginning, and the declarative method for the rest; I'm afraid it'll become
the standard/preferred method for SA 0.5.


> Personally I would prefer to allow people to use the documentation
> available and not have to "translate" into the declarative mode.

As Jorge has already pointed out, both methods are already present in the
documentation.

But I think the default template should use the declarative method and the
documentation should be mostly focused on this method.


> Purely from a support standpoint I don't think changing this is the best
> idea.

I think this only applies to SA 0.4, but things will change for v0.5.

Cheers,

signature.asc

Lee McFadden

unread,
Aug 3, 2008, 12:26:46 PM8/3/08
to turbogea...@googlegroups.com
On Sun, Aug 3, 2008 at 5:11 PM, Gustavo Narea
<gus...@gnulinuxmatters.org> wrote:
>
> I think this only applies to SA 0.4, but things will change for v0.5.
>

Apologies, I hadn't really checked the SA 0.5 docs very thoroughly as
the first section looked almost identical and the changes in 0.5
didn't seem that huge. If the declarative method is also used in the
documentation then I am +0 on this.

Mark Ramm

unread,
Aug 3, 2008, 12:51:17 PM8/3/08
to turbogea...@googlegroups.com
> If the declarative method is also used in the
> documentation then I am +0 on this.

If the SA docs use the declarative method, I say we should too. It's
a significant marketing win in terms of being more familiar looking to
SO/DjangoORM/ActiveRecord users, and we do want to attract those
people. And the declarative layer does look nice, and keeps things
together in a reasonable and easy to understand way, which is good for
a large set of applications.

At the same time, I'm most concerned that TG2 'scale up' to complex
problems and complex database stuff. Scaling down to solve easy
problems in a simple way is important too, but what I don't want is to
scale down at the expense of the ability to handle the complex stuff.

In this case I think declarative is a win for simple stuff, and it's
easy to switch to the manual when you need it.

So I'm +1 on this idea. If we patch the current TG to do it and
update the TG2 docs between now and the next alpha, I'm +2.

Christoph Zwerschke

unread,
Aug 3, 2008, 12:54:56 PM8/3/08
to turbogea...@googlegroups.com
Gustavo Narea schrieb:

> If you're talking about v0.4 that's right, but please check the documentation
> for v0.5. The ORM tutorial itself uses the traditional way only in the
> beginning, and the declarative method for the rest; I'm afraid it'll become
> the standard/preferred method for SA 0.5.

Sorry, I did not follow these developments - does this mean that Elixir
will lose its raison d'être?

-- Christoph

Gustavo Narea

unread,
Aug 3, 2008, 1:13:28 PM8/3/08
to turbogea...@googlegroups.com

Possibly. I think they both do the same thing, differently. But the
declarative method is plain SA.

Gustavo Narea

unread,
Aug 3, 2008, 1:14:06 PM8/3/08
to turbogea...@googlegroups.com

On Sunday 03 August 2008 18:51:17 Mark Ramm wrote:
> So I'm +1 on this idea.   If we patch the current TG to do it and
> update the TG2 docs between now and the next alpha, I'm +2.

I can take care of both things if it's accepted.

Mark Ramm

unread,
Aug 3, 2008, 2:10:51 PM8/3/08
to turbogea...@googlegroups.com
> On Sunday 03 August 2008 18:51:17 Mark Ramm wrote:
>> So I'm +1 on this idea. If we patch the current TG to do it and
>> update the TG2 docs between now and the next alpha, I'm +2.
>
> I can take care of both things if it's accepted.

I say go for it then. If there's some public outcry against it, we
can always have two templates one declarative, and one with tables,
objects, and mappers all split out.

--Mark Ramm

Gustavo Narea

unread,
Aug 3, 2008, 2:44:05 PM8/3/08
to turbogea...@googlegroups.com

On Sunday 03 August 2008 20:10:51 Mark Ramm wrote:
> I say go for it then.   If there's some public outcry against it, we
> can always have two templates one declarative, and one with tables,
> objects, and mappers all split out.

Perfect, I'll work on it tomorrow.

Cheers.

Gustavo Narea

unread,
Aug 6, 2008, 8:28:43 PM8/6/08
to turbogea...@googlegroups.com
OK, the patch (against r5096) is attached.

Any comments?

In addition to the declarative integration, I just modified the PKs to set
them to autoincrement - is this fine with you?

Hopefully I'll document the changes tomorrow.

Cheers.

tg2-sa-declarative.patch
signature.asc

Gustavo Narea

unread,
Aug 13, 2008, 12:52:37 PM8/13/08
to turbogea...@googlegroups.com
I've created a ticket for this: http://trac.turbogears.org/ticket/1938

But I tried to add another patch, to update the documentation, but it's
rejected by Akismet because of the amount of links. So the second patch is
attached. It corrects some minor mistakes, and adds three sections:
- Defining your own tables
- Using non-default names for identity-related tables and mapped classes
- Getting help


On Sunday 03 August 2008 20:10:51 Mark Ramm wrote:

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "TurboGears Trunk" group. To post to this group, send email to
> turbogea...@googlegroups.com To unsubscribe from this group, send
> email to turbogears-tru...@googlegroups.com For more options,
> visit this group at http://groups.google.com/group/turbogears-trunk?hl=en
> -~----------~----~----~----~------~----~------~--~---

tg-doc-1938.patch
signature.asc

Domingo Aguilera

unread,
Aug 13, 2008, 6:08:29 PM8/13/08
to TurboGears Trunk
I am eager to see this in action. BTW who's in charge of tg.devtools
repository ?

Cheers.

Domingo Aguilera ( aka "batok" ).

On Aug 13, 11:52 am, Gustavo Narea <gust...@gnulinuxmatters.org>
wrote:
> I've created a ticket for this:http://trac.turbogears.org/ticket/1938
>
> But I tried to add another patch, to update the documentation, but it's
> rejected by Akismet because of the amount of links. So the second patch is
> attached. It corrects some minor mistakes, and adds three sections:
> - Defining your own tables
> - Using non-default names for identity-related tables and mapped classes
> - Getting help
>
> On Sunday 03 August 2008 20:10:51 Mark Ramm wrote:
>
>
>
> > > On Sunday 03 August 2008 18:51:17 Mark Ramm wrote:
> > >> So I'm +1 on this idea. If we patch the current TG to do it and
> > >> update the TG2 docs between now and the next alpha, I'm +2.
>
> > > I can take care of both things if it's accepted.
>
> > I say go for it then. If there's some public outcry against it, we
> > can always have two templates one declarative, and one with tables,
> > objects, and mappers all split out.
>
> > --Mark Ramm
>
> > >
> --
> Gustavo Narea.
> General Secretary. GNU/Linux Matters.http://www.gnulinuxmatters.org/
>
> tg-doc-1938.patch
> 10KViewDownload
>
> signature.asc
> < 1KViewDownload

percious

unread,
Aug 14, 2008, 3:25:15 PM8/14/08
to TurboGears Trunk
-1

However, I think we should provide an option on quickstart to generate
the model using declarative.

-chris

On Aug 13, 4:08 pm, Domingo Aguilera <domingo.aguil...@gmail.com>
wrote:

Gustavo Narea

unread,
Aug 19, 2008, 6:43:45 PM8/19/08
to turbogea...@googlegroups.com
Hi,

This is now in SVN.

Cheers.

Reply all
Reply to author
Forward
0 new messages