I can't make "out of the box" version to work. (Views 3, Services 3).
These simple, but hardcode overrides solved the problem:
// services_views.module
function services_views_services_resources() {
$resources['views'] = array();
$resources['views']['retrieve'] = array(
'help' => 'Retrieves a view.',
'file' => array(
'type' => 'inc',
'module' => 'services_views',
'name' => 'services_views.resource',
),
'callback' => 'services_views_retrieve',
'access callback' => 'services_views_access',
'access arguments' => array('view'),
'access arguments append' => TRUE,
'args' => array(
// OVERRIDDEN
// 'view_name' => array(
'0' => array(
'name' => 'view_name',
'type' => 'string',
'description' => 'The name of the view to get.',
'source' => array('path' => '0'),
'optional' => FALSE,
),
// OVERRIDDEN
// 'display_id' => array(
'1' => array(
'name' => 'display_id',
'type' => 'string',
'description' => 'The display ID of the view to get.',
// OVERRIDDEN
// 'source' => array('param' => 'display_id'),
'source' => array('path' => '1'),
'optional' => TRUE,
'default value' => 'default',
),
// OVERRIDDEN
// 'args' => array(
'2' => array(
'name' => 'args',
'type' => 'array',
'description' => 'A list of arguments to pass to the view.',
// OVERRIDDEN
// 'source' => array('param' => 'args'),
'source' => array('path' => '2'),
'optional' => TRUE,
'default value' => array(),
),
// OVERRIDDEN
// 'offset' => array(
'3' => array(
'name' => 'offset',
'type' => 'int',
'description' => 'The number of the entry for the page begin with.',
// OVERRIDDEN
// 'source' => array('param' => 'offset'),
'source' => array('path' => '3'),
'optional' => TRUE,
'default value' => 0,
),
// OVERRIDDEN
// 'limit' => array(
'4' => array(
'name' => 'limit',
'type' => 'int',
'description' => 'The total number of entries to list.',
// OVERRIDDEN
// 'source' => array('param' => 'limit'),
'source' => array('path' => '4'),
'optional' => TRUE,
'default value' => 10,
),
// OVERRIDDEN
// 'theme_output' => array(
'5' => array(
'name' => 'theme_output',
'type' => 'bool',
'description' => 'Whether to return the raw data results or style the results.',
// OVERRIDDEN
// 'source' => array('param' => 'theme_output'),
'source' => array('path' => '5'),
'optional' => TRUE,
'default value' => FALSE,
),
),
);
...and one more "hook":
function services_views_access($op = 'view', $args = array()) {
// OVERRIDDEN
+ $args['view_name'] = $args[0];
+ $args['display_id'] = $args[1];
switch ($op) {
case 'view':
- - -
that's it.
the call looks like this (from other custom module):
$result = ..._call_xmlrplc('views.retrieve', $esid,
$view->name, // view name
$view->current_display, // display name
$view->args, // arguments
$view->get_offset(), // offset
$view->get_items_per_page() // items per page
);
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 0001-XMLRPC-server-compatibility-from-issue-1347312.patch | 3.02 KB | lucascaro |
Comments
Comment #1
stonevo commentedI did this way and built the xmlrpc client to get view information from drupal. But It couldn't be done. Finally I found out that I must clear cache for each changes in services_views module. Hope this will help someone be stucked on the same problem.
Comment #2
jhnphm commentedThe above fixes it on 7.x-1.x-dev too.
Comment #3
ygerasimov commentedI understand the changes here, but can you please advise what is the problem here? How to reproduce?
Comment #4
jhnphm commentedI believe one can reproduce it by trying to use services_views w/ XML-RPC. I'm using Services 7.x-3.x-dev and talking to it via python xmlrpc. It seems the original code breaks positional arguments.
Comment #5
lucascaro commentedI can confirm that the xmlrpc server won't work with a keyed array for args. in particular, line 71 of xmlrpc_server.module checks for:
but $index is 'view_name' (for views.retrieve for example) and args is array(0 => 'parameter').
if you check the other resources defined by services they define the arguments like:
so I'm guessing that adding a named key here is not common practice.
I'm working with the 6.x version. I'll try the proposed changes and report back if it works :)
Comment #6
lucascaro commentedOk, this worked for an xmlrpc server on 6.x-1.x-dev. here's a patch formatted for that branch:
Comment #7
lucascaro commentedComment #8
jhnphm commentedAny progress on applying the various patches?
Comment #9
lucascaro commentedon my end this works and allows us to use services_views both for xmlrpc and rest servers for 6.x