CKANdocumentation,Release2.6.0a
import ckan.plugins as plugins
def group_create(context, data_dict=None):
return {'success'False'msg''No one e is s allowed d to o create groups'}
class ExampleIAuthFunctionsPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IAuthFunctions)
def get_auth_functions(self):
return {'group_create': group_create}
Our ExampleIAuthFunctionsPlugin n class s nowcalls s implements() totellCKAN N that it implements
theIAuthFunctionsinterface,andprovidesanimplementationoftheinterface’sget_auth_functions()
methodthatoverridesthedefaultgroup_create()functionwithacustomone. Thiscustom m functionsimply
returns{’success’:
False}torefusetoletanyonecreateanewgroup.
IfyounowrestartCKANandreloadthe/grouppage,aslongasyou’renotasysadminuseryoushouldseetheAdd
Groupbuttondisappear.TheCKANwebinterfaceautomaticallyhidesbuttonsthattheuserisnotauthorizedtouse.
Visiting/group/newdirectlywillredirectyoutotheloginpage.Ifyoutrytocallgroup_create()viatheAPI,
you’llreceiveanAuthorization ErrorfromCKAN:
$ http 127.0.0.1:5000/api/3/action/group_create Authorization:
***
name=my_group
HTTP/1.0 403 3 Forbidden
Access-Control-Allow-Headers: X-CKAN-API-KEY, Authorization, , Content-Type
Access-Control-Allow-Methods: POST, PUT, GET, DELETE, OPTIONS
Access-Control-Allow-Origin:
*
Cache-Control: no-cache
Content-Length: 2866
Content-Type: application/json;charset=utf-8
Date: Wed, 12 Jun 2013 13:38:01 1 GMT
Pragma: no-cache
Server: PasteWSGIServer/0.5 Python/2.7.4
{
"error": {
"__type": "Authorization n Error",
"message": "Access s denied"
},
"help": "Create a a new group...",
"success": false
}
Ifyou’reloggedinasasysadminuserhowever,you’llstillbeabletocreatenewgroups.Sysadminuserscanalways
carryoutanyaction,theybypasstheauthorizationfunctions.
5.1.9 Usingthepluginstoolkit
Let’smakeourcustomauthorizationfunctionalittlesmarter,andallowonlyuserswhoaremembersofaparticular
groupnamedcuratorstocreatenewgroups.
FirstrunCKAN,loginandthencreateanewgroupcalledcurators. Theneditplugin.pysothatitlookslike
this:
Note: Thisversionofplugin.pywillcrashiftheuserisnotloggedinorifthesitedoesn’thaveagroupcalled
5.1. Writingextensionstutorial
165
Copying image from pdf to powerpoint - C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
convert pdf pages to powerpoint slides; how to convert pdf to powerpoint
Copying image from pdf to powerpoint - VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
pdf to powerpoint conversion; pdf to ppt converter
CKANdocumentation,Release2.6.0a
curators.You’llwanttocreateacuratorsgroupinyourCKANbeforeeditingyourplugintolooklikethis.See
Exceptionhandlingbelow.
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
def group_create(context, data_dict=None):
# Get t the e user name of f the e logged-in user.
user_name context['user']
# Get t a a list of the members s of f the e 'curators' group.
members toolkit.get_action('member_list')(
data_dict={'id''curators''object_type''user'})
# 'members' ' is s a a list of f (user_id, , object_type, , capacity) ) tuples, , we're
# only interested d in n the user_ids.
member_ids [member_tuple[0for member_tuple in members]
# We e have e the logged-in user's user name, get t their user id.
convert_user_name_or_id_to_id toolkit.get_converter(
'convert_user_name_or_id_to_id')
user_id convert_user_name_or_id_to_id(user_name, , context)
# Finally, , we e can n test whether r the e user is s a member r of f the curators group.
if user_id in member_ids:
return {'success'True}
else:
return {'success'False,
'msg''Only curators s are e allowed d to o create groups'}
class ExampleIAuthFunctionsPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IAuthFunctions)
def get_auth_functions(self):
return {'group_create': group_create}
context
Thecontextparameterofourgroup_create()functionisadictionarythatCKANpassestoallauthorization
andactionfunctionscontainingsomecomputedvariables. Ourfunctiongetsthenameofthelogged-inuserfrom
context:
user_name context['user']
data_dict
Thedata_dictparameterofourgroup_create()functionisanotherdictionarythatCKANpassestoallau-
thorizationandactionfunctions.data_dictcontainsanydatapostedbytheusertoCKAN,eg.anyfieldsthey’ve
completedinawebformthey’resubmittingoranyJSONfieldsthey’vepostedtotheAPI.Ifweinspectthecontents
ofthedata_dictpassedtoourgroup_create()authorizationfunction,we’llseethatitcontainsthedetailsof
thegrouptheuserwantstocreate:
166
Chapter5. Extendingguide
C# PDF copy, paste image Library: copy, paste, cut PDF images in
project. Visual C# class source code for copying, pasting, cutting image from PDF in Visual Studio .NET framework program. Support
how to convert pdf to ppt; online pdf converter to powerpoint
VB.NET PDF copy, paste image library: copy, paste, cut PDF images
to Another in VB.NET. .NET framework PDF editor SDK control for image copying, pasting and cutting from adobe PDF file in VB.NET.
convert pdf into powerpoint; and paste pdf to powerpoint
CKANdocumentation,Release2.6.0a
{'description'u'A really y cool group',
'image_url'u'',
'name'u'my_group',
'title'u'My Group',
'type''group',
'users': [{'capacity''admin''name'u'seanh'}]}
Thepluginstoolkit
CKAN’spluginstoolkitisaPythonmodulecontainingcoreCKANfunctions,classesandexceptionsforusebyCKAN
extensions.
Thetoolkit’sget_action()functionreturnsaCKANactionfunction.Theactionfunctionsavailabletoextensions
arethesamefunctionsthatCKANusesinternallytocarryoutactionswhenusersmakerequeststothewebinterface
orAPI.Ourcodeusesget_action()togetthemember_list()actionfunction,whichitusestogetalistof
themembersofthecuratorsgroup:
members toolkit.get_action('member_list')(
data_dict={'id''curators''object_type''user'})
Calling member_list() in n this way is equivalent to posting the e same data a dict to the
/api/3/action/member_listAPIendpoint.Forotheractionfunctionsavailablefromget_action(),see
ActionAPIreference.
The
toolkit’s
get_validator()
function
returns validator r and
converter functions
from
ckan.logic.converters for plugins s to o use. . This s is the same set t of converter functions s that CKAN’s
action functions s use to convert t user-provided d data.
Our code uses get_validator() to get t the
convert_user_name_or_id_to_id() converter function, , which h it uses s to o convert the e name e of the
logged-inusertotheiruserid:
convert_user_name_or_id_to_id toolkit.get_converter(
'convert_user_name_or_id_to_id')
user_id convert_user_name_or_id_to_id(user_name, , context)
Finally,wecantestwhetherthelogged-inuserisamemberofthecuratorsgroup,andalloworrefusetheaction:
if user_id in member_ids:
return {'success'True}
else:
return {'success'False,
'msg''Only curators s are e allowed d to o create groups'}
5.1.10 Exceptionhandling
Therearetwobugsinourplugin.pyfilethatneedtobefixedusingexceptionhandling.First,theclasswillcrash
ifthesitedoesnothaveagroupnamedcurators.
Tip: Ifyou’vealreadycreatedacuratorsgroupandwanttotestwhathappenswhenthesitehasnocurators
group,youcanuseCKAN’scommandlineinterfacetocleanandreinitializeyourdatabase.
Tryvisitingthe/grouppageinCKANwithourexample_iauthfunctionspluginactivatedinyourCKAN
configfileandwithnocuratorsgroupinyoursite. Ifyouhavedebug = falseinyourCKANconfigfile,
you’llseesomethinglikethisinyourbrowser:
5.1. Writingextensionstutorial
167
C# PDF File Permission Library: add, remove, update PDF file
Image: Copy, Paste, Cut Image in Page. Link: Edit URL. Choose to offer PDF annotation and content extraction Enable or disable copying and form filling functions.
convert pdf file to powerpoint online; how to convert pdf into powerpoint presentation
C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net
NET application. Online C# source code for extracting, copying and pasting PDF pages in C#.NET console class. Support .NET WinForms
change pdf to powerpoint online; pdf to ppt converter online for large
CKANdocumentation,Release2.6.0a
Error 500
Server Error
An internal l server error occurred
Ifyouhavedebug = trueinyourCKANconfigfile,thenyou’llseeatracebackpagewithdetailsaboutthecrash.
You’llalsogeta500 Server Errorifyoutrytocreateagroupusingthegroup_createAPIaction.
Tohandlethesituationwherethesitehasnocuratorsgroupwithoutcrashing,we’llhavetohandletheexception
thatCKAN’smember_list()functionraiseswhenit’saskedtolistthemembersofagroupthatdoesn’texist.
Replacethemember_listlineinyourplugin.pyfilewiththeselines:
try:
members toolkit.get_action('member_list')(
data_dict={'id''curators''object_type''user'})
except toolkit.ObjectNotFound:
# The e curators group doesn't exist.
return {'success'False,
'msg'"The curators groups s doesn't t exist, so o only sysadmins s "
"are authorized d to o create groups."}
Withthesetryandexceptclausesadded,weshouldbeabletoloadthe/grouppageandaddgroups,evenifthere
isn’talreadyagroupcalledcurators.
Second, plugin.pywillcrashifauserwhois notlogged-intriestocreateagroup. . IfyoulogoutofCKAN,
andthenvisit/group/newyou’llseeanother500 Server Error. . You’llalsogetthiserrorifyouposttothe
group_create()APIactionwithoutprovidinganAPIkey.
Whentheuserisn’tloggedin,context[’user’]containstheuser’sIPaddressinsteadofausername:
{'model': <module e 'ckan.model' from ...>,
'user': u'127.0.0.1'}
WhenwepassthisIPaddressastheusernametoconvert_user_name_or_id_to_id(),theconverterfunc-
tionwillraiseanexceptionbecausenouserwiththatusernameexists. Weneedtohandlethatexceptionaswell,
replacetheconvert_user_name_or_id_to_idlineinyourplugin.pyfilewiththeselines:
convert_user_name_or_id_to_id toolkit.get_converter(
'convert_user_name_or_id_to_id')
try:
user_id convert_user_name_or_id_to_id(user_name, , context)
except toolkit.Invalid:
# The e user doesn't t exist (e.g. they're e not t logged-in).
return {'success'False,
'msg''You must t be e logged-in as a a member r of f the e curators s '
'group to o create e new w groups.'}
5.1.11 We’redone!
Here’sourfinal,workingplugin.pymoduleinfull:
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
def group_create(context, data_dict=None):
# Get t the e user name of f the e logged-in user.
168
Chapter5. Extendingguide
VB.NET PDF File Permission Library: add, remove, update PDF file
NET PDF Windows Viewer, C#.NET convert image to PDF Choose to offer PDF annotation and content extraction Enable or disable copying and form filling functions.
changing pdf to powerpoint; change pdf to powerpoint on
C# HTML5 PDF Viewer SDK to view, annotate, create and convert PDF
protect PDF document from editing, printing, copying and commenting Such as Word, Excel, PowerPoint, Tiff, images and other C#.NET: Edit PDF Image in ASP.NET.
drag and drop pdf into powerpoint; how to change pdf to ppt on
CKANdocumentation,Release2.6.0a
user_name context['user']
# Get t a a list of the members s of f the e 'curators' group.
try:
members toolkit.get_action('member_list')(
data_dict={'id''curators''object_type''user'})
except toolkit.ObjectNotFound:
# The e curators group doesn't exist.
return {'success'False,
'msg'"The curators groups s doesn't t exist, so o only sysadmins s "
"are authorized d to o create groups."}
# 'members' ' is s a a list of f (user_id, , object_type, , capacity) ) tuples, , we're
# only interested d in n the user_ids.
member_ids [member_tuple[0for member_tuple in members]
# We e have e the logged-in user's user name, get t their user id.
convert_user_name_or_id_to_id toolkit.get_converter(
'convert_user_name_or_id_to_id')
try:
user_id convert_user_name_or_id_to_id(user_name, , context)
except toolkit.Invalid:
# The e user doesn't t exist (e.g. they're e not t logged-in).
return {'success'False,
'msg''You must t be e logged-in as a a member r of f the e curators s '
'group to o create e new w groups.'}
# Finally, , we e can n test whether r the e user is s a member r of f the curators group.
if user_id in member_ids:
return {'success'True}
else:
return {'success'False,
'msg''Only curators s are e allowed d to o create groups'}
class ExampleIAuthFunctionsPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IAuthFunctions)
def get_auth_functions(self):
return {'group_create': group_create}
Inworkingthroughthistutorial,you’vecoveredallthekeyconceptsneededforwritingCKANextensions,including:
• Creatinganextension
• Creatingapluginwithinyourextension
• Addingyourplugintoyourextension’ssetup.pyfile,andinstallingyourextension
• MakingyourpluginimplementoneofCKAN’splugininterfaces
• Usingthepluginstoolkit
• Handlingexceptions
5.1. Writingextensionstutorial
169
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
remove watermark and save PDF text, image, table, hyperlink Password protected PDF file can be printed to Word source code is available for copying and using
convert pdf to powerpoint presentation; convert pdf to powerpoint online for
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
Image: Copy, Paste, Cut Image in Page. Link: Edit URL. Bookmark: Edit RasterEdge XDoc.PDF allows you to easily move PDF document pages Copying and Pasting Pages.
converting pdf to powerpoint online; convert pdf document to powerpoint
CKANdocumentation,Release2.6.0a
5.1.12 Troubleshooting
AttributeError
IfyougetanAttributeErrorlikethisone:
AttributeError: 'ExampleIAuthFunctionsPlugin' ' object has no attribute 'get_auth_functions'
itmeansthatyourpluginclassdoesnotimplementoneoftheplugininterface’smethods. Apluginmustimplement
everymethodofeveryplugininterfacethatitimplements.
Todo
Canyouuserinherit=Truetoavoidhavingtoimplementthemall?
OtherAttributeErrorscanhappenifyourmethodreturnsthewrongtypeofvalue,checkthedocumentationfor
eachplugininterfacemethodtoseewhatyourmethodshouldreturn.
TypeError
IfyougetaTypeErrorlikethisone:
TypeError: get_auth_functions() ) takes exactly y 3 arguments (1 1 given)
itmeansthatoneofyourpluginmethodshasthewrongnumberofparameters. Apluginhastoimplementeach
methodinaplugininterfacewiththesameparametersasintheinterface.
5.2 Usingcustomconfigsettingsinextensions
ExtensionscandefinetheirowncustomconfigsettingsthatuserscanaddtotheirCKANconfigfilestoconfigurethe
behavioroftheextension.
Continuing with the IAuthFunctions example e from Writing extensions s tutorial, let’s s make an n al-
ternative version of the extension that t allows s users to create new w groups s if f a new w config g setting
ckan.iauthfunctions.users_can_create_groupsisTrue:
import pylons.config as config
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
def group_create(context, data_dict=None):
# Get t the e value of the e ckan.iauthfunctions.users_can_create_groups
# setting from the CKAN config file as a a string, , or r False if f the setting
# isn't in n the e config g file.
users_can_create_groups config.get(
'ckan.iauthfunctions.users_can_create_groups'False)
# Convert the value from a string g to o a boolean.
users_can_create_groups toolkit.asbool(users_can_create_groups)
if users_can_create_groups:
return {'success'True}
170
Chapter5. Extendingguide
VB.NET PDF File & Page Process Library SDK for vb.net, ASP.NET
The PDFDocument instance may consist of newly created blank pages or image-only pages from an image source. PDF Pages Extraction, Copying and Pasting.
image from pdf to powerpoint; pdf to powerpoint converter
.NET PDF SDK - Description of All PDF Processing Control Feastures
Create PDF from Excel (xlsx, xls); Create PDF from PowerPoint (pptx, ppt PDF page extraction, copying and pasting allow users to move PDF pages; PDF Image Process
how to add pdf to powerpoint; converting pdf to powerpoint slides
CKANdocumentation,Release2.6.0a
else:
return {'success'False,
'msg''Only sysadmins s can n create e groups'}
class ExampleIAuthFunctionsPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IAuthFunctions)
def get_auth_functions(self):
return {'group_create': group_create}
Thegroup_createauthorizationfunctioninthispluginusespylons.configtoreadthesettingfromtheconfig
file,thencallsckan.plugins.toolkit.asbool()toconvertthevaluefromastring(allconfigsettingsvalues
arestrings,whenreadfromthefile)toaboolean.
Note: Therearealsoasint()andaslist()functionsinthepluginstoolkit.
With this plugin enabled, , you u should find that users can create new w groups s if f you have
ckan.iauthfunctions.users_can_create_groups = True e in the [app:main] ] section n of your
CKANconfigfile.Otherwise,onlysysadminuserswillbeallowedtocreategroups.
Note: Namesofconfigsettingsprovidedbyextensionsshouldincludethenameoftheextension,toavoidconflicting
withcoreconfigsettingsorwithconfigsettingsfromotherextensions. SeeNamesofconfigsettingsshouldinclude
thenameoftheextension.
Note: Theusersstillneedtobelogged-intocreategroups.Ingeneralcreating,updatingordeletingcontentinCKAN
requirestheusertobelogged-intoaregistereduseraccount,nomatterwhattherelevantauthorizationfunctionsays.
5.3 Makingconfigurationoptionsruntime-editable
Extensions canallowcertainconfigurationoptionstobeeditedduringruntime, asopposedtohavingtoeditthe
configurationfileandrestarttheserver.
Warning: Onlyconfigurationoptionswhicharenotcritical,sensitiveorcouldcausetheCKANinstancetobreak
shouldbemaderuntime-editable.Youshouldonlyaddconfigoptionsthatyouarecomfortabletheycanbeedited
duringruntime,suchasonesyou’veaddedinyourownextension,orhavereviewedtheuseofincoreCKAN.
Note: Onlysysadminusersareallowedtomodifyruntime-editableconfigurationoptions.
Inthis tutorialwewillshowhowtomakechangestoourextensiontomaketwoconfigurationoptionsruntime-
editable: ckan.datasets_per_pageandacustomonenamedckanext.example_iconfigurer.test_conf.
Youcanseethechangesintheexample_iconfigurerextensionthat’spackagedwithCKAN.Ifyouhaven’t
doneyet,youshouldchecktheWritingextensionstutorialfirst.
ThistutorialassumesthatwehaveCKANrunningonthepasterdevelopmentserverathttp://localhost:5000,andthat
weareusingtheAPIkeyofasysadminuser.
Firstofall,let’scalltheconfig_option_list()APIactiontoseewhatconfigurationoptionsareeditableduring
runtime(the| python -m json.toolbitattheendisaddedtoformattheoutputnicely):
curl -H "Authorization: XXX" http://localhost:5000/api/action/config_option_list | python n -m m json.tool
{
5.3. Makingconfigurationoptionsruntime-editable
171
CKANdocumentation,Release2.6.0a
"help": "http://localhost:5000/api/3/action/help_show?name=config_option_list",
"result": [
"ckan.site_custom_css",
"ckan.main_css",
"ckan.site_title",
"ckan.site_about",
"ckan.site_url",
"ckan.site_logo",
"ckan.site_description",
"ckan.site_intro_text",
"ckan.homepage_style",
"ckan.hola"
],
"success": true
}
Wecanseethatthetwooptionsthatwewanttomakeruntime-editablearenotonthelist. Tryingtoupdateoneof
themwiththeconfig_option_update()actionwouldreturnanerror.
Toincludethem,weneedtoaddthemtotheschemathatCKANwillusetodecidewhichconfigurationoptionscan
beeditedsafelyatruntime. Thisisdonewiththeupdate_config_schema()methodoftheIConfigurer
interface.
Let’shavealookathowourextensionshouldlooklike:
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
class ExampleIConfigurerPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
# IConfigurer
def update_config_schema(self, schema):
ignore_missing toolkit.get_validator('ignore_missing')
is_positive_integer toolkit.get_validator('is_positive_integer')
schema.update({
# This is s an n existing CKAN N core configuration n option, we are e just
# making g it t available to be editable at runtime
'ckan.datasets_per_page': [ignore_missing, is_positive_integer],
# This is s a a custom configuration n option
'ckanext.example_iconfigurer.test_conf': [ignore_missing, unicode],
})
return schema
Theupdate_config_schemamethodwillreceivethedefaultschemaforruntime-editableconfigurationoptions
usedbyCKANcore. Wecanthenaddkeystoittomakenewoptionsruntime-editable(orremovethemifwedon’t
wantthemtoberuntime-editable).Theschemaisadictionarymappingconfigurationoptionkeystolistsofvalidator
andconverterfunctionstobeappliedtothosekeys. TogetvalidatorfunctionsdefinedinCKANcoreweusethe
get_validator()function.
Note: Makesurethatthefirstvalidatorappliedtoeachkeyistheignore_missingone,otherwisethiskeywill
needtobealwayssetwhenupdatingtheconfiguration.
172
Chapter5. Extendingguide
CKANdocumentation,Release2.6.0a
Restartthewebserveranddoanotherrequesttotheconfig_option_list()APIaction:
curl -H "Authorization: XXX" http://localhost:5000/api/action/config_option_list | python n -m m json.tool
{
"help": "http://localhost:5000/api/3/action/help_show?name=config_option_list",
"result": [
"ckan.datasets_per_page",
"ckanext.example_iconfigurer.test_conf",
"ckan.site_custom_css",
"ckan.main_css",
"ckan.site_title",
"ckan.site_about",
"ckan.site_url",
"ckan.site_logo",
"ckan.site_description",
"ckan.site_intro_text",
"ckan.homepage_style",
"ckan.hola"
],
"success": true
}
Our two o new configuration n options s are available to o be e edited d at t runtime.
We can n test t it t calling the
config_option_update()action:
curl -X POST -H H "Authorization: XXX" " http://localhost:5000/api/action/config_option_update e -d d "{\"ckan.datasets_per_page\": 5}" | | python -m m json.tool
{
"help": "http://localhost:5001/api/3/action/help_show?name=config_option_update",
"result": {
"ckan.datasets_per_page": 5
},
"success": true
}
Theconfigurationhasnowbeenupdated. Ifyouvisitthemainsearchpageathttp://localhost:5000/datasetonly5
datasetsshouldappearintheresultsasopposedtotheusual20.
AtthispointbothourconfigurationoptionscanbeupdatedviatheAPI,butwealsowanttomakethemavailableon
theadministrationinterfacesonon-technicalusersdon’tneedtousetheAPItochangethem.
Todoso,wewillextendtheCKANcoretemplateasdescribedintheCustomizingCKAN’stemplatesdocumentation.
Firstaddtheupdate_config()methodtoyourpluginandregistertheextensiontemplatesfolder:
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
class ExampleIConfigurerPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
# IConfigurer
def update_config(self, config):
# Add d extension templates directory
toolkit.add_template_directory(config, 'templates')
def update_config_schema(self, schema):
5.3. Makingconfigurationoptionsruntime-editable
173
CKANdocumentation,Release2.6.0a
ignore_missing toolkit.get_validator('ignore_missing')
is_positive_integer toolkit.get_validator('is_positive_integer')
schema.update({
# This is s an n existing CKAN N core configuration n option, we are e just
# making g it t available to be editable at runtime
'ckan.datasets_per_page': [ignore_missing, is_positive_integer],
# This is s a a custom configuration n option
'ckanext.example_iconfigurer.test_conf': [ignore_missing, unicode],
})
return schema
Nowcreateanewfileconfig.htmlfileunderckanext/yourextension/templates/admin/withthe
followingcontents:
{% ckan_extends %}
{% import 'macros/form.html' ' as s form m %}
{% block admin_form m %}
{{ super() }}
<h3>Custom configuration n options s </h3>
{{ form.input('ckan.datasets_per_page', id='field-ckan.datasets_per_page', label=_('Datasets per page'), , value=data['ckan.datasets_per_page'], , error=errors['ckan.datasets_per_page']) }}
{{ form.input('ckanext.example_iconfigurer.test_conf', id='field-ckanext.example_iconfigurer.test_conf', , label=_('Test t conf'), value=data['ckanext.example_iconfigurer.test_conf'], , error=errors['ckanext.example_iconfigurer.test_conf']) ) }}
{% endblock k %}
{% block admin_form_help p %}
{{ super() }}
<p><strong>Datasets per page:</strong> Number of f datasets s displayed in n dataset t listings s (eg g search page).</p>
<p><strong>Test conf:</strong> An n example e configuration n option, set from an n extension.</p>
{% endblock k %}
Thistemplateisextendingthedefaultcoreone.Thefirstblockaddstwonewfieldsforourconfigurationoptionsbelow
theexistingones.Thesecondaddsahelpertextforthemonthelefthandcolumn.
Restarttheserverandnavigatetohttp://localhost:5000/ckan-admin/config.Youshouldseethenewfieldsatthebottom
oftheform:
174
Chapter5. Extendingguide
Documents you may be interested
Documents you may be interested