Posted
about 14 years
ago
by
active questions tagged zope - Stack Overflow
I am trying to dynamically update a form field based on a variable that is included in a HTTP get variable. Specifically www.site.com/form?id=name. I want to pull the 'id' field from the url and automatically populate the memberID field of the form.
... [More]
I have access to the get variable using self.request.get('id'). However I haven't been able to figure out how to update the form field. I examined the widget documentation http://packages.python.org/z3c.form/widget.html but none of the suggestions have worked.
class IUpdateEmailFormSchema(interface.Interface):
# -*- extra stuff goes here -*-
"""
"""
memberID = schema.TextLine(title=(u'Member id'))
email = schema.TextLine(title=(u'Email'), description=(u'The email'))
class updateEmailForm(form.Form):
fields = field.Fields(IUpdateEmailFormSchema)
label = _(u'Change Email')
ignoreContext = True
@button.buttonAndHandler(u'Update')
def handleUpdate(self,action):
data, errors = self.extractData()
if data.has_key('email'):
portal_membership = getToolByName(self.context, 'portal_membership')
member = portal_membership.getMemberById(data['memberID'])
def updateWidgets(self):
print "This is update widget \n\n"
import pdb; pdb.set_trace()
print self.request.form['id'] #Does not work as specified in http://packages.python.org/z3c.form/widget.html
#self.widgets["memberID"].value = self.request.get('id').encode('utf-8')
form.Form.updateWidgets(self)
updateEmailFormView = wrap_form(updateEmailForm)
*Update: updateWidget wasn't correctly indented. [Less]
|
Posted
about 14 years
ago
by
active questions tagged zope - Stack Overflow
I have this scenario:
A web page created with zope/plone and some mine python api. There's a web page, call it "a", that by a python method calls a database (postgres) and returns some information. On page "a" you can modify database data "offline"
... [More]
(I intend that the changes aren't written on db instantly but in a second moment when you press "save" and call a python api method). So, imagine this scenario: an user, called "Sam", loads the page and start to modify data. Meanwhile an user, called "Sara", modifies the db by the page "a" clicking "save". Now Sam doesn't have the actual db data: he'll push "save" and overwrite Sara's data change.
I would have an alert on my page in real time. I thought i can do something like this:
Make an Ajax call, that isn't blockable, and keep going with page render. The Ajax calls a python method that creates a thread that does an infinite loop (on an "X" condition). When I write data on database, i'll call a function that will change "X condition" stopping the thread and returning to Ajax.
Moreover, i can't lock the db because I have to give free access to every user that wants to modify my db.
My problem is: how can I identify a python thread ? I've just saw that every single method on a class that inherit from Thread wants "self" as parameter. Moreover, I have to call the thread as I access the "a" page and this will be somewhere in the code (say on the "threads module") but the inserts are on the other module. So, how can i realize my idea ?
And if someone have an alternative idea, tell me without any problem :)
Thank you in advance and sorry for my bad english.
Regards,
S. [Less]
|
Posted
about 14 years
ago
by
BlueDynamics Alliance - Zope Related
Shortly after Plone 4.2 feature freeze announcement, we - Rok Garbas and
Johannes Raggam - met up to bring plone.app.event [1] forward and see what's
missing to be submitted for the next Plone release. Well, we didn't catch the
deadline, but did
... [More]
some amazing work which will ultimately lead in a better
event implementation.
Rok and me met up on a sunny Saturday morning in Ljubljana. Since there was no
hacker space available to be opened on this weekend - people were on the
seaside, which was actually a very good idea - we developed a new sprint-style:
bar-driven development. We started in a cafe, discussed all TODOs and began to
work on the first couple of tasks. Before we closed the sprint 26 hours later,
we have been in 4 more bars, excluding those we visited without our laptops
[2]. Our only need was free WIFI, power plugs, cafe and drinks. That worked out
very well and was fun too!
Plone.app.event was started at the cologne sprint in march 2010 [3], building
upon previous work like vs.event, Dateable, Kalends and Products.DateRecurringIndex. Now, while discussing
the left over TODOs from the Artsprint 2011 in Vienna [4], we rethought some
design decisions and came to the conclusion, that refactoring of all involved
packages is what we need in order to meet plone.app.event's initial goals: An
encapsulated and independent [a], archetypes and dexterity aware [b], standards
compliant [c], event implementation with support of recurrence [d], a modern
dateinput widget [e], with features like whole-day-events [f] and proper
timezone support [g].
Encapsulation and Independence
To meet the goal [a] - encapsulation, we moved as much as possible event related code out from the
packages Products.CMFCore, plone.app.portlets and Products.ATContentTypes into
plone.app.event [5] and plone.rfc5545 [6] (formerly plone.event). Event the
catalog index registration via Generic Setup was moved out of Products.CMFCore
into plone.app.event, since it's only needed if there are eventish content
types with and start and end dates available. The goal is also to remove the
dependency of Products.CMFCalendar, which functionality should be provided by
plone.app.event then.
Archetypes and Dexterity aware
To support archetypes and at the same time dexterity [b], we factored out
generic code into reusable modules. Plone.rfc5545 is generic without
dependencies to the Plone core and can thus be used independently of Plone. All
Archetypes related code is encapsulated in a submodule of plone.app.event
respectively plone.formwidget.dateinput. A dexterity content type is yet not
available, but will be provided sometime soon.
Standards compliancy
The standards involved [c] covers compliance with the iCalendar standard - also
known as RFC5545 [7], which obsoletes RFC2445. Rok started to create an RFC
compatible serializer which utilizes the Zope's component architecture in a
very smart way. An deserializer can later be added. This might lead sometime
into a (Attention: Utopia!) caldav server which is able to handle
subscriptions from calendar clients like Apples iCal or Mozillas Sunbird. Zope
even provides an webdav interface, so we can build upon a stable
infrastructure. Imagine the awesome capabilities if Plone provides such a
functionality!
Recurrence support
The recurrence support [d] is build upon the library python-dateutil [8],
which itself is RFC2445 compliant. The difference to RFC5545 is mostly, that
RFC5545 does not allow (respectively should not use) more than one recurrence
rule definitions and removes the ability to define exclusion rule sets. The
library handles the calculations of occurrences of an event and can parse RFC
compatible recurrence strings directly. There is also an index, which handles
recurring dates - the package Products.DateRecurringIndex [9]. It is
production ready and works as a direct and transparent replacement of Zope's
DateIndex. If you query for events on a specific date, it will return also
Events, which do not have their start date but a recurrence on the queried
date. If you need all occurrences of an specific event, you have to use a
method on this recurrence-enabled event to get it. The possibility to query the
index for that is - yet - not available. Lennart Regebro, who is also a
specialist on recurring events, delivered another index for that purpose -
the plone.app.eventindex [10]. It does lazy indexing on query time and is an very
interesting alternative. Anyway, the discussion about indexing recurring
events flared up and some open questions regarding indexing performance and
meaningful benchmarks - as well as an still to be polished recurrence input
widget [11] - are the reasons why here is still some more work to do.
Dateinput widget
[e] Plone's current dateinput widget has come into its days. There are fresher
JQuery based alternatives available, especially the JQueryUI Datepicker [12]
and the JQueryTools Dateinput [13]. Since Plone uses JQueryTools we are using
the Datepicker. We developed the package archetypes.datetimewidget as a fork of
collective.z3cforms.datetimewidget. Those packages share a lot of common
functionality, so we merged them into plone.app.dateinput [14]. It's on it's
way.
Whole-day events
Plone.app.event will support whole-day events [f]. Not a big deal, but very
convenient. Whole-day events are still stored with a time component, which for
the start field is set to 0:00 and for the end field to 23:59. The time
component is hidden per JavaScript when selecting the whole-day checkbox.
Timezone support
And finally Timezones [g]: Proper timezone support was long missing in Plone,
it's planned to land in the 4.x series. With plone.app.event, we can
set the Portal's default timezone, a timezone for a specific event (the options
are limited through an available timezones property in plone.app.registry), and
eventually timezones per user. UTC serves as our reference timezone and all
dates are stored in UTC, while the timezone is stored in a separate field. This
makes handling of timezones and converting to different zones for display much more
predictable, since UTC is not subject to change. Internally we rely on the pytz
library instead of Zope-DateTime's own implementation. Pytz [15] is a python
implementation of the Olson Database [16], which is updated several times a
year. Proper timezone support is necessary, especially for recurring events
over Daylight Saving Time changes, where it's necessary to know if or if not a
additional offset has to be added. It's mostly implemented except the support
of user timezones.
What next?
If you want to try everything out, i suggest to use out the pre-refactored
implementation from plone-svn [17]. If you want to try out and test the
refactored cutting edge development version, go for this one: [5]. Run
buildout, run the tests, start the instance (at least for the pre-refactored
version) and start playing.
Vincent Fretin uses the pre-refactored implementation in production. We are
now in a state, where the conceptional refactoring and migration to
plone.app.testing as base test infrastructure is almost done. We have to get
all refactored packages work again and fix all failing tests. The recurrence
widget has to be polished and brought into a workable state, including
javascript tests. The recurrence indexes have to be benchmarked and further
developed. There is still some more work TODO, as you can see here [18].
So come and join in, help with finding and/or fixing bugs, install and test it.
Or maybe finance a sprint or the development itself, if you are in need of
a working event content type and framework implementation, that might be
superior to any calendaring application ever seen on this planet ;).
Contact
For more information contact:
Johannes Raggam <[email protected]>
Rok Garbas <[email protected]>
Vincent Fretin <[email protected]>
BlueDynamics Alliance <[email protected]>
Or one of the contributors listed here [19].
References
[1] http://dev.plone.org/plone/ticket/10886
[2] http://en.wikipedia.org/wiki/Metelkova
[3] http://www.zopyx.de/blog/plone.app.event
[4] http://www.coactivate.org/projects/artsprint2011
[5] https://github.com/collective/plone.app.event
[6] https://github.com/collective/plone.rfc5545
[7] http://tools.ietf.org/html/rfc5545
[8] http://labix.org/python-dateutil
[9] https://github.com/collective/Products.DateRecurringIndex
[10] http://svn.plone.org/svn/collective/plone.app.eventindex/trunk/
[11] https://github.com/collective/plone.formwidget.recurrence
[12] http://jqueryui.com/demos/datepicker/
[13] http://flowplayer.org/tools/demos/dateinput/index.html
[14] https://github.com/collective/plone.formwidget.dateinput
[15] http://pypi.python.org/pypi/pytz/
[16] http://en.wikipedia.org/wiki/Tz_database
[17] https://svn.plone.org/svn/plone/plone.app.event/trunk/
[18] https://github.com/collective/plone.app.event/blob/master/TODO.rst
[19] https://github.com/collective/plone.app.event/blob/master/README.txt [Less]
|
Posted
about 14 years
ago
by
gmane.comp.web.zope.announce
On behalf of the Plone and Zope Security Teams I'd like to draw your
attention to a security announcement that has just been published.
This is a pre-announcement only, it does not contain any vulnerability
details. Your sites are a safe today as
... [More]
they were yesterday. However,
as the problem that has been found is so serious we are giving you
advance warning that a patch is upcoming and recommending that you
plan a maintenance period for your sites to coincide with the full
announcement on Tuesday next week.
Full details are available at
http://plone.org/products/plone/security/advisories/pre-announcement-20110622
You can feel free to ask more questions on the plone-users mailing
list or in the #plone IRC channel about details and how to protect
yourself, but it is important to make a plan for this now. It is
important to plan down-time at the time specified in that announcement
or your site will potentially be at risk - following the release of a
hotfix for the previous serious security vulnerability we [Less]
|
Posted
about 14 years
ago
by
Plone News
All recent versions of Zope are affected. All supported versions of Plone are affected. More specific details on checking your sites and which versions need to be patched will be released along with the hotfix.
The fix will be released at 15:00 UTC
... [More]
on Tuesday 28th June, 2011.
Due to the nature of the vulnerability, the security team has decided to pre-announce that a fix is upcoming before disclosing the details, to ensure that concerned users can plan around the release. As the fix being published will make the details of the vulnerability public we are recommending that all users plan a maintenance window for 30 minutes either side of the announcement where your site is completely inaccessible in which to install the fix.
Extra help
Should you not have in-house server administrators or a service agreement looking after your website you can find consultancy companies under the providers section.
There is also free support available online.
Questions and Answers
Q: When will the patch be made available?
A: The Plone and Zope Security Teams will release the patch at 15:00 UTC (11:00am US EDT) on Tuesday 28th June, 2011.
Q: How was this vulnerability found?
A: This issue was found as part of a routine audit performed by the Zope and Plone Security teams.
Q: My site is highly visible and mission-critical. I hear the patch has already been developed. Can I get the fix before the release date?
A: The Security Team has made the decision to not allow any early release of this patch so as to reduce the risks of exploitation. This decision applies to everyone, even Plone Foundation Members and Board members.
Q: If the patch has been developed already, why isn't it already made available to the public?
A: The Security Team is still testing the patch and running various scenarios thoroughly. The team is also making sure everybody has appropriate time to plan to patch their Plone installation(s). Some consultancy organizations have hundreds of sites to patch and need the extra time to coordinate their efforts with their clients.
Q: How does one exploit the vulnerability?
A: For obvious security reasons, the information will not be made available until after the patch is made available.
Q: Are there any third-party products I can use to protect my site until the patch is available?
A: No.
Q: Will making my database read-only protect my site?
A: This will not protect against unauthorized data access. [Less]
|
Posted
about 14 years
ago
by
active questions tagged zope - Stack Overflow
Plone 4.1. I am creating a control widget for constructing a form (kind of PloneFormGen for ad hoc purposes). The user is allowed to pick different blocks for their form and reorder them.
Available options include:
Text block
Table block
Accordion
... [More]
block
And then you should be able to produce a list like:
Text block 1
Text block 2
Accordion block
Text block 3
Out of them. Basically selecting items, but with an option to select the same item multiple times.
What would be a good widget / approach to create this kind of a selector? [Less]
|
Posted
about 14 years
ago
by
active questions tagged zope - Stack Overflow
My data.fs was 500mb, I packed it then backed up data.fs (100mb).
My hosting account is only 500mb, so I am wondering if it is safe to delete data.fs.old (500mb)?
|
Posted
about 14 years
ago
by
RedTurtle Technology
Pyramid CRUD sprint is over. It was an amazing event thanks to Gaël Pasgrimaud and Patrick Gerken. We have been sprinting in Redturtle's office to improve pyramid_formalchemy and fa.jquery. We have archived most of the sprint goals!
Patrick was
... [More]
working on the first two tasks:
PASTER TEMPLATE
It can be used to add a skeleton to an existing project or to create a new project. If you create a new project, you must first install pyramid_formalchemy in your python environment, either with pip:
$ pip install pyramid_formalchemy
or with easy_install:
$ easy_install pyramid_formalchemy
Only after that, the paster template becomes available. The template was made with the idea that it can be used to extend existing applications. It does not create an app for you. The provided template works well with pyramid_alchemy, pyramid_routesalchemy and akhet. To bootstrap an application, call paster like that:
$ paster create -t akhet -t pyramid_fa myapp
The application is created by akhet, akhet does not know about pyramid_formalchemy, and pyramid_formalchemy cannot modify the app configuration. So you have to do this by hand. First, you must add the install dependency like explained earlier. Second, you must add the following line in the main method that returns the wsgi app, directly after Configurator has been created (The example assumes that the Configurator instance is stored under the name “config”):
...
config.include(myapp.fainit)
...
To add the minimum configuration to an existing application, you should be able to run:
$ paster create -t pyramid_fa myapp
All files that paster creates are prefixed with fa, and should not interfere with existing code.
FANSTATIC
Patrick's second task was fanstatic integration. Fanstatic is a small but powerful framework for the automatic publication of resources on a web page. Think Javascript and CSS. It just serves static content, but it does it really well. Integrating it with fa.jquery was a time consuming task but we managed to get a working proof of concept. I will blog more details when we publish something stable.
Next tasks were handled by Gaël:
CUSTOMISABLE ACTIONS
Action are basically links or input button. By default there is only one category buttons which are the forms buttons but you can add some categories like this:
>>> from pyramid_formalchemy.views import ModelView
>>> from pyramid_formalchemy import actions
>>> class MyView(ModelView):
... actions_categories = ('buttons', 'custom_actions')
... defaults_actions = actions.defaults_actions.copy()
... defaults_actions.update(edit_custom_actions=Actions())
Where myactions is an Actions instance
You can also customize the actions per Model:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarative_base
>>> Base = declarative_base()
>>> class MyArticle(Base):
... __tablename__ = 'myarticles'
... edit_buttons = Actions()
... id = Column(Integer, primary_key=True)
The available actions are: listing, new, edit
But you can add your own:
>>> from pyramid_formalchemy.views import ModelView
>>> from pyramid_formalchemy import actions
>>> class MyView(ModelView):
... actions.action()
... def extra(self):
... # do your stuff
... return self.render(**kw)
I18N
Yes, pyramid_formalchemy is now i18n! You need to add to your pipeline:
[app:pyramid]
...
default_locale_name = en
available_languages = fr en
and that's it! Right now we have english and french translations but others are coming.
I was working on the first three tasks:
View customization
This was one of the main sprint tasks - to have a possibility to customize CRUD views per model. You can register them simply like that:
config.formalchemy_model_view('admin',
model='pyramidapp.models.Foo',
context='pyramid_formalchemy.resources.ModelListing',
renderer='templates/foolisting.pt',
attr='listing',
request_method='GET',
permission='view')
and per Model:
config.formalchemy_model_view('admin',
model='pyramidapp.models.Foo',
context='pyramid_formalchemy.resources.Model',
name='',
renderer='templates/fooshow.pt',
attr='show',
request_method='GET',
permission='view')
formalchemy_model_view is an extension for config.add_view so you can use all view specific kwargs.
Widgets
We were able to finish simple implementation of autocomplete widget. It's not yet fully documented but it will be released in pyramid_formalchemy 0.4. Here is how you use it:
from pyramid_formalchemy.renderers import pyramid_autocomplete
User.group.set(renderer=pyramid_autocomplete(filter_by='name'))
where User is your fieldset and group is your relation field; filter_by parameter is the SQLAlchemy column you want to filter (autocomplete) on.
Events hooks
We have provided four events:
IBeforeValidateEventIAfterSyncEventIBeforeDeleteEventIBeforeRenderEvent
There are also two more specific render evnts:
IBeforeShowRenderEventIBeforeEditRenderEvent
You can use pyramid_formalchemy.events.subscriber decorator to use them:
from pyramid_formalchemy import events
from pyramidapp.models import Foo
@events.subscriber([Foo, events.IBeforeValidateEvent])
def before_foo_validate(context, event):
#do your stuff here
Summary
It was a very productive four days. Thanks again for all your help. We should release new versions of pyramid_formalchemy and fa.jquery in the following days. If you don't want to wait - grab the development versions on github.
You can find more sprint photos here - http://www.flickr.com/photos/tags/crudsprint2011 [Less]
|
Posted
about 14 years
ago
by
Andy McKay
Two weeks ago I went to Djangocon.eu in Amsterdam and had a chance to talk about the great stuff that Mozilla has been doing with Django. It's taken me a while to get around to blogging about it, my apologies. At the other end of the spectrum
... [More]
, Reinout van Rees did an awesome job of live blogging throughout the conference. He was finishing blog posts as speakers were finishing.
Every time I arrive in Amsterdam, it feels like I'm stepping into the future. The one where there's no flying cars, but bikes and public transit because there's no oil left. And socially, things are more liberal.
The hotel was the exact opposite. The hotel was rather cheap with no free wifi and they gave me the TV remote on checkin - with a warning about the costs if I lose the TV remote.
The conference was in an awesome venue, a great renovated building in Amsterdam docks. Next door was an island. Java-eiland. My first impression was the great job that the organisers had done with the AV, a very nice setup.
Fortunately my talk was up quickly, so I didn't have much chance to fret. I just got caught out by the talk time moving up 15 mins, I didn't know, so everyone was waiting. The talk went well I think, I ended talking about how awesome cache machine is and calling it all object caching throughout. I meant model caching, but everyone got that.
In the future if I'm doing a talk at the beginning, I feel I could run through my talk and say: "we use X, here's briefly how and why and see talk X later in the conference for more detail". There were plenty of talks later on the Mozilla Django tool chain.
At the beginning I mentioned that Canada keeps beating the US at hockey and that night would be game 3 of the Stanley Cup and inviting people to meet my friends to watch the game at 2am. We did meet up, a bunch of random Canadians sat in a bar in Amsterdam, sang the national anthem and then watched our team get completely hammered. So let's just pretend that bit didn't happen.
Over the three days, there was only one track for the conference, which meant that the group stayed together. I would have liked a couple of tracks, but overall the talks were of good quality. Having a couple of tracks might have diluted that.
Of the notable talks I enjoyed:
Idan talking about responsive design. Idan's a great talker with great tips for anyone building mobile sites.
Jesper had a great talk about his work on Bitbucket. I only caught the last half or so unfortunately. But, it's always good to hear about big successful Django sites, it's exactly the sort of thing that the project needs.
Andrew did a great talk about how ep.io works. It's not simple and he's clearly gained some scars from building out that site.
The hallway and break chats were good. I had some great conversations and met some awesome people in the community. One other advantage of having a talk to everyone at the beginning was that, lots of people wanted to talk about how Mozilla uses Django. I even met a couple of people who thanked me for my Plone book (there's a few Plone refugees in Django land).
At the end of the conference I was on a scalability panel. I've never been a big fan of panels so was a little sceptical, but this went better than most. Hopefully it was useful.
In only three days the whole thing was over and it was off to the UK to spend a brief amount of time with my family.
It was great to go, thank you Mozilla for letting that happen. I think its good for Django and Python to repeatedly show how successful this toolset can be. Having large deployments coming out and saying so, really helps open source projects.
There was one thing I'd like to reiterate to conference organisers: please print peoples names in a large font on both sides of the badge. (example)
Image from http://www.flickr.com/photos/stephrdev/ [Less]
|
Posted
about 14 years
ago
by
active questions tagged zope - Stack Overflow
The following browser view should return the content of the front page of the first Plone Site in it's context. However, I can not seem to obtain an object which is able to render html content.
from Products.Five import BrowserView
from
... [More]
zope.component import getMultiAdapter
class RenderFirst (BrowserView):
def __call__ (self):
def findPlones (context):
plones = context.objectValues("Plone Site")
folders = context.objectValues("Folder")
folders = set(folders).difference(set(plones))
for folder in folders:
plones += findPlones(folder)
return plones
plones = findPlones(context)
if len(plones):
default_page = plones[0].getDefaultPage()
content = plones[0].unrestrictedTraverse (default_page)
view = getMultiAdapter ((content, self.request))
return view()
else:
return "no plone"
The previous code when run tells me that the object view is not callable.
plones[0] is a Plone Site object and when called produces a KeyError for folder_listing
if I call the content object I get an AttributeError for document_view
There are lots of combinations here, of calling different adapters of different objects. Haven't yet found the right object which can render the page. Anyone know how to do this? [Less]
|