Example #1
0
	def handle_edit_action(self, action, data):
		if form.applyChanges(self.context, self.form_fields, data,
							 self.adapters):
			self.status = _("Changes saved.")
			self._on_save(data)
		else:
			self.status = _("No changes made.")
Example #2
0
	def handle_cancel_action(self, action, data):
		IStatusMessage(self.request).addStatusMessage(_("Changes canceled."),
													  type="info")
		url = getMultiAdapter((self.context, self.request),
							  name='absolute_url')()
		self.request.response.redirect(url)
		return ''
Example #3
0
	def action_save(self, action, data):
		"""
		2008-04-22 one question remains. how to use the portal factory tool. need to move the object out of the portal_factory
		"""
		if form.applyChanges(
			self.context, self.form_fields, data, self.adapters):
			context = aq_inner(self.context)
			newId = data['title'].replace(' ','-')
			newId = newId.replace('/', '-')
			#newId = context.generateNewId()
			#context.invokeFactory(id=newId, type_name='Phenotype')
			#new_context = getattr(context, newId)
			
			#import sys
			#sys.stderr.write("id: %s, title: %s, newId: %s.\n"%(context.id, context.title, newId))
			#sys.stderr.write("type(newId): %s, dir(newId): %s.\n"%(repr(type(newId)), repr(dir(newId)) ))
			
			#use below to decide if this is first time being created by portal_factory or followup editing
			grandpa = aq_parent(aq_parent(context))
			if grandpa.id=='portal_factory':
				#phenotype.generateNewId()
				
				#2008-04-23. below is probably a simpler line. don't know where i got it.
				#new_context = context.portal_factory.doCreate(context, id)
				
				#2008-04-23. got the clue from FactoryTool.doCreate() of Products/CMFPlone/FactoryTool.py
				type_name = aq_parent(context).id  # get the ID of the TempFolder
				folder = aq_parent(aq_parent(aq_parent(context)))
				folder.invokeFactory(id=newId, type_name=type_name)
				
				new_context = getattr(folder, newId)
				new_context.setId(str(newId))	#type of newId is unicode. and str is required for catalog

				#manually set all these properties
				new_context.title = data['title']
				new_context.description = data['description']
				new_context.QC_method_id = data['QC_method_id']
				new_context.input_dir = data['input_dir']
			else:
				new_context = context
				new_context.setId(str(newId))
			#import pdb
			#pdb.set_trace()
			new_context.short_name = unicode(str(new_context.QC_method_id))
			
			settings = getUtility(IStockDatabaseSettings, name='variation.stockdatabasesettings')
			from variation.src.QC_250k import QC_250k
			QC_method_id2cmp_data_filename = {1: '/usr/local/home_ubuntu/crocea/script/variation/data/2010/data_2010_x_250k_y0001.tsv',
				2: '/usr/local/home_ubuntu/crocea/script/variation/data/perlegen/data_perlegen_ecotype_id_x_250k_y0101.tsv',
				3: '/usr/local/home_ubuntu/crocea/script/variation/stock20080403/data_y10001101.tsv'}
			from pymodule import ProcessOptions
			argv_list = ['QC_250k.py', '-i', QC_method_id2cmp_data_filename[int(new_context.QC_method_id)], \
				'-n', new_context.input_dir, '-m', new_context.QC_method_id, '-u', settings.username, '-p', settings.password]
			po = ProcessOptions(argv_list, QC_250k.option_default_dict, error_doc=QC_250k.__doc__)
			
			#instance = QC_250k(**po.long_option2value)
			#new_context.row_id2NA_mismatch_rate = instance.plone_run()
			#del instance
			
			zope.event.notify(
				ObjectModifiedEvent(new_context)
				)
			# TODO: Needs locale support. See also Five.form.EditView.
			self.status = _(
				"Updated on ${date_time}", 
				mapping={'date_time': str(datetime.utcnow())}
				)
			#confirm = u"Phenotype Checked Out."
			#IStatusMessage(self.request).addStatusMessage(confirm, type='info')
			
			#04/18/08 old way of handling from the (The Definitive Guide to Plone)
			#self.state.set(context=new_context, portal_status_message="Phenotype Checked out.")
			
			self.request.response.redirect(new_context.absolute_url())
		else:
			#use below to decide if this is first time being created by portal_factory or followup editing
			context = aq_inner(self.context)
			grandpa = aq_parent(aq_parent(context))
			if grandpa.id=='portal_factory':
				context = aq_parent(aq_parent(aq_parent(aq_inner(self.context))))
			
			confirm = u"Cancelled."
			IStatusMessage(self.request).addStatusMessage(confirm, type='info')
			self.request.response.redirect(context.absolute_url())
Example #4
0
	def action_save(self, action, data):
		"""
		2008-04-22 one question remains. how to use the portal factory tool. need to move the object out of the portal_factory
		"""
		if form.applyChanges(
			self.context, self.form_fields, data, self.adapters):
			#method_id = method_id_short_name.split(' ')[0]
			#method_id = int(method_id)
			context = aq_inner(self.context)
			newId = data['title'].replace(' ','-')
			newId = newId.replace('/', '-')
			#newId = context.generateNewId()
			#context.invokeFactory(id=newId, type_name='Phenotype')
			#new_context = getattr(context, newId)
			
			#import sys
			#sys.stderr.write("id: %s, title: %s, newId: %s.\n"%(context.id, context.title, newId))
			#sys.stderr.write("type(newId): %s, dir(newId): %s.\n"%(repr(type(newId)), repr(dir(newId)) ))
			
			#use below to decide if this is first time being created by portal_factory or followup editing
			grandpa = aq_parent(aq_parent(context))
			if grandpa.id=='portal_factory':
				#phenotype.generateNewId()
				
				#2008-04-23. below is probably a simpler line. don't know where i got it.
				#new_context = context.portal_factory.doCreate(context, id)
				
				#2008-04-23. got the clue from FactoryTool.doCreate() of Products/CMFPlone/FactoryTool.py
				type_name = aq_parent(context).id  # get the ID of the TempFolder
				folder = aq_parent(aq_parent(aq_parent(context)))
				folder.invokeFactory(id=newId, type_name=type_name)
				
				new_context = getattr(folder, newId)
				new_context.setId(str(newId))	#type of newId is unicode. and str is required for catalog

				#manually set all these properties
				new_context.title = data['title']
				new_context.description = data['description']
				new_context.method_id_ls = data['method_id_ls']
			else:
				new_context = context
				new_context.setId(str(newId))
			
			locator = getUtility(IDBLocator)
			new_context.phenotype_obj_ls = locator.get_phenotype_obj_ls(new_context.method_id_ls)
			
			zope.event.notify(
				ObjectModifiedEvent(new_context)
				)
			# TODO: Needs locale support. See also Five.form.EditView.
			self.status = _(
				"Phenotype Updated on ${date_time}", 
				mapping={'date_time': str(datetime.utcnow())}
				)
			#confirm = u"Phenotype Checked Out."
			#IStatusMessage(self.request).addStatusMessage(confirm, type='info')
			
			#04/18/08 old way of handling from the (The Definitive Guide to Plone)
			#self.state.set(context=new_context, portal_status_message="Phenotype Checked out.")
			
			self.request.response.redirect(new_context.absolute_url())
		else:
			#use below to decide if this is first time being created by portal_factory or followup editing
			context = aq_inner(self.context)
			grandpa = aq_parent(aq_parent(context))
			if grandpa.id=='portal_factory':
				context = aq_parent(aq_parent(aq_parent(aq_inner(self.context))))
			
			confirm = u"Phenotype Unchanged."
			IStatusMessage(self.request).addStatusMessage(confirm, type='info')
			self.request.response.redirect(context.absolute_url())
Example #5
0
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

from Variation.SNP250k.interfaces import IVariationFolder
from Variation.SNP250k.config import PROJECTNAME

from Variation.SNP250k import VariationMessageFactory as _

VariationFolderSchema = folder.ATBTreeFolderSchema.copy() + atapi.Schema((
	atapi.TextField('text',
		required=False,
		searchable=True,
		storage=atapi.AnnotationStorage(),
		default_output_type='text/html',
		allowable_content_types = ('text/plain', 'text/restructured', 'text/html',),
		widget=atapi.RichWidget(label=_(u"Descriptive text"),
								description=_(u""),
								rows=25,
								allow_file_upload=True),
		),
	))

VariationFolderSchema['title'].storage = atapi.AnnotationStorage()
VariationFolderSchema['description'].storage = atapi.AnnotationStorage()

finalizeATCTSchema(VariationFolderSchema, folderish=True, moveDiscussion=False)

class VariationFolder(folder.ATBTreeFolder):
	"""Contains multiple films.
	"""
	implements(IVariationFolder)