Mailing List Archive

Any success setting events from Perl?
In the archives I found a few questions about creating events from perl,
but no working answer.
I tried with Cal::DAV and with HTTP::DAV directly. I can read an
existing calendar but so far I was not able to write it back.
As a test I used the calendar I could read, only change the description
of an event and try to write it back -- as I said without any success.

The error message when saving with Cal::DAV is "You may not PUT to a
collection URL". Well I used the same URL ('.../testuser1/home') where I
read the calendar from. Is there another one for writing?

I read that it is necessary to properly set the Content-type but neither
in the HTTP::DAV docs nor in the source I found a way how to do this.

Please, if anybody got this working I would be so grateful for some
working code.

-Michael


Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general
Any success setting events from Perl? [ In reply to ]
I had a look at this a few weeks ago and didn't get very far. The problem is
Cal::DAV is very poorly documented so diagnosing at which end the problems are
occurring is very difficult. After spending two days looking at the underlying
Perl libraries I gave up.

Since my calendars are read only sporting fixtures, I was able to sidestep the
problems by creating collections using Perl's Data::ICal, outputting to ics,
then connecting to DAViCal using 'dave', deleting the collection on the
server, and uploading the new calendars. So rather than update, I delete and
create again.

On Monday 09 Aug 2010 11:05:37 Michael Lackhoff wrote:
> In the archives I found a few questions about creating events from perl,
> but no working answer.
> I tried with Cal::DAV and with HTTP::DAV directly. I can read an
> existing calendar but so far I was not able to write it back.
> As a test I used the calendar I could read, only change the description
> of an event and try to write it back -- as I said without any success.
>
> The error message when saving with Cal::DAV is "You may not PUT to a
> collection URL". Well I used the same URL ('.../testuser1/home') where I
> read the calendar from. Is there another one for writing?
>
> I read that it is necessary to properly set the Content-type but neither
> in the HTTP::DAV docs nor in the source I found a way how to do this.
>
> Please, if anybody got this working I would be so grateful for some
> working code.
>
> -Michael
>
> ---------------------------------------------------------------------------
> --- This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> rscds-general mailing list
> rscds-general at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rscds-general
>

--

Friends of Badzilla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.morphoss.com/pipermail/davical-users/attachments/20100809/7c6456c6/attachment.htm>
-------------- next part --------------

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
-------------- next part --------------
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general
Any success setting events from Perl? [ In reply to ]
Thanks Nigel,

> I had a look at this a few weeks ago and didn't get very far. The problem is
> Cal::DAV is very poorly documented so diagnosing at which end the problems are
> occurring is very difficult. After spending two days looking at the underlying
> Perl libraries I gave up.

Cal::DAV is only a very thin wrapper around HTTP::DAV (and Data::ICal)
and I would be happy to do the wrapping myself. For me the problem seems
to be to have HTTP::DAV do exactly what DAViCal is expecting. E.g. I did
not find an easy way yet to add headers to the HTTP::DAV request. The
other side of the problem might be that DAViCal is not very forgiving in
what it accepts (just a first impression).
So I am still hoping that someone has done this already, the only
alternatives seem to be to look at the communication Sunbird (or some
other client) is doing under the hood and try to somehow clone this
behaviour, if necessary by hacking HTTP::DAV.

> Since my calendars are read only sporting fixtures, I was able to sidestep the
> problems by creating collections using Perl's Data::ICal, outputting to ics,
> then connecting to DAViCal using 'dave', deleting the collection on the
> server, and uploading the new calendars. So rather than update, I delete and
> create again.

Unfortunately this is not an option for me, at least for most tasks. But
still I would like to see how dave is doing this, so can you share the
code? I am thankful for everything I can learn about this stuff that is
still very new to me.

-Michael


Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general
Any success setting events from Perl? [ In reply to ]
On Tuesday 10 Aug 2010 07:54:27 Michael Lackhoff wrote:
> Thanks Nigel,
>
> > I had a look at this a few weeks ago and didn't get very far. The problem
> > is Cal::DAV is very poorly documented so diagnosing at which end the
> > problems are occurring is very difficult. After spending two days looking
> > at the underlying Perl libraries I gave up.
>
> Cal::DAV is only a very thin wrapper around HTTP::DAV (and Data::ICal)
> and I would be happy to do the wrapping myself. For me the problem seems
> to be to have HTTP::DAV do exactly what DAViCal is expecting. E.g. I did
> not find an easy way yet to add headers to the HTTP::DAV request. The
> other side of the problem might be that DAViCal is not very forgiving in
> what it accepts (just a first impression).
> So I am still hoping that someone has done this already, the only
> alternatives seem to be to look at the communication Sunbird (or some
> other client) is doing under the hood and try to somehow clone this
> behaviour, if necessary by hacking HTTP::DAV.

Hi Michael

You are retracing my steps exactly. I had a good look at HTTP::DAV and tried
to hack it to send something DAViCal would accept - but no joy. Like you I
then decided to look at the source of a working client to see how it does it -
I chose Chandler instead of Sunbird. But since Chandler is Python, and I have
no experience, unsurprisingly I couldn't understand what was going on and I
gave up after a day.


>
> > Since my calendars are read only sporting fixtures, I was able to
> > sidestep the problems by creating collections using Perl's Data::ICal,
> > outputting to ics, then connecting to DAViCal using 'dave', deleting the
> > collection on the server, and uploading the new calendars. So rather than
> > update, I delete and create again.
>
> Unfortunately this is not an option for me, at least for most tasks. But
> still I would like to see how dave is doing this, so can you share the
> code? I am thankful for everything I can learn about this stuff that is
> still very new to me.

As far as I am aware, 'dave' is a wrapper for HTTP::DAV so the answer is there
somewhere, maybe deconstructing dave would be a good way to go. Happy to show
you my dave script, but I don't think it'll give you much - it is simply a set
of commands to log on to DAViCal, delete what it finds, then push new
calendars instead.

#!/bin/sh


davuser=userid
davpass=password

httppath=http://path_to_davical_server

icspath=/srv/www/htdocs/sync/calendars/individual/sport/football/english/
logpath=logs/football.log



# write date into log so we know where we are
date >> $logpath

# Football Teams
empty -f -L ${logpath} dave -u $davuser -p $davpass ${httppath}
for team in AFCWimbledon Altrincham Barrow BathCity CambridgeUnited
CrawleyTown Darlington EastbourneBorough FleetwoodTown ForestGreenRovers
Gateshead GrimsbyTown Hayes Histon KetteringTown KidderminsterHarriers Luton
MansfieldTown NewportCounty RushdenDiamonds Southport Tamworth Wrexham
YorkCity
do
empty -w "ave> " "delete ${team}.ics\n"
empty -w "ave> " "put `echo ${icspath}``echo $team | tr '[A-Z]' '[a-
z]'`/${team}.ics\n"
done
empty -w "ave> " "quit\n"



Cheers
Nigel







Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general
Any success setting events from Perl? [ In reply to ]
On Tuesday 10 Aug 2010 12:34:47 Michael Lackhoff wrote:
> Hi Nigel,
>
> > You are retracing my steps exactly. I had a good look at HTTP::DAV and
> > tried to hack it to send something DAViCal would accept - but no joy.
> > Like you I then decided to look at the source of a working client to see
> > how it does it - I chose Chandler instead of Sunbird. But since Chandler
> > is Python, and I have no experience, unsurprisingly I couldn't understand
> > what was going on and I gave up after a day.
>
> Not very encouraging, but thanks. If nothing works, I can try to either
> write directly to the database (not very clean but perhaps the most
> effective solution) or try another calendar server. We'll see...

We really are covering the same territory. I was going to write a Perl API to
DAViCal if 'dave' didn't work. The db structure looks quite easy to
understand, and of course the developers are on here to help you :)

If you jump ship, you could look at Chandler server. My biggest beef with it
is it needs a Java platform which equates to more expense when it comes to
remote hosting. Of course if you don't need remote hosting, that expense
disappears. Then there's Google but that has quite a complicated
authentication process if I recall. I seem to remember trying to interface PHP
to it but being forced to use the Zend Framework's authentication classes
which didn't appeal.


>
> > #!/bin/sh
> >
> >
> > davuser=userid
> > davpass=password
> >
> > httppath=http://path_to_davical_server
> >
> > icspath=/srv/www/htdocs/sync/calendars/individual/sport/football/english/
> > logpath=logs/football.log
> >
> >
> >
> > # write date into log so we know where we are
> > date >> $logpath
> >
> > # Football Teams
> > empty -f -L ${logpath} dave -u $davuser -p $davpass ${httppath}
> > for team in AFCWimbledon Altrincham Barrow BathCity CambridgeUnited
> > CrawleyTown Darlington EastbourneBorough FleetwoodTown ForestGreenRovers
> > Gateshead GrimsbyTown Hayes Histon KetteringTown KidderminsterHarriers
> > Luton MansfieldTown NewportCounty RushdenDiamonds Southport Tamworth
> > Wrexham YorkCity
> > do
> > empty -w "ave> " "delete ${team}.ics\n"
> > empty -w "ave> " "put `echo ${icspath}``echo $team | tr '[A-Z]' '[a-
> > z]'`/${team}.ics\n"
> > done
> > empty -w "ave> " "quit\n"
>
> Hm, I don't really understand what is happening there. What would be the
> single line to delete and recreate the calendar respectively?
> Is it (
> dave -u $davuser -p $davpass $httppath delete ${team}.ics
> and
> dave -u $davuser -p $davpass $httppath put $icspath ${team}/${team}.ics
> (provided $team is lowercased before)?
>
> -Michael
>

Yes, I am deleting what already exists. This is because I couldn't get update
to work. My process is this:
1. Screenscrape new football fixtures every week when they change from various
sports websites using Perl and shell scripts;
2. Create new .ics files using Perl
3. Connect to DAViCal using 'dave'. Delete the ics file in a collection, then
upload the new ics file to replace it into the same collection
4. Subscribers will see their schedule of football matches change in their
calendars when they next sync with DAViCal.

Since it is all one-way and publicly read-only I can do this. Works fine.


Cheers
Nigel


Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general
Any success setting events from Perl? [ In reply to ]
On Mon, 2010-08-09 at 12:05 +0200, Michael Lackhoff wrote:
> In the archives I found a few questions about creating events from perl,
> but no working answer.
> I tried with Cal::DAV and with HTTP::DAV directly. I can read an
> existing calendar but so far I was not able to write it back.
> As a test I used the calendar I could read, only change the description
> of an event and try to write it back -- as I said without any success.
>
> The error message when saving with Cal::DAV is "You may not PUT to a
> collection URL". Well I used the same URL ('.../testuser1/home') where I
> read the calendar from. Is there another one for writing?
>
> I read that it is necessary to properly set the Content-type but neither
> in the HTTP::DAV docs nor in the source I found a way how to do this.
>
> Please, if anybody got this working I would be so grateful for some
> working code.

Hi Michael,

DAViCal falls back to providing the whole calendar in response to a GET
request to the calendar URL. It can also replace the whole calendar in
response to a PUT request to that URL, but that's not CalDAV: it's
WebDAV.

For CalDAV each event is a unique resource within the collection, and
will have it's own URL. There are several ways to retrieve the list of
resources within a DAV collection. In basic DAV you can do a PROPFIND
request with Depth: 1 on the collection URL and you will get back an XML
document listing the collection resource and all of the resources within
the collection, along with the properties that you requested as part of
the propfind (usually getetag and getcontenttype or something like
that), so then you have a list of all of the resources in the
collection, their URLs and some other meta-information about them.

In CalDAV there are also REPORT requests that you can make which will
similarly return you the meta-data, and potentially even the actual
calendar data. Given a calendar event resource URL, you can of course
GET directly on that URL to retrieve the individual event data, and
likewise you can PUT to that URL to replace it with modified data.

The error you're getting above is because you're trying to do the whole
of calendar URL as described in paragraph 1, which is disabled by
default in DAViCal as it can cause people to overwrite their entire
calendar with a single event, so people shouldn't do it that way without
knowing what they are doing. Rewriting the entire calendar every time
there is a small change to a single event is also very inefficient.

Cheers,
Andrew.

--
------------------------------------------------------------------------
andrew (AT) morphoss (DOT) com +64(272)DEBIAN
You're a card which will have to be dealt with.
------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.morphoss.com/pipermail/davical-users/attachments/20100813/8e5cfcfc/attachment-0001.pgp>
-------------- next part --------------

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
-------------- next part --------------
_______________________________________________
rscds-general mailing list
rscds-general at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rscds-general