Changeset 1327:132fbdaa8899
- Timestamp:
- 01/10/10 15:58:34 (2 years ago)
- Branch:
- default
- Parents:
- 1280:e7db1dd838ba (diff), 1326:4b0d1121e32c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 1 deleted
- 20 edited
-
external-plugins/eric_the_fish/__init__.py (modified) (1 diff)
-
external-plugins/eric_the_fish/__init__.py (modified) (3 diffs)
-
external-plugins/eric_the_fish/database.py (modified) (1 diff)
-
scripts/_install-posix.py (modified) (1 diff)
-
scripts/_install-posix.py (modified) (1 diff)
-
scripts/_make-setup-virtualenv.py (modified) (1 diff)
-
scripts/_make-setup-virtualenv.py (modified) (1 diff)
-
scripts/manage-database (modified) (1 diff)
-
zine/_core.py (modified) (4 diffs)
-
zine/_core.py (modified) (3 diffs)
-
zine/application.py (modified) (4 diffs)
-
zine/application.py (modified) (3 diffs)
-
zine/database.py (modified) (4 diffs)
-
zine/database.py (modified) (1 diff)
-
zine/models.py (modified) (4 diffs)
-
zine/models.py (modified) (3 diffs)
-
zine/templates/admin/import_blogger.html (deleted)
-
zine/upgrades/__init__.py (modified) (1 diff)
-
zine/upgrades/customisation.py (modified) (1 diff)
-
zine/upgrades/versions/__init__.py (modified) (1 diff)
-
zine/upgrades/webapp.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
external-plugins/eric_the_fish/__init__.py
r1319 r1327 8 8 registration system. 9 9 10 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.10 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 11 11 :license: BSD, see LICENSE for more details. 12 12 """ -
external-plugins/eric_the_fish/__init__.py
r1279 r1327 45 45 from zine.privileges import BLOG_ADMIN 46 46 47 # the last thing is importing the FORTUNES list from the fortunes.py file 48 # from the same folder. It's just a long list with quotes. 49 from zine.plugins.eric_the_fish.fortunes import FORTUNES 47 # import Zine's database related stuff 48 from zine.database import db 49 50 # the last thing is importing the Fortunes database mapped object. 51 from zine.plugins.eric_the_fish.database import Fortune 50 52 51 53 # because we have an admin panel page we need to store the templates … … 89 91 for link_id, url, title, children in navigation_bar: 90 92 if link_id == 'options': 91 children.insert(-3, ('eric_the_fish', url_for('eric_the_fish/config'), 93 children.insert(-3, ('eric_the_fish', 94 url_for('eric_the_fish/config'), 92 95 _('Eric The Fish'))) 93 96 … … 116 119 117 120 def get_fortune(req): 118 """The servicepoint function. Just return one fortune from the list.""" 119 return {'fortune': choice(FORTUNES)} 121 """The servicepoint function. Just return one fortune from the database.""" 122 fortune_ids = db.session.query(Fortune.id).all() 123 return {'fortune': db.session.query(Fortune).get(choice(fortune_ids)).text} 120 124 121 125 122 126 def setup(app, plugin): 123 """This function is called by Zine in the application initiali zation127 """This function is called by Zine in the application initialisation 124 128 phase. Here we connect to the events and register our template paths, 125 129 url rules, views etc. 126 130 """ 131 132 # we need to register eric's database upgrades repository; 133 # Basically it should be a folder which itself has another child folder 134 # named "versions" where the upgrade script(s) should reside. 135 # In "Eric the fish" case we pass the plugin's folder which has that child 136 # folder called "versions" 137 app.register_upgrade_repository(plugin, dirname(__file__)) 127 138 128 139 # we want our fish to appear in the admin panel, so hook into the -
external-plugins/eric_the_fish/database.py
r1316 r1327 6 6 Database tables and objects for the "Annoying fish for the admin panel". 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
scripts/_install-posix.py
r1323 r1327 6 6 This script is invoked by the makefile to install Zine on a POSIX system. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
scripts/_install-posix.py
r1279 r1327 18 18 19 19 20 PACKAGES = '_dynamic _ext importers u tils views websetup docs'.split()20 PACKAGES = '_dynamic _ext importers upgrades utils views websetup docs'.split() 21 21 SCRIPTS = 'create-apache-config server shell'.split() 22 22 DESTDIR = os.environ.get('DESTDIR') -
scripts/_make-setup-virtualenv.py
r1324 r1327 6 6 Execute this file to regenerate the `setup-virtualenv` script. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
scripts/_make-setup-virtualenv.py
r1279 r1327 25 25 'SQLAlchemy==dev', 26 26 'pytz', 27 'Babel>=0.9.4' 27 'Babel>=0.9.4', 28 'sqlalchemy-migrate==0.5.4' 28 29 ] 29 30 -
scripts/manage-database
r1314 r1327 7 7 Database maintenance script. 8 8 9 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.9 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 10 10 :license: BSD, see LICENSE for more details. 11 11 """ -
zine/_core.py
r1325 r1327 6 6 Internal core module that survives reloads. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ … … 40 40 after `timeout` seconds a `RuntimeError` is raised. 41 41 """ 42 global _application 42 global _application, _setup_failed 43 43 _setup_failed = False 44 44 _setup_lock.acquire() … … 84 84 def _unload_zine(): 85 85 """Unload all zine libraries.""" 86 global _application 86 global _application, _setup_failed 87 87 import sys 88 88 … … 111 111 for key, value in module.__dict__.iteritems(): 112 112 setattr(module, key, None) 113 # clear references 113 114 value = None 114 115 except: -
zine/_core.py
r1279 r1327 27 27 instance folder. 28 28 """ 29 30 class InstanceUpgradeRequired(RuntimeError): 31 """Zine requires a database upgrade""" 32 33 class MissingDependency(RuntimeError): 34 """Zine requires an external library which is not installed.""" 29 35 30 36 … … 60 66 try: 61 67 app.__init__(instance_folder) 68 app.upgrade_required 69 except InstanceUpgradeRequired: 70 from zine.upgrades.webapp import WebUpgrades 71 _application = app = WebUpgrades(app) 62 72 except: 63 73 # if an exception happened, tear down the application … … 92 102 if key not in preserve and not key.startswith('__'): 93 103 module.__dict__.pop(key, None) 94 elif name.startswith('zine.') and name != 'zine._core': 104 elif name.startswith('zine.') and name not in ( 105 'zine._core', 'zine.upgrades', 106 'zine.upgrades.customisation'): 95 107 # get rid of the module 96 108 sys.modules.pop(name, None) -
zine/application.py
r1326 r1327 8 8 9 9 10 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.10 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 11 11 :license: BSD, see LICENSE for more details. 12 12 """ … … 14 14 from os import path, remove, makedirs, walk, environ 15 15 from time import time 16 from itertools import izip 17 from datetime import datetime, timedelta 18 from urlparse import urlparse, urljoin 16 from urlparse import urlparse 19 17 from collections import deque 20 18 from inspect import getdoc … … 1320 1318 result = callback(request) 1321 1319 if result is not None: 1322 return result (environ, start_response)1320 return result 1323 1321 1324 1322 # normal request dispatching … … 1494 1492 from zine import i18n 1495 1493 from zine.utils import log 1494 from zine.utils.net import NetException 1496 1495 from zine.utils.http import make_external_url -
zine/application.py
r1279 r1327 636 636 self.__class__.__name__) 637 637 self.instance_folder = path.abspath(instance_folder) 638 self.upgrade_lockfile = path.join(instance_folder, 639 '.upgrade_in_progress') 638 640 639 641 # create the event manager, this is the first thing we have to … … 832 834 self.list_parsers() 833 835 836 # Register Zine's upgrade repository 837 from zine.upgrades import REPOSITORY_PATH 838 self.register_upgrade_repository('Zine', REPOSITORY_PATH) 839 # Allow plugins to register their upgrade's repositories 840 emit_event('register-upgrade-repository') 841 834 842 self.initialized = True 835 843 836 844 #! called after the application and all plugins are initialized 837 845 emit_event('application-setup-done') 846 847 def register_upgrade_repository(self, repo_id, repo_path): 848 """This function is responsible for adding upgrade repositories to the 849 database. 850 """ 851 from zine.models import SchemaVersion 852 from zine.pluginsystem import Plugin 853 from zine.upgrades.customisation import Repository 854 if isinstance(repo_id, Plugin): 855 repo_id = repo_id.metadata.get('name') 856 repo_path = path.abspath(repo_path) 857 try: 858 sv = SchemaVersion.query.filter_by(repository_id=repo_id).first() 859 if not sv: 860 db.session.add(SchemaVersion(Repository(repo_path, repo_id))) 861 db.session.commit() 862 except (SQLAlchemyError, AttributeError): 863 # The schema_versions table does not yet exist. Let's create it 864 db.session.rollback() 865 from zine.database import metadata, schema_versions 866 metadata.bind = self.database_engine 867 if not schema_versions.exists(): 868 schema_versions.create(self.database_engine) 869 db.session.add(SchemaVersion(Repository(repo_path, repo_id))) 870 db.session.commit() 871 872 873 @property 874 def upgrade_required(self): 875 from zine.models import SchemaVersion 876 from zine.upgrades.customisation import Repository 877 878 for sv in SchemaVersion.query.all(): 879 repository = Repository(sv.repository_path, sv.repository_id) 880 try: 881 self.repository_has_upgrade(repository, sv) 882 except _core.InstanceUpgradeRequired: 883 # Set Zine in maintenance mode 884 cfg = self.cfg.edit() 885 cfg['maintenance_mode'] = True 886 cfg.commit() 887 raise _core.InstanceUpgradeRequired() 888 889 # We got here, let's check for a bad upgrade lockfile left behind 890 if path.isfile(self.upgrade_lockfile): 891 remove(self.upgrade_lockfile) 892 893 def repository_has_upgrade(self, repository, schema_version): 894 try: 895 if schema_version.version < repository.latest: 896 raise _core.InstanceUpgradeRequired() 897 except (SQLAlchemyError, AttributeError): 898 self.log.error('WE EVEN GOT HERE??? schema_versions table does not ' 899 'yet exist at this stage?') 900 # The schema_versions table does not yet exist. Let's create it 901 db.session.rollback() 902 from zine.database import metadata, schema_versions 903 metadata.bind = self.database_engine 904 if not schema_versions.exists(): 905 schema_versions.create(self.database_engine) 906 db.session.add(SchemaVersion(Repository(repo_path))) 907 db.session.commit() 908 raise _core.InstanceUpgradeRequired() 838 909 839 910 @property … … 1211 1282 from zine.notifications import send_notification_template, ZINE_ERROR 1212 1283 request_buffer = StringIO() 1213 pprint(request.__dict__, request_buffer)1214 1284 request_buffer.seek(0) 1215 1285 send_notification_template( -
zine/database.py
r1314 r1327 11 11 12 12 13 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.13 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 14 14 :license: BSD, see LICENSE for more details. 15 15 """ … … 18 18 import sys 19 19 import time 20 import urlparse21 20 from os import path 22 from datetime import datetime, timedelta23 21 from types import ModuleType 24 22 from copy import deepcopy … … 30 28 from sqlalchemy.exc import ArgumentError 31 29 from sqlalchemy.ext.declarative import declarative_base 32 from sqlalchemy.util import to_list33 30 from sqlalchemy.engine.url import make_url, URL 34 from sqlalchemy.types import MutableType,TypeDecorator31 from sqlalchemy.types import TypeDecorator 35 32 from sqlalchemy.ext.associationproxy import association_proxy 36 33 … … 159 156 if value is None: 160 157 return 161 from zine.utils.zeml import dump_parser_data , RootElement158 from zine.utils.zeml import dump_parser_data 162 159 return dump_parser_data(value) 163 160 -
zine/database.py
r1279 r1327 248 248 metadata = db.MetaData() 249 249 250 schema_versions = db.Table('schema_versions', metadata, 251 db.Column('repository_id', db.String(255), primary_key=True), 252 db.Column('repository_path', db.Text), 253 db.Column('version', db.Integer) 254 ) 250 255 251 256 users = db.Table('users', metadata, -
zine/models.py
r1314 r1327 6 6 The core models and query helper functions. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ … … 25 25 from zine.utils.crypto import gen_pwhash, check_pwhash 26 26 from zine.utils.http import make_external_url 27 from zine.privileges import Privilege,_Privilege, privilege_attribute, \27 from zine.privileges import _Privilege, privilege_attribute, \ 28 28 add_admin_privilege, MODERATE_COMMENTS, ENTER_ADMIN_PANEL, BLOG_ADMIN, \ 29 29 VIEW_DRAFTS, VIEW_PROTECTED, MODERATE_OWN_ENTRIES, MODERATE_OWN_PAGES … … 575 575 def set_auto_slug(self): 576 576 """Generate a slug for this post.""" 577 cfg = get_application().cfg577 #cfg = get_application().cfg 578 578 slug = gen_slug(self.title) 579 579 if not slug: … … 1083 1083 if user is None: 1084 1084 user = request.user 1085 if user.has_privilege(MODERATE_OWN_ENTRIES | MODERATE_OWN_PAGES):1086 # Comment belongs to a post the user is the author. It's visible.1087 return self.post.author is user1085 if self.post.author is user and \ 1086 user.has_privilege(MODERATE_OWN_ENTRIES | MODERATE_OWN_PAGES): 1087 return True 1088 1088 elif user.has_privilege(MODERATE_COMMENTS): 1089 1089 # User is able to manage comments. It's visible. -
zine/models.py
r1279 r1327 18 18 post_categories, post_tags, tags, comments, groups, group_users, \ 19 19 privileges, user_privileges, group_privileges, texts, \ 20 notification_subscriptions, db20 notification_subscriptions, schema_versions, db 21 21 from zine.utils import zeml 22 22 from zine.utils.text import gen_slug, gen_timestamped_slug, build_tag_uri, \ … … 177 177 def authors(self): 178 178 return self.filter_by(is_author=True) 179 180 181 class SchemaVersion(object): 182 """Represents a database schema version.""" 183 184 query = db.query_property(db.Query) 185 186 def __init__(self, repos, version=0): 187 self.repository_id = repos.config.get('repository_id') 188 self.repository_path = repos.path 189 self.version = version 179 190 180 191 … … 1256 1267 1257 1268 # connect the tables. 1269 db.mapper(SchemaVersion, schema_versions) 1258 1270 db.mapper(User, users, properties={ 1259 1271 'id': users.c.user_id, -
zine/upgrades/__init__.py
r1325 r1327 6 6 database. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
zine/upgrades/customisation.py
r1318 r1327 6 6 to do our job. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
zine/upgrades/versions/__init__.py
r1318 r1327 6 6 to maintain the database schema changes. 7 7 8 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.8 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 9 9 :license: BSD, see LICENSE for more details. 10 10 """ -
zine/upgrades/webapp.py
r1318 r1327 7 7 for upgrading Zine to the latest schema changes. 8 8 9 :copyright: (c) 20 09by the Zine Team, see AUTHORS for more details.9 :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. 10 10 :license: BSD, see LICENSE for more details. 11 11 """
Note: See TracChangeset
for help on using the changeset viewer.