Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Bernard committed Jan 4, 2007
1 parent 7b68780 commit bd6a70c
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Script (Python) "newPatchNote"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=nb, lang=None,type=None,format=None,url, desc=None
##title=
##

format = (format,)
type = (type,)
lang = (lang,)
path = '/'.join(context.getPhysicalPath())
result = context.portal_catalog(
meta_type=['Surveillant',],
path={'query':path, 'level': 0},
sort_on='Date',
sort_order='reverse',
)
lastId = result[0].getId

#creation en boucle a partir de lastId+1 jusqu'a lastId+nb

r = range(int(lastId)+1,int(lastId)+int(nb)+1)
for i in r:
newid = str(i)
if len(newid) <3:
newid = '00'+newid
elif len(newid) <2:
newid = '0'+newid
print newid
context.invokeFactory(id=newid, type_name='Surveillant', title=newid, langs = lang, types = type, formats = format,description=desc, urlRedirection=url)
new_obj = getattr(context, newid)
new_obj.setTitle(newid)
new_obj.setLangs(lang)
new_obj.setFormats(format)
new_obj.setTypes(type)
new_obj.setUrlRedirection(url)

#publication
#plustard

#container.REQUEST.RESPONSE.redirect(context.absolute_url())

return printed
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Script (Python) "sortSurveillants"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=capoZ,lang=None,format=None,type=None,text=None
##title=
##

def FindTextInDesc(text,capo):
text = text.split(';')
result = []
for brain in capo:
for i in text:
if i.upper() in str(brain.getObject().getDescription()).upper():
result.append(brain)
return result

def FilterByLang(lang,capo):
lang = [lang]
if 'all' in lang:
return capo
result = []
for brain in capo
if lang in brain.getObject().getLangs():
result.append(brain)
return result

def FilterByFormat(format,capo):
format = [format]
if 'all' in format:
return capo
result = []
for brain in capo
if format in brain.getObject().getformats():
result.append(brain)
return result

def FilterByType(type,capo):
type = [type]
if 'all' in type:
return capo
result = []
for brain in capo
if type in brain.getObject().gettypes():
result.append(brain)
return result


if text:
capoZ = FindTextInDesc(text,capoZ)
if lang:
capoZ = FilterByLang(lang,capoZ)
if format:
capoZ = FilterByFormat(format,capoZ)
if type:
capoZ = FilterByType(type,capoZ)
return capoZ

0 comments on commit bd6a70c

Please sign in to comment.