[ckan-dev] Create Package programmatically

Ryan Clark ryan.clark at azgs.az.gov
Fri Mar 8 18:49:06 UTC 2013


This is starting to make sense to me. If I understood Toby correctly, I should

ckan.logic.get_action("package_create")(None, { "package": "data" })

I realize that it'll make up the missing context variable for me, but I'll deal with that later. Now the question is, can I use this approach to attach whatever "extras" I want to the package? For my project its really important that I be able to attach a specific set of "extras". 

Thanks!
____________________

Ryan Clark
ryan.clark at azgs.az.gov
(520) 302-4871






On Mar 8, 2013, at 7:28 AM, Ryan Clark <ryan.clark at azgs.az.gov> wrote:

> I'm building a CSW-based harvesting mechanism. I know there are existing harvesting tools, but they don't quite get to what I need, and my project's deadline means I can't wait...
> 
> The harvesting itself will need to happen at fixed intervals, without user input. When an XML record is received, it will be parsed and a package will be created. After setting up a job, no user input should be required. This is why I say I won't have a "context" when I get to the point of wanting to generate a package. 
> 
> Thanks!
> Ryan
> 
> 
> 
> On Mar 8, 2013, at 6:52 AM, Nigel Babu <nigel.babu at okfn.org> wrote:
> 
>> Hi Ryan,
>> 
>> `ckan.logic.action.package_create` is probably the right way to do it. Can you explain more about there not being an HTTP call associated with your code? You could use the action API via the paster post command, but you'd need to be on the server for that.  Or from Python via the plugins toolkit[1] (again, you have to be on the server).
>> 
>> [1] http://docs.ckan.org/en/latest/toolkit.html
>> 
>> Nigel
>> 
>> 
>> On 7 March 2013 04:21, Ryan Clark <ryan.clark at azgs.az.gov> wrote:
>> I'm trying to generate Packages from ISO 19139 documents. What is the best way to create a new package programmatically? I was thinking that ckan.logic.action.package_create looked like it might be the best place, but I'd rather not have to spoof the context object, since there won't be an HTTP request associated with the code I'm writing. 
>> 
>> Thanks!!
>> ____________________
>> 
>> Ryan Clark
>> ryan.clark at azgs.az.gov
>> (520) 302-4871
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>> 
>> 
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130308/34a6eb3b/attachment-0001.html>


More information about the ckan-dev mailing list