[Zope-CMF] ZClip! using Portal - Code Included

alan runyan runyaga@thisbox.com
Tue, 15 May 2001 07:38:25 -0500


Hi.

widdling away on what use to be called ZClip!  It creates a Link object in
your Members/memberName/myBookmarks folder.

I created a Python Script that I can put in my Portal.  and call it
directly.  it appears to work.  I'm having problems with workflow, if your a
reviewer put it in publish mode if your a member put it in review mode --
how do I get my permissions?

Param List: type_name, id, title, remote_url, body_stx=""
-- cut here --
userName = context.REQUEST['__ac_name']
linkFolder = 'myBookmarks'
newLink = None
userFolder = None

#lets make sure we have a place to store the Links
if hasattr(context.Members, userName):
    userFolder=getattr(context.Members, userName)
    if hasattr(userFolder, linkFolder):
        linkFolder=getattr(userFolder, linkFolder)
    else:
        newFolder=userFolder.invokeFactory('Folder', linkFolder)
        if hasattr(userFolder, linkFolder):
            linkFolder=getattr(userFolder, linkFolder)
        else:
            return 'couldnt get the folder I created?, use the source Luke'
else:
    return context.REQUEST.RESPONSE.redirect('login_form')

#now we for sure have the linkFolder
linkFolder.invokeFactory(type_name, id)

if hasattr(linkFolder, id):
    newLink = getattr(linkFolder, id)
    newLink.edit(remote_url)
    newLink.editMetadata(title=title,
                         description=body_stx)
else:
    return str(id)+' not found in runyaga.myBookmarks'

#if reviewer, auto publish else put in review mode
#if context.REQUEST.AUTHENTICATED_USER.hasRole(context.portal_types.Link,
'Reviewer'):
#    return 'you are a review'
#    context.portal_workflow.doActionFor(newLink, 'publish')


closeWindowHTML = '''<html><head><body
onLoad="javascript:parent.close()"></body></head></html>;'''
return closeWindowHTML

-- cut here --

the javascript that I use is (body_stx) isnt working, yet:

javascript:function stripIllegals(url) {var retVal = '';for
(x=0;x<url.length;x++){if ( (url.charCodeAt(x) >=97 && url.charCodeAt(x)
<=122) ||(url.charCodeAt(x) >=62 && url.charCodeAt(x) <=90) )
{retVal+=url.charAt(x);}}return
retVal;}Q='';if(top.frames.length==0)Q=this.document.selection.createRange()
.text;void(btw=window.open('http://thecommode.com/Members/createZClip?type_n
ame=Link&body_stx='+escape(Q)+'&remote_url='+escape(location.href)+'&title='
+escape(this.document.title)+'&id='+stripIllegals(escape(this.document.title
)),'zURLform','scrollbars=no,width=485,height=315,left=75,top=175,status=yes
'));btw.focus();


good luck and tell me if it works for you ;)
~runyaga