+##
+# Is created with options from the request
+#
+# Implementations set result
+class Operation
+    constructor: (opts) ->
+        @opts = opts
+
+    run: (cb) ->
+        model.transaction (err, t) ->
+            if err
+                return req.callback err
+
+            @transaction t, (err) ->
+                if err
+                    t.rollback ->
+                        cb err
+                else
+                    t.commit ->
+                        cb
+
+    transaction: (t, cb) ->
+        # Must be implemented by subclass
+        cb null
+
+class PrivilegedOperation extends Operation
+
+    transaction: (t, cb) ->
+        # Check privileges
+
 defaultConfig = (req) ->
   owner = req.from
   a = owner.split(":")
   owner = a[a.length - 1].split("@")[0]
-  
+
     title: owner + "'s node"
     description: "Where " + owner + " publishes things"
     type: "http://www.w3.org/2005/Atom"

      else
        debug "transaction commit"
        t.commit this
    
    if operation.afterTransaction
      steps.push (err) ->
        if err

          this()
        else
          this new errors.Forbidden(operation.requiredAffiliation + " required")

    steps.push (err) ->
      if err
        throw err
