rhmessaging commits: r3755 - in mgmt/trunk: cumin/python/cumin/grid and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-21 17:54:54 -0500 (Mon, 21 Dec 2009)
New Revision: 3755
Modified:
mgmt/trunk/cumin/python/cumin/grid/submission.py
mgmt/trunk/cumin/python/cumin/messaging/exchange.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/wooly/python/wooly/forms.py
mgmt/trunk/wooly/python/wooly/forms.strings
mgmt/trunk/wooly/python/wooly/parameters.py
Log:
* Create radio and checkbox input fields that work from a
data-oriented interface (get_items)
* Convert ExchangeAdd to use them
Modified: mgmt/trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-12-21 22:54:54 UTC (rev 3755)
@@ -261,23 +261,23 @@
def render_title(self, session):
return "Standard error"
- class OptionsField(CheckboxField):
- def __init__(self, app, name):
- super(SubmissionAddForm.OptionsField, self).__init__(app, name)
+ # class OptionsField(CheckboxField):
+ # def __init__(self, app, name):
+ # super(SubmissionAddForm.OptionsField, self).__init__(app, name)
- self.add_option(self.SaveAsTemplate(app, "template"))
- self.add_option(self.UseCloud(app, "cloud"))
+ # self.add_option(self.SaveAsTemplate(app, "template"))
+ # self.add_option(self.UseCloud(app, "cloud"))
- def render_title(self, session):
- return "Options"
+ # def render_title(self, session):
+ # return "Options"
- class SaveAsTemplate(CheckboxFieldOption):
- def render_title(self, session):
- return "Save as template"
+ # class SaveAsTemplate(CheckboxFieldOption):
+ # def render_title(self, session):
+ # return "Save as template"
- class UseCloud(CheckboxFieldOption):
- def render_title(self, session):
- return "Use cloud"
+ # class UseCloud(CheckboxFieldOption):
+ # def render_title(self, session):
+ # return "Use cloud"
class AttributesField(MultilineStringField):
def render_title(self, session):
Modified: mgmt/trunk/cumin/python/cumin/messaging/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-12-21 22:54:54 UTC (rev 3755)
@@ -246,156 +246,147 @@
elems.append(self.phase.get_sql_constraint(session, exchange))
return "where %s" % " and ".join(elems)
-class ExchangeAddForm(CuminFieldForm):
- def __init__(self, app, name, task):
- super(ExchangeAddForm, self).__init__(app, name)
+class ExchangeTypeField(RadioItemSetField):
+ def __init__(self, app, name):
+ param = SymbolParameter(app, "param")
+ param.default = "direct"
- self.task = task
+ super(ExchangeTypeField, self).__init__(app, name, param)
- self.vhost = VhostParameter(app, "vhost")
- self.add_parameter(self.vhost)
+ self.add_parameter(param)
- self.exchange_name = ExchangeNameField(app, "exchange_name")
- self.add_field(self.exchange_name)
+ def render_title(self, session):
+ return "Routing"
- self.exchange_type = self.ExchangeTypeField(app, "exchange_type")
- self.add_field(self.exchange_type)
+ def do_get_items(self, session):
+ items = list()
- self.more = MoreFieldSet(app, "more")
- self.add_field(self.more)
+ item = RadioItem("direct")
+ item.title = "Direct"
+ item.description = "Route messages to queues by queue name"
+ items.append(item)
- self.durable = self.ExchangeDurabilityField(app, "durable")
- self.more.add_field(self.durable)
+ item = RadioItem("topic")
+ item.title = "Topic"
+ item.description = "Route messages to topics by matching routing-key pattern"
+ items.append(item)
- self.sequence = self.SequenceField(app, "sequence")
- self.more.add_field(self.sequence)
+ item = RadioItem("fanout")
+ item.title = "Fan out"
+ item.description = \
+ "Route messages to all queues bound to this exchange"
+ items.append(item)
- self.ive = self.IVEField(app, "ive")
- self.more.add_field(self.ive)
+ item = RadioItem("header")
+ item.title = "Header"
+ item.description = \
+ "Route messages to queues by the content of their headers"
+ items.append(item)
- def process_submit(self, session):
- self.check(session)
+ item = RadioItem("xml")
+ item.title = "XML"
+ item.description = "Route messages to queues by their XML content"
+ items.append(item)
- if not self.errors.get(session):
- vhost = self.vhost.get(session)
- name = self.exchange_name.get(session)
- type = self.exchange_type.get(session)
- durable = self.durable.get(session) == "yes"
- sequence = self.sequence.get(session) == "yes"
- ive = self.ive.get(session) == "yes"
+ return items
- self.task.invoke(session, vhost, name, type,
- durable, sequence, ive)
- self.task.exit_with_redirect(session, vhost)
+class ExchangeDurabilityField(RadioItemSetField):
+ def __init__(self, app, name):
+ param = BooleanParameter(app, "param")
+ param.default = True
- def render_title(self, session):
- vhost = self.vhost.get(session)
- return self.task.get_description(session, vhost)
+ super(ExchangeDurabilityField, self).__init__(app, name, param)
- class SequenceField(TwoOptionRadioField):
- def render_title(self, session):
- return "Insert Sequence?"
+ # XXX don't like this
+ self.add_parameter(param)
- def render_field_help(self, session):
- return "(Exchange will insert a 'qpid.msg_sequence' field in the message header)"
+ def render_title(self, session):
+ return "Durability"
- def render_title_1(self, session):
- return "Insert Sequence"
+ def do_get_items(self, session):
+ items = list()
- def render_title_2(self, session):
- return "No Sequence"
+ item = RadioItem(True)
+ item.title = "Durable"
+ item.description = \
+ "Save this exchange definition and restore it when the broker " + \
+ "restarts"
+ items.append(item)
- class IVEField(TwoOptionRadioField):
- def render_title(self, session):
- return "Initial Value Exchange?"
+ item = RadioItem(False)
+ item.title = "Transient"
+ item.description = \
+ "Discard this exchange definition when the broker restarts"
+ items.append(item)
- def render_field_help(self, session):
- return "(Exchange will behave as an 'initial-value-exchange', keeping a reference to the last message forwarded and enqueuing that message to newly bound queues)"
+ return items
- def render_title_1(self, session):
- return "Initial-Value-Exchange"
+class ExchangeArgumentsField(CheckboxItemSetField):
+ def __init__(self, app, name):
+ item_parameter = SymbolParameter(app, "item")
- def render_title_2(self, session):
- return "No IVE"
+ super(ExchangeArgumentsField, self).__init__(app, name, item_parameter)
- class ExchangeDurabilityField(TwoOptionRadioField):
- def render_title(self, session):
- return "Durable?"
+ def do_get_items(self, session):
+ items = list()
- def render_field_help(self, session):
- return "(Queue is durable)"
+ item = CheckboxItem("initial_value")
+ item.title = "Initial value"
+ item.description = "Save the last message encountered and send it to newly bound queues"
+ items.append(item)
- def render_title_1(self, session):
- return "Durable"
+ item = CheckboxItem("message_sequence")
+ item.title = "Sequence numbers"
+ item.description = "Insert a sequence number into the header of each message"
+ items.append(item)
- def render_title_2(self, session):
- return "Transient"
+ return items
- class ExchangeTypeField(RadioField):
- def __init__(self, app, name):
- super(ExchangeAddForm.ExchangeTypeField, self).__init__ \
- (app, name, None)
+ def render_title(self, session):
+ return "Advanced options"
- self.param = Parameter(app, "param")
- self.param.default = "direct"
- self.add_parameter(self.param)
+class ExchangeAddForm(FoldingFieldSubmitForm):
+ def __init__(self, app, name, task):
+ super(ExchangeAddForm, self).__init__(app, name)
- option = self.Direct(app, "direct", self.param)
- self.add_option(option)
+ self.task = task
- option = self.Topic(app, "topic", self.param)
- self.add_option(option)
+ self.vhost = VhostParameter(app, "vhost")
+ self.add_parameter(self.vhost)
- option = self.Fanout(app, "fanout", self.param)
- self.add_option(option)
+ self.exchange_name = ExchangeNameField(app, "exchange_name")
+ self.main_fields.add_field(self.exchange_name)
- option = self.Headers(app, "headers", self.param)
- self.add_option(option)
+ self.exchange_type = ExchangeTypeField(app, "exchange_type")
+ self.main_fields.add_field(self.exchange_type)
- option = self.XML(app, "xml", self.param)
- self.add_option(option)
+ self.durability = ExchangeDurabilityField(app, "durability")
+ self.main_fields.add_field(self.durability)
- def render_title(self, session):
- return "Exchange Type"
+ self.args = ExchangeArgumentsField(app, "args")
+ self.extra_fields.add_field(self.args)
- def render_field_help(self, session):
- return "(Type of exchange to add)"
+ def process_submit(self, session):
+ self.check(session)
- class Direct(RadioFieldOption):
- def render_value(self, session):
- return "direct"
+ if not self.errors.get(session):
+ vhost = self.vhost.get(session)
+ name = self.exchange_name.get(session)
+ type = self.exchange_type.get(session)
+ durable = self.durability.get(session)
+ args = self.args.get(session)
- def render_title(self, session):
- return "<em>Direct:</em> Route messages to queues by queue name"
+ sequence_numbers = "sequence_numbers" in args
+ initial_value = "initial_value" in args
- class Topic(RadioFieldOption):
- def render_value(self, session):
- return "topic"
+ self.task.invoke(session, vhost, name, type,
+ durable, sequence_numbers, initial_value)
+ self.task.exit_with_redirect(session, vhost)
- def render_title(self, session):
- return "<em>Topic:</em> Route messages to queues by topic keyword match"
+ def render_title(self, session):
+ vhost = self.vhost.get(session)
+ return self.task.get_description(session, vhost)
- class Fanout(RadioFieldOption):
- def render_value(self, session):
- return "fanout"
-
- def render_title(self, session):
- return "<em>Fan Out:</em> Route message to all queues attached to this exchange"
-
- class Headers(RadioFieldOption):
- def render_value(self, session):
- return "headers"
-
- def render_title(self, session):
- return "<em>Headers:</em> Route message to queues based on content of the message header"
-
- class XML(RadioFieldOption):
- def render_value(self, session):
- return "xml"
-
- def render_title(self, session):
- return "<em>XML:</em> Route message to queues based on XML content of the message"
-
class ExchangeStats(Widget):
def __init__(self, app, name, exchange):
super(ExchangeStats, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2009-12-21 22:54:54 UTC (rev 3755)
@@ -301,6 +301,7 @@
def render_help_href(self, session, *args):
return "resource?name=help.html#%s" % self.path
+# XXX get rid of this!
class CuminFieldForm(FieldSubmitForm, Frame):
def validate(self, session):
self.check(session)
Modified: mgmt/trunk/wooly/python/wooly/forms.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/forms.py 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/wooly/python/wooly/forms.py 2009-12-21 22:54:54 UTC (rev 3755)
@@ -151,7 +151,7 @@
def __init__(self, app, name):
super(StringInput, self).__init__(app, name, None)
- self.param = Parameter(app, "param")
+ self.param = StringParameter(app, "param")
self.add_parameter(self.param)
self.size = 30
@@ -247,12 +247,61 @@
return "click_button"
class CheckboxInputSet(FormInput, ItemSet):
- def render_item_value(self, session, *args):
+ def render_item_value(self, session, item):
return None
- def render_item_checked_attr(self, session, *args):
+ def render_item_checked_attr(self, session, item):
return None
+class FormInputItemSet(FormInput, ItemSet):
+ def render_item_value(self, session, item):
+ return item.value
+
+ def render_item_title(self, session, item):
+ return item.title
+
+ def render_item_description(self, session, item):
+ return item.description
+
+ def render_item_disabled_attr(self, session, item):
+ if item.disabled:
+ return "disabled=\"disabled\""
+
+class FormInputItem(object):
+ def __init__(self, value):
+ self.value = value
+ self.title = None
+ self.description = None
+ self.disabled = False
+
+class RadioItemSet(FormInputItemSet):
+ def render_item_type(self, session, item):
+ return "radio"
+
+ def render_item_checked_attr(self, session, item):
+ if item.value == self.get(session):
+ return "checked=\"checked\""
+
+class RadioItem(FormInputItem):
+ pass
+
+class CheckboxItemSet(FormInputItemSet):
+ def __init__(self, app, name, item_parameter):
+ super(CheckboxItemSet, self).__init__(app, name, None)
+
+ self.param = ListParameter(app, "param", item_parameter)
+ self.add_parameter(self.param)
+
+ def render_item_type(self, session, item):
+ return "checkbox"
+
+ def render_item_checked_attr(self, session, item):
+ if item.value in self.get(session):
+ return "checked=\"checked\""
+
+class CheckboxItem(FormInputItem):
+ pass
+
class RadioInputSet(ScalarInput, ItemSet):
def render_item_value(self, session, *args):
return None
@@ -297,6 +346,7 @@
def render_help(self, session, *args):
return self.help
+ # XXX hmmm
def render_form_field_class(self, session, *args):
return self.css_class
@@ -440,29 +490,40 @@
class RadioFieldOption(RadioInput):
pass
-class CheckboxField(FormField):
- def __init__(self, app, name):
- super(CheckboxField, self).__init__(app, name)
+class RadioItemSetField(FormField):
+ def __init__(self, app, name, param):
+ super(RadioItemSetField, self).__init__(app, name)
- self.options = list()
+ self.inputs = self.Inputs(app, "inputs", param)
+ self.add_child(self.inputs)
- def add_option(self, option):
- assert isinstance(option, CheckboxFieldOption)
+ def get(self, session):
+ return self.inputs.get(session)
- self.options.append(option)
- self.add_child(option)
+ def do_get_items(self, session):
+ raise Exception("Not implemented")
- def render_inputs(self, session, *args):
- writer = Writer()
+ class Inputs(RadioItemSet):
+ def do_get_items(self, session):
+ return self.parent.do_get_items(session)
- for option in self.options:
- writer.write(option.render(session))
+class CheckboxItemSetField(FormField):
+ def __init__(self, app, name, item_parameter):
+ super(CheckboxItemSetField, self).__init__(app, name)
- return writer.to_string()
+ self.inputs = self.Inputs(app, "inputs", item_parameter)
+ self.add_child(self.inputs)
-class CheckboxFieldOption(CheckboxInput):
- pass
+ def get(self, session):
+ return self.inputs.get(session)
+ def do_get_items(self, session):
+ raise Exception("Not implemented")
+
+ class Inputs(CheckboxItemSet):
+ def do_get_items(self, session):
+ return self.parent.do_get_items(session)
+
class ButtonForm(Form):
def __init__(self, app, name):
super(ButtonForm, self).__init__(app, name)
@@ -594,8 +655,8 @@
def check(self, session):
super(FoldingFieldSubmitForm, self).check(session)
- self.main.check(session)
- self.extra.check(session)
+ self.main_fields.check(session)
+ self.extra_fields.check(session)
def render_content(self, session, *args):
return self.content.render(session, *args)
Modified: mgmt/trunk/wooly/python/wooly/forms.strings
===================================================================
--- mgmt/trunk/wooly/python/wooly/forms.strings 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/wooly/python/wooly/forms.strings 2009-12-21 22:54:54 UTC (rev 3755)
@@ -86,24 +86,62 @@
[RadioInput.html]
<input type="radio" id="{id}" name="{name}" value="{value}" tabindex="{tab_index}" {checked_attr} {disabled_attr}/>
-[CheckboxInputSet.html]
+[RadioInputSet.html]
<ul>{items}</ul>
-[CheckboxInputSet.item_html]
+[RadioInputSet.item_html]
<li>
- <input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
+ <input type="radio" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
{item_content}
</li>
-[RadioInputSet.html]
+[CheckboxInputSet.html]
<ul>{items}</ul>
-[RadioInputSet.item_html]
+[CheckboxInputSet.item_html]
<li>
- <input type="radio" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
+ <input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
{item_content}
</li>
+[FormInputItemSet.css]
+table.FormInputItemSet {
+ border-collapse: collapse;
+}
+
+table.FormInputItemSet > tbody > tr {
+ vertical-align: top;
+}
+
+table.FormInputItemSet > tbody > tr > td {
+ padding: 0 0.5em 0.5em 0;
+ font-size: 0.9em;
+}
+
+table.FormInputItemSet > tbody > tr > td > input {
+ margin: 0.25em 0 0 0;
+}
+
+table.FormInputItemSet > tbody > tr > td > label {
+ font-weight: bold;
+ display: block;
+}
+
+[FormInputItemSet.html]
+<table class="FormInputItemSet"><tbody>{items}</tbody></table>
+
+[FormInputItemSet.item_html]
+<tr>
+ <td>
+ <input id="{id}.{item_value}" type="{item_type}" name="{name}" value="{item_value}"
+ tabindex="{tab_index}" {item_checked_attr} {item_disabled_attr}/>
+ </td>
+ <td>
+ <label for="{id}.{item_value}">{item_title}</label>
+ {item_description}
+ </td>
+</tr>
+
[OptionInputSet.html]
<select name="{name}" tabindex="{tab_index}" {disabled_attr}>{items}</select>
@@ -223,13 +261,6 @@
<label for="{id}">{title}</label>
</div>
-[CheckboxFieldOption.html]
-<div>
- <input type="checkbox" name="{name}" id="{id}" value="{value}"
- tabindex="{tab_index}" {checked_attr} {disabled_attr}/>
- <label for="{id}">{title}</label>
-</div>
-
[ButtonForm.css]
form.ButtonForm {
background-color: #fafafa;
Modified: mgmt/trunk/wooly/python/wooly/parameters.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/parameters.py 2009-12-21 15:12:54 UTC (rev 3754)
+++ mgmt/trunk/wooly/python/wooly/parameters.py 2009-12-21 22:54:54 UTC (rev 3755)
@@ -73,6 +73,13 @@
def do_marshal(self, object):
return self.item_parameter.do_marshal(object)
+class StringParameter(Parameter):
+ pass
+
+# XXX this will be a strict sort of string parameter
+class SymbolParameter(StringParameter):
+ pass
+
class IntegerParameter(Parameter):
def do_unmarshal(self, string):
try:
15 years
rhmessaging commits: r3754 - mgmt/trunk/cumin/python/cumin/account.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-21 10:12:54 -0500 (Mon, 21 Dec 2009)
New Revision: 3754
Modified:
mgmt/trunk/cumin/python/cumin/account/widgets.py
Log:
Convert ChangePasswordForm to use FieldSubmitForm; fix an error accessing the login session; consolidate input checks
Modified: mgmt/trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.py 2009-12-21 14:52:26 UTC (rev 3753)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.py 2009-12-21 15:12:54 UTC (rev 3754)
@@ -148,33 +148,38 @@
def render_content(self, session):
return "Submit"
-class ChangePasswordForm(CuminFieldForm):
+class ChangePasswordForm(FieldSubmitForm):
def __init__(self, app, name, task):
super(ChangePasswordForm, self).__init__(app, name)
self.task = task
- self.__current = self.Current(app, "current")
- self.add_field(self.__current)
- self.__current.input.size = 20
+ self.current = self.Current(app, "current")
+ self.current.required = True
+ self.current.input.size = 20
+ self.add_field(self.current)
- self.__new0 = self.New0(app, "new0")
- self.add_field(self.__new0)
- self.__new0.input.size = 20
+ self.new0 = self.New0(app, "new0")
+ self.new0.required = True
+ self.new0.input.size = 20
+ self.add_field(self.new0)
- self.__new1 = self.New1(app, "new1")
- self.add_field(self.__new1)
- self.__new1.input.size = 20
+ self.new1 = self.New1(app, "new1")
+ self.new1.required = True
+ self.new1.input.size = 20
+ self.add_field(self.new1)
- def process_submit(self, session):
- curr = self.__current.get(session)
- new0 = self.__new0.get(session)
- new1 = self.__new1.get(session)
+ def check(self, session):
+ super(ChangePasswordForm, self).check(session)
- subject = session.user_session.subject
- crypted = subject.password
+ current = self.current.get(session)
+ new0 = self.new0.get(session)
+ new1 = self.new1.get(session)
- if crypt_password(curr, crypted) != crypted:
+ user = session.client_session.attributes["login_session"].user
+ crypted = user.password
+
+ if crypt_password(current, crypted) != crypted:
error = FormError("The password is incorrect")
self.errors.add(session, error)
@@ -182,12 +187,16 @@
error = FormError("The new passwords do not match")
self.errors.add(session, error)
+ def process_submit(self, session):
self.check(session)
if not self.errors.get(session):
- self.task.invoke(session, subject, new0)
- self.task.exit_with_redirect(session, subject)
+ user = session.client_session.attributes["login_session"].user
+ password = self.new0.get(session)
+ self.task.invoke(session, user, password)
+ self.task.exit_with_redirect(session, user)
+
def render_title(self, session):
return "Change password"
15 years
rhmessaging commits: r3753 - in mgmt/trunk: wooly/python/wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-21 09:52:26 -0500 (Mon, 21 Dec 2009)
New Revision: 3753
Modified:
mgmt/trunk/cumin/python/cumin/grid/submission.py
mgmt/trunk/wooly/python/wooly/forms.py
Log:
Add a 'folding' form widget with a showable extra field set; use it for the submission add form
Modified: mgmt/trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-12-21 14:48:13 UTC (rev 3752)
+++ mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-12-21 14:52:26 UTC (rev 3753)
@@ -108,7 +108,7 @@
def render_title(self, session):
return "Jobs"
-class SubmissionAddForm(FieldSubmitForm):
+class SubmissionAddForm(FoldingFieldSubmitForm):
def __init__(self, app, name, task):
super(SubmissionAddForm, self).__init__(app, name)
@@ -117,71 +117,61 @@
self.task = task
- self.content = Widget(app, "fields")
- self.add_child(self.content)
-
- self.main = FormFieldSet(app, "main")
- self.content.add_child(self.main)
-
- self.extra = ShowableFieldSet(app, "extra")
- self.content.add_child(self.extra)
-
from scheduler import SchedulerSelectField # XXX
self.scheduler = SchedulerSelectField(app, "scheduler", self.pool)
self.scheduler.required = True
self.scheduler.help = "Create submission at this scheduler"
- self.main.add_field(self.scheduler)
+ self.main_fields.add_field(self.scheduler)
self.description = self.DescriptionField(app, "description")
self.description.input.size = 50
self.description.required = True
self.description.help = "This text will identify the submission"
- self.main.add_field(self.description)
+ self.main_fields.add_field(self.description)
self.command = self.CommandField(app, "command")
self.command.input.columns = 50
self.command.required = True
self.command.help = "The path to the executable and any arguments"
- self.main.add_field(self.command)
+ self.main_fields.add_field(self.command)
self.requirements = self.RequirementsField(app, "requirements")
self.requirements.input.columns = 50
self.requirements.help = "Attributes controlling where and when " + \
"this submission will run"
-
- self.main.add_field(self.requirements)
+ self.main_fields.add_field(self.requirements)
self.directory = self.WorkingDirectoryField(app, "directory")
self.directory.input.size = 50
self.directory.help = "Run the process in this directory"
- self.extra.add_field(self.directory)
+ self.extra_fields.add_field(self.directory)
self.stdin = self.StdinField(app, "stdin")
self.stdin.input.size = 50
self.stdin.help = "Get process input from this file"
- self.extra.add_field(self.stdin)
+ self.extra_fields.add_field(self.stdin)
self.stdout = self.StdoutField(app, "stdout")
self.stdout.input.size = 50
self.stdout.help = "Send process output to this file"
- self.extra.add_field(self.stdout)
+ self.extra_fields.add_field(self.stdout)
self.stderr = self.StderrField(app, "stderr")
self.stderr.input.size = 50
self.stderr.help = "Send error output to this file"
- self.extra.add_field(self.stderr)
+ self.extra_fields.add_field(self.stderr)
#self.options = self.OptionsField(app, "options")
#self.main.add_field(self.options)
self.attributes_ = self.AttributesField(app, "attributes")
self.attributes_.input.columns = 50
- self.extra.add_field(self.attributes_)
+ self.extra_fields.add_field(self.attributes_)
def check(self, session):
- self.main.check(session)
- self.extra.check(session)
+ self.main_fields.check(session)
+ self.extra_fields.check(session)
def process_submit(self, session):
self.check(session)
Modified: mgmt/trunk/wooly/python/wooly/forms.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/forms.py 2009-12-21 14:48:13 UTC (rev 3752)
+++ mgmt/trunk/wooly/python/wooly/forms.py 2009-12-21 14:52:26 UTC (rev 3753)
@@ -470,8 +470,6 @@
self.error_display = FormErrorSet(app, "errors")
self.add_child(self.error_display)
- self.content = None
-
self.buttons = list()
def add_button(self, button):
@@ -485,7 +483,7 @@
return self.error_display.render(session, *args)
def render_content(self, session, *args):
- return self.content.render(session, *args)
+ raise Exception("Not implemented")
def render_buttons(self, session, *args):
writer = Writer()
@@ -576,3 +574,28 @@
super(FieldSubmitForm, self).check(session)
self.content.check(session)
+
+ def render_content(self, session, *args):
+ return self.content.render(session, *args)
+
+class FoldingFieldSubmitForm(SubmitForm):
+ def __init__(self, app, name):
+ super(FoldingFieldSubmitForm, self).__init__(app, name)
+
+ self.content = Widget(app, "fields")
+ self.add_child(self.content)
+
+ self.main_fields = FormFieldSet(app, "main")
+ self.content.add_child(self.main_fields)
+
+ self.extra_fields = ShowableFieldSet(app, "extra")
+ self.content.add_child(self.extra_fields)
+
+ def check(self, session):
+ super(FoldingFieldSubmitForm, self).check(session)
+
+ self.main.check(session)
+ self.extra.check(session)
+
+ def render_content(self, session, *args):
+ return self.content.render(session, *args)
15 years
rhmessaging commits: r3752 - mgmt/trunk/cumin/python/cumin/messaging.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-21 09:48:13 -0500 (Mon, 21 Dec 2009)
New Revision: 3752
Modified:
mgmt/trunk/cumin/python/cumin/messaging/queue.py
Log:
Use a standard FieldSubmitForm
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-12-18 18:07:38 UTC (rev 3751)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-12-21 14:48:13 UTC (rev 3752)
@@ -514,7 +514,7 @@
self.object = QueueParameter(app, "queue")
self.add_parameter(self.object)
-class QueuePurgeForm(CuminFieldForm):
+class QueuePurgeForm(FieldSubmitForm):
def __init__(self, app, name, task):
super(QueuePurgeForm, self).__init__(app, name)
@@ -528,31 +528,27 @@
def render_title(self, session):
queue = self.queue.get(session)
- return "Purge Messages from Queue '%s'" % queue.name
+ return self.task.get_description(session, queue)
def process_submit(self, session):
- queue = self.queue.get(session)
- request_amt = self.purge_request.get(session)
+ self.check(session)
- if request_amt == "all":
- count = 0
- elif request_amt == "top":
- count = 1
- elif request_amt == "N":
- count = self.purge_request.top_n.get_n_value(session)
- else:
- raise Exception("Wrong Value")
+ if not self.errors.get(session):
+ queue = self.queue.get(session)
+ request_amt = self.purge_request.get(session)
- self.task.invoke(session, queue, count)
- self.task.exit_with_redirect(session, queue)
+ if request_amt == "all":
+ count = 0
+ elif request_amt == "top":
+ count = 1
+ elif request_amt == "N":
+ count = self.purge_request.top_n.get_n_value(session)
+ else:
+ raise Exception("Wrong Value")
- def render_submit_content(self, session):
- queue = self.queue.get(session)
- return "Yes, Purge Messages from Queue '%s'" % queue.name
+ self.task.invoke(session, queue, count)
+ self.task.exit_with_redirect(session, queue)
- def render_cancel_content(self, session):
- return "No, Cancel"
-
class QueueSetTaskForm(CuminTaskForm):
def __init__(self, app, name, task):
super(QueueSetTaskForm, self).__init__(app, name, task)
15 years
rhmessaging commits: r3751 - store/trunk/cpp/tests/new_python_tests.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-12-18 13:07:38 -0500 (Fri, 18 Dec 2009)
New Revision: 3751
Added:
store/trunk/cpp/tests/new_python_tests/client_persistence.py
Removed:
store/trunk/cpp/tests/new_python_tests/client_persistence_tests.py
Modified:
store/trunk/cpp/tests/new_python_tests/__init__.py
Log:
Updated tests for AlternateExchange; added test for redelivered flag.
Modified: store/trunk/cpp/tests/new_python_tests/__init__.py
===================================================================
--- store/trunk/cpp/tests/new_python_tests/__init__.py 2009-12-16 19:39:16 UTC (rev 3750)
+++ store/trunk/cpp/tests/new_python_tests/__init__.py 2009-12-18 18:07:38 UTC (rev 3751)
@@ -21,4 +21,4 @@
#
# The GNU Lesser General Public License is available in the file COPYING.
-from client_persistence_tests import *
+from client_persistence import *
Copied: store/trunk/cpp/tests/new_python_tests/client_persistence.py (from rev 3750, store/trunk/cpp/tests/new_python_tests/client_persistence_tests.py)
===================================================================
--- store/trunk/cpp/tests/new_python_tests/client_persistence.py (rev 0)
+++ store/trunk/cpp/tests/new_python_tests/client_persistence.py 2009-12-18 18:07:38 UTC (rev 3751)
@@ -0,0 +1,136 @@
+# Copyright (c) 2008 Red Hat, Inc.
+#
+# This file is part of the Qpid async store library msgstore.so.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+#
+# The GNU Lesser General Public License is available in the file COPYING.
+
+from qpid.brokertest import *
+from qpid.messaging import Message
+from qmf.console import Session
+
+class Qmf:
+ """
+ QMF functions not yet available in the new QMF API. Remove this and replace with new API when it becomes available.
+ """
+ def __init__(self, broker):
+ self.__session = Session()
+ self.__broker = self.__session.addBroker("amqp://localhost:%d"%broker.port())
+
+ def addExchange(self, exchangeName, exchangeType, altExchangeName=None, passive=False, durable=False, arguments = {}):
+ """Add a new exchange"""
+ amqpSession = self.__broker.getAmqpSession()
+ if altExchangeName:
+ amqpSession.exchange_declare(exchange=exchangeName, type=exchangeType, alternate_exchange=altExchangeName, passive=passive, durable=durable, arguments=arguments)
+ else:
+ amqpSession.exchange_declare(exchange=exchangeName, type=exchangeType, passive=passive, durable=durable, arguments=arguments)
+
+ def addQueue(self, queueName, altExchangeName=None, passive=False, durable=False, arguments = {}):
+ """Add a new queue"""
+ amqpSession = self.__broker.getAmqpSession()
+ if altExchangeName:
+ amqpSession = amqpSession.queue_declare(queueName, alternate_exchange=altExchangeName, passive=passive, durable=durable, arguments=arguments)
+ else:
+ amqpSession = amqpSession.queue_declare(queueName, passive=passive, durable=durable, arguments=arguments)
+
+ def __query(self, name, _class, package, altExchangeName=None):
+ try:
+ objList = self.__session.getObjects(_class=_class, _package=package)
+ found = False
+ for o in objList:
+ if o.name == name:
+ found = True
+ if altExchangeName != None:
+ altExchList = self.__session.getObjects(_objectId=o.altExchange)
+ if len(altExchList) == 0 or altExchList[0].name != altExchangeName: return False
+ break
+ return found
+ except: return False
+
+
+ def queryExchange(self, exchangeName, altExchangeName=None):
+ """Test for the presence of an exchange, and optionally whether it has an alternate exchange set to a known value."""
+ return self.__query(exchangeName, "exchange", "org.apache.qpid.broker", altExchangeName)
+
+ def queryQueue(self, queueName, altExchangeName=None):
+ """Test for the presence of an exchange, and optionally whether it has an alternate exchange set to a known value."""
+ return self.__query(queueName, "queue", "org.apache.qpid.broker", altExchangeName)
+
+
+class AlternateExchagePropertyTests(BrokerTest):
+ """
+ Test the persistence of the Alternate Exchange property for exchanges and queues.
+ """
+
+ def __args(self):
+ assert BrokerTest.store_lib
+ return ["--load-module", BrokerTest.store_lib]
+
+ def testExchange(self):
+ """Exchange alternate exchange property persistence test"""
+ broker = self.broker(self.__args(), name="testBroker", expect=EXPECT_EXIT_FAIL)
+ qmf = Qmf(broker)
+ qmf.addExchange("altExch", "direct", durable=True) # Serves as alternate exchange instance
+ qmf.addExchange("testExch", "direct", durable=True, altExchangeName="altExch")
+ broker.kill()
+
+ broker = self.broker(self.__args(), name="testBroker")
+ qmf = Qmf(broker)
+ try: qmf.addExchange("altExch", "direct", passive=True)
+ except Exception, e: self.fail("Alternate exchange (\"altExch\") instance not recovered: %s" % e)
+ try: qmf.addExchange("testExch", "direct", passive=True)
+ except Exception, e: self.fail("Test exchange (\"testExch\") instance not recovered: %s" % e)
+ self.assertTrue(qmf.queryExchange("testExch", altExchangeName = "altExch"), "Alternate exchange property not found or is incorrect on exchange \"testExch\".")
+
+ def testQueue(self):
+ """Queue alternate exchange property persistexchangeNamece test"""
+ broker = self.broker(self.__args(), name="testBroker", expect=EXPECT_EXIT_FAIL)
+ qmf = Qmf(broker)
+ qmf.addExchange("altExch", "direct", durable=True) # Serves as alternate exchange instance
+ qmf.addQueue("testQueue", durable=True, altExchangeName="altExch")
+ broker.kill()
+
+ broker = self.broker(self.__args(), name="testBroker")
+ qmf = Qmf(broker)
+ try: qmf.addExchange("altExch", "direct", passive=True)
+ except Exception, e: self.fail("Alternate exchange (\"altExch\") instance not recovered: %s" % e)
+ try: qmf.addQueue("testQueue", passive=True)
+ except Exception, e: self.fail("Test queue (\"testQueue\") instance not recovered: %s" % e)
+ self.assertTrue(qmf.queryQueue("testQueue", altExchangeName = "altExch"), "Alternate exchange property not found or is incorrect on queue \"testQueue\".")
+
+
+class RedeliveredTests(BrokerTest):
+ """
+ Test the behavior of the redelivered flag in the context of persistence
+ """
+
+ def __args(self):
+ assert BrokerTest.store_lib
+ return ["--load-module", BrokerTest.store_lib]
+
+ def testBrokerRecovery(self):
+ """Test that the redelivered flag is set on messages after recovery of broker"""
+ broker = self.broker(self.__args(), name="testAfterRecover", expect=EXPECT_EXIT_FAIL)
+ mc = "xyz"*100
+ m = Message(mc, durable=True)
+ broker.send_message("testQueue", m)
+ broker.kill()
+ broker = self.broker(self.__args(), name="testAfterRecover")
+ rm = broker.get_message("testQueue")
+ self.assertEqual(mc, rm.content)
+ self.assertTrue(rm.redelivered)
+
\ No newline at end of file
Deleted: store/trunk/cpp/tests/new_python_tests/client_persistence_tests.py
===================================================================
--- store/trunk/cpp/tests/new_python_tests/client_persistence_tests.py 2009-12-16 19:39:16 UTC (rev 3750)
+++ store/trunk/cpp/tests/new_python_tests/client_persistence_tests.py 2009-12-18 18:07:38 UTC (rev 3751)
@@ -1,94 +0,0 @@
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This file is part of the Qpid async store library msgstore.so.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-# USA
-#
-# The GNU Lesser General Public License is available in the file COPYING.
-
-from qpid.brokertest import *
-from qpid.messaging import Message
-from qmf.console import Session
-
-
-
-class AlternateExchageTests(BrokerTest):
- """
- Test the persistence of the Alternate Exchange property for exchanges and queues.
- """
-
- def args(self):
- assert BrokerTest.store_lib
- return ["--load-module", BrokerTest.store_lib]
-
- def testExchangeAlternateExchangeProperty(self):
- """Exchange alternate exchange property persistence test"""
-
- brokerName = "TestQueueAlternateExchange"
- exchangeName = "TestExchange"
- alternateExchangeName = "TestAlternateExchange"
-
- broker = self.broker(self.args(), name=brokerName, expect=EXPECT_EXIT_FAIL)
- # Use old API until new one can handle these operations
- connection = broker.connect_old()
- session = connection.session(str(qpid.datatypes.uuid4()))
- session.exchange_declare(exchange=alternateExchangeName, type="direct", durable=True)
- session.exchange_declare(exchange=exchangeName, type="direct", alternate_exchange=alternateExchangeName, durable=True)
- connection.close()
- broker.kill()
-
- broker = self.broker(self.args(), name=brokerName)
- connection = broker.connect_old()
- session = connection.session(str(qpid.datatypes.uuid4()))
- session.exchange_declare(exchange=alternateExchangeName, type="direct", durable=True, passive=True)
- session.exchange_declare(exchange=exchangeName, type="direct", durable=True, passive=True)
- # There is no AMQP support for directly querying exchanges for alternate-exchange (unlike queues)!!,
- # so use QMF instead.
- qmfSession = Session()
- qmfBroker = qmfSession.addBroker("amqp://localhost:%d"%broker.port())
- exchanges = qmfSession.getObjects(_class="exchange", _package="org.apache.qpid.broker")
- for e in exchanges:
- if e.name == exchangeName:
- altExch = qmfSession.getObjects(_objectId=e.altExchange)
- alternateExchangeNameProps = altExch[0].getProperties()
- self.assertEqual(altExch[0].name, alternateExchangeName)
-
- connection.close()
-
- def testQueueAlternateExchangeProperty(self):
- """Queue alternate exchange property persistexchangeNamece test"""
-
- brokerName = "TestQueueAlternateExchange"
- queueName = "TestQueue"
- alternateExchangeName = "TestAlternateExchange"
-
- broker = self.broker(self.args(), name=brokerName, expect=EXPECT_EXIT_FAIL)
- # Use old API until new one can handle these operations
- connection = broker.connect_old()
- session = connection.session(str(qpid.datatypes.uuid4()))
- session.exchange_declare(exchange=alternateExchangeName, type="direct", durable=True)
- session.queue_declare(queue=queueName, alternate_exchange=alternateExchangeName, durable=True)
- connection.close()
- broker.kill()
-
- broker = self.broker(self.args(), name=brokerName)
- connection = broker.connect_old()
- session = connection.session(str(qpid.datatypes.uuid4()))
- session.exchange_declare(exchange=alternateExchangeName, type="direct", durable=True, passive=True)
- session.queue_declare(queue=queueName, alternate_exchange=alternateExchangeName, durable=True, passive=True)
- self.assertEqual(session.queue_query(queue=queueName)["alternate_exchange"], alternateExchangeName)
-
- connection.close()
15 years
rhmessaging commits: r3750 - mgmt/trunk/mint/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-16 14:39:16 -0500 (Wed, 16 Dec 2009)
New Revision: 3750
Modified:
mgmt/trunk/mint/bin/mint-database
Log:
A better access check
Modified: mgmt/trunk/mint/bin/mint-database
===================================================================
--- mgmt/trunk/mint/bin/mint-database 2009-12-16 19:30:03 UTC (rev 3749)
+++ mgmt/trunk/mint/bin/mint-database 2009-12-16 19:39:16 UTC (rev 3750)
@@ -127,7 +127,7 @@
# Is it accessible?
# Does it have a schema loaded?
- run "psql -c '\q'" postgres || {
+ run "psql -d cumin -U cumin -h localhost -c '\q'" postgres || {
echo "The database is not accessible"
exit 1
}
15 years
rhmessaging commits: r3749 - mgmt/trunk/mint/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-16 14:30:03 -0500 (Wed, 16 Dec 2009)
New Revision: 3749
Modified:
mgmt/trunk/mint/bin/mint-database
Log:
Restart postgres if we had to stop it
Modified: mgmt/trunk/mint/bin/mint-database
===================================================================
--- mgmt/trunk/mint/bin/mint-database 2009-12-16 18:48:36 UTC (rev 3748)
+++ mgmt/trunk/mint/bin/mint-database 2009-12-16 19:30:03 UTC (rev 3749)
@@ -142,11 +142,15 @@
exit 1
fi
+ local i_stopped_postgres=""
+
if run "/sbin/service postgresql status"; then
- echo "The database is running. To proceed with configuration, I need to stop it."
+ echo "The database is running. To proceed with configuration, I need to stop it"
+ echo "(I'll start it again after I'm done)."
if confirmed; then
run "/sbin/service postgresql stop"
+ i_stopped_postgres="yes"
fi
fi
@@ -160,6 +164,10 @@
modify-postgresql-config
+ if [[ "$i_stopped_postgres" == "yes" ]]; then
+ run "/sbin/service postgresql start"
+ fi
+
echo "The database is configured. You can now run 'mint-database create'."
# chkconfig stuff ?
15 years
rhmessaging commits: r3748 - mgmt/trunk/wooly.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-16 13:48:36 -0500 (Wed, 16 Dec 2009)
New Revision: 3748
Modified:
mgmt/trunk/wooly/Makefile
Log:
Update makefile for wsgiserver's code reorg
Modified: mgmt/trunk/wooly/Makefile
===================================================================
--- mgmt/trunk/wooly/Makefile 2009-12-16 18:24:45 UTC (rev 3747)
+++ mgmt/trunk/wooly/Makefile 2009-12-16 18:48:36 UTC (rev 3748)
@@ -12,7 +12,9 @@
install: build
install -d ${lib}
- install -pm 0644 python/wooly/*.py python/wooly/*.pyc python/wooly/*.strings ${PYTHON_LIB_DIR}/wooly
+ install -pm 0644 python/wooly/*.py python/wooly/*.pyc python/wooly/*.strings ${lib}
+ install -d ${lib}/wsgiserver
+ install -pm 0644 python/wooly/wsgiserver/*.py python/wooly/wsgiserver/*.pyc ${lib}/wsgiserver
install -d ${doc}
install -pm 0644 LICENSE* COPYING* ${doc}
install -d ${share}/resources
15 years
rhmessaging commits: r3747 - store/trunk/cpp/lib.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-12-16 13:24:45 -0500 (Wed, 16 Dec 2009)
New Revision: 3747
Modified:
store/trunk/cpp/lib/MessageStoreImpl.cpp
Log:
Partial fix for BZ 508144 - this turns on the redelivered flag for all messages which are recovered. Requires qpid r.891362.
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-16 16:52:51 UTC (rev 3746)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-16 18:24:45 UTC (rev 3747)
@@ -926,6 +926,9 @@
msg = recovery.recoverMessage(headerBuff);
}
msg->setPersistenceId(dtok.rid());
+ // At some future point if delivery attempts are stored, then this call would
+ // become optional depending on that information.
+ msg->setRedelivered();
u_int32_t contentOffset = headerSize + preambleLength;
u_int64_t contentSize = readSize - contentOffset;
15 years
rhmessaging commits: r3746 - in mgmt/trunk: wooly/python/wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2009-12-16 11:52:51 -0500 (Wed, 16 Dec 2009)
New Revision: 3746
Modified:
mgmt/trunk/basil/python/basil/model.py
mgmt/trunk/wooly/python/wooly/bench.py
mgmt/trunk/wooly/python/wooly/profile.py
mgmt/trunk/wooly/python/wooly/util.py
Log:
defaultdict isn't available in python 2.4; create one as needed
Modified: mgmt/trunk/basil/python/basil/model.py
===================================================================
--- mgmt/trunk/basil/python/basil/model.py 2009-12-16 16:19:00 UTC (rev 3745)
+++ mgmt/trunk/basil/python/basil/model.py 2009-12-16 16:52:51 UTC (rev 3746)
@@ -1,7 +1,9 @@
-from collections import defaultdict, deque
+from collections import deque
from qmf.console import *
from threading import Lock
+from util import *
+
class BasilModel(object):
def __init__(self):
super(BasilModel, self).__init__()
Modified: mgmt/trunk/wooly/python/wooly/bench.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/bench.py 2009-12-16 16:19:00 UTC (rev 3745)
+++ mgmt/trunk/wooly/python/wooly/bench.py 2009-12-16 16:52:51 UTC (rev 3746)
@@ -1,12 +1,7 @@
-import os
-import sys
-
-from collections import defaultdict
-from traceback import print_exc
-from time import time
from xml.parsers.expat import ParserCreate
from wooly import Session, ClientSession
+from util import *
class BenchmarkHarness(object):
def __init__(self, app):
Modified: mgmt/trunk/wooly/python/wooly/profile.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/profile.py 2009-12-16 16:19:00 UTC (rev 3745)
+++ mgmt/trunk/wooly/python/wooly/profile.py 2009-12-16 16:52:51 UTC (rev 3746)
@@ -1,8 +1,5 @@
-import sys
+from util import *
-from time import time
-from collections import defaultdict
-
class PageProfile(object):
def __init__(self, page):
self.page = page
@@ -140,7 +137,7 @@
def do(self, session):
self.profile.current_calls.append(self)
- self.start = time()
+ self.start = time.time()
if self.widget.update_enabled:
self.widget.page.enable_update(session, self.widget)
@@ -151,7 +148,7 @@
args = self.widget.get_args(session)
self.widget.do_process(session, *args)
- self.end = time()
+ self.end = time.time()
self.profile.current_calls.pop()
self.profile.process_calls.append(self)
@@ -160,7 +157,7 @@
def do(self, session):
self.profile.current_calls.append(self)
- self.start = time()
+ self.start = time.time()
args = self.widget.get_args(session)
result = self.widget.do_render(session, *args)
@@ -168,7 +165,7 @@
if result is None:
result = ""
- self.end = time()
+ self.end = time.time()
assert self.start < self.end
Modified: mgmt/trunk/wooly/python/wooly/util.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/util.py 2009-12-16 16:19:00 UTC (rev 3745)
+++ mgmt/trunk/wooly/python/wooly/util.py 2009-12-16 16:52:51 UTC (rev 3746)
@@ -1,8 +1,11 @@
import logging
+import os
import random
+import sys
+import time
from datetime import datetime
-from time import clock
+from traceback import print_exc
def unique_id():
bits0 = random.getrandbits(32)
@@ -11,3 +14,21 @@
bits3 = random.getrandbits(32)
return "%08x-%08x-%08x-%08x" % (bits0, bits1, bits2, bits3)
+
+try:
+ from collections import defaultdict
+except ImportError:
+ class defaultdict(dict):
+ def __init__(self, default_factory=None):
+ super(dict, self).__init__()
+
+ self.default_factory = default_factory
+
+ def __getitem__(self, key):
+ try:
+ super(dict, self).__getitem__(key)
+ except KeyError:
+ if self.default_factory is None:
+ raise
+ else:
+ return self.default_factory()
15 years