Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Initializing db in case of Relstorage and solving sharing_post functi…
Browse files Browse the repository at this point in the history
…on to not class aware
  • Loading branch information
Ramon Navarro Bosch committed Jan 13, 2017
1 parent 41bf515 commit 3c50d7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plone.server/plone/server/api/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ async def sharing_get(context, request):

@service(context=IResource, method='POST', permission='plone.ChangePermissions',
name='@sharing')
async def sharing_post(self):
data = await self.request.json()
prinrole = IPrincipalRoleManager(self.context)
async def sharing_post(context, request):
data = await request.json()
prinrole = IPrincipalRoleManager(context)
if 'prinrole' not in data:
raise HTTPNotFound('prinrole missing')
for user, roles in data['prinrole'].items():
for role in roles:
prinrole.assignRoleToPrincipal(role, user)
await notify(ObjectPermissionsModifiedEvent(self.context))
await notify(ObjectPermissionsModifiedEvent(context))


@service(context=IResource, method='DELETE', permission='plone.DeleteContent')
Expand Down
14 changes: 14 additions & 0 deletions src/plone.server/plone/server/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,20 @@ def make_app(config_file=None, settings=None):
dsn = "dbname={dbname} user={username} host={host} password={password} port={port}".format(**dbconfig['dsn'])
adapter = PostgreSQLAdapter(dsn=dsn, options=options)
rs = RelStorage(adapter=adapter, options=options)
db = DB(rs)
try:
conn = db.open()
rootobj = conn.root()
if not IDatabase.providedBy(rootobj):
alsoProvides(rootobj, IDatabase)
transaction.commit()
except:
pass
finally:
rootobj = None
conn.close()
db.close()
rs = RelStorage(adapter=adapter, options=options)
db = RequestAwareDB(rs, **config)
dbo = Database(key, db)
elif dbconfig['storage'] == 'DEMO':
Expand Down

0 comments on commit 3c50d7a

Please sign in to comment.