rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
mod = self.view.get_model()
mod = self.main_db.view.get_model()
def on_row_activated (self, tree, path, col): mod = self.view.get_model() it = mod.get_iter_from_string(str(path[0])) utils.InfoDialog(self, _("Riepilogo"), self.col_lst, self.vars, mod.get_value (it, 14)) #pass
utils.InfoDialog(self, _("Riepilogo"), self.col_lst, self.vars, mod.get_value (it, 14))
utils.InfoDialog(self.main_db, _("Riepilogo"), self.col_lst, self.main_db.vars)
def on_row_activated (self, tree, path, col): mod = self.view.get_model() it = mod.get_iter_from_string(str(path[0])) utils.InfoDialog(self, _("Riepilogo"), self.col_lst, self.vars, mod.get_value (it, 14)) #pass
mod, it = self.view.get_selection ().get_selected ()
mod, it = self.main_db.view.get_selection ().get_selected ()
def after_refresh (self, it): # Implementata dalla sovraclasse mod, it = self.view.get_selection ().get_selected () id = mod.get_value (it, 0) vasca = self.vars[0].get_text () data = self.vars[1].get_text () tipo = self.vars[2].get_text () nome = self.vars[3].get_text () quantita = self.vars[4].get_text () giorni...
vasca = self.vars[0].get_text () data = self.vars[1].get_text () tipo = self.vars[2].get_text () nome = self.vars[3].get_text () quantita = self.vars[4].get_text () giorni = self.vars[5].get_text () note = self.vars[6].get_text ()
vasca = self.main_db.vars[0].get_text () data = self.main_db.vars[1].get_text () tipo = self.main_db.vars[2].get_text () nome = self.main_db.vars[3].get_text () quantita = self.main_db.vars[4].get_text () giorni = self.main_db.vars[5].get_text () note = self.main_db.vars[6].get_text ()
def after_refresh (self, it): # Implementata dalla sovraclasse mod, it = self.view.get_selection ().get_selected () id = mod.get_value (it, 0) vasca = self.vars[0].get_text () data = self.vars[1].get_text () tipo = self.vars[2].get_text () nome = self.vars[3].get_text () quantita = self.vars[4].get_text () giorni...
self.update_status (dbwindow.NotifyType.SAVE, _("Row aggiornata (ID: %d)") % id)
self.main_db.update_status (NotifyType.SAVE, _("Row aggiornata (ID: %d)") % id)
def after_refresh (self, it): # Implementata dalla sovraclasse mod, it = self.view.get_selection ().get_selected () id = mod.get_value (it, 0) vasca = self.vars[0].get_text () data = self.vars[1].get_text () tipo = self.vars[2].get_text () nome = self.vars[3].get_text () quantita = self.vars[4].get_text () giorni...
mod, id = self.view.get_selection().get_selected()
mod, id = self.main_db.view.get_selection().get_selected()
def add_entry (self, it): # Aggiunge la entry nel database mod, id = self.view.get_selection().get_selected() id = mod.get_value (it, 0) #for i in self.vars: # print i.get_text () utils.cmd ('insert into manutenzione values(?,?,?,?,?,?,?,?)', id, self.vars[0].get_text (), self.vars[1].get_text (), self.vars[2].get_te...
self.vars[0].get_text (), self.vars[1].get_text (), self.vars[2].get_text (), self.vars[3].get_text (), self.vars[4].get_text (), self.vars[5].get_text (), self.vars[6].get_text ())
self.main_db.vars[0].get_text (), self.main_db.vars[1].get_text (), self.main_db.vars[2].get_text (), self.main_db.vars[3].get_text (), self.main_db.vars[4].get_text (), self.main_db.vars[5].get_text (), self.main_db.vars[6].get_text ())
def add_entry (self, it): # Aggiunge la entry nel database mod, id = self.view.get_selection().get_selected() id = mod.get_value (it, 0) #for i in self.vars: # print i.get_text () utils.cmd ('insert into manutenzione values(?,?,?,?,?,?,?,?)', id, self.vars[0].get_text (), self.vars[1].get_text (), self.vars[2].get_te...
self.update_status (dbwindow.NotifyType.ADD, _("Row aggiunta (ID: %d)") % id)
self.main_db.update_status (NotifyType.ADD, _("Row aggiunta (ID: %d)") % id)
def add_entry (self, it): # Aggiunge la entry nel database mod, id = self.view.get_selection().get_selected() id = mod.get_value (it, 0) #for i in self.vars: # print i.get_text () utils.cmd ('insert into manutenzione values(?,?,?,?,?,?,?,?)', id, self.vars[0].get_text (), self.vars[1].get_text (), self.vars[2].get_te...
self.update_status (dbwindow.NotifyType.DEL, _("Row rimossa (ID: %d)") % id)
self.main_db.update_status (NotifyType.DEL, _("Row rimossa (ID: %d)") % id)
def remove_id (self, id): # Passa l'id da rimuovere nel database utils.cmd ('delete from manutenzione where id=%d' % id) self.update_status (dbwindow.NotifyType.DEL, _("Row rimossa (ID: %d)") % id) #pass
try:
print "Carico il modulo senza try/except.. fixami prima della revisione finale"
def load (self, path, name, klass): # Aggiungiamo la path old = sys.path sys.path.append (path) try: module = __import__ (name)#, globals (), locals (), [klass]) instance = vars(module)[klass]
except: print ">> Restoring path" sys.path = old
def load (self, path, name, klass): # Aggiungiamo la path old = sys.path sys.path.append (path) try: module = __import__ (name)#, globals (), locals (), [klass]) instance = vars(module)[klass]
print "!! %s::%s (%s)" % (klass, sys.exc_value, sys.exc_type) return False
def load (self, path, name, klass): # Aggiungiamo la path old = sys.path sys.path.append (path) try: module = __import__ (name)#, globals (), locals (), [klass]) instance = vars(module)[klass]
self.set_resizable(False)
def __init__(self): gtk.Window.__init__(self) self.set_title("Calcoli") #f1 = gtk.Frame('Valori'); f2 = gtk.Frame('Risultati') #main_vbox.pack_start(f1); main_vbox.pack_start(f2); #tbl_valori = gtk.Table(...); tbl_risultati = gtk.Table(...) #f1.add(tbl_valori); f2.add(tbl_risultati) vbox = gtk.VBox() vbox.set_spacin...
vbox.pack_start(f1); vbox.pack_start(f2);
def __init__(self): gtk.Window.__init__(self) self.set_title("Calcoli") #f1 = gtk.Frame('Valori'); f2 = gtk.Frame('Risultati') #main_vbox.pack_start(f1); main_vbox.pack_start(f2); #tbl_valori = gtk.Table(...); tbl_risultati = gtk.Table(...) #f1.add(tbl_valori); f2.add(tbl_risultati) vbox = gtk.VBox() vbox.set_spacin...
tbl_valori = gtk.Table(8, 2)
vbox.pack_start(f1, False, False, 0) vbox.pack_start(f2, False, False, 0) tbl_valori = gtk.Table(3, 2) tbl_valori.set_border_width(4) tbl_valori.set_row_spacings(4)
def __init__(self): gtk.Window.__init__(self) self.set_title("Calcoli") #f1 = gtk.Frame('Valori'); f2 = gtk.Frame('Risultati') #main_vbox.pack_start(f1); main_vbox.pack_start(f2); #tbl_valori = gtk.Table(...); tbl_risultati = gtk.Table(...) #f1.add(tbl_valori); f2.add(tbl_risultati) vbox = gtk.VBox() vbox.set_spacin...
tbl_valori.attach(self.e_altezza, 1, 2, 0, 1) tbl_valori.attach(self.e_lunghezza, 1, 2, 1, 2) tbl_valori.attach(self.e_larghezza, 1, 2, 2, 3)
tbl_valori.attach(self.e_altezza, 1, 2, 0, 1, yoptions=0) tbl_valori.attach(self.e_lunghezza, 1, 2, 1, 2, yoptions=0) tbl_valori.attach(self.e_larghezza, 1, 2, 2, 3, yoptions=0)
def __init__(self): gtk.Window.__init__(self) self.set_title("Calcoli") #f1 = gtk.Frame('Valori'); f2 = gtk.Frame('Risultati') #main_vbox.pack_start(f1); main_vbox.pack_start(f2); #tbl_valori = gtk.Table(...); tbl_risultati = gtk.Table(...) #f1.add(tbl_valori); f2.add(tbl_risultati) vbox = gtk.VBox() vbox.set_spacin...
tbl = gtk.Table(8, 2)
tbl = gtk.Table(6, 2) tbl.set_border_width(4) tbl.set_row_spacings(4)
def __init__(self): gtk.Window.__init__(self) self.set_title("Calcoli") #f1 = gtk.Frame('Valori'); f2 = gtk.Frame('Risultati') #main_vbox.pack_start(f1); main_vbox.pack_start(f2); #tbl_valori = gtk.Table(...); tbl_risultati = gtk.Table(...) #f1.add(tbl_valori); f2.add(tbl_risultati) vbox = gtk.VBox() vbox.set_spacin...
skinob = baseself
skinob = None
def getSkinByPath(self, path, raise_exc=0): """ Get a skin at the given path. """ baseself = aq_base(self) skinob = baseself parts = list( path.split(',') ) parts.reverse() for part_path in parts: partob = baseself for name in part_path.strip().split('/'): if name == '': continue if name[:1] == '_': # Not allowed. part...
skinob = partob.__of__(skinob)
partob = aq_base(partob) if skinob is None: skinob = partob else: skinob = partob.__of__(skinob)
def getSkinByPath(self, path, raise_exc=0): """ Get a skin at the given path. """ baseself = aq_base(self) skinob = baseself parts = list( path.split(',') ) parts.reverse() for part_path in parts: partob = baseself for name in part_path.strip().split('/'): if name == '': continue if name[:1] == '_': # Not allowed. part...
talkback = getattr(self, 'talkback', None)
if hasattr( aq_base( self ), 'talkback' ): talkback = self.talkback
def objectItems(self): """ since 'talkback' is the only opaque item on content right now, I will return that. Should be replaced with a list of tuples for every opaque item! """ talkback = getattr(self, 'talkback', None) if talkback is not None: return ((talkback.id, talkback),) else: return []
raise RuntimeError('Could not launch Homesite.')
raise RuntimeError('Could not launch Word.')
def __init__(self, file): """Launch editor process""" word = win32com.client.Dispatch('Word.Application') # Try to open the file, keep retrying until we succeed or timeout i = 0 timeout = 45 while i < timeout: try: word.Documents.Open(file) except: i += 1 if i >= timeout: raise RuntimeError('Could not launch Homesite.'...
def _queryFactoryMethod(self, container, m=None):
def _queryFactoryMethod(self, container, default=None): if not self.product or not self.factory: return default
def _queryFactoryMethod(self, container, m=None): try: if self.product and self.factory: p = container.manage_addProduct[self.product] t = getattr(p, self.factory, None) if getSecurityManager().validate(p, p, self.factory, t): m = t except: LOG('Types Tool', ERROR, '_queryFactoryMethod raised an exception', error=sys.e...
if self.product and self.factory: p = container.manage_addProduct[self.product] t = getattr(p, self.factory, None) if getSecurityManager().validate(p, p, self.factory, t): m = t
p = container.manage_addProduct[self.product] m = getattr(p, self.factory, None) if m is None: return default try: if getSecurityManager().validate(p, p, self.factory, m): return m except Unauthorized: pass return default
def _queryFactoryMethod(self, container, m=None): try: if self.product and self.factory: p = container.manage_addProduct[self.product] t = getattr(p, self.factory, None) if getSecurityManager().validate(p, p, self.factory, t): m = t except: LOG('Types Tool', ERROR, '_queryFactoryMethod raised an exception', error=sys.e...
return m
return default
def _queryFactoryMethod(self, container, m=None): try: if self.product and self.factory: p = container.manage_addProduct[self.product] t = getattr(p, self.factory, None) if getSecurityManager().validate(p, p, self.factory, t): m = t except: LOG('Types Tool', ERROR, '_queryFactoryMethod raised an exception', error=sys.e...
for i in self.objectValues(filter=_filter):
for i in self.contentValues(filter=_filter):
def _reindex_issues(self, internal_only=1): """For, eg, allowedRolesAndUsers recompute after local_role changes.
h.putheader("Cookie", self.metadata['cookie']+'\n')
h.putheader("Cookie", self.metadata['cookie'])
def zope_request(self, method, headers={}, body=''): """Send a request back to Zope""" try: if self.ssl: h = HTTPSConnection(self.host) else: h = HTTPConnection(self.host)
url = '%s?came_from=%s&retry=%s' % (
url = '%s?came_from=%s&retry=%s&disable_cookie_login__=1' % (
def getLoginURL(self): ''' Redirects to the login page. ''' if self.auto_login_page: req = self.REQUEST resp = req['RESPONSE'] iself = getattr(self, 'aq_inner', self) parent = getattr(iself, 'aq_parent', None) page = getattr(parent, self.auto_login_page, None) if page is not None: retry = getattr(resp, '_auth', 0) and ...
- "WORKFLOW_METHOD" -> fired as the result of execting a WorkflowMethod
def _extractTransitions( self, workflow ):
def __del__(self): if self.changed: self.save()
def __init__(self, path): # Create/read config file on instantiation self.path = path if not os.path.exists(path): f = open(path, 'w') f.write(default_configuration) f.close() self.changed = 0 self.config = ConfigParser() self.config.readfp(open(path))
self.body_file = body_file
def __init__(self, input_file): try: # Read the configuration file config_path = os.path.expanduser('~/.zope-external-edit') self.config = Configuration(config_path)
if getattr(self, 'clean_up', 1):
if getattr(self, 'clean_up', 1) and hasattr(self, 'body_file'):
def __del__(self): # for security we always delete the files by default if getattr(self, 'clean_up', 1): os.remove(self.body_file)
self.fatalError('Editor not found at "%s"' % path)
fatalError('Editor not found at "%s"' % path)
def getEditorPath(self): """Return the absolute path to the editor""" path = self.options.get('editor') if path: path = whereIs(path) elif has_tk(): from tkSimpleDialog import askstring path = askstring('Zope External Editor', 'Enter the default editor name') if not path: sys.exit(0) path = whereIs(path) if os.path.ex...
if key is not '(Default)':
if key != '(Default)':
def __before_publishing_traverse__(self, arg1, arg2=None): """ Pre-traversal hook. """ # XXX hack around a bug(?) in BeforeTraverse.MultiHook REQUEST = arg2 or arg1
if id is not '(Default)':
if id != '(Default)':
def __before_publishing_traverse__(self, arg1, arg2=None): """ Pre-traversal hook. """ # XXX hack around a bug(?) in BeforeTraverse.MultiHook REQUEST = arg2 or arg1
, 'text/xml'
, 'text/plain'
def test_ContentTypeFromFSMetadata(self): # Test to see if a content_type specified in a .metadata file # is respected script = self._makeOne('testPT2', 'testPT2.pt') script = script.__of__(self.root) script() self.assertEqual( self.RESPONSE.getHeader('content-type') , 'text/xml' )
message = 'New+criteria+added.'
message = urllib.quote_plus('New criteria added.')
def addCriteria(self, field, criteria_type, REQUEST=None): """ Create a new search criteria in this topic """ crit = None newid = 'crit__%s' % field for ct in self._criteriaTypes: if criteria_type == ct.meta_type: crit = ct(newid, field)
message = 'Criteria+deleted.'
message = urllib.quote_plus('Criteria deleted.')
def deleteCriteria(self, criterion_ids=[], REQUEST=None): """ Delete selected criteria """ for cid in criterion_ids: self._delObject(cid)
message = 'Changes+saved.'
message = urllib.quote_plus('Changes saved.')
def editCriteria(self, criteria=[], REQUEST=None): """\ Save changes to the list of criteria. This is done by going over the submitted criteria records and comparing them against the criteria object's editable attributes. A 'command' object is built to send to the Criteria objects 'edit' command. """ for rec in crite...
"Subtopic+'%s'+added" % id )
urllib.quote_plus("Subtopic '%s' added" % id ))
def addSubtopic(self, id, REQUEST=None): """ Add a new subtopic """ types = utils.getToolByName(self, 'portal_types') topictype = types.getTypeInfo('Topic')
from Products.CMFCore.register import registerPortalContent registerPortalContent( Topic, meta_type='Portal Topic', icon = 'images/topic.gif', permission = TopicPermissions.AddTopics, productGlobals = globals(), )
def addSubtopic(self, id, REQUEST=None): """ Add a new subtopic """ types = utils.getToolByName(self, 'portal_types') topictype = types.getTypeInfo('Topic')
count = self._recursiveUpdateRoleMappings(portal, wfs)
catalog = getToolByName(self, 'portal_catalog', None) count = self._recursiveUpdateRoleMappings(portal, wfs, catalog)
def updateRoleMappings(self, REQUEST=None): ''' ''' wfs = {} for id in self.objectIds(): wf = self.getWorkflowById(id) if hasattr(aq_base(wf), 'updateRoleMappingsFor'): wfs[id] = wf portal = aq_parent(aq_inner(self)) count = self._recursiveUpdateRoleMappings(portal, wfs) if REQUEST is not None: return self.manage_selec...
catalog = getToolByName(ob, 'portal_catalog', None) if catalog is not None: catalog.reindexObject(ob)
self._reindexWorkflowVariables(ob)
def _invokeWithNotification(self, wfs, ob, action, func, args, kw): ''' Private utility method. ''' reindex = 1 for w in wfs: w.notifyBefore(ob, action) try: res = apply(func, args, kw) except ObjectDeleted, ex: res = ex.getResult() reindex = 0 except ObjectMoved, ex: res = ex.getResult() ob = ex.getNewObject() except:...
def _recursiveUpdateRoleMappings(self, ob, wfs):
def _recursiveUpdateRoleMappings(self, ob, wfs, catalog):
def _recursiveUpdateRoleMappings(self, ob, wfs): # Returns a count of updated objects. count = 0 wf_ids = self.getChainFor(ob) if wf_ids: changed = 0 for wf_id in wf_ids: wf = wfs.get(wf_id, None) if wf is not None: did = wf.updateRoleMappingsFor(ob) if did: changed = 1 if changed: count = count + 1 if hasattr(aq_base(...
count = count + self._recursiveUpdateRoleMappings(v, wfs)
count = count + self._recursiveUpdateRoleMappings(v, wfs, catalog)
def _recursiveUpdateRoleMappings(self, ob, wfs): # Returns a count of updated objects. count = 0 wf_ids = self.getChainFor(ob) if wf_ids: changed = 0 for wf_id in wf_ids: wf = wfs.get(wf_id, None) if wf is not None: did = wf.updateRoleMappingsFor(ob) if did: changed = 1 if changed: count = count + 1 if hasattr(aq_base(...
if status is not None and status.has_key(id): value = status[id]
if status is not None and status.has_key(name): value = status[name]
vdef = self.variables[name]
output('<a name="
output('<a name="%s">[%s]</a>' % (name, name))
def namedLink(self, doc, level, output): """\ XXX Trial subclassed implementation of HTMLClass#namedLink(), as default implementation seems to be broken... """ name = doc.getNodeValue() if name[:2] == '..': name = name[2:] output('<a name="#%s">[%s]</a>' % (name, name))
import traceback traceback.print_exc()
from zLOG import LOG, ERROR import sys type,value,tb = sys.exc_info() LOG('DirectoryView', ERROR, 'Error during prepareContents:', "\nType:%s\nValue:%s\n" % (type,value))
def getContents(self, registry): changed = 0 if Globals.DevelopmentMode: try: mtime = stat(expandpath(self.filepath))[8] except: mtime = 0 if mtime != self._v_last_read: self._v_last_read = mtime changed = 1
for doc in self.excelapp.Workbooks: if head == doc.Path.lower() and tail == doc.Name.lower():
try: for doc in self.excelapp.Workbooks: if head == doc.Path.lower() and tail == doc.Name.lower(): return 1 return 0 except pythoncom.com_error, why: if why[0] == -2147418111:
def isAlive(self): """Returns true if the editor process is still alive""" head, tail = os.path.split(self.file) head, tail = head.lower(), tail.lower() for doc in self.excelapp.Workbooks: if head == doc.Path.lower() and tail == doc.Name.lower(): return 1 return 0
return 0
else: raise
def isAlive(self): """Returns true if the editor process is still alive""" head, tail = os.path.split(self.file) head, tail = head.lower(), tail.lower() for doc in self.excelapp.Workbooks: if head == doc.Path.lower() and tail == doc.Name.lower(): return 1 return 0
return self.subject
return getattr( self, 'subject', () )
def Subject( self ): "Dublin Core element - resource keywords" return self.subject
return self.creation_date.ISO()
return self.creation_date and self.creation_date.ISO() or 'Unknown'
def CreationDate( self ): """ Dublin Core element - date resource created. """ return self.creation_date.ISO()
return self.creation_date __FLOOR_DATE = DateTime( 1000, 0 )
date = getattr( self, 'creation_date', None ) return date is None and self.__FLOOR_DATE or date
def created( self ): """ Dublin Core element - date resource created, returned as DateTime. """ return self.creation_date
o User will implement IExtensibleUser.
o User will implement IPropertiedUser.
def getPropertiesForUser( user, request=None ):
for t in ti: id = t.getId() field_name = 'chain_%s' % id chain = props.get(field_name, '(Default)').strip() if chain == '(Default)': if cbt.has_key(id): del cbt[id] else: chain = chain.replace(',', ' ') ids = [] for wf_id in chain.split(' '): if wf_id: if not self.getWorkflowById(wf_id): raise ValueError, ( '"%s" is n...
if props is not None: for t in ti: id = t.getId() field_name = 'chain_%s' % id chain = props.get(field_name, '(Default)').strip() if chain == '(Default)': if cbt.has_key(id): del cbt[id] else: chain = chain.replace(',', ' ') ids = [] for wf_id in chain.split(' '): if wf_id: if not self.getWorkflowById(wf_id): raise Va...
def manage_changeWorkflows(self, default_chain, props=None, REQUEST=None):
try: root._delObject('test') except AttributeError: pass
def setUp( self ): SecurityTest.setUp(self)
old, sub._p_jar = sub._p_jar, self.root._p_jar try: folder.manage_renameObject( id='sub', new_id='new_sub' ) finally: sub._p_jar = old
get_transaction().commit(1) folder.manage_renameObject(id='sub', new_id='new_sub')
def test_folderMove( self ): # # Does the catalog stay synched when folders are moved? # test = self.root.test
old, bar._p_jar = sub._p_jar, self.root._p_jar try: cookie = folder.manage_cutObjects( ids=['bar'] ) sub2.manage_pasteObjects( cookie ) finally: bar._p_jar = old
get_transaction().commit(1) cookie = folder.manage_cutObjects(ids=['bar']) sub2.manage_pasteObjects(cookie)
def test_folderMove( self ): # # Does the catalog stay synched when folders are moved? # test = self.root.test
old, dummy._p_jar = dummy._p_jar, self.root._p_jar try: cookie = sub1.manage_cutObjects( ids = ( 'dummy', ) ) sub3.all_meta_types = [] sub3.all_meta_types.extend( sub3.all_meta_types ) sub3.all_meta_types.extend( extra_meta_types() ) sub3.manage_pasteObjects( cookie ) finally: dummy._p_jar = old
get_transaction().commit(1) cookie = sub1.manage_cutObjects( ids = ('dummy',) ) sub3.all_meta_types = [] sub3.all_meta_types.extend(sub3.all_meta_types) sub3.all_meta_types.extend( extra_meta_types() ) sub3.manage_pasteObjects(cookie)
def test_contentPaste( self ): # # Does copy / paste work? # test = self.root.test
if user.getUserName() == 'Anonymous User':
if getSecurityManager().getUser().getUserName() == 'Anonymous User':
def create_page(self, page, text='', title='', log=None, page_type='structuredtext'): """Create a new page.""" if hasattr(aq_base(self._my_folder()), page): raise ValueError, ("Document with name '%s' already exists.\n" "(Perhaps it was created while you were " "editing.)" % page) ob = self.__class__(source_string='', ...
<p>Migrate PTK content to CMF site</p> <p>Path (not including "http://") to PTK instance (source):
<h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source):
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <p>Migrate PTK content to CMF site</p> <p>Path (not including "http://") to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including "http://") to CMF site...
<p>Path (not including "http://") to CMF site (destination):
<p>Path (not including server URL) to CMF site (destination):
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <p>Migrate PTK content to CMF site</p> <p>Path (not including "http://") to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including "http://") to CMF site...
__traceback_info__ = bound_names, args, kw, self.func_defaults
new_globals = f.func_globals.copy() new_globals['__traceback_supplement__'] = ( FSPythonScriptTracebackSupplement, self)
def _exec(self, bound_names, args, kw): """Call a Python Script
new_globals = f.func_globals.copy()
def _exec(self, bound_names, args, kw): """Call a Python Script
self.func_code = None
self.func_code = bad_func_code()
def _write(self, text, compile): ''' Parses the source, storing the body, params, title, bindings, and source in self. If compile is set, compiles the function. ''' ps = PythonScript(self.id) ps.write(text) if compile: ps._makeFunction(1) self._v_f = f = ps._v_f if f is not None: self.func_code = f.func_code self.func...
validate_email, default_charset):
validate_email, default_charset=''):
def setupDefaultProperties(self, p, title, description, email_from_address, email_from_name, validate_email, default_charset): p._setProperty('email_from_address', email_from_address, 'string') p._setProperty('email_from_name', email_from_name, 'string') p._setProperty('validate_email', validate_email and 1 or 0, 'bool...
p._setProperty('default_charset', '', 'string')
p._setProperty('default_charset', default_charset, 'string')
def setupDefaultProperties(self, p, title, description, email_from_address, email_from_name, validate_email, default_charset): p._setProperty('email_from_address', email_from_address, 'string') p._setProperty('email_from_name', email_from_name, 'string') p._setProperty('validate_email', validate_email and 1 or 0, 'bool...
obj = getattr(folder, m)
def _simplewikilink_replace(self, match, allowed=1, state=None, text=''): """replace an occurrence of simplewikilink with a suitable hyperlink
if classname is not None and editor is None: try: key = OpenKeyEx(HKEY_CLASSES_ROOT, classname+'\\Shell') index = 0 while 1: try: subkey = EnumKey(key, index) index += 1 if str(subkey).lower().startswith('edit'): subkey = OpenKeyEx(key, subkey + '\\Command') editor, nil = QueryValueEx(subkey, None) else: continue exc...
if editor is None: try: key = OpenKeyEx(HKEY_CLASSES_ROOT, classname+'\\Shell') index = 0 while 1: try: subkey = EnumKey(key, index) index += 1 if str(subkey).lower().startswith('edit'): subkey = OpenKeyEx(key, subkey + '\\Command') editor, nil = QueryValueEx(subkey, None) else: continue except EnvironmentError: brea...
def getEditorCommand(self): """Return the editor command""" editor = self.options.get('editor') if win32 and editor is None: from _winreg import HKEY_CLASSES_ROOT, OpenKeyEx, \ QueryValueEx, EnumKey from win32api import FindExecutable import pywintypes # Find editor application based on mime type and extension content...
) + all
) + tuple(all)
def all_meta_types(self): all = TypesTool.inheritedAttribute('all_meta_types')(self) return ( {'name':FactoryTypeInformation.meta_type, 'action':'manage_addFactoryTIForm', 'permission':'Manage portal'}, {'name':ScriptableTypeInformation.meta_type, 'action':'manage_addScriptableTIForm', 'permission':'Manage portal'}, ) ...
lockitem = LockItem(user)
lockitem = LockItem(user, timeout=(self.timeout_days * 86400))
def lock(self, object): '''Locks an object''' locker = self.locker(object) if locker: raise LockingError, '%s is already locked' % pathOf(object)
creator = values[0].getCreator() if creator: return creator[1] return ''
for lock in values: if lock.isValid(): creator = lock.getCreator() if creator: return creator[1] return ''
def locker(self, object): '''Returns the locker of an object''' if not WriteLockInterface.isImplementedBy(object): raise LockingError, "%s is not lockable" % pathOf(object)
class Converter: def allowDescendChildren(self): raise 'Not implemented' def convert(self, ob): raise 'Not implemented' def showDuplicationError(self): raise 'Not implemented' def pathOf(ob): return join(ob.getPhysicalPath(), '/') def _migrateObjectManager(src_folder, dst_folder, conversions, skip, res): res.visited...
def migrateObjectManager(self, src_folder, dst_folder, place=()): self.visited_folders.append(join(place, '/')) for id, s_ob in src_folder.objectItems(): d_ob = getattr(dst_folder, id, None) to_store = self.migrateObject(id, s_ob, d_ob, dst_folder, place + (id,)) if to_store is not None: owner = getattr(to_store, '_own...
def __init__(self): self.visited_folders = [] self.warnings = [] self.copied = [] self.skipped = []
res.skipped.append(pathname + (descend_ok and ' (descended)' or ' ')) elif hasattr(aq_base(dst_folder), id): descend_ok = 1 show_message = 1 converter = conversions.get(klass, None) if converter is not None: descend_ok = converter.allowDescendChildren() show_message = converter.showDuplicationError() if show_message: r...
else: descend_ok = 0 self.warnings.append('Could not copy %s' % pathname) if descend_ok: if to_store is not None: d_ob = to_store if d_ob is not None: try: d_ob._p_jar = dst_folder._p_jar except: pass self.migratePossibleContainer(s_ob, d_ob, place) return to_store
def _migrateObject(id, s_ob, dst_folder, conversions, skip, res): klass = s_ob.__class__ descend_ok = 1 pathname = pathOf(s_ob) base_ob = aq_base(s_ob) if skip.has_key(id): descend_ok = skip[id] if descend_ok and not hasattr(aq_base(dst_folder), id): descend_ok = 0 res.skipped.append(pathname + (descend_ok and ' (desce...
try: newob.id = ob.getId() except AttributeError: pass
id = ob.id if callable(id): id = id() try: newob._setId(id) except AttributeError: newob.id = id
def convert(self, ob): ob = aq_base(ob) k = self._klass if hasattr(k, '__basicnew__'): newob = k.__basicnew__() else: newob = new.instance(k, {}) try: newob.id = ob.getId() except AttributeError: pass newob.__dict__.update(ob.__dict__) if hasattr(newob, '_objects'): # Clear the children. for info in newob._objects: del...
newob._container.clear()
newob._container = PersistentMapping()
def convert(self, ob): ob = aq_base(ob) k = self._klass if hasattr(k, '__basicnew__'): newob = k.__basicnew__() else: newob = new.instance(k, {}) try: newob.id = ob.getId() except AttributeError: pass newob.__dict__.update(ob.__dict__) if hasattr(newob, '_objects'): # Clear the children. for info in newob._objects: del...
def migrate(self, src_path='', dest_path=''):
def migrate(self, src_path='', dest_path='', copy_users=0, ownership_only=0):
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including server URL) to CMF ...
src_folder = root.restrictedTraverse(src_path)
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including server URL) to CMF ...
res = MigrationResults() _migrateObjectManager(src_folder, dst_folder, ptk2cmf_conversions, ptk2cmf_skip, res)
if not ownership_only: src_folder = root.restrictedTraverse(src_path) if copy_users: _copyUsers(src_folder, dst_folder) m = Migrator(ptk2cmf_conversions, ptk2cmf_skip) m.migrateObjectManager(src_folder, dst_folder)
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including server URL) to CMF ...
''' % (join(res.warnings, '</li>\n<li>'), join(res.visited_folders, '</li>\n<li>'), join(res.skipped, '</li>\n<li>'), join(res.copied, '\n'),
''' % (join(m.warnings, '</li>\n<li>'), join(m.visited_folders, '</li>\n<li>'), join(m.skipped, '</li>\n<li>'), join(m.copied, '\n'),
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including server URL) to CMF ...
setupDirectConversions('PTKDemo', 'CMFDefault', demo_conversions,
BEFORE_CONTENT_MOVE = 0 if BEFORE_CONTENT_MOVE: content_product = 'PTKBase' else: content_product = 'PTKDemo' setupDirectConversions(content_product, 'CMFDefault', demo_conversions,
def migrate(self, src_path='', dest_path=''): if not src_path or not dest_path: return ''' <html><body><form action="%s" method="POST"> <h2>Migrate PTK content to CMF site</h2> <p>Path (not including server URL) to PTK instance (source): <input type="text" name="src_path"></p> <p>Path (not including server URL) to CMF ...
, 'ExpiresDate'
, 'ExpirationDate'
def enumerateColumns( self ): # Return a sequence of schema names to be cached. return ( 'Subject' , 'Title' , 'Description' , 'Type' , 'review_state' , 'listCreators' , 'Date' , 'getIcon' , 'created' , 'effective' , 'expires' , 'modified' , 'CreationDate' , 'EffectiveDate' , 'ExpiresDate' , 'ModificationDate' , 'get...
wf.notifyFailure(instance, action, sys.exc_info())
wf.notifyException(instance, action, sys.exc_info())
def __call__(self, instance, *args, **kw): ''' Invokes the method. ''' wf = getToolByName(instance, 'portal_workflow', None) if wf is None: # No workflow found. return apply(self._m, (instance,) + args, kw) else: action = self._a wf.notifyBefore(instance, action) # Can throw an exception. try: res = apply(self._m, (in...
raise Unauthorized, ('No accessible views available for %s' %
raise 'Unauthorized', ('No accessible views available for %s' %
def _getDefaultView(self): ti = self.getTypeInfo() if ti is not None: actions = ti.getActions() for action in actions: if action.get('id', None) == 'view': if self._verifyActionPermissions(action): return self.restrictedTraverse(action['action']) # "view" action is not present or not allowed. # Find something that's al...
self.assertEqual(self.req.response['cache-control'], 'no-cache')
self.assertEqual(self.req.response['cache-control'], 'private')
def testCacheHeaderLoggingIn(self): # Should set cache-control self.req.cookies['__ac_name'] = 'abraham' self.req.cookies['__ac_password'] = 'pass-w' self.req.traverse('/') self.assertEqual(self.req.response['cache-control'], 'no-cache')
self.assertEqual(self.req.response['cache-control'], 'no-cache')
self.assertEqual(self.req.response['cache-control'], 'private')
def testCacheHeaderAuthenticated(self): # Should set cache-control self.req.cookies['__ac'] = self.credentials self.req.traverse('/') self.assertEqual(self.req.response['cache-control'], 'no-cache')
self.failIfLocked()
if hasattr(self, 'failIfLocked'): self.failIfLocked()
def editMetadata(self , title='' , subject=() , description='' , contributors=() , effective_date=None , expiration_date=None , format='text/html' , language='en-US' , rights='' ): """ used to be: editMetadata = WorkflowAction(_editMetadata) Need to add check for webDAV locked resource for TTW methods. """ self.failIf...
def createReply(self, title, text, REQUEST, RESPONSE):
def createReply(self, title, text, REQUEST={}, RESPONSE=None):
def createReply(self, title, text, REQUEST, RESPONSE): """ Create a reply in the proper place """ container = self._container
RESPONSE.redirect( self.aq_inner.aq_parent.absolute_url() + '/view' )
if RESPONSE is not None: RESPONSE.redirect( self.aq_inner.aq_parent.absolute_url() + '/view' )
def createReply(self, title, text, REQUEST, RESPONSE): """ Create a reply in the proper place """ container = self._container
conn.request( 'PUT', URL, body, self._getAuthHeaders() )
conn.request( 'PUT', URL, body, headers )
def _uploadFile( self, filename ):
self.setModificationDate(DateTime(modification_date))
self._setModificationDate(DateTime(modification_date))
def __init__(self, id, container, title='', description='', submitter_id=None, submitter_name=None, submitter_email=None, kibitzers=None, security_related=0, topic=None, classification=None, importance=None, resolution=None, version_info=None, creation_date=None, modification_date=None, effective_date=None, expiration_...
self.notifyModified()
self._notifyModified()
def edit(self, title=None, submitter_id=None, submitter_name=None, submitter_email=None, security_related=None, description=None, topic=None, classification=None, importance=None, version_info=None, stealthy=None, comment=None, text=None): """Update the explicitly passed fields."""
self.notifyModified()
self._notifyModified()
def do_action(self, action, comment, assignees=None, file=None, fileid=None, filetype=None): """Execute an action, adding comment to the transcript."""
item.Creator = REQUEST[ 'Creator' ]
item.creator = REQUEST[ 'Creator' ]
def createReply(self, title, text, REQUEST, RESPONSE): """ Create a reply in the proper place """ container = self._container
if modification_date is None: modification_date = self.creation_date self.modification_date = modification_date
if modification_date: self.setModificationDate(DateTime(modification_date))
def __init__(self, id, container, title='', description='', submitter_id=None, submitter_name=None, submitter_email=None, kibitzers=None, security_related=0, topic=None, classification=None, importance=None, resolution=None, version_info=None, creation_date=None, modification_date=None, effective_date=None, expiration_...
if command.find('%1') > -1: command = command.replace('%1', self.content_file)
if win32: file_insert = '%1' else: file_insert = '$1' if command.find(file_insert) > -1: command = command.replace(file_insert, self.content_file)
def launch(self): """Launch external editor""" use_locks = int(self.options.get('use_locks', 0)) if use_locks and self.metadata.get('lock-token'): # A lock token came down with the data, so the object is # already locked, see if we can borrow the lock if int(self.options.get('always_borrow_locks', 0)) \ or askYesNo('Th...
command = command.split() self.pid = os.spawnvp(os.P_NOWAIT, command[0], command)
arg_re = r"""\s*([^'"]\S+)\s+|\s*"([^"]+)"\s*|\s*'([^']+)'\s*""" args = re.split(arg_re, command.strip()) args = filter(None, args) self.pid = os.spawnvp(os.P_NOWAIT, args[0], args)
def __init__(self, command): """Launch editor process""" command = command.split() self.pid = os.spawnvp(os.P_NOWAIT, command[0], command)
def validate(self, inst, parent, name, value, md):
def validate(self, inst, parent, name, value, md=None):
def validate(self, inst, parent, name, value, md): return getSecurityManager().validate(inst, parent, name, value)
, 'xyzzy', None, None, None, None, None, None )
, 'xyzzy', None, None, None, None, None, None, '' )
def test_empty( self ):
mgr._addPolicy( 'first', 'python:1', None, 0, 0, 0, 0 )
mgr._addPolicy( 'first', 'python:1', None, 0, 0, 0, 0, '' )
def test_addPolicy( self ):
, None, 0, 0, 0, 0 )
, None, 0, 0, 0, 0, '' )
def test_reorder( self ):