On Monday 20 October 2014 21:26:50 Carl Meyer wrote:
> Hi Marc,
> 
> On 10/19/2014 12:54 AM, Marc Tamlyn wrote:
> > I guess now with migrations we have a nice way of running the SQL
> > against the database to create the stored procedures.
> > 
> > However if we plan to make this a public API, it should be a nice one.
> > Something along the lines of db.procedures.proc_name(*args, **kwargs)
> > would be preferable I think. Obviously this requires more magic to make
> > it work (or explicit registration of your procedures).
> 
> I know this is hypothetical, but I don't think that is a particularly
> nicer API, or that we should provide such syntactic sugar atop
> callproc(). Providing the procedure name as a string is not really a
> problem, and is preferable to doing `__getattr__` magic or requiring
> registration of procedures; the syntactic sugar just doesn't provide
> enough benefit to justify the magic, and all the various ways that that
> magic could confuse users and cause maintenance issues.
> 

I respectfully disagree. The kind of "magic" Marc suggested lets you, as a 
user. treat procedure calls as function calls; that is a very natural thing to 
do. I'd argue that in the common case, the user shouldn't care if the function 
they are calling is implemented in Python or Procedural SQL (assuming it is 
going to interact with the database either way), and so it is good API design 
to abstact this detail away.

(I encourage everyone to take a look at plumbum[1], which, among other things, 
allows you to import shell commands into your namespace using a similar 
abstraction. This is actually not my favorite part of that library -- that 
would be plumbum.cli[2] -- but when you want to write system scripts, it makes 
things really sweet; you get the software-engineering benefits of Python, with 
the shell's straightforward command invocation).

Shai

[1] http://plumbum.readthedocs.org, https://github.com/tomerfiliba/plumbum
[2] http://plumbum.readthedocs.org/en/latest/cli.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/201410220104.23065.shai%40platonix.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to