Changing custom Archetype from Python Script

classic Classic list List threaded Threaded
2 messages Options
Diego Municio Diego Municio
Reply | Threaded
Open this post in threaded view
|

Changing custom Archetype from Python Script

I have created an Archetype called Course which Schema is:

schema = BaseSchema + Schema ((
    StringField('type',
                vocabulary=COURSE_TYPE,
                widget=SelectionWidget(),
                ),

),

now I want to create and modify programatically a Course object with a
Python Script:

#  create a new course object  -> it works
parent.invokeFactory(id='index_html', type_name='Course')
# get course instance
course = getattr(newFolder,'index_html')
# modify course object   -> it only modifies title
course.plone_utils.contentEdit(course,
                   id='index_html',
                   title='Pagina web',
                   type='troncal')

I don't know how can I modify type field in my new archetype object...
Do I have to define a method in the class definition? Is it generated
automatically by Archetypes?
I have seen something like edit() and atct_edit(), but couldn't use
them successfully..

Thanks


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
J Cameron Cooper-3 J Cameron Cooper-3
Reply | Threaded
Open this post in threaded view
|

Re: Changing custom Archetype from Python Script

Diego Municio wrote:

> I have created an Archetype called Course which Schema is:
>
> schema = BaseSchema + Schema ((
>     StringField('type',
>                 vocabulary=COURSE_TYPE,
>                 widget=SelectionWidget(),
>                 ),
>
> ),
>
> now I want to create and modify programatically a Course object with a
> Python Script:
>
> #  create a new course object  -> it works
> parent.invokeFactory(id='index_html', type_name='Course')
> # get course instance
> course = getattr(newFolder,'index_html')
> # modify course object   -> it only modifies title
> course.plone_utils.contentEdit(course,
>                    id='index_html',
>                    title='Pagina web',
>                    type='troncal')
>
> I don't know how can I modify type field in my new archetype object...
> Do I have to define a method in the class definition? Is it generated
> automatically by Archetypes?
> I have seen something like edit() and atct_edit(), but couldn't use
> them successfully..

You are writing Archetypes and do not how how it generates accessors and
mutators for you?

http://plone.org/documentation/archetypes/quickref#id4

                --jcc

--
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users