List Info

Thread: bric_soap writer library




bric_soap writer library
user name
2006-09-15 16:44:56
On Sep 15, 2006, at 00:52, Scott Lanning wrote:

> You can do something like this:
>
>   use Bric::SOAP::Writer;
>   use Bric::SOAP::Writer::Story;
>   use Bric::SOAP::Writer::Story::Elements;
>
>   my $writer = Bric::SOAP::Writer->new(file =>
'story.xml',  
> NEWLINES => 1);
>   my $now = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime());
>
>   my $elements =
Bric::SOAP::Writer::Story::Elements->new 
> (start_order => 2);
>   $elements->push_data(header => 'Ipsum
delirium');
>   my $page = $elements->push_container('page');
>   $page->push_data(paragraph => 'Lorem
dolorian');
>   $page->push_data(paragraph => 'Sit amet');

I would recommend calling them push_value() or, better,
push_field(),  
for compatability with the API and naming normalization in
1.10.

>   # most of these have defaults, so are optional
>   my $story = Bric::SOAP::Writer::Story->new(
>       id => '',
>       element => 'story',
>       site => 'Default Site',
>       name => 'some title',
>       description => '',
>       slug => 'foo',
>       primary_uri => '/foo/index.html',
>       priority => '3',
>       publish_status => '0',
>       active => '1',
>       source => 'Internal',
>       cover_date => $now,
>       expire_date => '',
>       publish_date => '',
>       first_publish_date => '',
>       categories => ['/'],
>       output_channels => ['Web'],
>       keywords => [],
>       contributors => [],
>       elements => $elements,
>   );
>   $writer->write($story);
>
> And it will output this (the funny XML output is from
> the NEWLINES => 1 argument to XML::Writer):

Hey, that's really cool! I like it!

> TODO:
>  - usage of `bric_soap element export` output (or
equivalent)
>    to check the <elements> (e.g. to check of a
"page" container
>    can contain "paragraph" elements); usage
of other bric_soap output
>    for other similar functionality

Do you mean you want to get the export of element types to
validate  
that your writer is doing the right thing? That's a good
idea.

>  - tests
>  - add at least Media and Category (ideally all
modules)

Cool, thanks for sharing!

Best,

David

-- 
David Wheeler
President, Kineticode, Inc.
http://www.kineticode.com/

Kineticode. Setting knowledge in motion.[sm]


bric_soap writer library
user name
2006-09-15 16:44:56
On Sep 15, 2006, at 00:52, Scott Lanning wrote:

> You can do something like this:
>
>   use Bric::SOAP::Writer;
>   use Bric::SOAP::Writer::Story;
>   use Bric::SOAP::Writer::Story::Elements;
>
>   my $writer = Bric::SOAP::Writer->new(file =>
'story.xml',  
> NEWLINES => 1);
>   my $now = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime());
>
>   my $elements =
Bric::SOAP::Writer::Story::Elements->new 
> (start_order => 2);
>   $elements->push_data(header => 'Ipsum
delirium');
>   my $page = $elements->push_container('page');
>   $page->push_data(paragraph => 'Lorem
dolorian');
>   $page->push_data(paragraph => 'Sit amet');

I would recommend calling them push_value() or, better,
push_field(),  
for compatability with the API and naming normalization in
1.10.

>   # most of these have defaults, so are optional
>   my $story = Bric::SOAP::Writer::Story->new(
>       id => '',
>       element => 'story',
>       site => 'Default Site',
>       name => 'some title',
>       description => '',
>       slug => 'foo',
>       primary_uri => '/foo/index.html',
>       priority => '3',
>       publish_status => '0',
>       active => '1',
>       source => 'Internal',
>       cover_date => $now,
>       expire_date => '',
>       publish_date => '',
>       first_publish_date => '',
>       categories => ['/'],
>       output_channels => ['Web'],
>       keywords => [],
>       contributors => [],
>       elements => $elements,
>   );
>   $writer->write($story);
>
> And it will output this (the funny XML output is from
> the NEWLINES => 1 argument to XML::Writer):

Hey, that's really cool! I like it!

> TODO:
>  - usage of `bric_soap element export` output (or
equivalent)
>    to check the <elements> (e.g. to check of a
"page" container
>    can contain "paragraph" elements); usage
of other bric_soap output
>    for other similar functionality

Do you mean you want to get the export of element types to
validate  
that your writer is doing the right thing? That's a good
idea.

>  - tests
>  - add at least Media and Category (ideally all
modules)

Cool, thanks for sharing!

Best,

David

-- 
David Wheeler
President, Kineticode, Inc.
http://www.kineticode.com/

Kineticode. Setting knowledge in motion.[sm]


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )