[Checkins] SVN: megrok.quarry/trunk/src/megrok/quarry/ * added
workaround for DatetimeValue
Kevin Smith
kevin at mcweekly.com
Tue May 8 01:05:52 EDT 2007
Log message for revision 75619:
* added workaround for DatetimeValue
* update quarry.template, searches __class__ then __module__ if no dot
present in the name for string or pagetemplate
class MyView(quarry.View):
"""<h2>Success</h2>"""
quarry.template('__doc__')
Changed:
U megrok.quarry/trunk/src/megrok/quarry/components.py
U megrok.quarry/trunk/src/megrok/quarry/index.py
U megrok.quarry/trunk/src/megrok/quarry/meta.py
-=-
Modified: megrok.quarry/trunk/src/megrok/quarry/components.py
===================================================================
--- megrok.quarry/trunk/src/megrok/quarry/components.py 2007-05-08 03:38:00 UTC (rev 75618)
+++ megrok.quarry/trunk/src/megrok/quarry/components.py 2007-05-08 05:05:52 UTC (rev 75619)
@@ -26,6 +26,22 @@
namespace['static'] = self.static
return self.template.pt_render(namespace)
+ def application(self):
+ obj = self.context
+ while obj is not None:
+ if isinstance(obj, grok.Application):
+ return obj
+ obj = obj.__parent__
+ raise ValueErrror("No application found.")
+
+ def site(self):
+ obj = self.context
+ while obj is not None:
+ if isinstance(obj, grok.Site):
+ return obj
+ obj = obj.__parent__
+ raise ValueErrror("No site found.")
+
def application_url(self):
obj = self.context
while obj is not None:
@@ -73,8 +89,19 @@
interface.Interface,
name=self.module_info.package_dotted_name
)
+ # static files for closest application
+ self.app_static = component.queryAdapter(
+ self.request,
+ interface.Interface,
+ name=self.application().__name__)
+ # static files for closest site
+ self.site_static = component.queryAdapter(
+ self.request,
+ interface.Interface,
+ name=self.site().__name__)
+
def __call__(self):
mapply(self.update, (), self.request)
if self.request.response.getStatus() in (302, 303):
Modified: megrok.quarry/trunk/src/megrok/quarry/index.py
===================================================================
--- megrok.quarry/trunk/src/megrok/quarry/index.py 2007-05-08 03:38:00 UTC (rev 75618)
+++ megrok.quarry/trunk/src/megrok/quarry/index.py 2007-05-08 05:05:52 UTC (rev 75619)
@@ -14,8 +14,11 @@
class DatetimeValue(IndexDefinition):
- index_class = DateTimeValueIndex
+ @property
+ def index_class(self):
+ #import pdb; pdb.set_trace()
+ return DateTimeValueIndex
class DatetimeSet(IndexDefinition):
Modified: megrok.quarry/trunk/src/megrok/quarry/meta.py
===================================================================
--- megrok.quarry/trunk/src/megrok/quarry/meta.py 2007-05-08 03:38:00 UTC (rev 75618)
+++ megrok.quarry/trunk/src/megrok/quarry/meta.py 2007-05-08 05:05:52 UTC (rev 75619)
@@ -81,7 +81,12 @@
# no conflicts, lets try and load the template
# using quarry.template('with.dotted.name')
try:
- factory.template = resolve(template_name)
+ if template_name.find('.') < 0:
+ factory.template = getattr(factory, template_name, None)
+ if factory.template is None:
+ factory.template = resolve(template_name, factory.__module__)
+ else:
+ factory.template = resolve(template_name)
# accept string and unicode objects, useful if .__doc__ is referenced
if isinstance(factory.template, (str, unicode)):
factory.template = grok.PageTemplate(factory.template)
More information about the Checkins
mailing list