Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-joomla-15-installing-creating-and-managing-modules
Packt
10 Nov 2010
2 min read
Save for later

Joomla! 1.5: Installing, Creating, and Managing Modules

Packt
10 Nov 2010
2 min read
Joomla! 1.5 Cookbook Over 60 quick and direct recipes to help you overcome common Joomla! queries. Find quick solutions to common Joomla! problems Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible Look at recipes that cover the portions of Joomla! 1.6 that are brand new Over 60 practical recipes covering a range of site management and core Joomla! activities         In this recipe, we'll look at all aspects of a module. How to do it... Installing a Module Login to your Administrator Console. Click Extensions | Install/Uninstall. Once you are in here, you'll have a few options to choose from: There are three methods to install a module, in this section we'll focus on the first method. We'll examine the other two in a moment. Click Browse... and find the file. Click Upload File & Install.Once you successfully installed the module, Joomla! will indicate this with this message: How it works... Module installation is a very similar process to components. The Joomla! universal installer has made it very simple. The installer will write the appropriate settings to the database and will copy the files down to their respective locations. There's more... There comes a time when you no longer need a module. Or you may wish to disable it or even create a new one that didn't exist before. As modules are essentially very lightweight in nature, creating them and placing them is easy. The next few recipes cover these items. Deleting modules There are two methods to delete a module. METHOD 1: Click Extensions | Install/Uninstall. Click Modules. Check the module you wish to delete. Once you check the module(s) you wish to delete, click Uninstall in the upper right-hand side: Once you successfully uninstall the module, Joomla! will indicate this with this message: METHOD 2: Click Extensions | Module Manager. Check the module you wish to delete. Click Delete in the upper right-hand side, the key difference is the message:
Read more
  • 0
  • 0
  • 3083

article-image-getting-started-enterprise-library
Packt
10 Nov 2010
6 min read
Save for later

Getting Started with Enterprise Library

Packt
10 Nov 2010
6 min read
Introducing Enterprise Library Enterprise Library (EntLib) is a collection of reusable software components or application blocks designed to assist software developers with common enterprise development challenges. Each application block addresses a specific cross-cutting concern and provides highly configurable features, which results in higher developer productivity. EntLib is implemented and provided by Microsoft patterns & practices group, a dedicated team of professionals who work on solving these cross-cutting concerns with active participation from the developer community. This is an open source project and thus freely available under the Microsoft Public License (Ms-PL) at the CodePlex open source community site (http://entlib.codeplex.com), basically granting us a royalty-free copyright license to reproduce its contribution, build derivative works, and distribute them. More information can be found at the Enterprise Library community site http://www.codeplex.com/entlib. Enterprise Library consists of nine application blocks; two are concerned with wiring up stuff together and the remaining seven are functional application blocks. The following is the complete list of application blocks; these are briefly discussed in the next sections. Wiring Blocks Unity Dependency Injection Policy Injection Application Block Functional Blocks Data Access Application Block Logging Application Block Exception Handling Application Block Caching Application Block Validation Application Block Security Application Block Cryptography Application Block Wiring Application Blocks Wiring blocks provide mechanisms to build highly flexible, loosely coupled, and maintainable systems. These blocks are mainly about wiring or plugging together different functionalities. The following two blocks fall under this category: Unity Dependency Injection Policy Injection Application Block Unity Application Block The Unity Application Block is a lightweight, flexible, and extensible dependency injection container that supports interception and various injection mechanisms such as constructor, property, and method call injection. The Unity Block is a standalone open source project, which can be leveraged in our application. This block allows us to develop loosely coupled, maintainable, and testable applications. Enterprise Library leverages this block for wiring the configured objects. More information on the Unity block is available at http://unity.codeplex.com. Policy Injection Application Block The Policy Injection Application Block is included in this release of Enterprise Library for backwards compatibility and policy injection is implemented using the Unity interception mechanism. This block provides a mechanism to change object behavior by inserting code between the client and the target object without modifying the code of the target object. Functional Application Blocks Enterprise Library consists of the following functional application blocks, which can be used individually or can be grouped together to address a specific cross-cutting concern. Data Access Application Block Logging Application Block Exception Handling Application Block Caching Application Block Validation Application Block Security Application Block Cryptography Application Block Data Access Application Block Developing an application that stores/ retrieve data in/from some kind of a relational database is quite common; this involves performing CRUD (Create, Read, Update, Delete) operations on the database by executing T-SQL or stored procedure commands. But we often end up writing the plumbing code over and over again to perform these operations: plumbing code such as creating a connection object, opening and closing a connection, parameter caching, and so on. The following are the key benefits of the Data Access block: The Data Access Application Block (DAAB) abstracts developers from the underlying database technology by providing a common interface to perform database operations. DAAB also takes care of the ordinary tasks like creating a connection object, opening and closing a connection, parameter caching, and so on. It helps in bringing consistency to the application and allows changing of database type by modifying the configuration. Logging Application Block Logging is an essential activity, which is required to understand what's happening behind the scene while the application is running. This is especially helpful in identifying issues and tracing the source of the problem without debugging. The Logging Application Block provides a very simple, flexible, standard, and consistent way to log messages. Administrators have the power to change the log destination (file, database, e-mail, and so on), modify message format, decide on which category is turned on/off, and so on. Exception Handling Application Block Handling exceptions appropriately and allowing the user to either continue or exit gracefully is essential for any application to avoid user frustration. The Exception Handling Application Block adapts the policy-driven approach to allow developers/administrators to define how to handle exceptions. The following are the key benefits of the Exception Handling Block: It provides the ability to log exception messages using the Logging Application Block. It provides a mechanism to replace the original exception with another exception, which prevents disclosure of sensitive information. It provides mechanism to wrap the original exception inside another exception to maintain the contextual information. Caching Application Block Caching in general is a good practice for data that has a long life span; caching is recommended if the possibility of data being changed at the source is low and the change doesn't have significant impact on the application. The Caching Application Block allows us to cache data locally in our application; it also gives us the flexibility to cache the data in-memory, in a database or in an isolated storage. Validation Application Block The Validation Application Block (VAB) provides various mechanisms to validate user inputs. As a rule of thumb always assume user input is not valid unless proven to be valid. The Validation block allows us to perform validation in three different ways; we can use configuration, attributes, or code to provide validation rules. Additionally it also includes adapters specifically targeting ASP.NET, Windows Forms, and Windows Communication Foundation (WCF). Security Application Block The Security Application Block simplifies authorization based on rules and provides caching of the user's authorization and authentication data. Authorization can be done against Microsoft Active Directory Service, Authorization Manager (AzMan) , Active Directory Application Mode (ADAM), and Custom Authorization Provider. Decoupling of the authorization code from the authorization provider allows administrators to change the provider in the configuration without changing the code. Cryptography Application Block The Cryptography Application Block provides a common API to perform basic cryptography operations without inclining towards any specific cryptography provider and the provider is configurable. Using this application block we can perform encryption/decryption, hashing, & validate whether the hash matches some text.
Read more
  • 0
  • 0
  • 2410

article-image-apache-felix-gogo
Packt
10 Nov 2010
10 min read
Save for later

Apache Felix Gogo

Packt
10 Nov 2010
10 min read
  OSGi and Apache Felix 3.0 Beginner's Guide Build your very own OSGi applications using the flexible and powerful Felix Framework Build a completely operational real-life application composed of multiple bundles and a web front end using Felix Get yourself acquainted with the OSGi concepts, in an easy-to-follow progressive manner Learn everything needed about the Felix Framework and get familiar with Gogo, its command-line shell to start developing your OSGi applications Simplify your OSGi development experience by learning about Felix iPOJO A relentlessly practical beginner's guide that will walk you through making real-life OSGi applications while showing you the development tools (Maven, Eclipse, and so on) that will make the journey more enjoyable The Tiny Shell Language The command syntax for the shell interface is based on the Tiny Shell Language (TSL) . It is simple enough to allow a lightweight implementation, yet provides features such as pipes, closures, variable setting and referencing, collection types such as lists and maps, and so on. The TSL syntax allows the creation of scripts that can be executed by the shell runtime service. The introduction you will get here does not cover the complete syntax; instead, you will see the basic parts of it. For a review of the proposal in its initial state, (http://www.osgi.org/download/osgi-4.2-early-draft.pdf). You may also refer to the RFC 147 Overview on the Felix documentation pages (http://felix.apache.org/site/rfc-147-overview.html) for potential differences with the initial draft . Chained execution A program is a set of chained execution blocks. Blocks are executed in parallel, and the output of a block is streamed as input to the next. Blocks are separated by the pipe character ( | ). Each block is made up of a sequence of statements, separated by a semicolon ( ; ). For example, as we'll see in the next section, the bundles command lists the currently installed bundles and the grep command takes a parameter that it uses to filter the input. The program below: bundles | grep gogo is made of two statement blocks, namely, bundles and grep gogo. The output of the bundles statement will be connected to the input of the grep gogo statement (here each the statement block contains one statement). Running this program on your Felix installation, in the state it is now, will produce: g! bundles | grep gogo 2|Active | 1|org.apache.felix.gogo.command (0.6.0) 3|Active | 1|org.apache.felix.gogo.runtime (0.6.0) 4|Active | 1|org.apache.felix.gogo.shell (0.6.0) true The grep statement has filtered the output of the bundles statement for lines containing the filter string gogo. In this case, the grep statement outputs the results of its execution to the shell which prints it. Executing the statement grep gogo on its own, without a piped block that feeds it input, will connect its input to the user command line. In that case, use Ctrl-Z to terminate your input: g! grep gogo line 1 line 2 gogo line 2 gogo line 3 ^Z true Notice that line 2 gogo is repeated right after you have entered it, showing that the grep statement is running in parallel. It receives the input and processes it right after you enter it. Variable assignment and referencing A session variable is assigned a value using the equal character ( = ) and referenced using its name preceded with a dollar character ( $ ). For example: g! var1 = 'this is a string' this is a string g! echo $var1 this is a string The assignment operation returns the assigned value. Value types We've seen the string type previously, which is indicated by surrounding text with single quotes ( ' ). A list is a sequence of terms separated by whitespace characters and is delimited by an opening and a closing square bracket. For example: g! days = [ mon tue wed thu fri sat sun ] mon tue wed thu fri sat sun Here the variable, days, was created, assigned the list as a value, and stored in the session. A map is a list of assignments, the value is assigned to the key using the equal character ( = ) . For example: For example: g! sounds = [ dog=bark cat=meow lion=roar ] dog bark cat meow lion roar Here, the variable sounds is assigned a map with the preceding key value pairs. Object properties and operations The shell uses a mapping process that involves reflection to find the best operation to perform for a request. We're not going to go into the details of how this happens; instead, we'll give a few examples of the operations that can be performed. We'll see a few others as we go along. In the same session, days and sounds are defined previously to retrieve an entry in the $days list: g! $days get 1 tue To retrieve an entry in the sounds map g! $sounds get dog bark An example we've seen earlier is the bundles command used when illustrating the piping. Bundles was mapped to the method getBundles() from the Gogo Runtime bundle BundleContext instance. Another property of this object that we'll use in the next section is bundle &ltid> to get a bundle object instance using getBundle(long). Execution quotes Similar to the UNIX back-quote syntax, but providing one that's simpler for a lightweight parser, the execution quotes are used to return the output of an executed program. For example: g!(bundle 1) location file:/C:/felix/bundle/org.apache.felix.bundlerepository-1.6.2.jar Here, (bundle 1) has returned the bundle with ID 1, which we've re-used to retrieve the property location making use of Gogo's reflexion on beans (location is mapped to getLocation() on the Bundle object ). Commands and scopes The Gogo Runti me command processor is extensible and allows any bundle to register the commands it needs to expose to the user. Then, when the user types a command, the processor will attempt to find the method that's best fit to be executed, based on the command name and passed arguments. However, there are potential cases where two bundles would need to register the same command name. To avoid this clash, commands are registered with an opti onal scope. When there is no ambiguity as to which scope the command belongs to, the command can be used without a scope; otherwise, the scope must be included. The scope of a command is specified by pre-pending it to the command, separated from the command with a colon ( : ). In the previous examples, we've used the grep command, which is in the gogo scope. In this case, grep and gogo:grep achieve the same result. We will look closer at the command registration mechanism. Let's take a tour of some of the commands available in the Felix distribution. At the time of writing of this article, the Gogo bundles are at version 0.6.0, which means that they are not yet finalized and may change by the time they are released with version 1.0. felix scope commands One of the many powerful features of Felix (and OSGi-compliant applications in general) is that many actions can be applied on bundles without needing to restart the framework. Bundles can be installed, updated, uninstalled, and so on while the remaining functionality of the framework is active. The following are some of the available commands and a description of their usage. We will get to use many of those as we go along, so you need not worry much about learning them by heart. Just know they exist. Listing installed bundles: lb One of the most frequently used shell commands is the list bundles command (lb) , which gives a listing of the currently installed bundles, showing some informationon each of them. Let's check what's running on our newly installed framework: g! lb START LEVEL 1 ID|State |Level|Name 0|Active | 0|System Bundle (3.0.1) 1|Active | 1|Apache Felix Bundle Repository (1.6.2) 2|Active | 1|Apache Felix Gogo Command (0.6.0) 3|Active | 1|Apache Felix Gogo Runtime (0.6.0) 4|Active | 1|Apache Felix Gogo Shell (0.6.0) The listing provides the following useful information about each bundle: Each bundle is given a unique id on install—this ID is used by commands such as update or uninstall to apply acti ons on that bundle The bundle's start level The bundle's name and version This command also takes a parameter for filtering the bundles list. For example, to include only bundles that have 'bundle' in their name: g! lb bundle START LEVEL 1 ID|State |Level|Name 0|Active | 0|System Bundle (3.0.1) 1|Active | 1|Apache Felix Bundle Repository (1.6.2) help The help command provides hints on the usage of commands. When called without any parameters, the help command gives a listing of the available commands: g! help felix:bundlelevel felix:cd felix:frameworklevel felix:headers felix:help felix:inspect felix:install felix:lb felix:log felix:ls felix:refresh felix:resolve felix:start felix:stop felix:uninstall felix:update felix:which gogo:cat gogo:each gogo:echo gogo:format gogo:getopt gogo:gosh gogo:grep gogo:not gogo:set gogo:sh gogo:source gogo:tac gogo:telnetd gogo:type gogo:until obr:deploy obr:info obr:javadoc obr:list obr:repos obr:source More help on the syntax of each command can be requested by typing help &ltcommand-name>. For example, for more help on the repos command: g! help repos repos - manage repositories scope: obr parameters: String ( add | list | refresh | remove ) String[] space-delimited list of repository URL When the command is available with multiple signatures, a help block per signature is provided, for example: g! help help help - displays information about a specific command scope: felix parameters: String target command help - displays available commands scope: felix Here, the help command has 2 syntaxes: one that takes a parameter (the target command), and another that takes no parameters. We've used the first one to get help on help. Some commands may have not registered help content with the shell service. Those will show minimal information using help &ltcommand>. In most cases, they expose a separate help listing—usually &ltcommand> -? or &ltcommand> -- help. install The install command is used to instruct Felix to install an external bundle. The syntax is as follows: g! help install install - install bundle using URLs scope: felix parameters: String[] target URLs Each bundle is located using the URL and is downloaded to the local cache for installation. Once a bundle is installed, it is given a unique id. This ID is used to refer to this bundle when using commands such as update or uninstall. For example: g! install http://www.mysite.com/testbundle-1.0.0.jar Bundle ID: 7 Here, the bundle I've just installed has the ID 7. g! lb START LEVEL 1 ID|State |Level|Name 0|Active | 0|System Bundle (3.0.1) 1|Active | 1|Apache Felix Bundle Repository (1.6.2) 2|Active | 1|Apache Felix Gogo Command (0.6.0) 3|Active | 1|Apache Felix Gogo Runtime (0.6.0) 4|Active | 1|Apache Felix Gogo Shell (0.6.0) 7|Installed | 1|Test Bundle (1.0.0) In cases where many bundles are to be installed from the same base URL, you may want to set a session variable with the common base URL to simplify the task. For example, instead of executing: g! install http://site.com/bundle1.jar http://site.com/bundle2.jar You would write: g! b = http://site.com g! install $b/bundle1.jar $b/bundle2.jar
Read more
  • 0
  • 0
  • 4183

article-image-python-text-processing-nltk-storing-frequency-distributions-redis
Packt
09 Nov 2010
9 min read
Save for later

Python Text Processing with NLTK: Storing Frequency Distributions in Redis

Packt
09 Nov 2010
9 min read
Storing a frequency distribution in Redis` Redis is a data structure server that is one of the more popular NoSQL databases. Among other things, it provides a network accessible database for storing dictionaries (also known as hash maps). Building a FreqDist interface to a Redis hash map will allow us to create a persistent FreqDist that is accessible to multiple local and remote processes at the same time. Most Redis operations are atomic, so it's even possible to have multiple processes write to the FreqDist concurrently. Getting ready For this and subsequent recipes, we need to install both Redis and redis-py. A quick start install guide for Redis is available at http://code.google.com/p/redis/wiki/ QuickStart. To use hash maps, you should install at least version 2.0.0 (the latest version as of this writing). The Redis Python driver redis-py can be installed using pip install redis or easy_ install redis. Ensure you install at least version 2.0.0 to use hash maps. The redispy homepage is at http://github.com/andymccurdy/redis-py/. Once both are installed and a redis-server process is running, you're ready to go. Let's assume redis-server is running on localhost on port 6379 (the default host and port). How to do it... The FreqDist class extends the built-in dict class, which makes a FreqDist an enhanced dictionary. The FreqDist class provides two additional key methods: inc() and N(). The inc() method takes a single sample argument for the key, along with an optional count keyword argument that defaults to 1, and increments the value at sample by count. N() returns the number of sample outcomes, which is the sum of all the values in the frequency distribution. We can create an API-compatible class on top of Redis by extending a RedisHashMap (that will be explained in the next section), then implementing the inc() and N() methods. Since the FreqDist only stores integers, we also override a few other methods to ensure values are always integers. This RedisHashFreqDist (defined in redisprob.py) uses the hincrby command for the inc() method to increment the sample value by count, and sums all the values in the hash map for the N() method. from rediscollections import RedisHashMap class RedisHashFreqDist(RedisHashMap): def inc(self, sample, count=1): self._r.hincrby(self._name, sample, count) def N(self): return int(sum(self.values())) def __getitem__(self, key): return int(RedisHashMap.__getitem__(self, key) or 0) def values(self): return [int(v) for v in RedisHashMap.values(self)] def items(self): return [(k, int(v)) for (k, v) in RedisHashMap.items(self)] We can use this class just like a FreqDist. To instantiate it, we must pass a Redis connection and the name of our hash map. The name should be a unique reference to this particular FreqDist so that it doesn't clash with any other keys in Redis. >>> from redis import Redis >>> from redisprob import RedisHashFreqDist >>> r = Redis() >>> rhfd = RedisHashFreqDist(r, 'test') >>> len(rhfd) 0 >>> rhfd.inc('foo') >>> rhfd['foo'] 1 >>> rhfd.items() >>> len(rhfd) 1 The name of the hash map and the sample keys will be encoded to replace whitespace and & characters with _. This is because the Redis protocol uses these characters for communication. It's best if the name and keys don't include whitespace to begin with. How it works... Most of the work is done in the RedisHashMap class, found in rediscollections.py, which extends collections.MutableMapping, then overrides all methods that require Redis-specific commands. Here's an outline of each method that uses a specific Redis command: __len__(): Uses the hlen command to get the number of elements in the hash map __contains__(): Uses the hexists command to check if an element exists in the hash map __getitem__(): Uses the hget command to get a value from the hash map __setitem__(): Uses the hset command to set a value in the hash map __delitem__(): Uses the hdel command to remove a value from the hash map keys(): Uses the hkeys command to get all the keys in the hash map values(): Uses the hvals command to get all the values in the hash map items(): Uses the hgetall command to get a dictionary containing all the keys and values in the hash map clear(): Uses the delete command to remove the entire hash map from Redis Extending collections.MutableMapping provides a number of other dict compatible methods based on the previous methods, such as update() and setdefault(), so we don't have to implement them ourselves. The initialization used for the RedisHashFreqDist is actually implemented here, and requires a Redis connection and a name for the hash map. The connection and name are both stored internally to use with all the subsequent commands. As mentioned before, whitespace is replaced by underscore in the name and all keys, for compatibility with the Redis network protocol. import collections, re white = r'[s&]+' def encode_key(key): return re.sub(white, '_', key.strip()) class RedisHashMap(collections.MutableMapping): def __init__(self, r, name): self._r = r self._name = encode_key(name) def __iter__(self): return iter(self.items()) def __len__(self): return self._r.hlen(self._name) def __contains__(self, key): return self._r.hexists(self._name, encode_key(key)) def __getitem__(self, key): return self._r.hget(self._name, encode_key(key)) def __setitem__(self, key, val): self._r.hset(self._name, encode_key(key), val) def __delitem__(self, key): self._r.hdel(self._name, encode_key(key)) def keys(self): return self._r.hkeys(self._name) def values(self): return self._r.hvals(self._name) def items(self): return self._r.hgetall(self._name).items() def get(self, key, default=0): return self[key] or default def iteritems(self): return iter(self) def clear(self): self._r.delete(self._name) There's more... The RedisHashMap can be used by itself as a persistent key-value dictionary. However, while the hash map can support a large number of keys and arbitrary string values, its storage structure is more optimal for integer values and smaller numbers of keys. However, don't let that stop you from taking full advantage of Redis. It's very fast (for a network server) and does its best to efficiently encode whatever data you throw at it. While Redis is quite fast for a network database, it will be significantly slower than the in-memory FreqDist. There's no way around this, but while you sacrifice speed, you gain persistence and the ability to do concurrent processing. See also In the next recipe, we'll create a conditional frequency distribution based on the Redis frequency distribution created here. Storing a conditional frequency distribution in Redis The nltk.probability.ConditionalFreqDist class is a container for FreqDist instances, with one FreqDist per condition. It is used to count frequencies that are dependent on another condition, such as another word or a class label. Here, we'll create an API-compatible class on top of Redis using the RedisHashFreqDist from the previous recipe. Getting ready As in the previous recipe, you'll need to have Redis and redis-py installed with an instance of redis-server running. How to do it... We define a RedisConditionalHashFreqDist class in redisprob.py that extends nltk.probability.ConditionalFreqDist and overrides the __contains__() and __getitem__() methods. We then override __getitem__() so we can create an instance of RedisHashFreqDist instead of a FreqDist, and override __contains__() so we can call encode_key() from the rediscollections module before checking if the RedisHashFreqDist exists. from nltk.probability import ConditionalFreqDist from rediscollections import encode_key class RedisConditionalHashFreqDist(ConditionalFreqDist): def __init__(self, r, name, cond_samples=None): self._r = r self._name = name ConditionalFreqDist.__init__(self, cond_samples) # initialize self._fdists for all matching keys for key in self._r.keys(encode_key('%s:*' % name)): condition = key.split(':')[1] self[condition] # calls self.__getitem__(condition) def __contains__(self, condition): return encode_key(condition) in self._fdists def __getitem__(self, condition): if condition not in self._fdists: key = '%s:%s' % (self._name, condition) self._fdists[condition] = RedisHashFreqDist(self._r, key) return self._fdists[condition] def clear(self): for fdist in self._fdists.values(): fdist.clear() An instance of this class can be created by passing in a Redis connection and a base name. After that, it works just like a ConditionalFreqDist. >>> from redis import Redis >>> from redisprob import RedisConditionalHashFreqDist >>> r = Redis() >>> rchfd = RedisConditionalHashFreqDist(r, 'condhash') >>> rchfd.N() 0 >>> rchfd.conditions() [] >>> rchfd['cond1'].inc('foo') >>> rchfd.N() 1 >>> rchfd['cond1']['foo'] 1 >>> rchfd.conditions() ['cond1'] >>> rchfd.clear() How it works... The RedisConditionalHashFreqDist uses name prefixes to reference RedisHashFreqDist instances. The name passed in to the RedisConditionalHashFreqDist is a base name that is combined with each condition to create a unique name for each RedisHashFreqDist. For example, if the base name of the RedisConditionalHashFreqDist is 'condhash', and the condition is 'cond1', then the final name for the RedisHashFreqDist is 'condhash:cond1'. This naming pattern is used at initialization to find all the existing hash maps using the keys command. By searching for all keys matching 'condhash:*', we can identify all the existing conditions and create an instance of RedisHashFreqDist for each. Combining strings with colons is a common naming convention for Redis keys as a way to define namespaces. In our case, each RedisConditionalHashFreqDist instance defines a single namespace of hash maps. The ConditionalFreqDist class stores an internal dictionary at self._fdists that is a mapping of condition to FreqDist. The RedisConditionalHashFreqDist class still uses self._fdists, but the values are instances of RedisHashFreqDist instead of FreqDist. self._fdists is created when we call ConditionalFreqDist.__init__(), and values are initialized as necessary in the __getitem__() method. There's more... RedisConditionalHashFreqDist also defines a clear() method. This is a helper method that calls clear() on all the internal RedisHashFreqDist instances. The clear() method is not defined in ConditionalFreqDist. See also The previous recipe covers the RedisHashFreqDist in detail.
Read more
  • 0
  • 0
  • 9688

article-image-manage-emails-efficiently-using-lotus-notes-85
Packt
09 Nov 2010
6 min read
Save for later

Manage emails efficiently using Lotus Notes 8.5

Packt
09 Nov 2010
6 min read
IBM Lotus Notes 8.5 User Guide A practical hands-on user guide with time saving tips and comprehensive instructions for using Lotus Notes effectively and efficiently Understand and master the features of Lotus Notes and put them to work in your business quickly Contains comprehensive coverage of new Lotus Notes 8.5 features Includes easy-to-follow real-world examples with plenty of screenshots to clearly demonstrate how to get the most out of Lotus Notes Packed with expert tips and best practices, for using business e-mail, calendars and other Lotus Notes applications for efficient business communication         Read more about this book       This article, by Karen Hooper, author of IBM Lotus Notes 8.5 User Guide, focuses on the advanced features available in mail and how we can best utilize them to assist us in being efficient with mail management. In this article, we will explore the following topics: Senders Colors and Recipient Icons Collaboration history Finding available time Copying into Tool … Memo/Calendar/To Do Follow up Feature (flagging) Stationery Message recall (For more resources on IBM, see here.) Senders Colors and Recipient Icons Often it is important for us to identify particular e-mails in our inbox quickly, specifically if they are sent only to us or we have been Cc'd, or if an e-mail has been received from a certain person. We can specify text and background colors to identify messages from particular senders. For example, we could use one color combination to identify co-workers on an important project, another color combination for our manager, and some other combination for personal messages from friends. We can specify several color combinations. In the following screenshot, background colors of red and blue have been selected for specific individuals: We can also display icons that identify messages in which we are the only recipient in the To field or our name appears only in the Cc field. Specifying colors that identify senders We can follow the instructions given next to enable Sender Colors: If necessary, open your e-mail. Click the More button above the message list, and then click Preferences. Select the Sender Colors tab. In the first Sender names field, enter one or more names of people whose messages we want to display in the first color combination. Separate names by pressing Enter (rather than using a comma as a separator). To select names from a directory, click the down arrow next to the field. We can enter individual names only; we cannot enter group names. Select a background color and or text color. Click OK. To remove all color combinations, return to the Senders Colors tab in Preferences, click Restore Default Colors, and then click OK. Displaying icons that identify your recipient level To Cc a person in a message typically means that the message content is for information and we may not need to respond or action anything. E-mail etiquette dictates that if we want a person to take action on an item we have included in the e-mail, we add their name into the To field. It is therefore handy for us to immediately identify an e-mail where we have been Cc'd or an e-mail where our name is in the To field. The following are the instructions on how to enable this feature: If necessary, open mail. Click the More button above the message list, and then click Preferences. Go to the Recipient Icons tab. Select one or more of the display fields to display solid-circle if Mail sent to me only, half-circle if Mail sent to no more than this number of recipients in the To field and then select the number, or empty-circle icons if Mail sent to me as a cc. To display the selected icons when mail is addressed to us with an alternate e-mail address or group name, specify one or more alternate addresses or group names in the field below, this step is optional. Click OK to save the settings. Collaboration history Collaboration history incorporates quite a few features. We can view a history of collaborations or communications that we have had with one of our contacts such as e-mail, Sametime chat transcripts (if you have saved them), or meetings. Collaboration history includes all activity with a selected contact for the previous two weeks. Viewing collaboration history for a person Follow the instructions given next to see the options available with collaboration history: From within your mail select a message from a person who you want to view collaboration history. Right-click on the message and we will see the person's name that we have selected at the top of the menu options. This is marked as step 1 in the following screenshot. Select the person's name and then we will see an extended menu. We will see an extended menu. Select Collaboration History. This is step 2 in the following screenshot. A dialog box will appear with a collaboration list; select and double-click to open one of the collaborations. Finding available time Often when we receive a message from a person and we realize that we need to organize a meeting with them. The Find Available Time feature is a great shortcut to show us the first available time for ourselves and the sender of the message so that we can create a meeting with them. We can select the context menu by right-clicking on a person's name in our mail; we can then see their name listed at the top of the context menu. When we select their name, an extended context menu appears. Select Find Available Time to open the Calendar Scheduler and see when is the first available time for ourself and the person we have selected. If the person we have selected is an external person to our organization, the scheduler shows greyed out time slots as the information is not available; however, it does show our first available time. From the Calendar Scheduler window, we can create a meeting as shown in the following screenshot:
Read more
  • 0
  • 0
  • 11394

article-image-creating-layout-example-inkscape
Packt
09 Nov 2010
6 min read
Save for later

Creating a Layout Example in Inkscape

Packt
09 Nov 2010
6 min read
  Inkscape 0.48 Essentials for Web Designers Use the fascinating Inkscape graphics editor to create attractive layout designs, images, and icons for your website The first book on the newly released Inkscape version 0.48, with an exclusive focus on web design Comprehensive coverage of all aspects of Inkscape required for web design Incorporate eye-catching designs, patterns, and other visual elements to spice up your web pages Learn how to create your own Inkscape templates in addition to using the built-in ones Written in a simple illustrative manner, which will appeal to web designers and experienced Inkscape users alike Designing the background In Inkscape, since your canvas is white, it looks like your web page might have a white background. It does not, without creating a background image, currently it would be transparent or 0 percent opacity. So we need to start by determining which colors to use for the background. You can get really creative here, as you don't need to use just one color! Create a header background color, one for the main body, and then another for the footer area. Let's start by creating a simple background based on our Basic Layout layer. Making the header background To start, we're going to create a simple header background—a rectangle with a simple divider line and drop shadow. Here are the detailed steps to make this header background: With your new document open and the newly created guides viewable, first lock the Basic Layout layer (click the lock icon) and hide its elements (click the Eye icon). Now create a Background Layer. Draw a rectangle that fills the header and navigational areas. We're going to create only one background for both of these, as the navigation will be in the same color and area as the header. Choose a fill color and no stroke (border). If you decide you want to change either of the option, open the fill and stroke dialog box (from the main menu select File and then Fill and Stroke or the keypad shortcut Shift + Ctrl + F) and adjust colors accordingly. Want to add in a gradient? Click the Gradient icon, and adjust how you want your gradient to appear. By default the Inkscape gradient applies an alpha setting of 0 to the stop gradient, which will be fully transparent. This means, in the above settings, the right side of the gradient would be transparent. Click Edit to change this setting. From the Linear gradient field, choose the Add stop. Change the alpha opacity setting (A) to a solid color—either move the slider to the left side of the screen or change the value to 255. Next change the solid color value. In this example, we used white and changed the R, G, B values to achieve the results. For this example, the gradient goes from a bit darker green on the left to a lighter shade on the right side. Next, let's add a simple drop shadow. From the main menu select Filters, Shadows and Glows, and then Drop Shadow. For this example, the Blur Radius px 10, Opacity, 20% and a vertical offset px of 5 and click Apply. Close the drop shadow box and then save your file. Your header is complete! Now let's add to this to create the main content background. To change the gradient orientation, you can drag the outer two gradient stop nodes indicated by the square and circle handles on the object. You can also add more gradient stops and edit their transparency (A) values and colors to adjust to your liking. Building the main body background For the main part of the web page sample, we're using a white box as a background with a similar drop shadow. Here's how to add this to your Background layer: Draw a rectangle that fills the entire content, main content area. This includes the entire middle portion of your web page, and covers all the 'sections' between the header and the footer in the basic layout. The example above shows white as the fill color and no stroke (border). Let's also put a drop shadow on this box as well. From the main menu select Filters, Shadows and Glows, and then Drop Shadow. Adjust the settings to be the same as the previous drop shadow so they match (Blur Radius px 10, Opacity, 20% and a vertical offset px of 5) and click Apply. Close the drop shadow box and then save your file. The main content background is complete. Lastly, we need to create the footer background. Creating the footer background Creating a footer background is the last step to this process. Very much like the header, we'll follow these steps: Duplicate the header background. Select the header and from the main menu, choose Edit and then Duplicate. Drag the duplicate rectangle down to the footer area of the page and adjust the size so it fits within the footer defined area. Notice, since the object was duplicated all formatting—gradients and drop shadows—were maintained. Save your file. Now that your footer background is complete, so is the entire web page background. Let's move on to details. Designing the header Now that we have the entire background already created, it's time to add details to the header area like a logo and company name. Here are the steps to add in these basic details to our example design: Before any more work is done, it makes sense to 'lock' the background layer. We don't want any items shifting, or any elements being selected accidentally when we are working on other layers. To lock the background layer, click the lock icon in the Background layer dialog box. Create a new layer and name it Logo. To create a new layer, you can use the Shift+Ctrl+N keyboard shortcut. Within the Logo layer, create and/or import the logo and place it on the header background. If you are importing a graphic that has already been created, it's as simple as clicking File and selecting Import. Find the logo file and use the selection tool to place it correctly in the header area. Lock the logo layer, and then create a new layer and name it Title. Within this layer, use the Create and Edit Text tool and type in the business name and then place it on the header background. Save your file. Next up, is to create the Navigation tool bar.
Read more
  • 0
  • 0
  • 7034
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-designing-site-layouts-inkscape
Packt
09 Nov 2010
11 min read
Save for later

Designing Site Layouts in Inkscape

Packt
09 Nov 2010
11 min read
  Inkscape 0.48 Essentials for Web Designers Use the fascinating Inkscape graphics editor to create attractive layout designs, images, and icons for your website The first book on the newly released Inkscape version 0.48, with an exclusive focus on web design Comprehensive coverage of all aspects of Inkscape required for web design Incorporate eye-catching designs, patterns, and other visual elements to spice up your web pages Learn how to create your own Inkscape templates in addition to using the built-in ones Written in a simple illustrative manner, which will appeal to web designers and experienced Inkscape users alike Architecting a web site Although as a web designer you will usually be regarded as the "look and feel" person for a web site, you are also a key partner in determining the site architecture. As you design, you often define how the site will be navigated. Is this web site one page or will an end-user "click around" the site to other areas or sub-pages and explore? Where will each page inter-link or link out to other websites? What is the main navigational element: a navigation bar? Where will it reside on all the pages? Is this site content or search driven? All these questions (and many more) require the entire team's involvement (and a client's opinion) to make the appropriate decisions. As the web designer, it is your job to work with all of these elements at a visual level—navigation bars, search fields, buttons, title bars, footers, and more—and fit them into the overall web site design. Web layout—principles and basics Designing for the web and for print are similar in that they have the same principles and goals for an end-viewer: appealing content that works together in the space. Although the principles are basic, they represent guidelines that improve any web page design. Here are the techniques: Proximity or grouping similar information together on a web page. You can get creative in how you group this information by using alignment, icons, and even just white space, but regardless, the technique and principles are the same. Information that belongs together should be together. Alignment is the simple idea of making sure all of the elements line up on the screen. If you have everything left aligned, keep it that way on the page. Use natural alignments within an entire web space when you use more than one graphical element such as photos, graphics, and/or text. Repetition can help unify a web page. Repeating elements such as buttons, shapes (graphical or just placement), or colors can really make an impact and keep the design simple and clean, thus, easier for a viewer to navigate. Contrast can have a huge and favorable impact in web design, as long as it is used effectively. Contrast is achieved with size, colors, direction, shapes, and fonts (mixing modern with old style). Even font weight can help create contrast. Just make sure that all of these elements still work well with the content on the web page itself—not for the sake of contrast. The basic design Before designing the layout in Inkscape, it can help to plan the placement of the main areas of a web page—in essence to help with the design's overall alignment of items and proximity of similar items. For our purposes, we'll create a simple main web page for a small business. This main page will have these areas: Header Footer Sidebar Content Navigation Each web page project is different and you may have to add more page elements to this list or delete some so that the final list of elements fits the needs of the overall design. For the purposes of getting agreement from a team working on this project, a good practice is to create a basic layout showing where each of the areas will be placed on the screen—and is often referred to as the web page wireframe. Typically, wireframes are completed before any graphics are created. The following screenshot illustrates a basic layout or wireframe: This high-level approach is a great start to actually building the page design. It gives us general placements of each area of the design and then we can set up grids and guidelines. Starting a new design project When you open Inkscape, it opens to a new document. However, we want to ensure that we have a page size that is the right size for our web page, so we create a new document based on predefined desktop sizes, which are common web page sizes, as follows: From the main menu select File and then New. A pop-up menu appears showing a number of default page sizes to choose from. Choose a template size based on the browser standards or specifications. Most of the templates in this menu are based on web designs. If you want to view the print media template sizes, go to the main menu and select File and Document Properties and view the Format section. We'll choose desktop_800x600. However, the dimensions should be specified by how your target viewer will view the site, whether it is via a computer, or via a mobile device. Also, sometimes your client or company will specify a specific size your web pages need to be. A new document opens in Inkscape and you are ready to begin. Let's set a few more preferences and then save the file with your project name before we start designing. Using grids and guidelines When designing any space on the web keep the page clean and—as stated in the design principles and techniques—aligned. So let's make the canvas grid viewable on the screen and set up some guidelines based on our wireframes. Viewing the grid With your new document still open on your computer, on the Inkscape main menu select View and then Grid. You'll see that a blue grid will appear across the entire canvas area. We'll use these grids to create basic areas of our layout and then create guides to begin creating our actual layout elements. Making guides Guides are lines on the screen that you will use for aligning i.e. guiding objects. These lines are only seen while you are working in Inkscape and we can set objects to "snap to" them when we are designing. Both of these simple tools (guides and the Snap to feature) will give you automatic alignment for the basic areas of your web page layout—which in turn will help your web page have the best design. To create a guide in any open document, make sure the Select tool is selected and drag from the left side or top of the screen towards your page as shown in the following screenshot. A red line represents the guide until you 'let go' of the guide and place it on the page. Then the line turns blue. You can move the guides after placing them on the page, by using the select tool and clicking and dragging the circle node on the guide. Now let's discuss how to use wireframes and create guides based on those web page layout elements. Creating a new layer When you create documents within Inskcape, you can have layers of objects. This gives great flexibility when creating web layouts. You can move groups of objects on a layer, separate objects by layer, and 'stack', re-ordered, or hide layers. Settings can be set by layer, so you can save drafts or different versions of mockups and keep all of this in one file. The layer you are currently using is called the drawing layer. It is selected in the Layer Dialog and is shown in a darker color. In your open document with viewable grids let's make the layers viewable and create a layer called Basic Layout. To make the Layers Dockable Dialog viewable, from the main menu select Layer and then Layers. On the right side of your screen the Layers Dialog is displayed. You can also press Shift + Ctrl + L on your keyboard to display the Layers Dialogue. In the Layers Dialog, press the + button to create a new layer. In the Layer Name field type the name: Basic Layout and click Add. You will notice the new layer is added above the existing one in the Layers Dialog. Creating basic design areas in Inkscape Here's where we begin to transfer our wireframes into Inkscape so we can start the design process. To start: Use the Rectangle Tool to draw rectangles for each of your layout areas in your basic design. For now, use different shades of gray for each area so you can easily distinguish between them at a glance. To change the fill color of a particular rectangle, left click the rectangle and choose a gray shade for the rectangle. Or drag the gray shade from the color palette onto the rectangle. Use sharp edged (not rounded) rectangles. If you need to change to sharp, click the Make Corners Sharp button in the Tool Controls Bar. Make sure your rectangle shapes do not have an outline or stroke. Use the Shift + Left click keypad shortcut to open the Stroke dialog and choose No Color (the icon with an X) to delete the stroke. Position the rectangles so there are no white spaces in between them. From the main menu choose Object and then Align and Distribute. In the Remove Overlaps section, click the icon. This makes sure that the bounding boxes around each object don't overlap each other and place the objects tangent to each other. Use the Tool Controls Bar W(width): number field to apply a setting of 800.0 px. The X:0.0 and Y:0.0 fields reference the bottom left corner of your page border. Here's roughly what your canvas should look like: Converting shapes to guides Once all of your areas are blocked out on the canvas, we'll need to convert the current rectangles into guides so we can use the guides when creating our web page layout graphics. We can easily keep the Basic Layout Export layer intact; we need to copy all of the rectangles in this layer. On the main menu, select Edit and then Select All (or use the keyboard shortcut keys Ctrl + A). Then select Edit and Duplicate (or use the keyboard shortcut Ctrl + D) to duplicate all of the elements in this layer. Now you are ready to convert these current shapes into guides. First, select all the rectangles in the top (duplicate) layout. Do this by clicking a rectangle and then hold the Shift key on your keypad. Then click/select the next rectangle. When you have all five rectangles selected, from the main menu select Object and then Object to Guide. Your duplicate rectangles will be removed from the canvas and replaced with blue guides. To better see the guides, turn off the grid (from the main menu choose View and Grid). You'll also notice your originally created basic layout areas defined on the screen. We'll use these shapes later on to help export our design into workable graphics for the HTML programmers. Now it is time to save this new document before you start the details of the design. From the main menu select File and then Save As. Choose an appropriate file name for your project and save it. Make sure you save this document in the native Inkscape format of SVG to retain its editable features and layers. Project file management To keep all files for this project in an easy-to-find location, it might make sense to create a project folder on your computer and save this design file within that folder. As you export designs for use within web pages and HTML, you will need a number of files. Using a directory or folder to house all project files makes them easier to find. Summary In this article we took a look at architecting a web site. We discussed design techniques that can make web pages move from good to great. In the next article, Creating a Layout Example in Inkscape, we will see an example to create a web page layout. Further resources on this subject: Creating a Layout Example in Inkscape [Article] Logos in Inkscape [Article] Web Design Principles in Inkscape [Article] Creating Web Templates in Inkscape [Article]
Read more
  • 0
  • 0
  • 10531

article-image-using-execnet-parallel-and-distributed-processing-nltk
Packt
09 Nov 2010
8 min read
Save for later

Using Execnet for Parallel and Distributed Processing with NLTK

Packt
09 Nov 2010
8 min read
  Python Text Processing with NLTK 2.0 Cookbook Use Python's NLTK suite of libraries to maximize your Natural Language Processing capabilities. Quickly get to grips with Natural Language Processing – with Text Analysis, Text Mining, and beyond Learn how machines and crawlers interpret and process natural languages Easily work with huge amounts of data and learn how to handle distributed processing Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible     Introduction NLTK is great for in-memory single-processor natural language processing. However, there are times when you have a lot of data to process and want to take advantage of multiple CPUs, multi-core CPUs, and even multiple computers. Or perhaps you want to store frequencies and probabilities in a persistent, shared database so multiple processes can access it simultaneously. For the first case, we'll be using execnet to do parallel and distributed processing with NLTK. For the second case, you'll learn how to use the Redis data structure server/database to store frequency distributions and more. Distributed tagging with execnet Execnet is a distributed execution library for python. It allows you to create gateways and channels for remote code execution. A gateway is a connection from the calling process to a remote environment. The remote environment can be a local subprocess or an SSH connection to a remote node. A channel is created from a gateway and handles communication between the channel creator and the remote code. Since many NLTK processes require 100 percent CPU utilization during computation, execnet is an ideal way to distribute that computation for maximum resource usage. You can create one gateway per CPU core, and it doesn't matter whether the cores are in your local computer or spread across remote machines. In many situations, you only need to have the trained objects and data on a single machine, and can send the objects and data to the remote nodes as needed. Getting ready You'll need to install execnet for this to work. It should be as simple as sudo pip install execnet or sudo easy_install execnet. The current version of execnet, as of this writing, is 1.0.8. The execnet homepage, which has API documentation and examples, is at http://codespeak.net/execnet/. How to do it... We start by importing the required modules, as well as an additional module remote_tag. py that will be explained in the next section. We also need to import pickle so we can serialize the tagger. Execnet does not natively know how to deal with complex objects such as a part-of-speech tagger, so we must dump the tagger to a string using pickle.dumps(). We'll use the default tagger that's used by the nltk.tag.pos_tag() function, but you could load and dump any pre-trained part-of-speech tagger as long as it implements the TaggerI interface. Once we have a serialized tagger, we start execnet by making a gateway with execnet. makegateway(). The default gateway creates a Python subprocess, and we can call the remote_exec() method with the remote_tag module to create a channel. With an open channel, we send over the serialized tagger and then the first tokenized sentence of the treebank corpus. You don't have to do any special serialization of simple types such as lists and tuples, since execnet already knows how to handle serializing the built-in types. Now if we call channel.receive(), we get back a tagged sentence that is equivalent to the first tagged sentence in the treebank corpus, so we know the tagging worked. We end by exiting the gateway, which closes the channel and kills the subprocess. >>> import execnet, remote_tag, nltk.tag, nltk.data >>> from nltk.corpus import treebank >>> import cPickle as pickle >>> tagger = pickle.dumps(nltk.data.load(nltk.tag._POS_TAGGER)) >>> gw = execnet.makegateway() >>> channel = gw.remote_exec(remote_tag) >>> channel.send(tagger) >>> channel.send(treebank.sents()[0]) >>> tagged_sentence = channel.receive() >>> tagged_sentence == treebank.tagged_sents()[0] True >>> gw.exit() Visually, the communication process looks like this: How it works... The gateway's remote_exec() method takes a single argument that can be one of the following three types: A string of code to execute remotely. The name of a pure function that will be serialized and executed remotely. The name of a pure module whose source will be executed remotely. We use the third option with the remote_tag.py module, which is defined as follows: import cPickle as pickle if __name__ == '__channelexec__': tagger = pickle.loads(channel.receive()) for sentence in channel: channel.send(tagger.tag(sentence)) A pure module is a module that is self-contained. It can only access Python modules that are available where it executes, and does not have access to any variables or states that exist wherever the gateway is initially created. To detect that the module is being executed by execnet, you can look at the __name__ variable. If it's equal to '__channelexec__', then it is being used to create a remote channel. This is similar to doing if __name__ == '__ main__' to check if a module is being executed on the command line. The first thing we do is call channel.receive() to get the serialized tagger, which we load using pickle.loads(). You may notice that channel is not imported anywhere—that's because it is included in the global namespace of the module. Any module that execnet executes remotely has access to the channel variable in order to communicate with the channel` creator. Once we have the tagger, we iteratively tag() each tokenized sentence that we receive from the channel. This allows us to tag as many sentences as the sender wants to send, as iteration will not stop until the channel is closed. What we've essentially created is a compute node for part-of-speech tagging that dedicates 100 percent of its resources to tagging whatever sentences it receives. As long as the channel remains open, the node is available for processing. There's more... This is a simple example that opens a single gateway and channel. But execnet can do a lot more, such as opening multiple channels to increase parallel processing, as well as opening gateways to remote hosts over SSH to do distributed processing. Multiple channels We can create multiple channels, one per gateway, to make the processing more parallel. Each gateway creates a new subprocess (or remote interpreter if using an SSH gateway) and we use one channel per gateway for communication. Once we've created two channels, we can combine them using the MultiChannel class, which allows us to iterate over the channels, and make a receive queue to receive messages from each channel. After creating each channel and sending the tagger, we cycle through the channels to send an even number of sentences to each channel for tagging. Then we collect all the responses from the queue. A call to queue.get() will return a 2-tuple of (channel, message) in case you need to know which channel the message came from. If you don't want to wait forever, you can also pass a timeout keyword argument with the maximum number of seconds you want to wait, as in queue.get(timeout=4). This can be a good way to handle network errors. Once all the tagged sentences have been collected, we can exit the gateways. Here's the code: >>> import itertools >>> gw1 = execnet.makegateway() >>> gw2 = execnet.makegateway() >>> ch1 = gw1.remote_exec(remote_tag) >>> ch1.send(tagger) >>> ch2 = gw2.remote_exec(remote_tag) >>> ch2.send(tagger) >>> mch = execnet.MultiChannel([ch1, ch2]) >>> queue = mch.make_receive_queue() >>> channels = itertools.cycle(mch) >>> for sentence in treebank.sents()[:4]: ... channel = channels.next() ... channel.send(sentence) >>> tagged_sentences = [] >>> for i in range(4): ... channel, tagged_sentence = queue.get() ... tagged_sentences.append(tagged_sentence) >>> len(tagged_sentences) 4 >>> gw1.exit() >>> gw2.exit() Local versus remote gateways The default gateway spec is popen, which creates a Python subprocess on the local machine. This means execnet.makegateway() is equivalent to execnet. makegateway('popen'). If you have passwordless SSH access to a remote machine, then you can create a remote gateway using execnet.makegateway('ssh=remotehost') where remotehost should be the hostname of the machine. A SSH gateway spawns a new Python interpreter for executing the code remotely. As long as the code you're using for remote execution is pure, you only need a Python interpreter on the remote machine. Channels work exactly the same no matter what kind of gateway is used; the only difference will be communication time. This means you can mix and match local subprocesses with remote interpreters to distribute your computations across many machines in a network. There are many more details on gateways in the API documentation at http://codespeak.net/execnet/basics.html.
Read more
  • 0
  • 0
  • 3905

article-image-joomla-15-creating-menu-items-components
Packt
09 Nov 2010
2 min read
Save for later

Joomla! 1.5: Creating Menu Items for Components

Packt
09 Nov 2010
2 min read
How to create a menu in Joomla! 1.5 Carrying on with our Agora example, let's create a menu for Agora so our WidgetWorld Users can post threads on the products. How to do it... Log in to your Administrator Console. Click Menus and choose the menu you wish - in this case, use Main Menu - thus Menus | Main Menu. Click New in the upper right-hand corner. The above screenshot is a snippet of the Select Menu Item Type - Yours will vary. In this example, we see several items - we want Agora Forum. Click Agora Forum. Scroll down and fill out the details as you see here (use your own details): This will give the forum menu on the home page a title called WidgetWorld FORUM. Click Save.Now when we visit this from the front of the site we see the completed WidgetWorld FORUM on our menu: How it works... The creation and location for the component is stored in the database. When the Joomla! template renders the page, it will include the component. Thus - when you create a menu item for the component you are giving the user the ability to 'use' the component. There's more... As you gain more experience with Joomla!, you'll want to work with the menu to give it a more custom feel. Let's look at changing the location of menus. Changing the location of the menu You likely noted that the forum in the last example was at the bottom of the Main Menu. Let's change the order. Click Menu | Main Menu - see the Order column. This is the order of display. Type 2 in the Order number box for the WidgetWorld FORUM. Click the Floppy disk <save> icon next to Order - the result should be as you see in the following screenshot: Here are the menus before and after side-by-side:   Further resources on this subject: Joomla! 1.5: Installing, Creating, and Managing Modules Installation and Introduction of K2 Content Construction Kit Managing Articles Using the K2 Content Construction Kit Joomla! 1.5: Installing and Managing Components
Read more
  • 0
  • 0
  • 1518

article-image-modules-assessing-students-moodle
Packt
08 Nov 2010
6 min read
Save for later

Modules for Assessing Students in Moodle

Packt
08 Nov 2010
6 min read
  Moodle 1.9 Top Extensions Cookbook Over 60 simple and incredibly effective recipes for harnessing the power of the best Moodle modules to create effective online learning sites Packed with recipes to help you get the most out of Moodle modules Improve education outcomes by situating learning in a real-world context using Moodle Organize your content and customize your courses Reviews of the best Moodle modules—out of the available 600 modules Installation and configuration guides Written in a conversational and easy-to-follow manner         Read more about this book       (For more resources on Moodle, see here.) Involving students in assessment design Who said writing questions was the teacher's job? For students, the challenge of creating questions encourages them to think in a new and different way about the material they are studying. The incentive of being able to create questions that may be used in their own future assessment is also a thrill. Question Creation module Extending quizzes Like many parts of Moodle, the Quiz module is extensible. New question types can be added to the Quiz module so that teachers can produce more creative questions and challenge learners from a wider range. Drag-and-drop matching question type Drag-and-drop ordering question type Image target question type Simple formative feedback Students are motivated to earn marks, but that doesn't mean you can't sneak in a bit of formative assessment without them realizing it. Simply encouraging students to anticipate small snippets of the material can probe their knowledge, reinforcing their correct understandings and challenging their misunderstandings. Hidden Text filter Encouraging competition It is a disservice to delude students into believing that they standout when they are in fact falling behind. Displaying the highest standard for assignments and other assessable items on a leader-board can motivate students to compete, while recognizing those who are excelling. Course Results block Allowing students to contribute to assessment Name Question Creation Module Module type Activity Author Jamie Pratt Released 2008 Maintained Actively Languages English, Spanish Compliance Good Documentation Limited online documentation, help files Errors Some errors displayed when error reporting is turned on The Question Creation Module allows students to contribute Quiz questions and be rewarded with marks. This is a great pedagogical activity and the questions produced by students can be used in creative ways. Getting ready Unzip and copy the module directory into the /moodle/mod/ directory then visit the Notifications page. How to do it... After adding the Question Creation Module you can create an instance of this activity from the Add an activity... menu. The configuration page for this module is somewhat overcomplicated, however, once you have used it, the settings become apparent. (Move the mouse over the image to enlarge.) Like most modules, there is a Name. There is also a description that appears as an Introduction to students in their view of the activity. A time period for the activity can be specified with an opening and closing date. In the Grading section, there are a number of options, some of which are obvious and some that require explanation. A Question Creation activity can contribute to a course assessment and as such there is a Grade value. This grade value is constituted from a mix of: Automatic grading (based on number of questions created by a student, that is, a participation mark) Manual grading (based on a judgment of quality by the teacher A 50%/50% mix means that the student gains half the available marks by simply creating the required number of questions and the other half based on the judgment of the teacher. A different ratio can be chose to shift this balance depending on the teacher's preference. For a fully automated assessment, a ratio of 100%/0% can be used. For a grade that is wholly based on the teacher's judgment a ratio of 0%/100% can be used. The number of questions that need to be created can be specified. The grade value is then distributed across this number of questions. The types of Quiz questions can be restricted to specific types or students can be allowed to create questions of any type. The teacher can direct that the student create a minimum number of questions of specified question types. For example, the teacher could direct that two of the questions that a student creates should be Multiple Choice. Such enforcement is achieved in the sections labeled (rather incomprehensibly) as Will Grade Minimum Number of Questions of Type (optional). At the bottom of the configuration page, there is a setting that controls what level of editing students have over their own questions. It is not clear at first what each level of access means, nor why access needs to be restricted. Students can be controlled in their freedom to create, preview, edit, and delete questions. The module author suggests that there may be complications if a student edits a question after it has been graded, although he also suggests that students could improve questions based on feedback and such questions could then be re-graded (and the module facilitates this). For the most intuitive setup for students, the highest level of access is probably best. The teacher could then grade the questions after a set deadline. In a two phased approach that allows questions to be improved, questions could be checked at a specified date, with final question edits required by the set deadline. Students have an interface to launch the question creation process. When a question type is selected, students then create a question of that type using the same interface that a teacher uses when they create questions for a quiz. Students can create more than the required number of questions. Their final mark is based on the best questions they have created. Questions created by students appear in a list much like an assignments submission table. In this view, a teacher can preview a question and grade it. They can also provide comments on each question. The final grade is calculated when the teacher clicks the button at the bottom of this page labeled Save all grades & feedback. Grades are calculated according to how many of the required questions a student has created and the quality of each question. The student's final grade is the calculated value across all of their questions. How it works... Questions created by students are stored in the Moodle Question Bank. In that form they can be used by teachers in the course like any other question in the Question Bank. There's more... Requiring students to create questions is a great learning exercise. It forces students to think about the course materials at a higher level in order to form questions that someone else will find challenging. The real possibilities of this activity fall not in what the students can create, but in what the teacher can do with the questions that students have made. Here are some ideas: Using the best questions for regular quizzes (keeping in mind that at least one student will already know the answer) Using the best questions for quizzes for a successive cohort Using student created questions as the basis for a final exam
Read more
  • 0
  • 0
  • 1462
article-image-survey-seeks-define-open-source-cms-market-leaders-key-market-dynamics
Packt
08 Nov 2010
3 min read
Save for later

Survey Seeks to Define Open Source CMS Market Leaders, Key Market Dynamics

Packt
08 Nov 2010
3 min read
“We ran a similar CMS user survey in 2009. That survey gathered responses from over 500 CMS users. We’re hoping to top that this year in order to gather a broader sampling of opinions in this rapidly changing and competitive market,” notes Ric Shreves, partner at water&stone and lead analyst on the Report. The survey asks users about the selection criteria they use for screening content management systems and inquires into user opinions on thirty different open source CMS products. “We will select the final set of the Top 20 products based, in part, on what we learn from the survey,” states Shreves. Participants in the survey can request to receive an advance copy of the final Report. The Open Source CMS Market Share Report was launched in 2008 by digital agency water&stone. The Report is non-commercial and released under an open license. Since its inception, the Open Source CMS Market Share Report has become the industry standard for purpose of defining market share and adoption rates in the open source content management system market. The final 2010 Report is expected to be published in early December, 2010. >> You can download a copy of the 2009 Open Source CMS Market Share Report from http://www.waterandstone.com/downloads/2009OSCMSMarketShare.zip   About the publisher water&stone water&stone is a full service digital agency, located in Bali, Indonesia. The company is focused on helping clients realize increased value from the implementation of open source tools, in particular open source content management systems. water&stone was formed in 2003, specifically in response to the growth and maturation of open source CMS solutions. Since that time, the team has delivered more than 400 web projects to clients located all over the world. As an indication of their expertise, many of the firm's clients are other web development and design studios located in Australia, the UK, North America and Europe. In addition to design and development, water&stone provides consultancy and search marketing services, including brand monitoring and reputation management. Contact water&stone via email:     contactus@waterandstone.com Visit the company site:         http://waterandstone.com Become a Fan on Facebook:        http://facebook.com/waterandstone Follow water&stone on Twitter:     http://twitter.com/waterandstone   Media Contacts: Please contact Ric Shreves by email at ric@waterandstone.com  
Read more
  • 0
  • 0
  • 1025

article-image-apache-ofbiz-entity-engine
Packt
08 Nov 2010
8 min read
Save for later

Apache OFBiz Entity Engine

Packt
08 Nov 2010
8 min read
  Apache OfBiz Cookbook Over 60 simple but incredibly effective recipes for taking control of OFBiz Optimize your OFBiz experience and save hours of frustration with this timesaving collection of practical recipes covering a wide range of OFBiz topics. Get answers to the most commonly asked OFBiz questions in an easy-to-digest reference style of presentation. Discover insights into OFBiz design, implementation, and best practices by exploring real-life solutions. Each recipe in this Cookbook is crafted to describe not only "how" to accomplish a specific task, but also "why" the technique works to ensure you get the most out of your OFBiz implementation.         Read more about this book       (For more resources on Apache, see here.) Introduction Secure and reliable data storage is the key business driver behind any data management strategy. That OFBiz takes data management seriously and does not leave all the tedious and error-prone data management tasks to the application developer or the integrator is evident from the visionary design and implementation of the Entity Engine. The Entity Engine is a database agnostic application development and deployment framework seamlessly integrated into the OFBiz project code. It handles all the day-to-day data management tasks necessary to securely and reliably operate an enterprise. These tasks include, but are not limited to support for: Simultaneously connecting to an unlimited number of databases Managing an unlimited number of database connection pools Overseeing database transactions Handling database error conditions The true power of the Entity Engine is that it provides OFBiz Applications with all the tools, utilities, and an Application Programming Interface (API) necessary to easily read and write data to all configured data sources in a consistent and predictable manner without concern for database connections, the physical location of the data, or the underlying data type. To best understand how to effectively use the Entity Engine to meet all your data storage needs, a quick review of Relational Database Management Systems (RDBMS) is in order: RDBMS tables are the basic organizational structure of a relational database. An OFBiz entity is a model of a database table. As a model, entities describe a table's structure, content format, and any applicable associations a table may have with other tables. Database tables are further broken down into one or more columns. Table columns have data type and format characteristics constrained by the underlying RDBMS and assigned to them as part of a table's definition. The entity model describes a mapping of table columns to entity fields. Physically, data is stored in tables as one or more rows. A record is a unique instance of the content within a table's row. Users access table records by reading and writing one or more rows as mapped by an entity's model. In OFBiz, records are called entity values. Keys are a special type of field. Although there are several types of keys, OFBiz is primarily concerned with primary keys and foreign keys. A table's primary key is a column or group of columns that uniquely identifies a row within a table. The value of the primary key uniquely identifies a table's row throughout the entire database. A foreign key is a key used in one table to represent the value of a primary key in a related table. Foreign keys are used to establish unique and referentially correct relationships between one or more tables. Relationships are any associations that tables may have with one another. Views are "virtual" tables composed of columns from one or more tables in the database. OFBiz has a similar construct (although it differs from the traditional RDBMS definition of a "view") in the view-entity. Note: while this discussion has focused on RDMS, there is nothing to preclude you from using the Entity Engine in conjunction with any other types of data source(s). The Entity Engine provides all the tools and utilities necessary to effectively and securely access an unlimited number of databases regardless of the physical location of the data source, as shown in the following figure: Changing the default database Out-of-the-box, OFBiz is integrated with the Apache Derby database system (http://db.apache.org/derby). While Derby is sufficient to handle OFBiz during software development, evaluation, and functional testing, it is not recommended for environments that experience high transaction volumes. In particular, it is not recommended for use in production environments. Getting ready Before configuring an external database, the following few steps have to be ensured: Before changing the OFBiz Entity Engine configuration to use a remote data source, you must first create the remote database; the remote database must exist. Note: if you are not going to install the OFBiz schema and/or seed data on the remote database, but rather intend to use it as is, you will not need to create a database. You will need, however, to define entities for each remote database table you wish to access, and assign those entities to one or more entity groups. Add a user/owner for the remote database. OFBiz will access the database as this user. Make sure the user has all necessary privileges to create and remove database tables. Add a user/owner password (if desired or necessary) to the remote database. Ensure that the IP port the database is listening on for remote connections is open and clear of any firewall obstructions (for example, by default, PostgreSQL listens for connections on port 5432). Add the appropriate database driver to the ~framework/entity/lib/jdbc directory. For example, if you are using PostgreSQL version 8.3, download the postgresql-8.3-605.jdbc2.jar driver from the PostgreSQL website (http://jdbc.postgresql.org/download.html). How to do it... To configure another external database, follow these few steps: Open the Entity Engine's configuration file located at:~framework/entity/config/entityengine.xml Within the entityengine.xml file, configure the remote database's usage settings. A suggested method for doing this is to take an existing datasource element entry and modify that to reflect the necessary settings for a remote database. There are examples provided for most of the commonly used databases.For example, to configure a remote PostgreSQL database with the name of myofbiz_db, with a username ofbiz and password of ofbiz, edit the localpostnew configuration entry as shown here: <datasource name="localpostnew" helper-class= "org.ofbiz.entity.datasource.GenericHelperDAO" schema-name="public" field-type-name="postnew" check-on-start="true" add-missing-on-start="true" use-fk-initially-deferred="false" alias-view-columns="false" join-style="ansi" result-fetch-size="50" use-binary-type-for-blob="true"> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <read-data reader-name="demo"/> <read-data reader-name="ext"/> <inline-jdbc jdbc-driver="org.postgresql.Driver" jdbc-uri="jdbc:postgresql://127.0.0.1/myofbiz_db" jdbc-username="ofbiz" jdbc-password="ofbiz" isolation-level="ReadCommitted" pool-minsize="2" pool-maxsize="250"/> </datasource> Configure the default delegator for this data source: <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false"> <group-map group-name="org.ofbiz" datasource-name="localpostnew"/> <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/> </delegator> Save and close the entityengine.xml file. From the OFBiz install directory, rebuild OFBiz by running the ant run-install command. Start OFBiz. Test by observing that the database was created and populated. You may use the WebTools entity reference page (https://localhost:8443/webtools/control/entityref) to search for your newly created entities, or a third-party tool designed to work with your specific database. How it works... The Entity Engine is configured using the entityengine.xml file. Whenever OFBiz is restarted, the Entity Engine initializes itself by first referencing this file, and then building and testing all the designated database connections. In this way, an unlimited number of data source connections, database types, and even low-level driver combinations may be applied at runtime without affecting the higher-level database access logic. By abstracting the connection using one or more delegators, OFBiz further offloads lowlevel database connection management from the developer, and handles all connection maintenance, data mappings, and the default transaction configuration for an unlimited number of target databases. To configure one or more database connections, add datasource element declarations with settings as shown here: To specify that the Entity Engine should be connected to a database using a JDBC driver and to configure the specific connection parameters to pass, set the inline-jdbc element attributes as detailed here: Connecting to a remote database A "remote" database is any data source that is not the default Derby database. A remote database may be network connected and/or installed on the local server. The Entity Engine supports simultaneous connections to an unlimited number of remote databases in addition to, or as a replacement for, the default instance of Derby. Each remote database connection requires a datasource element entry in the entityengine.xml file. Adding and removing database connections may be performed at any time; however, entityengine.xml file changes are only effective upon OFBiz restart.
Read more
  • 0
  • 0
  • 4862

article-image-moodle-modules-assessment
Packt
08 Nov 2010
8 min read
Save for later

Moodle Modules for Assessment

Packt
08 Nov 2010
8 min read
  Moodle 1.9 Top Extensions Cookbook Over 60 simple and incredibly effective recipes for harnessing the power of the best Moodle modules to create effective online learning sites Packed with recipes to help you get the most out of Moodle modules Improve education outcomes by situating learning in a real-world context using Moodle Organize your content and customize your courses Reviews of the best Moodle modules—out of the available 600 modules Installation and configuration guides Written in a conversational and easy-to-follow manner Assignment alternatives An assignment is a significant form of assessment, allowing students to demonstrate the understanding they have developed over a period of learning. Many teachers struggle to break away from traditional essays and reports. As well as the assignment types available in core Moodle, there are some well constructed, contributed assignment types that are sure to lure the most ardent traditionalist away from "red pen on paper". Peer Review Assignment Type NanoGong Assignment Type UploadPDF Assignment Type Using peer assessment Name Peer Review Module typeAssignment typeAuthorMichael de RaadtReleased2010MaintainedActivelyLanguagesEnglishComplianceGoodDocumentationOnline documentation, help filesErrorsNone displayed Peer assessment can benefit students by causing them to evaluate the work of their peers. Evaluation is a higher order thinking skill, and requiring students to evaluate the work of others can enhance their learning experience. Other benefits are student involvement in the assessment process and the fact that they will receive more than just instructor feedback. When used in conjunction with communication tools, peer assessment has the potential to encourage a learning community. This is particularly useful when students are studying in the Moodle environment, but physically separated from each other. The Workshop module—a core Moodle module, was the first contributed Moodle module. It brought peer assessment to Moodle, exemplifying the constructivist nature that has driven Moodle development over the years. However, in recent years, the Workshop module has not been maintained, and is disabled by default in Moodle. The Workshop module is currently being revived for Moodle 2.0 and shows great promise. Various peer assessment tools (outside Moodle) can reduce the quantity of marking for teachers, by relying on the student feedback as a basis for marking. This can be somewhat controversial when student feedback is the only source of grades. The Peer Review Assignment Type uses peer-feedback moderated by teachers as the basis for marks. The Peer Review Assignment Type attempts to simplify the peer assessment experience of the Workshop module for both teachers and students. Only one deadline is needed (students can even submit late and still be involved); most students will submit then immediately move on to reviewing, while the assignment is fresh in their minds. The Peer Review Assignment Type manages the relationships between students automatically, so all the teacher has to do is set up the assignment, then moderate reviews after the assignment deadline. Getting ready Being an Assignment Type, you need to unzip the peerreview directory into the /moodle/mod/assignment/type/ directory before visiting the Notifications page. How to do it... Once installed, a Peer Review assignment can be added from the Add an activity... menu. You will find it nested below Assignments. As it is an Assignment Type, the Peer Review Assignment Type has the same General settings as other Assignment Types (including a name, description, grade value, and due date). There are four settings specific to this Assignment Type listed in the Peer Review section of the configuration page. The first setting allows the teacher to decide if submissions will be in the form of a submitted file or text entered online in a WYSIWYG editor. If Submitted document is selected, the maximum file size and file type must be specified. These two settings should be made while keeping in mind that students will be downloading and reviewing each other's documents. Keep the maximum file size as low as practically possible, otherwise file transfer problems may arise. A file type that all students can work with should be selected. So, for instance, if students have a mix of Office 2003, Office 2007, and OpenOffice, using the .doc file type would allow all students be able to open and review submitted documents. Each student is expected to complete two reviews and this is seen as part of the learning experience. The final setting in this section allows a reward value to be set for each of the reviews the student completes. With the assignment configuration complete, click on Save and Display and you will be taken to a page where review criteria can be written. On this page, the criteria descriptions and values can be set. Some help is provided on writing good criteria; this is worth reading. For each criterion, you can enter a textual description that will appear to the student with the assignment description. This can include HTML tags if formatting is needed. For each criterion, a second alternate description can be provided, which can contain information that you want hidden from students before they submit (such as answers or test data); this is only shown to students as they complete reviews. A value also needs to be set for each criterion. The values of criteria and the reward students will receive for completing reviews need to add up to the total grade value for the assignment. At the bottom of the Criteria page, there is a JavaScript driven calculator that indicates if values sum correctly. Once you have entered the criteria, save them and you will be taken to the description of the assignment showing the criteria added at the end. Students will also see a facility to submit a file, or a WYSIWYG editor if online-text is to be entered. With the Description and the Criteria set, there is nothing to do until students have submitted and the assignment deadline has passed. If you are running this Assignment Type on a test server and want to see how it works, you will need to set up at least five dummy student accounts and use these to submit assignments and complete reviews. After students have submitted and completed reviews, they are shown a wealth of information about their submission, reviews they have conducted, and reviews they have received from their peers and teachers. Students have the opportunity to flag reviews they are unhappy with. When students have submitted and reviewed, it is the teacher's job to resolve conflicts. The Peer Review Assignment Type shows a submission table, like other Assignment Types, but adds information about review relationships and conflicts. (Move the mouse over the image to enlarge.) The teacher must add additional "moderation" reviews to override reviews that are conflicting. The tail end of the submissions list must also be reviewed by the teacher if there are not sufficient reviews for the system to suggest a mark. When conducting moderation reviews, the teacher is provided with information that students do not get to see. The teacher can see which criteria students have checked, and also the comments they have written about the submission currently being moderated. Teachers can see which student conducted each review and how long they spent reviewing. The teacher has access to a textbox, in which they can add and save comments to be re-used later. Multiple markers have access to this same saved comments list. When all conflicts are resolved, and all status indicators are green, the system is able to suggest marks for all students. These can be released individually or all at once by clicking the button labeled Set all unset calculatable grades at the bottom of the submissions list. The Peer Review Assignment Type also includes an Analysis page which may be useful when refining an assignment for later re-use, or for teachers conducting research around assessment. How it works... The Peer Review Assignment Type achieves a simpler model of peer assessment by altering the way review relationships are allocated. With the Workshop module and other peer assessment systems, a phased approach is taken, with students submitting before one deadline, waiting for relationships to be arranged, then reviewing before another deadline. Such a phased model does not leave room for late submissions, and the delay while students wait for reviews may cause them to lose track of the context of the assignment. With the Peer Review Assignment Type, there is an initial pooling period where early submitters must wait for more submissions to be made. When the fifth student submits, this triggers an event causing reviews to be allocated among the initial pool. When later students submit they are allocated earlier submissions to review, so these students can go directly from submission to reviewing without delay. This leaves some submissions at the tail end that require teacher moderation, however it also means late submitters can simply join the tail end. Because of the review allocation method, only a single submission is permitted. Students are warned about this. If a student submits the wrong file, a teacher can replace their submission (and ensure the replacement is moderated). There's more... The Peer Review Assignment Type can be used for teaching in a number of ways: As an extension of a regular assignment For a series of streamlined, small scale, focused assignments As a draft stage review before a final submission (submitted as a normal, instructor marked assignment) Outside regular teaching, the Peer Review Assignment Type could be used for the review of research papers submitted to a conference.
Read more
  • 0
  • 0
  • 1878
article-image-joomla-15-installing-and-managing-components
Packt
08 Nov 2010
3 min read
Save for later

Joomla! 1.5: Installing and Managing Components

Packt
08 Nov 2010
3 min read
  Joomla! 1.5 Cookbook Over 60 quick and direct recipes to help you overcome common Joomla! queries. Find quick solutions to common Joomla! problems Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible Look at recipes that cover the portions of Joomla! 1.6 that are brand new Over 60 practical recipes covering a range of site management and core Joomla! activities         Read more about this book       (For more resources on Joomla!, see here.) Introduction Joomla! is known as a 'framework' and it is extendable, or in other words, can be added to, with small programs known as 'extensions'. A specific class of those is known as modules and components. Modules are small applets. They present information on the site to the user. They can be used in a variety of positions and are typically very simple to use and configure. Components are full-fledged applications and are much more complex. They can only (usually) be displayed within the main area of the page. The typical component requires a menu item to link to it. Each adds to Joomla! some functionality or allows better interaction with users. In this article, we'll explore the installation and assignment of components. Installing and managing components Starting with Joomla! 1.5.0, the installer became "Universal" - or more easily said, you go to the same place to install your extensions, templates, plugins, and so forth. Each of the add-on programs are managed from different menus, but installed from the same place. There is, like most things in Joomla!, more than one way to do something. Installation is no different. Each 'extension' usually starts with a special prefix that helps you identify what it is. Here are two examples from some third-party developers. com_securelive.zip: Installs SECUREJOOMLA which is a third-party security component for Joomla! mod_corephp_weather: Installs the quick and elegant local weather information for your users with the 'corePHP' Weather Module. Getting ready As we're going to be going through a couple of examples, I have downloaded a couple of different programs. You'll need to have on hand a component to install. We'll be installing Agora Forum. You can download a copy of it at no charge from http://www.jvitals.com. How to do it... Installing a component. Login to your Administrator Console. Click Extensions | Install/Uninstall. Once you are in here you'll have a few options to choose from: There are three methods to install, in this section we'll focus on the first method. We'll examine the other two in a moment. Click Browse... and find the file. Typically, your browser will have a default location such as Download in the Documents directory. This will vary by operating system and browser. Click Upload File & Install. In this case, I have uploaded com_agora_3.0.13.zip, which contains the full Agora Forum. Upon a successful Upload File & Install you'll see this. This indicates it has been installed. But what about this?This indicates you have already installed the extension. You'll need to remove it or delete from the database. See Troubleshooting for more information. From here you can manage your component and interact with it. To do so, from the Administrator Console, click Components, and find the component in question.
Read more
  • 0
  • 0
  • 1594

article-image-getting-started-bookshelf-project-apache-felix
Packt
08 Nov 2010
4 min read
Save for later

Getting Started with Bookshelf Project in Apache Felix

Packt
08 Nov 2010
4 min read
  OSGi and Apache Felix 3.0 Beginner's Guide Build your very own OSGi applications using the flexible and powerful Felix Framework Build a completely operational real-life application composed of multiple bundles and a web front end using Felix Get yourself acquainted with the OSGi concepts, in an easy-to-follow progressive manner Learn everything needed about the Felix Framework and get familiar with Gogo, its command-line shell to start developing your OSGi applications Simplify your OSGi development experience by learning about Felix iPOJO A relentlessly practical beginner's guide that will walk you through making real-life OSGi applications while showing you the development tools (Maven, Eclipse, and so on) that will make the journey more enjoyable        A simple Bookshelf project The case study we will construct here is a three-tiered web-based bookshelf application. Each tier consists of a functional area of the application. The first tier is the data inventory tier, which is responsible for storing the books as well as providing management functionality. The second tier, the main bookshelf service, holds the business logic around the bookshelf functionality. The third tier is the user interaction tier. It provides user access to the application through a command-line interface at first, then through a simple servlet, and later through a JSP web application. This split between the user interface, business logic, and inventory is good practice. It adds flexibility to the design by allowing the upgrade or replacement of each of the layer implementations without impacting the others and thus reducing regression testing. Let's look at each of those layers in more detail. The data inventory tier For our case study, we will need a data inventory layer for storing, searching, and retrieving books. The Book interface defines the read-only book bean and it provides the user access to the bean attributes. This interface is used when the Book entry does not require any updates. The MutableBook interface exposes the attribute-setting methods for the book bean. It is used when the caller needs to update the bean attributes. This separation between Book and MutableBook is especially useful when developing a multi-threaded, multi-session implementation of the data inventory repository. It allows us to keep track of changes by monitoring the beans as they change and notify components of those changes when needed. We will define a BookInventory interface that abstracts over the repository implementation specifics. In addition to the CRUD functionality, the book inventory interface also offers a factory method for creating new book entries. This factory method gives the caller a mutable book. What's CRUD? CRUD is short for Create-Retrieve-Update-Delete. It is the typical functionality-set expected from an inventory service: Create: Add a new book to the inventory. This operation typically checks the repository for an item with the same identifier (unique reference) and throws an exception if there's an attempt to add an item that already exists. Retrieve: Load a book based on its unique reference, also get a list of references of items that match a set of filter criteria Update: Modify an existing book properties, based on its unique reference Delete: Remove an existing book from the inventory based on its unique reference We'll separate the inventory API definition from its implementation, packaging each of them in its own bundle. It is recommended that you write another implementation for those interfaces—one that's based on permanent storage, when you're more comfortable with the process. The separation between the API and implementation will allow you to swap an implementation with another one when it is ready. We will focus on the mock implementation(out of the scope of this article) and leave it to you to implement other potential flavors of it (in the previous dashed boxes).
Read more
  • 0
  • 0
  • 1750
Modal Close icon
Modal Close icon