Skip to content. | Skip to navigation

Sections
Personal tools
You are here: Home News & views Namespace packages: replies to replies

Posted Jun 16, 2009

Namespace packages: replies to replies

by Erik Rose

Clarifications, your comments addressed, and why I still think we should lay off the namespace packages

Many thanks to all who posted such thoughtful replies to my apparently incendiary post on namespace packages. Since I was off-network last week (Grand Canyon—woo!) and not able to respond in realtime, I’ve taken the liberty of summarizing and addressing some salient points en masse below.

“Namespaces are useful for avoiding name collisions.”

Of course they are. I should been clearer in my main point, as a lot of folks ended up banging on an open door here. Namespaces—as an abstract concept—are lovely. What’s wrong is our use of setuptools’ implementation: as we use them, namespace packages are awfully noisy and obtrusive from a package consumer’s point of view—they make new users walk straight through their implementation details, both in svn and on disk, before they can get to any code.

But a lot of this is due to funny conventions. We use namespace packages in an unusual way in the Plone world: we never put anything but a single package inside them, making the outer folder mostly empty and mostly noise. We don’t take advantage of setuptools’ support for putting N submodules and packages inside a namespace package, which would make the signal-to-noise ratio more acceptable. So I wonder, can we come up with a shorter, fewer-empty-folders way of namespacing?

Indeed we can. One of my proposed solutions, using names like plone_app_redirector instead of plone.app.redirector, provoked an implication that I was simply inventing a different spelling. Quite the contrary, plone_app_redirector is simpler in 2 substantial ways:

  • No 2 extra folders to traverse on disk and in svn
  • No __init__.py files with unusual import magic to understand or ignore

“Products.* is no longer uniquely magic.”

Thanks to Martin Aspeli for pointing this out; I meant to mention it. As Martin says, any package can have the auto-loading magic of Products.* in Plone 3.3 if it declares the right egg entrypoints. No more ZCML slugs—hooray!

However, Ian Hood and Chris McDonough also raise a good point: as funny-looking as the Products namespace is, it at least signifies “this package is a Plone plugin”. (There aren’t many third-party Plone plugins that are also useful in a general Python context, so the distinction remains relevant.) We probably should include this I-am-for-Plone-ness in the package name so as to not crash into comparable plugins for other frameworks. A few possible naming conventions:

  • PloneFormGen. Start everything with a “Plone” prefix, as most Trac plugins start with “Trac”. But, if applied inconsistently (as it would be during any transition), this would land us in the same situation as KDE’s start menu, where things randomly start with K and new users wanting a spreadsheet have to look for both Spreadsheet and KSpreadsheet.
  • PonyPloneTheme. Put the Plone identifier at the end. With the entropy up front, this is better for visually scanning alphabetized lists and for type-to-select. (In places like the Collective svn, similar types of products, like themes, could be grouped into folders as with the current pasplugins folder.)
  • NerfHerder. Keep Plone signifiers out of the name, and use egg metadata like trove classifiers. This has the possible disadvantage of colliding with non-Plone packages, but, then again, namespace is pretty big. Regardless, we should get some trove classifiers for common types of Plone add-ons. If there can be a Topic :: Desktop Environment :: Window Managers :: Oroborus :: Themes, there can certainly be one for Plone themes, one for Plone plugins in general, and perhaps a few other subslicings.
  • Products.NerfHerder, perhaps the most reasonable compromise of evils: we’re already a decade into that particular hole, and it’s only one level deep. It doesn’t invent any more conventions to memorize or transition to like collective.* or plone.*, it doesn’t smash into general-Python namespace, and, if you don’t move your trunk when you eggify, it doesn’t defeat type-to-select either. I still dislike the namespace package due to the previously discussed implementation ugliness, but that may be fixable by technical means (watch this space). If I could erase the world and start over, I might go with a different scheme. But, since a transition would take forever and be confusing all the while, I’m willing to settle for Products.*. In fact, I’m fairly persuaded by Chris McDonough’s statement that “It’s completely, totally useless to have Products outside the Products namespace.”

“Namespaces should communicate licensing.”

Martin writes:

Namespaces also communicate ownership. For example, we’ve been able to formulate useful policy around the licensing of packages in the plone.* (soon to allow BSD licensing) and plone.app.* (to stay GPL licensed) namespaces.

Cordially disagree on this one: this is what the license metadata field is for. (Incidentally, I suspect no one outside an intimate group of core developers has any idea the difference between plone.app and plone.*.)

“The trunk should move when you eggify.”

Plone is one of the few projects where egg names typically reflect their import paths. Joel Burton, who interfaces with lots of new users in his training classes, finds this aids comprehension. So let’s keep it. In fact, I never suggested otherwise: either way, you’ll be checking out a folder called "trunk", not a folder named after the egg. My beef is with the practice of uprooting an existing svn trunk and moving it to a new location when eggifying an old product. There’s just no point. WebLion trains new developers all day long, and this practice is a rich source of confusion. It’s also a waste of time to have to look in two places when browsing a repository, and, if carried through, it’ll result in hundreds of abandoned top-level folders in places like the Collective.

Joel further writes, of keeping trunks still:

[T]he intended benefit, doesn’t exist. Your buildout wouldn’t still work if it expected a classic product at /svn/JoelsBlog--there isn’t a classic product there, but a nested egg namespace. So, your buildout would -still- break, and in a much less newbie-understandable way.

The intended benefit is not to keep buildout from breaking. It’s going to break no matter what—which is another failure that should be separately addressed, perhaps with better checking for common mistakes. My intent, rather, is to surprise people less when browsing repositories and, secondarily, to reduce top-level pollution in repositories.

“You’re an idiot.”

Probably. Here are my recommendations nonetheless, now a little better shaped thanks to your good-natured hammer blows:

  • Reserve namespace packages for breaking up enormous legacy packages, as intended. Namespacing for any other purpose can be done more simply with plain prefixes, and many of our existing uses of namespacing (collective.*, plonetheme.*) would be better served by egg metadata. I'll be using egg metadata only and hanging out in the Products namespace to avoid colliding with non-Plone projects.
  • Don’t move the trunk when eggifying. You’re going to break people’s checkouts either way, so why double the number of folders in the repo, make everyone search twice when browsing, and defeat type-to-select?
  • Keep company names, license names, and other metadata out of package names—since changing them breaks people’s imports and buildouts—and nest them cozily in egg metadata. Plone products should probably all be in the Products.* namespace. (You talked me into it. :-))
  • Fix those ZopeSkel templates. In answer to jjmojojjmojo’s question about how best to do that, I’d have the plone3_theme template spit out products in the Products.* namespace but give an example like “PonyTheme" when prompting for a name. And continue to put “web zope plone theme” in the egg keywords.

Again, I really appreciate all your responses. If any of my reasoning is wrong, please point it out and save me pain!

Document Actions

Some clarification

Posted by Martin Aspeli at Jun 16, 2009 12:48 PM
I'm a bit disappointed that you seem to have ignored some of the more poignant comments in that previous post. Chris Rossi and Martijn Faassen both provided very good responses, for example, and I fear I'll be repeating much of what they say here.

As far as I can tell, your main criticisms are:

 - setuptools forces you to spell the namespaces inside your packages as directories, so you get usually two levels of nesting that's boilerplate

 - changing namespaces is bad (d'uh)

I can't find any other non-emotional rationale to ditch them, but then it's late.

The first point I think is a smaller issue than you suggest. The latter is completely valid, but is not really anything to do with namespaces. It could be rephrased as "don't change your import locations if people are relying on your code", which is just good practice.

"""
But a lot of this is due to funny conventions. We use namespace packages in an unusual way in the Plone world: we never put anything but a single package inside them, making the outer folder mostly empty and mostly noise. We don’t take advantage of setuptools’ support for putting N submodules and packages inside a namespace package, which would make the signal-to-noise ratio more acceptable. So I wonder, can we come up with a shorter, fewer-empty-folders way of namespacing?
"""

I think you're confusing namespaces packages with another setuptools concept, namely having eggs that contain many packages. The plone.* namespace has *tons* of packages underneath it.

As far as I know, we don't use namespaces any differently to anyone else. We do have a convention that the egg name is the same as the dotted name to the 'main' package, including its namespace. As Joel says, that's just to make the eggs more discoverable, and I think it serves us well.

"""
Indeed we can. One of my proposed solutions, using names like plone_app_redirector instead of plone.app.redirector, provoked an implication that I was simply inventing a different spelling. Quite the contrary, plone_app_redirector is simpler in 2 substantial ways:

No 2 extra folders to traverse on disk and in svn
No __init__.py files with unusual import magic to understand or ignore"
"""

You are inventing a different way of spelling, except now we've lost the ability to manage those namespaces using Python import semantics. This namespace spelling is not consistent with how namespacing works in Python in general, and so people are more likely to get it wrong. It's all just one flat namespace, but you're hoping people will follow the convention to avoid collisions.

I'd be great if setuptools allowed me to say "the src/ folder contains the plone.foobar package root, where plone is a namespace package". But it doesn't, for various good and not so good reasons. I don't quite see how it's such a big problem. It feels like you're throwing the baby out with the proverbial bath water here.

"""
However, Ian Hood and Chris McDonough also raise a good point: as funny-looking as the Products namespace is, it at least signifies “this package is a Plone plugin”. (There aren’t many third-party Plone plugins that are also useful in a general Python context, so the distinction remains relevant.) We probably should include this I-am-for-Plone-ness in the package name so as to not crash into comparable plugins for other frameworks.
"""

It's not just about other frameworks. It's also about other packages in the Plone world, which is actually the largest community on PyPI, I think.

Products.* has the same problem as a flat top level namespace in that sense. And it should die. ;)

I've got some real, if anecdotal, evidence that namespacing in general and small packages in particular has had a positive impact. Before Plone 3, there were way fewer small-and-re-usable packages, and we were terrible at producing packages that the outside world could use. By moving to a toolset, conventions and patterns that other Python people use, we have been able to encourage developers to think about re-usability, split out re-usable parts into separate packages, and so on. Namespaces also give us a way to refactor, as you identified in your first post.

"""
A few possible naming conventions:
"""

These all suffer from the same problem. They rely on vague conventions that are easy to forget and don't sit well with Python's general approach to code structuring. By trying to invent a new set of conventions and a new form of namespacing (which is what it is you're trying to do), you've just made a more error-prone and less discoverable alternative. All to save you going into two folders? Mmmm....

"""
Cordially disagree on this one: this is what the license metadata field is for. (Incidentally, I suspect no one outside an intimate group of core developers has any idea the difference between plone.app and plone.*.)
"""

Well, true. The license metadata is the ultimate source of truth. But we can stipulate useful policy and general guidelines around the use of a namespace that the Foundation controls, and relate it to the Plone trademark. This has already happened, so you can't really disagree with it. ;-)

The plone.* and plone.app.* licensing restriction doesn't exist yet. When it will, people will know.

But ultimately, plone.* and plone.app.* are namespaces that "we the Plone core developers" own and manage. It's not really so important that others know about the standards we have for managing what code goes where. To users of those packages, it's all just code and package metadata. To us, the core developers, they are an important way to structure our code and manage our releases. As a case in point, moving from Products.CMFPlone as one uber-package to lots of small packages has allowed us to make releases more rapidly and incrementally, and allowed people to get upgrades to parts of the system (e.g. I need a new plone.portlets release to fix a bug in my current project) without having to track svn trunk of a huge package that is released rarely.

Of course, we could've achieved the same with plone_portlets and plone_app_portlets or whatever, but that'd be more painful, not less.

So, to your recommendations:

"""
Reserve namespace packages for breaking up enormous legacy packages, as intended.
"""

This is disingenuous. It's not the main or only intended use case for namespaces or namespace packages.

"""
Namespacing for any other purpose can be done more simply with plain prefixes, and many of our existing uses of namespacing (collective.*, plonetheme.*) would be better served by egg metadata. I'll be using egg metadata only and hanging out in the Products namespace to avoid colliding with non-Plone projects.
"""

I sincerely, sincerely hope that people don't follow this advice. I'd be disinclined to accept into Plone core any package that does not use sensible namespacing, for instance. For the sake of not having to navigate into two directories (which you can and should fix with collective.recipe.omelette anyway), we'd be creating confusion by moving away from a convention that's well established now (and which I still think is very valuable).

"""
Don’t move the trunk when eggifying. You’re going to break people’s checkouts either way, so why double the number of folders in the repo, make everyone search twice when browsing, and defeat type-to-select?
"""

I don't think this is very important one way or the other, so I won't reply.

"""
Keep company names, license names, and other metadata out of package names—since changing them breaks people’s imports and buildouts—and nest them cozily in egg metadata. Plone products should probably all be in the Products.* namespace. (You talked me into it. :-))
"""

You shouldn't change them. Your namespace needs to be something you own and control to guarantee uniqueness. I have no problem with company names there. But don't change them.

And I think the Products.* namespace should die. I disagree with Chris M's suggestion that there's no reason for Zope 2 products outside the Products.* namespace, but I think he's decided to disagree with me. ;-) The fact that something is a Zope 2 product or a Plone product or a Plone non-product package or a Trac plugin is implementation detail and completely orthogonal to namespacing in general. We try to refactor our packages to no longer require Zope 2 product-ness (i.e. an initialize() function), for example.

"""
Fix those ZopeSkel templates. In answer to jjmojojjmojo’s question about how best to do that, I’d have the plone3_theme template spit out products in the Products.* namespace but give an example like “PonyTheme" when prompting for a name. And continue to put “web zope plone theme” in the egg keywords.
"""

Better defaults would be nice. So long as they are actually better. ;-)

Martin

Egg folder depth

Posted by Sean Upton at Jun 16, 2009 02:51 PM
I guess I just do not see how symbolic links cannot solve the problem of nested folders to support each namespace package. Minor annoyance, IMHO. If it was that big of a deal, you use omelette make symlinks in one dir to the respective yolk of all your eggs. This is less invasive than adopting a new naming convention/spelling just to flatten things a bit. Bookmarks in some text editors and IDEs also can help minimize clicks through folders. The only thing the status quo does not have going for it is approachability for new developers, but I think we want developers to grok namespace packages (to understand the flexibility they yeild) at some point in their work.

Reply to reply to reply

Posted by Erik Rose at Jun 16, 2009 06:10 PM
'''I'm a bit disappointed that you seem to have ignored some of the more poignant comments in that previous post. Chris Rossi and Martijn Faassen both provided very good responses, for example, and I fear I'll be repeating much of what they say here.
'''

Poignancy aside, I'd hate to miss any good points, so I'll do my best to address anything you bring up.

That said, both Chris and Martijn's arguments hinged on an identification of namespaces (which are really just a particular way of spelling hierarchy) with namespace packages—a false conflation which I address at some length in the first section above. In short, there are many ways to hierarchalize namespace; namespace packages do not have a monopoly there and are overly complex for most cases.

'''As far as I can tell, your main criticisms are:

 - setuptools forces you to spell the namespaces inside your packages as directories, so you get usually two levels of nesting that's boilerplate

 - changing namespaces is bad (d'uh)
'''

Along with "don't make a copy of your whole project and move it elsewhere when you eggify", those are indeed my main points. It's really quite simple. I'm surprised at some of the reactions (though most of them came out of the miscommunication above).

'''The first point I think is a smaller issue than you suggest.
'''

It depends on your audience. I don't doubt that, as an advanced developer, you can read past the boilerplate and the extra level or two of folders without blinking an eye. I can read past it, too, though I would prefer that we all could save the extra steps. But who concerns me most are the new developers, themers, and integrators who need to understand this very in-your-face convention that adds no value (as we use it) over a simpler_naming_convention.

'''The latter is completely valid, but is not really anything to do with namespaces. It could be rephrased as "don't change your import locations if people are relying on your code", which is just good practice.
'''

We agree here. The point I originally made was that there have been namespaces that reflect change-prone things (like company names), making it needlessly likely that import paths would have to change.

"""
But a lot of this is due to funny conventions. We use namespace packages in an unusual way in the Plone world: we never put anything but a single package inside them, making the outer folder mostly empty and mostly noise. We don’t take advantage of setuptools’ support for putting N submodules and packages inside a namespace package, which would make the signal-to-noise ratio more acceptable. So I wonder, can we come up with a shorter, fewer-empty-folders way of namespacing?
"""

'''
I think you're confusing namespaces packages with another setuptools concept, namely having eggs that contain many packages. The plone.* namespace has *tons* of packages underneath it.
...
As far as I know, we don't use namespaces any differently to anyone else.
'''

Actually, I'm not confusing them. Your suspicion that they could be confused might itself be an indication that we should be less confusing. :-)

I'll try to explain it again. While the plone.* namespace has tons of packages underneath it, any given `plone` folder within a plone.* egg has (count 'em) 1. As a counterexample, see the `peak` namespace package: http://svn.eby-sarna.com/PEAK/src/peak/. There are over a dozen modules in there. That's the flexibility we're paying for but not using with our barely-populated packages.

'''We do have a convention that the egg name is the same as the dotted name to the 'main' package, including its namespace. As Joel says, that's just to make the eggs more discoverable, and I think it serves us well.
'''
I have never argued otherwise.

"""
Indeed we can. One of my proposed solutions, using names like plone_app_redirector instead of plone.app.redirector, provoked an implication that I was simply inventing a different spelling. Quite the contrary, plone_app_redirector is simpler in 2 substantial ways:

No 2 extra folders to traverse on disk and in svn
No __init__.py files with unusual import magic to understand or ignore"
"""
'''You are inventing a different way of spelling, except now we've lost the ability to manage those namespaces using Python import semantics.
'''

How have we lost anything but a bunch of boilerplate and extra folders?

'''This namespace spelling is not consistent with how namespacing works in Python in general, and so people are more likely to get it wrong. It's all just one flat namespace, but you're hoping people will follow the convention to avoid collisions.
'''

I think your first statement needs substantiation. As for hoping people will following conventions, that's a tremendously Pythonic frame of mind. Just for a few, take our interface convention of ISomeInterface and our private member convention of _leading_underscores. We also have conventions for docstrings (PEP 257) and code formatting (PEP 8). People seem to follow them pretty well.

'''I'd be great if setuptools allowed me to say "the src/ folder contains the plone.foobar package root, where plone is a namespace package". But it doesn't, for various good and not so good reasons.
'''

When I get around to it, I mean to give that a shot and at least see why it isn't available.

'''I don't quite see how it's such a big problem. It feels like you're throwing the baby out with the proverbial bath water here.
'''

You still haven't named a single reason (beyond the subjective "I like periods") that this boilerplate is worth the trouble.

"""
We probably should include this I-am-for-Plone-ness in the package name so as to not crash into comparable plugins for other frameworks.
"""
'''It's not just about other frameworks. It's also about other packages in the Plone world, which is actually the largest community on PyPI, I think.

Products.* has the same problem as a flat top level namespace in that sense. And it should die. ;)
'''

I disagree. I think people should name their packages more descriptively. "xml", for example, is too broad a package name no matter what namespace it's in. Does it really do *everything* with regard to XML? Of course not. And putting a namespace around it (whether you use a namespace package or call it acme_xml) doesn't fix the semantics. I would far rather have a couple librarians in charge of PyPI to enforce some modicum of sanity in package naming than to say "It's the Wild West, but let's segment everybody off in their own little Wild West."

'''I've got some real, if anecdotal, evidence that namespacing in general and small packages in particular has had a positive impact. Before Plone 3, there were way fewer small-and-re-usable packages, and we were terrible at producing packages that the outside world could use. By moving to a toolset, conventions and patterns that other Python people use, we have been able to encourage developers to think about re-usability, split out re-usable parts into separate packages, and so on. Namespaces also give us a way to refactor, as you identified in your first post.
'''

You're conflating orthogonal concerns. Small packages != namespace packages, and namespace packages' benefit to refactoring applies only when there are existing imports that must not be broken. Before plone.* was made a namespace package, there were no plone.* imports—thus, nothing to break. Nobody argues that small packages and frequent releases aren't good, but that has nothing to do with the argument at hand.

"""
A few possible naming conventions:
"""
'''These all suffer from the same problem. They rely on vague conventions that are easy to forget and don't sit well with Python's general approach to code structuring. By trying to invent a new set of conventions and a new form of namespacing (which is what it is you're trying to do), you've just made a more error-prone and less discoverable alternative. All to save you going into two folders? Mmmm....
'''

Honestly, how often do you type the contents of a namespace package's __init__.py by hand? Do you find it "easy to remember"? How discoverable do you think the setuptools boilerplate is to a new user? I think our brains just don't work the same way.

'''As a case in point, moving from Products.CMFPlone as one uber-package to lots of small packages has allowed us to make releases more rapidly and incrementally, and allowed people to get upgrades to parts of the system (e.g. I need a new plone.portlets release to fix a bug in my current project) without having to track svn trunk of a huge package that is released rarely.
'''

Again, nobody ever said small releases were bad. But small releases of plone_app_frobulator would be just as good as plone.app.frobulator (and have less boilerplate).

'''Of course, we could've achieved the same with plone_portlets and plone_app_portlets or whatever, but that'd be more painful, not less.
'''

I'm flummoxed as to how.

"""
Reserve namespace packages for breaking up enormous legacy packages, as intended.
"""
'''
This is disingenuous. It's not the main or only intended use case for namespaces or namespace packages.
'''

It certainly is the first (and arguably only) one mentioned in the setuptools documentation: http://peak.telecommunity.com/[…]/setuptools#namespace-packages

"""
Namespacing for any other purpose can be done more simply with plain prefixes, and many of our existing uses of namespacing (collective.*, plonetheme.*) would be better served by egg metadata. I'll be using egg metadata only and hanging out in the Products namespace to avoid colliding with non-Plone projects.
"""
'''I sincerely, sincerely hope that people don't follow this advice. I'd be disinclined to accept into Plone core any package that does not use sensible namespacing, for instance. For the sake of not having to navigate into two directories (which you can and should fix with collective.recipe.omelette anyway), we'd be creating confusion by moving away from a convention that's well established now (and which I still think is very valuable).
'''

I think the convention brings more confusion than value. If you want to keep it for the Plone core packages, fine, but I would discourage any other developers from going namespace-crazy. And as far as omelette goes, I dig the whole symlink-into-the-instance thing because it lets me scan one place with LaunchBar, but the other stuff is a patch around complexity. I would rather remove said complexity than hack around it.

"""
Keep company names, license names, and other metadata out of package names—since changing them breaks people’s imports and buildouts—and nest them cozily in egg metadata. Plone products should probably all be in the Products.* namespace. (You talked me into it. :-))
"""
'''You shouldn't change them. Your namespace needs to be something you own and control to guarantee uniqueness. I have no problem with company names there. But don't change them.
'''

So you want to corral every developer and collaboration of developers into their own namespace. I'm with nutjob and his nightmare of...

> ls -R src

org:
__init__.py gnu

org/gnu:
__init__.py regex

org/gnu/regex:
__init__.py parser searcher

'''The fact that something is a Zope 2 product or a Plone product or a Plone non-product package or a Trac plugin is implementation detail and completely orthogonal to namespacing in general. We try to refactor our packages to no longer require Zope 2 product-ness (i.e. an initialize() function), for example.
'''

My ultimate dream is for Products.* to no longer be magic (no more initialize()) and just be a general place to park Zope products.

Let me close, Martin, by just saying that you write really, really fast. :-)

Short summary

Posted by Martin Aspeli at Jun 17, 2009 12:19 AM
This is just getting too long, but let me try it another way.

It seems to me you're saying you agree that namespaces are good, but you don't want to use the best available infrastructure we have to manage them? And the reason you don't want to do that, is that you don't like the repeated package names in the directory structure and the boilerplate?

How about you release an *egg* called FacultyStaffDirectory, but it contains a package called weblion.facultystaffdirectory, where weblion is a namespace package? In this case, you'd have

  src/FacultyStaffDirectory/weblion/facultystaffdirectory

You'd have one __init__.py with boilerplate. Regrettable, but hardly insane. And you'd have the ability (as you do now) to add more packages, e.g. you want this egg to also ship with weblion/staffphotolibrary or something.

Now, Joel says that people prefer to have the egg name reflect the package name because it makes it easier to find the code. I think that's a good point, and is the reason that we prefer this convention in Plone, but again, that's somewhat separate to the discussion about namespace packages.

To be slightly more forceful:

Namespace packages are here to stay. Namespaces are here to stay. Python has a standard way to do namespaces and code grouping via dotted names. Setuptools has a standard way to allow you to manage those namespaces in a way that lets you release packages into a single namespace in multiple eggs. This is good practice and something most other platforms (Java, .NET) has had from year dot.

Sometimes, we may benefit from releasing slightly fatter eggs that contain multiple packages (in one or several namespaces) in a single .egg file. That's a matter of release management granularity, though, and doesn't have anything to do with the use of namespaces or namespace packages.

In Plone, we have some conventions and standards around the use of namespaces. Any package that goes into the core will be expected to follow those conventions and standards within reason. And any package that wants to play nice as an add-no product ought to do so, too. I hope no-one reads this and starts inventing their own package naming conventions believing that namespace packages are generally considered to be "bad". :)

Inventing new standards and conventions that are contrary to the currently established principles and to what other Python developers do is really counter-productive and a big step backwards. We have been there before with Products/* and flat namespace of PloneFooBar and PloneBarFoo. This is harder to manage and less condusive to splitting out things into smaller and more re-usable packages. I agree that namespaces by themselves don't enable this, but psychologically, they seem to have done so.

Let me put it differently: if you could avoid the boilerplate inside eggs (the namespace folder and the namespace/__init__.py module), would you get back in your box? :-) If so, the costs of what you're proposing in terms of consistency, our ability to manage a large and complex ecosystem of packages, our ability to introspect our package namespaces (as we do to enable z3c.autoinclude to work, for example), predictability of our conventions viz-a-viz other projects, and import aesthetics far outweigh the benefit, especially when the resolution is so simple:

I put collective.recipe.omelette in every buildout I use, even on Windows, not just to save some typing, but to make it easier to inspect and put breakpoints in the code that's currently used by zope, regardless of how my egg cache grows. I suggest you do the same.

Martin

Conventions and conflations

Posted by Erik Rose at Jun 23, 2009 06:23 PM
> It seems to me you're saying you agree that namespaces are good, but you
> don't want to use the best available infrastructure we have to manage them?

I'm pointing out some deficiencies and suggesting ways we can do better.

> And the reason you don't want to do that, is that you don't like the
> repeated package names in the directory structure and the boilerplate?

It's not the repeated package names that bother me; as Joel suggests based on his experience, those are probably nice mnemonics. The boilerplate and extra folders? No, I don't like those.

> To be slightly more forceful:
>
> Namespace packages are here to stay. Namespaces are here to stay.

Argument by vehement assertion, eh? ;-)

How and whether to namespace is a decision that individual developers can make as they create new packages. I'm simply encouraging them to do so with care rather than following after a needlessly complex convention.

> Python has a standard way to do namespaces and code grouping via dotted
> names. Setuptools has a standard way to allow you to manage those namespaces
> in a way that lets you release packages into a single namespace in multiple
> eggs. This is good practice and something most other platforms (Java, .NET)
> has had from year dot.

You continue to conflate setuptools namespace packages with namespacing in general. You can ship foo_bar and foo_baz just as easily (even more easily, in fact) than foo.bar and foo.baz (which require __init__.py boilerplate), and they have the same benefits.

> Sometimes, we may benefit from releasing slightly fatter eggs that contain
> multiple packages (in one or several namespaces) in a single .egg file. That's
> a matter of release management granularity, though, and doesn't have anything
> to do with the use of namespaces or namespace packages.

Of course it doesn't.

> In Plone, we have some conventions and standards around the use of
> namespaces. Any package that goes into the core will be expected to follow
> those conventions and standards within reason. And any package that wants to
> play nice as an add-no product ought to do so, too. I hope no-one reads this
> and starts inventing their own package naming conventions believing that
> namespace packages are generally considered to be "bad". :)

First, I'm not talking about core packages. I think they could have been handled better, but now that everyone is importing from them, it is too late. Second, I think your tendency, as an advanced developer, is to overestimate people's capability to deal with abstraction and count boilerplate, new configuration syntaxes, and such as trivial. This is open source. Each developer should make up his or her mind based not on anyone's pronouncement but rather on a careful consideration of technical tradeoffs, which we have argued amply at this point.

> Inventing new standards and conventions that are contrary to the currently
> established principles and to what other Python developers do is really
> counter-productive and a big step backwards.

One word: buildout.

> We have been there before with Products/* and flat namespace of PloneFooBar
> and PloneBarFoo. This is harder to manage and less condusive to splitting out
> things into smaller and more re-usable packages. I agree that namespaces by
> themselves don't enable this, but psychologically, they seem to have done so.

Neither of us has any hard data on this, but my guess would be that it's the possibility of using normal Python packages as Plone plugins that's done it.

> Let me put it differently: if you could avoid the boilerplate inside eggs
> (the namespace folder and the namespace/__init__.py module), would you get
> back in your box?

Sure. As I've said countless times by now, it's the comprehension cost and extra steps during routine tasks that are bad. Abstractly, hierarchies of names are fine.

> If so, the costs of what you're proposing in terms of consistency, our
> ability to manage a large and complex ecosystem of packages, our ability to
> introspect our package namespaces (as we do to enable z3c.autoinclude to work,
> for example), predictability of our conventions viz-a-viz other projects, and
> import aesthetics far outweigh the benefit, especially when the resolution is
> so simple:

Your claim of consistency is a false premise. Name two other projects that use namespace packages as Plone does. AFAIK, Plone's use of them is uniquely weird. As the docs say, their intended use was breaking up large legacy projects (http://peak.telecommunity.com/[…]/setuptools#namespace-packages).

Second, while a "large and complex ecosystem of packages" may be fun for you, it is a net harm to Plone integrators and developers. I say our goal should be a *simple and predictable combination of packages*. Python package QA is just not at a level where we can trust buildout (let alone something with a more capable dependency resolution algorithm) to assemble a working set of software. This is clear from the profusion of version-dumping recipes and tutorials. You yourself have shown this true with your invention of GoodPy and your recent articles for dealing with the mess this philosophy makes (http://www.martinaspeli.net[…]nown-good-versions-manager, http://www.martinaspeli.net/articles/scrambled-eggs). I would like to see Plone distributed as a batteries-included tarred-up set of packages again. Then we could stop spending half our time on IRC helping people recover from a misbehaving build system 95% of them shouldn't need. Once we have a better QA story, then and only then should we reconsider automated dependency resolution as a solution for the 95%.

NameSpace

Posted by Anonymous User at Jun 28, 2009 10:51 PM
There is only one namespace of which to be concerned, and that is mine, but only if you are in my namespace.
VGhost
Need help now?

Immediate assistance is available during university work hours:

News & views…
Posted Oct 13, 2009 Portlets gone wild with ContentWellPortlets 2.0.1 This new release adds the ability to add portlets to the footer area. It also has 6 portlet managers per area. This means 20 total portlet managers including the 2 on the sides that ship with plone.
Posted Sep 17, 2009 Plone 4 – An interview with Zope News Jan Ulrich Hasecke interviews me for Zope News.
Posted Aug 31, 2009 Web Services API for Plone Alpha 3 Release Details the release of the wsapi4plone.core package and the plans for future releases. The final report of the AtomPub for Plone Google Summer of Code project.
Posted Aug 28, 2009 Content editing and creation in Plone is faster with archetypes.schematuning Some bench marks of content editing and creation in Plone with and without archetypes.schematuning installed.
More news & views…