Re: silva-dev Digest, Vol 319, Issue 4

"Hugo Angel" <[email protected]> Tue, 23 Oct 2007 13:12:42 -0500
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
Thanks Marc,

Your hint worked very well for our purposes.

I found this Python Script with content creation at
https://lists.infrae.com/pipermail/silva-general/2006-April/000665.html


#Parameters: id, title

request = context.REQUEST
session = request.SESSION
model = request.model

# return a list of documents in the same folder as the current model
docobjects = model.get_container().objectIds()

#check to see if id is in container
if id in docobjects:
#quietly don't create the document
return
else:

model.get_container().manage_addProduct['SilvaDocument'].manage_addDocument(
id.encode('utf-8'), title)
doc = getattr(model, id)

# get the editable version of your document
version = doc.get_editable()

# get the XML document root
doc_root = version.content.documentElement

# Source 1
# create the new node of type 'source'
source = doc_root.createElement('source')

# set the source id attribute
source.setAttribute('id', 'module_information')

#now create and add a parameters to the new code source node

parameter = doc_root.createElement('parameter')
parameter.setAttribute('key', 'table')

parameter.appendChild(doc_root.createTextNode('RECMGR_EL_MODULE_Query'))
source.appendChild(parameter)

parameter = doc_root.createElement('parameter')
parameter.setAttribute('key', 'columns')
parameter.appendChild(doc_root.createTextNode('MODCODE, MODNAME'))
source.appendChild(parameter)

#This parameter needs to obtain its node value from the id this script is
being passed
parameter = doc_root.createElement('parameter')
parameter.setAttribute('key', 'argument')
parameter.appendChild(doc_root.createTextNode(id.encode('utf-8')))
source.appendChild(parameter)

#add more parameters if needed

#Add the new code source to your document version
doc_root.appendChild(source)
# Source 1 END
return doc

We haven't make it work yet in our Silva 2.0, mostly for the 'model'
variable that the Python Script can't figure out how to find

By the way,

Can someone point to a document to clarify to a "New to Zope/Silva" like
me, the referencing points (model, context, here et al) used in Python for
 and its precedence or hierarchy?

I ran pythondoc for the whole silva products (Silva, SilvaDocument,
SilvaMetadata, etc.) and I'm digging on it to try to find answers to this
matter

Cordially,

Hugo Angel

On 10/22/07, [email protected] <
[email protected]> wrote:

> Send silva-dev mailing list submissions to
>        [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://lists.infrae.com/mailman/listinfo/silva-dev
> or, via email, send a message with subject or body 'help' to
>        [email protected]
>
> You can reach the person managing the list at
>        [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of silva-dev digest..."
>
>
> Today's Topics:
>
>   1. Hints on How to build a Silva Document from Zope Python
>      Script (Hugo Angel)
>   2. Re: Hints on How to build a Silva Document from Zope      Python
>      Script (Marc Petitmermet)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 21 Oct 2007 11:50:59 -0500
> From: "Hugo Angel" <[email protected]>
> Subject: [silva-dev] Hints on How to build a Silva Document from Zope
>        Python  Script
> To: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello,
>
> I'm interested in building unpublished empty Silva Document (For Silva 2.0
> )
> holders directly from a Zope Python Script, to be called from a Silva form
> that will be filled later using XML import.
> I'd appreciate any suggestion on this matter.
>
> Cordially,
>
>
>
>
> --
> Hugo Angel M
> Calle 46 40-49 Medell?n, Colombia
> +57-4 239-5969
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.infrae.com/pipermail/silva-dev/attachments/20071021/97e73977/attachment.html
>
> ------------------------------
>
> Message: 2
> Date: Sun, 21 Oct 2007 21:27:01 +0200
> From: Marc Petitmermet <[email protected]>
> Subject: Re: [silva-dev] Hints on How to build a Silva Document from
>        Zope    Python Script
> To: Silva Developer <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> > I'm interested in building unpublished empty Silva Document (For
> > Silva 2.0) holders directly from a Zope Python Script, to be called
> > from a Silva form that will be filled later using XML import.
> >
> > I'd appreciate any suggestion on this matter.
>
> i've already done the same thing (creating silva document but with
> content) but i just cannot find the code source anymore:-((
>
> in such a case like yours it is always a good idea to "egrep" through
> the silva code (because they do this already when creating a silva
> document). and then you find something like this in SilvaDocument/
> Document.py:
>
>   object.manage_addProduct['SilvaDocument'].manage_addDocument(id,
> title)
>
> so you need to provide "object", "id" and "title". and i'm pretty
> sure that you have to take care about security (spam protection,
> proxy roles, etc.).
>
> regards,
> marc
>
>
>
>
> ------------------------------
>
> _______________________________________________
> silva-dev mailing list
> [email protected]
> https://lists.infrae.com/mailman/listinfo/silva-dev
>
>
> End of silva-dev Digest, Vol 319, Issue 4
> *****************************************
>



-- 
Hola :

Saludos,

-- 
Hugo Angel M
Calle 46 40-49 MedellĂ­n, Colombia
+57-4 239-5969

_______________________________________________
silva-dev mailing list
silva-dev-IAPFreCvJWM6s/[email protected]
https://lists.infrae.com/mailman/listinfo/silva-dev