Category: Open Source

Kids these days: Learning to code then and now

300px-Epson-hx-20This little beauty is an Epson HX-20. It’s one of the first laptop computers. What makes it special to me is that its 4 line LCD screen is where I took my first coding steps in the early 1980’s.

My Dad was an IT guy. He’d bring home the Epson so he could work remotely. I’d been to his office before and had spent hours playing hide-and-seek in the data center with my sister or hucking write protect rings from mag tapes across the room like frisbees. To this day a raised floor and the smell of chilled, vaguely plastic, air brings back fond memories. But what he did all day at work was completely abstract to me until he brought that little Epson home.

Learning those first few lines of BASIC removed a lot of the mystery about how computers worked. It was clear I could tell the computer to do anything I wanted and it would follow those instructions to the letter. I quickly caught the bug and eventually got my own computer (We were a staunch Atari family–sorry Commodore fans!).

Fast forward 30 years…

Now I work in software and my own son is learning to code. When he was 12 or so he was running Linux on his laptop. Then he became interested in coding so I taught him Python. He has since picked up JavaScript, some HTML/CSS, and is now learning Java in high school.

When I think about his experience learning to code compared to mine, there are some similarities:

  • Exposure. He has access to various devices (laptops, PCs, Macs, tablets) and operating systems at home and at school.
  • Curiosity. More than using these devices for entertainment, he’s curious about how they work. I see plenty of kids with their faces buried in a tablet for hours on end. But if they don’t care to know how those apps or that game or that web site came to be they may not be ready to dive into coding.
  • Encouragement. What’s great is that not only does he have his Dad and Grandpa encouraging him to dive in, he’s got lots of teachers who understand the importance of code. (More on the curriculum in a minute).

So those are the ingredients that were the same for both of us. What’s different for this generation of kids learning to code? A lot, and it’s not just about ever-increasing computing power at lower and lower prices.

There are a ton of great resources kids have to help them learn to code these days. Let me call out some of them. I’ll put them in three buckets: Tools, Curriculum, and Communities.

Tools

When I learned to code the tools were virtually non-existent. I had a computer, the BASIC programming language, and a reference manual. Now there are all kinds of freely-available, cross-platform tools that are great for teaching kids to code. Here are a few.

For many kids, Lego Mindstorms is a great entry point into coding. This is coding that feels like play. Mindstorms comes with a drag-and-drop programming app that you use to build apps as if you were assembling building blocks. The app is then downloaded to the robot and boom–the kid sees their own creation obeying their commands.

If you don’t like the drag-and-drop IDE there are several traditional coding environments for a variety of languages that work with Mindstorms.

Scratch was the first coding tool my son was exposed to in school. Hosted at MIT, Scratch was purpose-built for teaching kids to code. Its graphical interface is similar to Mindstorms in some respects.

One of the things I love about Scratch is that kids can share their projects and use the projects of others as a starting point for their own creations. It’s never too early to start teaching kids about open source-style collaboration!

Alice is a story-telling tool. Kids manipulate 3D objects on a canvas. By giving instructions to the objects in the virtual world, kids learn the basics of object oriented programming.

Jeroo is another tool that teaches kids programming by manipulating objects in a virtual world. In this one you have an island. On the island are these mammals–Jeroos–who like to eat flowers. Coding lessons involve instantiating instances of Jeroos and getting them to eat instances of flowers.

Whereas Scratch, Alice, and Jeroo are similar to multiple object-oriented langauges, Greenfoot is about teaching kids a specific language: Java. Working in Greenfoot students write standard Java to build all kinds of programs. It’s a nice tool for learning Java before moving into a full-fledged IDE.

The RaspberryPi is a tiny computer and a code-learning tool all wrapped into one for $25 – $35. About the size of a credit card, you plug this little guy into a keyboard, mouse, and monitor and you’ve got yourself a Linux box with 512 MB of RAM that’s ready for code. Python, Java, C, C++, Ruby, Scratch are all installed by default.

Curriculum

I grew up in a small rural town. In the mid-80’s, my high school computer science curriculum consisted of a year of typing (on these things called typewriters) and a year of programming. The programming class was divided into a semester of typing and 10-keying (this time, on a computer) and a semester of BASIC.

In our school system programming starts fairly early in 7th grade using tools that don’t really feel like coding and then is offered every year, gradually getting more complex throughout high school.

Here is the curriculum by grade. I’ll include rough age equivalents so my readers outside the U.S. can map it to their grade levels:

  • 7th Grade (~13 years old): Technology, Tools: HTML, Scratch, Alice
  • 8th Grade (~14 years old): Principles of Communication in Business & Technology, Tools: HTML, Scratch, Alice
  • 8th Grade (~14 years old): Engineering, Tools: Google Sketch-Up, Lego MindStorms, Vex Robotics
  • 9th Grade (~15 years old): Pre-AP Computer Science, Tools: Scratch, Alice, Jeroo, Greenfoot (Java)
  • 10th Grade (~16 years old): AP Computer Science, Tools: Eclipse (Java)

Unfortunately, that’s it. Nothing is offered beyond AP Computer Science.

Community

When I was a kid there was no Internet, CompuServe was out of my financial reach, and Bulletin Board Systems were just taking off. That meant learning to code (especially in a small town) was largely a solitary pursuit.

With ubiquitous network connectivity, today’s kids have instant access to a globally connected community of learning resources, mentors, and others who are also learning to code. Here are a few examples of resources and communities my son has found helpful:

  • Codecademy is a community of educators and students. There are courses on Python, JavaScript, Ruby, HTML, and others, all available for free.
  • Khan Academy is another free learning community that offers computer programming.
  • Once kids know a little bit about programming, if they are interested in learning Python, my son found Google’s Python Class very useful.

The Role of Open Source in Teaching Kids to Code

Open source software plays a huge role in teaching kids to code. All of the tools I’ve mentioned in this blog post are open source and freely-available. But, more importantly, kids can dig into the hundreds of thousands of open source projects that are out there to see how they work and, eventually, to participate in those projects by writing documentation, helping with QA, and coding bug fixes. Open source doesn’t care how old you are. Mozilla, in particular, has been a wonderful and supportive project that my son has been participating in.

One of the ways high school students can get introduced to open source is through the Google Code-In. Each Fall various open source projects create a bunch of tasks they need done. Students participating in the Code-In work on these tasks. Tasks might be things like writing documentation, creating unit tests, working on a web site, you name it.

At the end of the Code-In, the open source projects select the students who made the most and best contributions and those students (and a parent) are flown to San Francisco for a tour of the Googleplex.

Encourage Your Kid and/or Somebody Else’s Kid

Today kids are exposed to computing nearly all day, every day. A small percentage of them will be curious enough to want to learn how it works. You can use some of the tools and resources I’ve listed here to encourage them to dive in and you can get them plugged in to open source and code-learning communities on the Internet so they can dig deeper on their own.

The hardware, software, and network have changed a lot since I was a kid, but one thing hasn’t changed: A wonderful world of discovery and opportunity awaits for young coders.

This week, December 9 – December 15, is Computer Science Education Week. They are encouraging people to spend an hour teaching someone to code. They’ve got tutorials ready to go. All they need is your time!

What tools, resources, or communities has your kids leveraged as they’ve learned to code? How does your local high school’s computer science curriculum differ from this one? Let me know!

5 drivers of your decision to pay for commercial support

DISCLOSURE: I work for a commercial Open Source Software company called Alfresco that earns revenue by selling commercial support for the software we freely distribute under an OSI-approved license.

A recent CMSWire post cited a study commissioned by a proprietary software vendor to show that Open Source Software is of lesser quality than proprietary. The person funding the survey is quoted as saying, “You certainly can’t use Open Source for something that’s the lifeblood of the company.”

I commented to one of my colleagues that it seemed like this guy just stepped out of a time machine from the 90’s and is still spouting anti-Open Source Software FUD that was dispelled years ago. And because the entire planet, except for this one guy, realizes that Open Source Software in fact runs the mission critical operations of many companies of all sizes and, basically, most of the Internet, the cloud, mobile phones, tablets, and countless other electronic devices, I shall not spend any more time on his nonsense here.

What the post did do, however, was to get me thinking about how companies make the decision to pay for commercial support of the Open Source Software they have deployed in their companies.

In talking it over with my colleague, Richard Esplin, we’ve come up with five drivers that companies think through when they decide whether or not to pay for commercial support of the Open Source Software they use. You can think of this like a scorecard. The higher a software packages scores across these dimensions, the more likely it is that the company will pay for support.

First, a couple of assumptions. Let’s assume that a company has the budget to pay for support. Companies and non-profits that don’t, don’t have the luxury of this decision–they make due. And, let’s further assume that commercial support for a given piece of Open Source Software can be obtained within that budget. Not all OSS has a commercial support option, or one that fits within their budget.

Now, the company is left with a decision: Do we pay for support or not?

Richard and I argue that this decision comes down to these five drivers:

Mission criticality

This one is simple: The more mission critical a piece of Open Source Software is to the business, the more it makes sense to pay someone to help keep that software running.

Switching Costs

If something goes wrong with a library I’m using as a developer, I may be able to find a similar library or I’ll just code around it. However, if my Open Source CRM, ERP, or ECM system fails, it is a different story. Those migrations don’t happen overnight. The higher the switching costs, then, the greater the need for someone to be there to help push through any issues that do arise.

Adoption

Are you one of millions of people using a particular piece of Open Source Software or one of ten? One of the benefits of Open Source Software over proprietary software is that “with enough eyes, all bugs are shallow”. If there is a huge population of people using the software, that means it has been used for a variety of use cases on a variety of platforms. The risk of a problem caused by using the software in a new and unique way is lessened. And a thriving community not only helps with finding and fixing bugs, it can also make it easier and cheaper to get trained up and to get ideas around approaches or to discover new use cases by engaging with that community.

If, however, the Open Source Software is narrowly-adopted, a lot of the benefit of the network effect is lessened. In that case, rather than crowd sourcing support, a company pays someone to do it.

Complexity

Open Source Software runs the gamut of complexity, from relatively simple libraries and small web applications to operating systems and databases and entire software suites. A company’s willingness to pay for support for software comprised of a few thousand lines of code that performs a small number of functions is going to be vastly different than that of a package comprised of millions of lines of code with hundreds of moving parts. Also consider some Open Source Software projects that are built on top of multiple layers of more foundational components, which are also Open Source.

The more complicated the stack (large code base, lots of moving parts, lots of layers and dependencies), the more it makes sense to pay a single vendor with deep expertise in the entire stack.

Cost of Self-Support

The final driver is the cost of supporting the software internally. In this case, I mean “cost” in the economic sense of the word, to be inclusive of the real dollars it costs to hire, train, and employ people with expertise in that software but also in terms of the opportunity cost experienced when a company spends their own fiscal and human resources on supporting the software instead of on other things. For a huge company with a deep bench of under-utilized people with technical skills in a certain area, for example, the cost of self-support may be relatively cheap. Companies where that is not the case are more willing to pay someone else to support the software because it is extremely costly for them to do it on their own.

Weigh Each Driver to Make a Decision

You can see how a strong score in one of these areas might offset a weaker score in others. For example, maybe you are using an Open Source Software package that is widely Adopted and has low Switching Costs but is of relatively high Complexity. Even if the Cost of Self-Support is high relative to what commercial support would cost, you might still not pay for support because you judge that the benefits of wide Adoption and low Switching Costs outweigh everything else.

Mission Criticality has the potential to trump the other drivers, though. A company whose existence depends on a piece of software that is completely unsupported appears wreckless, despite how low the actual risks may be when a package scores low on the other dimensions. Commercial support works like an insurance policy in this case.

All software breaks. Companies have to decide how they will deal with that when it happens. Companies may weight each of these drivers differently, but I think these five drivers are a good model of the decision at hand. And isn’t that the cool thing about Open Source Software? A company gets to make their own decision whether or not they want to pay for commercial support and from whom they want to buy it. I think that’s pretty awesome.

Will Abson’s Wonderful World of Dashlets

Back when Alfresco first launched Surf, the framework on which Alfresco Share is based, a handful of us went to Chicago to hang out in a conference room on a ship in the harbor where we did a deep dive on the framework and then came up with proposed add-ons that would leverage it. I was at Optaros at the time. Our add-on was the Alfresco Share microblogging component and we also did some Surf Code Camps. The goal, of course, was to get the word out about Surf and encourage others to develop and contribute Share customizations.

The deep dive was great and the code camps that followed were valuable and well-attended. What I think the approach missed was that you don’t need to be a Surf expert to code some simple dashlets. We were handing out “How to Fly the Space Shuttle” when we probably should have started with “Building and Launching Your First Model Rocket”.

That’s why Will Abson is my current Alfresco community hero. At this year’s Alfresco Kickoff meeting in Orlando (notes), Will showed a project he and a few others have been working on called Share Extras. Share Extras is a collection of small projects ranging from “Hello World” dashlets to custom theme, data lists, and document action examples.

For example, the list of what I’d call simple, mash-up examples includes things like:

  • Twitter Feed Dashlet – Shows a specific Twitter user’s feed.
  • Twitter Search Dashlet – Shows a Twitter feed based on a hashtag.
  • BBC Weather Dashlet – Shows weather feed from BBC.
  • Flickr Dashlets – Shows flickr photos in a slideshow.
  • Google Site News – Shows the last ten blog posts from Google News.
  • iCal Feed – Shows entries from an iCal feed.
  • Notice Dashlet – Stores/shows arbitrary text, like what you’d use for a maintenance message or an announcement.
  • Train times – Shows the National Rail train schedule.

From there, you can move on to more extensive examples. For example, rather than simply displaying data from public services, these examples start to store/retrieve data in the underlying Alfresco repository:

  • Site Tags Dashlet – Displays a tag cloud consisting of tags used in your site.
  • Site Poll Dashlet – Uses a custom data list type called Poll to configure a simple poll. Shows results in bar chart.
  • Document Geographic Details – Adds a map using the document’s geocoding metadata just below the permissions section.
  • Sample Data Lists – A simple data list example that lets you capture info on Books (author, title, ISBN).
  • Execute Script Custom Document Action – Shows an example of adding a custom action to the action list that runs server-side JavaScript against a node.

The nice thing is that (almost) every one of these extensions deploys as a self-contained JAR file. Will’s build assumes you are running the repository and the Share web apps in the same container, so it deploys the JAR to $TOMCAT_HOME/shared/classes/lib, but you can obviously tweak that if your config is different. The ability to run everything out of a JAR, including what would normally be file system based resources like CSS, client-side JavaScript, and images is a relatively new feature (3.3, I think). It’s much nicer than fooling with AMPs.

Here is a list of my five favorites from the collection:

  • Node Browser – A port of the Explorer client’s node browser to the Share UI. I like this one because it brings an extremely useful developer tool into Share, which is where most of us are spending time these days. It also shows how you can plug your own tools into Share’s admin console.
  • Red Theme – A simple custom theme example. This is on my favorites list because creating a custom theme is something that is requested often and should be easy to do. Follow this example to create your own.
  • Site Geotagged Content Dashlet – Adds a dashlet that shows a map of geotagged content contained in the document library. I can’t help it. I like maps.
  • Site Blog Dashlet – Dashlet that shows site blog posts. This is a favorite because it plugs a hole in the product. If you’re going to use the blog tool in a Share site, you’re going to want to show those posts somewhere and a dashlet makes a lot of sense.
  • Wiki Rich Content – Automatically puts a table of contents at the top of a wiki page based on the headings contained within the page. Also does a nice job with pre-formatted text. This is another example of a feature that should probably be in the core product.

The Google Code project includes screenshots for each of these projects, but it is really easy to do a checkout on the code, import the projects into Eclipse, create a build.properties file in your home directory to override the tomcat.home prop, then run “ant hotcopy-tomcat-jar” to deploy one and see it in action for yourself. I tried them all out on Alfresco 3.4d Community and they worked great. I think all but one or two will work on 3.3.

The Share Extras project includes a Sample Project with a folder structure and Ant build that you can clone and use as a starting point for your own development. If you create something cool, you should share it on Google Code and then let me know about it. Or give it to Will and he can add it to his ever-growing pile of cool Share add-on examples.

Now available: Alfresco Fivestar Ratings add-on for Alfresco Share

A couple of weeks ago I posted a survey asking if anyone saw any value in a five star ratings widget for Alfresco Share. Honestly, it would have only taken one or two positive responses–even if no one needed one, there’s value in it for example’s sake. It turns out about 20 readers of this blog voted positively, so I went ahead and knocked it out.

This Alfresco Share customization makes it possible for any document in the repository to become “rateable”. When a document is rateable, the Alfresco Share user interface will show a clickable five star ratings widget. The stars light up to indicate the average rating for that document. Users simply click one of the stars to post their own rating. When clicked, the widget refreshes itself with the updated average.

Here is a short screencast that demonstrates the customization. You’ll want to make it full screen.

To implement this, I took the Someco Ratings Service from the Alfresco Developer Guide, moved it to the Metaversant namespace, and changed the names of my Spring beans and JavaScript root variable. Even though my initial target Alfresco version is 3.3, I didn’t want the code to conflict with Alfresco’s new back-end-only ratings service in 3.4 which uses some of the same names that were in the book. I also changed the JSON that the ratings web scripts use to be closer to what exists in 3.4. That way, when I do make a version that works with 3.4, it could potentially work with either my ratings back-end or Alfresco’s.

I then went to work on the UI side, integrating the widget into Share’s document details page, document library (both Share and repository views), search results page, and document-related dashlets. To go from what was in the book to a working integration I revamped the client-side ratings JavaScript from a set of functions to an actual object. Then, I started injecting my own methods into Alfresco’s client-side object prototypes to drop my widget in where appropriate.

Alfresco is still working to make customizations like this more modular and easier to plug in alongside their code and code from the community. Until then, be aware that if your Alfresco implementation already has customizations that override some of the same web scripts and client-side components this module does, there may be some manual integration needed. If you have an out-of-the-box installation (or a set of customizations that won’t conflict with this one) you can deploy the AMP to the Alfresco WAR and the Share customizations to the Share WAR and you’ll be set.

The Alfresco Fivestar Ratings project lives at Google Code. Feel free to check out the source, try it out, and use it on your projects. If you find a bug, log it, then fix it!

Apache Chemistry cmislib 0.4 incubating now available

Apache Chemistry LogoThe Apache Chemistry development team is pleased to announce that the 0.4 incubating release of cmislib, the Python client API for CMIS, is now available for download. You may have to use one of the backup servers until the mirrors fully update. Alternatively, you can use easy_install to install cmislib by typing “easy_install cmislib”.

This release has various fixes and enhancements that the community has contributed since cmislib joined the Apache Chemistry project with its 0.3 release. If you are using Alfresco, you might be interested in an enhancement in cmislib 0.4 that makes it possible to use ticket-based authentication instead of basic auth.

For those who haven’t used it, cmislib makes it easy to work with CMIS-compliant repositories from Python.

Introducing the Alfresco Community Committer Program

It’s been a little over two years since I wrote a blog post entitled, “Is Alfresco the ‘near beer’ of open source?“. In that post, I lamented the fact that the Alfresco code line is entirely closed to community developers and that Alfresco seems unwilling to relinquish any amount of control over the development of their open source product. Writing that post had me a bit riled up so during the Q&A session at the community meetup in San Jose later that week, I asked John Newton, Alfresco CTO, and former Alfrescan, Kevin Cochrane when and if it would ever be different. They said they were “working on it” (See Alfresco pledges to open community by 3.0).

I’m glad to say that, although it took a while, there is now a process by which your code can find its way into the Alfresco code base (Community, and even, potentially, Enterprise). It’s called the Alfresco Community Committer Program (ACCP). The ACCP is a motley crew of volunteers from Alfresco customers and partners around the world. Although not a requirement for membership, I think most of us have developed at least one open source add-on for Alfresco. Our goal is to help community-developed code find its way into the product. Does this mean Alfresco is now as open as “true” open source community projects like Apache and Drupal? No, and honestly, I’m not sure it will ever get there. But Alfresco’s support of the ACCP process is a start. Here’s how the process works.

First step: Nomination to the ACCP Incubator

Today, developers in the community create add-ons, utilities, extensions, language packs and all kinds of software built to work with Alfresco. Some of these might make great additions to the Alfresco product. At a high-level, what the ACCP seeks to do is to act as an on-ramp or incubator for that subset of projects. We want you, real world Alfresco developers and end-users, to nominate community-developed extensions that you find useful and that you would eventually like to see as part of the Alfresco product. The ACCP then reviews these nominations and votes for their inclusion into the incubator. The project’s developers can then decide to leave their code where it is (Google Code, Sourceforge, Alfresco forge, etc.) or they may choose to migrate to the Alfresco-hosted ACCP incubator subversion repository.

Projects accepted to the incubator so far include:

As a side note, it’s great that there are so many community-developed add-ons for Alfresco. But the lack of a central index makes it hard to see what’s available. As a related effort, Nancy Garrity is working on something that would provide a central index, support ratings, etc.

Second step: Community code line

Once a project has been in the incubator for a while, the ACCP may recommend its inclusion as part of Alfresco Community making it much easier for Alfresco Community users to leverage these add-ons. The exact nature of how these will be made available is still being worked out. You could imagine a “community-extensions” directory under the Alfresco Community subversion root or something similar. For certain types of contributions, maybe the installer could even provide an optional “install community extensions” step. Again, although we have recently voted some projects into the ACCP incubator, none have yet to reach Community so the details of exactly how those will be incorporated into the Community code base are still being worked out.

Third step: Enterprise code line

The ACCP may then recommend Enterprise adoption. This step is subject to Alfresco Engineering approval, which may be a significant hurdle for some, but if it happens, the entire Alfresco customer base gets the benefit of Alfresco’s ongoing support of the community-developed code. Note that the Enterprise approval step is the only one where Alfresco employees have a say about how an ACCP project is handled–per our charter, Alfresco employees cannot be voting members of the committee.

How you can get involved

First, and foremost, you can nominate an open source Alfresco add-on/extension/customization project. If you want to take an active role on the committee or know someone who would be a good addition, there are spots available. So, another way to help out would be to serve on the committee or nominate someone who should. The committee meets regularly to review and vote on project and committee member nominations. All you have to do is get in touch with me or one of the other regular members of the committee. You’ll find the list on the Alfresco Community Contributor Program wiki page.

We’ll be doing a webinar on July 27th to talk about this more and answer questions. Check out the Alfresco events page to register.

Updated Python CMIS library released

I’ve tagged and released a new version of cmislib, the Python CMIS client library. What’s cool about this release is that it is the first one known to work with more than one CMIS provider. Yea for interoperability! The beauty of CMIS, realized! Okay, it wasn’t that beautiful, it’s still “0.1”, and there are known issues. But I can now say the library works with both Alfresco and IBM FileNet and that’s a Good Thing.

IBM was a big help with this. Al Brown, one of the CMIS spec leads turned one of his colleagues, Jay Brown, onto cmislib. Jay called me up and asked, “If I give you access to a FileNet P8 server, can you test cmislib against it?” I was on it faster than you could say, “unittest.main()”.

I think the effort was valuable for all sides. Our little “mini plugfest” turned up issues in my client as well as both CMIS providers. Jay worked hard to chase down everything on the FileNet side. Dave Caruana chased a few down on the Alfresco side as well. Thanks to everyone for the team effort.

Anyway, give the new cmislib release a try and give me your feedback. If you want a feel for how easy it can be to work with CMIS repositories using the cmislib API, check out the documentation or dive right in. Installation is as easy as “easy_install cmislib” (easy_install instructions).

Next up is Nuxeo. Can the open source ECM vendor achieve cmislib Unit Test Greatness faster than Big Blue? We shall see!

Alfresco Share Status microblog component now supports 3.2 Enterprise

I’ve posted a new release of the Alfresco Share Status microblog component (original post). There are no new features–it’s just a few bug fixes. But one of the bugs was keeping it from working on 3.2 Enterprise. That’s now fixed, so if you’ve upgraded to Alfresco 3.2 Enterprise and you want to use this component in your Share sites, have at it.

Although I’ve tagged both the repository extensions and the surf extensions as “0.2”, only the surf extensions have changed since the last release. If you want to know specifically what’s changed, refer to the Release Notes.

cmislib: A CMIS client library for Python

I’ve started a new project on Google Code called cmislib. It is an interoperable client library for CMIS in Python that uses the Restful AtomPub Binding of a CMIS provider to perform CRUD and query functions on the repository.

I created it for a couple of reasons. First, it’s been bugging me that, unlike our Drupal Alfresco integration, our Django Alfresco integration does not use CMIS. After talking it over with one of our clients we decided it would make more sense to create a more general purpose CMIS API for Python that Django (and any other Python app) could leverage, rather than build CMIS support directly into the Django Alfresco integration.

Second, around the time I was putting together the Getting Started with CMIS tutorial, it struck me that there needed to be an API that didn’t have a lot of dependencies and was very easy to use. Otherwise, it’s too easy to get lost in the weeds and miss the whole point of CMIS: Easily working with rich content repositories, regardless of the underlying implementation.

Even if you’ve never worked with Python before, it is super easy to get started with cmislib. The install is less than 3 steps and the API should feel very natural to anyone that’s worked with a content repository before. Check it out.

Install

  1. If you don’t have Python installed already, do so. I’ve only tested on Python 2.6 so unless you’re looking to help test, stick with that.
  2. If you don’t have setuptools installed already, do so. It’s a nice tool to use for installing Python packages.
  3. Once setuptools is installed, type easy_install cmislib

That’s all there is to it. Now you’re ready to connect to your favorite CMIS-compliant repository.

Examples

There’s nothing in cmislib that is specific to any particular vendor. Once you give it your CMIS provider’s service URL and some credentials, it figures out where to go from there. But I haven’t tested with anything other than Alfresco yet, and this thing is still hot out of the oven. If you want to help test it against other CMIS 1.0cd04 repositories I’d love the help.

Anyway, let’s look at some examples using Alfresco’s public CMIS repository.

  1. From the command-line, start the Python shell by typing python then hit enter.
  2. Python 2.6.3 (r263:75183, Oct 22 2009, 20:01:16)
    GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
  3. Import the CmisClient and Repository classes:
  4. >>> from cmislib.model import CmisClient, Repository
  5. Point the CmisClient at the repository’s service URL
  6. >>> client = CmisClient('http://cmis.alfresco.com/s/cmis', 'admin', 'admin')
  7. Get the default repository for the service
  8. >>> repo = client.getDefaultRepository()
    >>> repo.getRepositoryId()
    u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
  9. Get the repository’s properties. This for-loop spits out everything cmislib knows about the repo.
  10. >>> repo.getRepositoryName()
        u'Main Repository'
    >>> info = repo.getRepositoryInfo()
    >>> for k,v in info.items():
        ...     print "%s:%s" % (k,v)
        ...
        cmisSpecificationTitle:Version 1.0 Committee Draft 04
        cmisVersionSupported:1.0
        repositoryDescription:None
        productVersion:3.2.0 (r2 2440)
        rootFolderId:workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348
        repositoryId:83beb297-a6fa-4ac5-844b-98c871c0eea9
        repositoryName:Main Repository
        vendorName:Alfresco
        productName:Alfresco Repository (Community)

Once you’ve got the Repository object you can start working with folders.

  1. Create a new folder in the root. You should name yours something unique.
  2. >>> root = repo.getRootFolder()
    >>> someFolder = root.createFolder('someFolder')
    >>> someFolder.getObjectId()
    u'workspace://SpacesStore/91f344ef-84e7-43d8-b379-959c0be7e8fc'
  3. Then, you can create some content:
  4. >>> someFile = open('test.txt', 'r')
    >>> someDoc = someFolder.createDocument('Test Document', contentFile=someFile)
  5. And, if you want, you can dump the properties of the newly-created document (this is a partial list):
  6. >>> props = someDoc.getProperties()
    >>> for k,v in props.items():
    ...     print '%s:%s' % (k,v)
    ...
    cmis:contentStreamMimeType:text/plain
    cmis:creationDate:2009-12-18T10:59:26.667-06:00
    cmis:baseTypeId:cmis:document
    cmis:isLatestMajorVersion:false
    cmis:isImmutable:false
    cmis:isMajorVersion:false
    cmis:objectId:workspace://SpacesStore/2cf36ad5-92b0-4731-94a4-9f3fef25b479
  7. You can also use cmislib to run CMIS queries. Let’s find the doc we just created with a full-text search. (Note that I’m currently seeing a problem with Alfresco in which the CMIS service returns one less result than what’s really there):
  8. >>> results = repo.query("select * from cmis:document where contains('test')")
    >>> for result in results:
    ...     print result.getName()
    ...
    Test Document2
    example test script.js
  9. Alternatively, you can also get objects by their object ID or their path, like this:
  10. >>> someDoc = repo.getObjectByPath('/someFolder/Test Document')
    >>> someDoc.getObjectId()
    u'workspace://SpacesStore/2cf36ad5-92b0-4731-94a4-9f3fef25b479'

Set Python loose on your CMIS repository

These are just a few examples meant to give you a feel for the API. There are several other things you can do with cmislib. The package comes with documentation so look there for more info. If you find any problems and you want to pitch in, you can check out the source from Google Code and create issues there as well.

Give this a try and let me know what you think.

[UPDATE: I had the wrong URL for the Alfresco-hosted CMIS service. It’s fixed now.]

Alfresco Share microblogging component released as open source

Back in February (I know, it’s been simmering on the back burner for too long), I did a couple of screencasts on Optaros Labs showing a demo of Alfresco Share (part 1, part 2). In part 2 of that screencast I showed two custom components: Status and Bookmark. Alfresco made Bookmark obsolete by releasing their own shared bookmarks module for Share, and that’s a Good Thing. I kind of expected them to release a microblog component as well, but they haven’t yet. Well, I finally got around to making ours available, so until a similar feature makes it into the product, feel free to use it in your own projects.

The component is simple: A “My Current Activity” dashlet lets you and your team give a quick blurb about what you’re working on. Another dashlet aggregates all of the status entries from your teammates. A global dashlet aggregates the entries from all Share sites. All status changes automatically show up in Alfresco’s Activity Feed as well.

My Current Activity Dashlet
My Current Activity Dashlet

Unlike Twitter, the status component lets you mark an entry as “done”. When you do that, your current status gets reset and the old entry moves to the archive. So it’s a little more task-oriented than more general purpose, free-form microblogging tools.

Deployment is pretty easy. An AMP gets deployed to your Alfresco WAR, and a ZIP gets unzipped into your Alfresco Share web application. That’s it. No configuration necessary. All of the data lives in the same structure as the other tools in your Share site.

I’ve put the code out on Google Code under a BSD license. There’s a pre-built AMP and a ZIP for download or you can checkout and build from source. There’s one Eclipse project for the repository tier and one for the Surf tier. I’ve tested this on Alfresco 3.2 Community. I’ll test it out on the Enterprise releases when I get a chance. There were some changes in the Activity Feed that I had to deal with and I’m not sure how far back those go so I may have to have version-specific releases.

Have a look and give me your feedback. If you want to dig in and make enhancements, bring ’em on.