[ckan-dev] dataset-id

Toby Dacre toby.okfn at gmail.com
Mon Oct 1 10:52:55 UTC 2012


On 1 October 2012 11:29, Crossbreed <Crossbreed at sms.at> wrote:
> Hi! I would like to copy the value of the ID-field into an other field when
> creating a new dataset. I have an extension which the PackageController
> implements. In this class (method: _save_new) i tried to set the ID to  the
> other field, but the value of the ID seems to be "none". So, how could I set
> the value of the ID-field to an other field, when creating a dataset? -
> Where is the value of the ID-field generated?

the id is generated when the dataset is saved

    pkg_dict = get_action('package_show')(context, data_dict)

get the value later in _save_new()

>  def _save_new(self, context, package_type=None):
> ...
>          data_dict = clean_dict(unflatten(
>                 tuplize_dict(parse_params(request.POST))))
>             data_dict['type'] = package_type
>             context['message'] = data_dict.get('log_message', '')
>             data_dict['testfield'] = data_dict['id']
>             pkg = get_action('package_create')(context, data_dict)
>             self._form_save_redirect(pkg['name'], 'new')
>
> ...
>
> kind regards!
>
>
> ________________________________
> Schau dir gleich die Seite von hsdf an! http://my.sms.at/crossbreed/
> ________________________________
> Dein Eventkalender auf sms.at! Events anlegen, Freunde einladen & kein
> Top-Event mehr verpassen! http://www.sms.at/events/
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>




More information about the ckan-dev mailing list