[Cubicweb] Making changes to cubes

aurélien campéas aurelien.campeas at gmail.com
Sat Dec 11 21:28:18 CET 2010


2010/12/11 Fletcher, John P <j.p.fletcher at aston.ac.uk>

> I am working in user mode and modifying the schema.py file of a cube
> as suggested in the documentation. e.g.
> http://docs.cubicweb.org/tutorials/base/components.html
> What is not working is that the new version is not being picked up.
>
> Example, I have modified schema.py for person to add the additional option
> of Dr as a title.
>
>    civility  = String(required=True, internationalizable=True,
>                       vocabulary=(_('Mr'), _('Ms'), _('Mrs'),_('Dr')),
>                       default='Mr')
> What do I have to do to get that used?  I have tried stopping, upgrading
> and restarting.
> It has not changed.
>

Yes. Modifying schema.py on disk does not entail an automatic update of some
running instance.

To update a vocabulary (any constraint actually) you must issue a
"sync_schema_props_perms" per instance.

You can immediately drop into a shell and apply it::

 # cubicweb-ctl shell myappinstance
 >>> sync_schema_props_perms('civility')
 >>>

Or :

* create a migration file in myapp/migration/0.5.2_Any.py (makes sense if
current version number is 0.5.1) containing the above call
* bump the version number attribute of the __pkginfo__.py module in the
myapp toplevel
* run::

 # cubicweb-ctl upgrade myappinstance




> Is it still using the copy in /usr/shared/cubicweb/cubes?
>
> I have also tried to modify folder as indicated here:
> http://pypi.python.org/pypi/cubicweb-folder/1.8.0
> by adding this code to the schema.py of folder.
>
> class missing_filed_under(RelationDefinition):
>      name = 'filed_under'
>      subject = ('Card', 'File')
>      object = 'Folder'
> I want to be able to put either a file or a card into a folder.
> I have not had any luck with that either.
>

the following migration instruction must be issued (using either of the
aforementioned methods):

add_relation_definition('Card', 'filed_under', 'Folder')

Note that for real development, you certainly want to do this in you own
cubes ...


>
> I am clearly missing something.
>

see: http://docs.cubicweb.org/devrepo/migration.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20101211/91c96e0d/attachment-0001.htm>


More information about the Cubicweb mailing list