web services and context - drupalcon london 2011 update.pdf · the web services and context core...

39

Upload: others

Post on 22-May-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 2: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Web Services and Context

Core Initiative

Presented by Larry Garfield

Core Conversations

Page 3: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

@Crell✤ Senior Architect, Palantir.net

✤ Web Services & Context Initiative Owner

✤ Architectural Gadfly

✤ Nerf Gunslinger

Page 4: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Web Services and ContextCore Initiative (WSCCI)

http://www.flickr.com/photos/spaterson/4995021726/

Page 5: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

"Drupal doesn't have multiple layouts. It has one layout it bends a lot."

--Earl Miles, c.2009

Page 6: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 7: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 8: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 9: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Five Fails

1) No unified context

2) One Layout to Rule them All

3) No plugin mechanism

4) HTML-only

5) Performance

Page 10: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

The Butler Project

"Give Drupal a unified, powerful context system that will support smarter, context-sensitive, easily

cacheable block-centric layouts and non-page responses using a robust unified plugin

mechanism."

Page 11: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

DrupalCon Chicago

Recast as

Web Services and Context Core Initiative

Page 12: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

WSCCI Goals

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class

CMS on top of it.

To do that, we must give Drupal a unified, powerful context system that will support smarter, context-

sensitive, easily cacheable block-centric layouts and non-page responses using a robust unified plugin

mechanism.

Page 13: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

1) Unified, powerful context system

2) Unified plugin mechanism

3) Any type of response

4) Smart block-centric layouts

Page 14: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

<Insert lots of discussion here>

Page 15: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

#0HTTP

Page 16: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

HTTP libraries✤ Don't reinvent the wheel.

✤ Tried PECL HTTP... Nyet

✤ 3rd party research

✤ Dave Hall (skwashd)

✤ Dick Olsson (dixon_)

✤ Zend vs. Symfony2: FIGHT!

✤ http://groups.drupal.org/node/167299

Page 17: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 18: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

http://www.flickr.com/photos/andycarvin/1936753622/

Page 19: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Status

Dries OKed this last night at 2 am.

Patch forthcoming...

Page 20: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

#1Context

Page 21: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Mediator Object

The mediator pattern provides a unified interface to a set of interfaces in a subsystem.

--Wikipedia

Page 22: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 23: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Work in progress

http://drupal.org/project/butler

... And core sandbox by the end of the week

Page 24: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

class Foo { protected $context;

public function __construct($context) { $this->context = $context; } public function behave() { $node = $this->context['node']; $var = $this->context['http:get:var']; // ... }}

Page 25: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

function behave() { $context = drupal_get_context(); $language = $context['language']; $foo = $context['http:header:foo'];}

Page 26: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

$butler->registerHandler('http:get', 'CtxHandlerHttp', array('query' => 'GET'));

$butler->registerHandler('http:post', 'CtxHandlerHttp', array('query' => 'POST'));

$butler->registerHandler('http:header','CtxHandlerHeader');

Page 27: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

$new_ctx = $butler->addLayer();

$new_ctx->registerHandler('og', 'AlternateHandler');$new_ctx['og:nid'] = 5; $new_ctx->lock();$plugin = get_plugin('stuff', 'blah', $new_ctx);

Page 28: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Status✤ Nearly ready to try implementing in core

✤ Come to the code sprint Friday and let's see how far we get!

Page 29: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

#2Plugins

Page 30: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

We have too many✤ One-off hacks

✤ Alt. include files

✤ Callback functions

✤ Pseudo-hooks

✤ caching system with OO

✤ Views Plugins/Handlers

✤ Ctools Plugins

✤ Webform components

✤ Etc.

Page 31: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 32: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class
Page 33: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Research✤ http://groups.drupal.org/node/137609

✤ Symfony2

✤ Zend Framework 2

✤ Kohana

✤ ctools.module

✤ No one is as good as we want to be...

Page 34: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Status✤ ctools TNG

✤ All OOP

✤ Two skunkworks implementations

✤ Crell

✤ neclimdul

✤ After context is in core...

Page 35: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

#3REST Routing

Page 36: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

More robust than hook_menu✤ 2 layer routing

✤ Method Path, domain, HTTP content­type

✤ "Other stuff" ­ Implementation TBD

✤ Maps to response object, not dumb function

✤ Any HTTP return (404, 302, etc.)

✤ Any content type, natively (text/html, text/json, application/pdf)

✤ http://groups.drupal.org/node/148149

Page 37: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

#4Smarter block layout

Page 38: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Figure out the UI first...

http://groups.drupal.org/node/137469

Page 39: Web Services and Context - DrupalCon London 2011 Update.pdf · The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class

Next steps...

Code sprint Friday!

Discuss here:

http://groups.drupal.org/wscci

Follow here:

http://drupal.org/node/1233232